Bug 729142 - Convert layout/style to MOZ_STATIC_ASSERT. r=dbaron

This commit is contained in:
Zack Weinberg 2012-02-23 08:19:00 -08:00
parent c194502b35
commit f4fb4a1991
18 changed files with 137 additions and 105 deletions

View File

@ -644,6 +644,7 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE NS_FONT_DECORATION_UNDERLINE
#define NS_STYLE_TEXT_DECORATION_LINE_OVERLINE NS_FONT_DECORATION_OVERLINE
#define NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH NS_FONT_DECORATION_LINE_THROUGH
#define NS_STYLE_TEXT_DECORATION_LINE_BLINK 0x08
#define NS_STYLE_TEXT_DECORATION_LINE_PREF_ANCHORS 0x10
// OVERRIDE_ALL does not occur in stylesheets; it only comes from HTML
// attribute mapping (and thus appears in computed data)

View File

@ -54,7 +54,8 @@ namespace css {
// check that we can fit all the CSS properties into a PRUint8
// for the mOrder array - if not, might need to use PRUint16!
PR_STATIC_ASSERT(eCSSProperty_COUNT_no_shorthands - 1 <= PR_UINT8_MAX);
MOZ_STATIC_ASSERT(eCSSProperty_COUNT_no_shorthands - 1 <= PR_UINT8_MAX,
"CSS longhand property numbers no longer fit in a PRUint8");
Declaration::Declaration()
: mImmutable(false)
@ -439,23 +440,23 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
aValue.Append(PRUnichar(' '));
position->mValue.AppendToString(eCSSProperty_background_position,
aValue);
NS_ABORT_IF_FALSE(clip->mValue.GetUnit() == eCSSUnit_Enumerated &&
origin->mValue.GetUnit() == eCSSUnit_Enumerated,
"should not be inherit/initial within list and "
"should have returned early for real inherit/initial");
"should not have inherit/initial within list");
if (clip->mValue.GetIntValue() != NS_STYLE_BG_CLIP_BORDER ||
origin->mValue.GetIntValue() != NS_STYLE_BG_ORIGIN_PADDING) {
PR_STATIC_ASSERT(NS_STYLE_BG_CLIP_BORDER ==
NS_STYLE_BG_ORIGIN_BORDER);
PR_STATIC_ASSERT(NS_STYLE_BG_CLIP_PADDING ==
NS_STYLE_BG_ORIGIN_PADDING);
PR_STATIC_ASSERT(NS_STYLE_BG_CLIP_CONTENT ==
NS_STYLE_BG_ORIGIN_CONTENT);
// The shorthand only has a single clip/origin value which
// sets both properties. So if they're different (and
// non-default), we can't represent the state using the
// shorthand.
// The shorthand only has a single clip/origin value which sets
// both properties. So if they're different (and non-default),
// we can't represent the state using the shorthand.
MOZ_STATIC_ASSERT(NS_STYLE_BG_CLIP_BORDER ==
NS_STYLE_BG_ORIGIN_BORDER &&
NS_STYLE_BG_CLIP_PADDING ==
NS_STYLE_BG_ORIGIN_PADDING &&
NS_STYLE_BG_CLIP_CONTENT ==
NS_STYLE_BG_ORIGIN_CONTENT,
"bg-clip and bg-origin style constants must agree");
if (clip->mValue != origin->mValue) {
aValue.Truncate();
return;

View File

@ -344,8 +344,8 @@ nsCSSSelector::nsCSSSelector(void)
mPseudoType(nsCSSPseudoElements::ePseudo_NotPseudoElement)
{
MOZ_COUNT_CTOR(nsCSSSelector);
// Make sure mPseudoType can hold all nsCSSPseudoElements::Type values
PR_STATIC_ASSERT(nsCSSPseudoElements::ePseudo_MAX < PR_INT16_MAX);
MOZ_STATIC_ASSERT(nsCSSPseudoElements::ePseudo_MAX < PR_INT16_MAX,
"nsCSSPseudoElements::Type values overflow mPseudoType");
}
nsCSSSelector*

View File

@ -571,8 +571,10 @@ public:
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
static PLDHashNumber HashKey(KeyTypePointer aKey) {
PR_STATIC_ASSERT(sizeof(PLDHashNumber) == sizeof(PRUint32));
PR_STATIC_ASSERT(PLDHashNumber(-1) > PLDHashNumber(0));
MOZ_STATIC_ASSERT(sizeof(PLDHashNumber) == sizeof(PRUint32),
"this hash function assumes PLDHashNumber is PRUint32");
MOZ_STATIC_ASSERT(PLDHashNumber(-1) > PLDHashNumber(0),
"this hash function assumes PLDHashNumber is PRUint32");
float key = *aKey;
NS_ABORT_IF_FALSE(0.0f <= key && key <= 1.0f, "out of range");
return PLDHashNumber(key * PR_UINT32_MAX);

View File

@ -161,8 +161,10 @@ private:
};
/* Make sure the CDBValueStorage elements are aligned appropriately. */
PR_STATIC_ASSERT(sizeof(nsCSSCompressedDataBlock) == 8);
PR_STATIC_ASSERT(NS_ALIGNMENT_OF(CDBValueStorage) <= 8);
MOZ_STATIC_ASSERT(sizeof(nsCSSCompressedDataBlock) == 8,
"nsCSSCompressedDataBlock's size has changed");
MOZ_STATIC_ASSERT(NS_ALIGNMENT_OF(CDBValueStorage) <= 8,
"CDBValueStorage needs too much alignment");
class nsCSSExpandedDataBlock {
friend class nsCSSCompressedDataBlock;

View File

@ -6009,12 +6009,14 @@ CSSParserImpl::ParseBackgroundItem(CSSParserImpl::BackgroundParseState& aState)
NS_NOTREACHED("should be able to parse");
return false;
}
PR_STATIC_ASSERT(NS_STYLE_BG_CLIP_BORDER ==
NS_STYLE_BG_ORIGIN_BORDER);
PR_STATIC_ASSERT(NS_STYLE_BG_CLIP_PADDING ==
NS_STYLE_BG_ORIGIN_PADDING);
PR_STATIC_ASSERT(NS_STYLE_BG_CLIP_CONTENT ==
NS_STYLE_BG_ORIGIN_CONTENT);
MOZ_STATIC_ASSERT(NS_STYLE_BG_CLIP_BORDER ==
NS_STYLE_BG_ORIGIN_BORDER &&
NS_STYLE_BG_CLIP_PADDING ==
NS_STYLE_BG_ORIGIN_PADDING &&
NS_STYLE_BG_CLIP_CONTENT ==
NS_STYLE_BG_ORIGIN_CONTENT,
"bg-clip and bg-origin style constants must agree");
aState.mClip->mValue = aState.mOrigin->mValue;
} else {
if (haveColor)
@ -8503,22 +8505,20 @@ bool
CSSParserImpl::ParseTextDecoration()
{
enum {
eDecorationNone = 0x00,
eDecorationUnderline = 0x01,
eDecorationOverline = 0x02,
eDecorationLineThrough = 0x04,
eDecorationBlink = 0x08,
eDecorationPrefAnchors = 0x10
eDecorationNone = NS_STYLE_TEXT_DECORATION_LINE_NONE,
eDecorationUnderline = NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE,
eDecorationOverline = NS_STYLE_TEXT_DECORATION_LINE_OVERLINE,
eDecorationLineThrough = NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH,
eDecorationBlink = NS_STYLE_TEXT_DECORATION_LINE_BLINK,
eDecorationPrefAnchors = NS_STYLE_TEXT_DECORATION_LINE_PREF_ANCHORS
};
PR_STATIC_ASSERT(eDecorationUnderline ==
NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE);
PR_STATIC_ASSERT(eDecorationOverline ==
NS_STYLE_TEXT_DECORATION_LINE_OVERLINE);
PR_STATIC_ASSERT(eDecorationLineThrough ==
NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH);
PR_STATIC_ASSERT(eDecorationPrefAnchors ==
NS_STYLE_TEXT_DECORATION_LINE_PREF_ANCHORS);
MOZ_STATIC_ASSERT((eDecorationNone ^ eDecorationUnderline ^
eDecorationOverline ^ eDecorationLineThrough ^
eDecorationBlink ^ eDecorationPrefAnchors) ==
(eDecorationNone | eDecorationUnderline |
eDecorationOverline | eDecorationLineThrough |
eDecorationBlink | eDecorationPrefAnchors),
"text decoration constants need to be bitmasks");
static const PRInt32 kTextDecorationKTable[] = {
eCSSKeyword_none, eDecorationNone,

View File

@ -55,7 +55,6 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsStaticNameTable.h"
#include "prlog.h" // for PR_STATIC_ASSERT
using namespace mozilla;
@ -604,9 +603,10 @@ const PRInt32 nsCSSProps::kBackgroundInlinePolicyKTable[] = {
eCSSKeyword_UNKNOWN,-1
};
PR_STATIC_ASSERT(NS_STYLE_BG_CLIP_BORDER == NS_STYLE_BG_ORIGIN_BORDER);
PR_STATIC_ASSERT(NS_STYLE_BG_CLIP_PADDING == NS_STYLE_BG_ORIGIN_PADDING);
PR_STATIC_ASSERT(NS_STYLE_BG_CLIP_CONTENT == NS_STYLE_BG_ORIGIN_CONTENT);
MOZ_STATIC_ASSERT(NS_STYLE_BG_CLIP_BORDER == NS_STYLE_BG_ORIGIN_BORDER &&
NS_STYLE_BG_CLIP_PADDING == NS_STYLE_BG_ORIGIN_PADDING &&
NS_STYLE_BG_CLIP_CONTENT == NS_STYLE_BG_ORIGIN_CONTENT,
"bg-clip and bg-origin style constants must agree");
const PRInt32 nsCSSProps::kBackgroundOriginKTable[] = {
eCSSKeyword_border_box, NS_STYLE_BG_ORIGIN_BORDER,
eCSSKeyword_padding_box, NS_STYLE_BG_ORIGIN_PADDING,
@ -1703,10 +1703,9 @@ static const nsCSSProperty gBorderBottomSubpropTable[] = {
eCSSProperty_UNKNOWN
};
PR_STATIC_ASSERT(NS_SIDE_TOP == 0);
PR_STATIC_ASSERT(NS_SIDE_RIGHT == 1);
PR_STATIC_ASSERT(NS_SIDE_BOTTOM == 2);
PR_STATIC_ASSERT(NS_SIDE_LEFT == 3);
MOZ_STATIC_ASSERT(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
"box side constants not top/right/bottom/left == 0/1/2/3");
static const nsCSSProperty gBorderColorSubpropTable[] = {
// Code relies on these being in top-right-bottom-left order.
// Code relies on these matching the NS_SIDE_* constants.

View File

@ -105,8 +105,9 @@
// See CSSParserImpl::ParseSingleValueProperty
#define CSS_PROPERTY_VALUE_PARSER_FUNCTION (1<<12)
PR_STATIC_ASSERT((CSS_PROPERTY_PARSE_PROPERTY_MASK &
CSS_PROPERTY_VALUE_PARSER_FUNCTION) == 0);
MOZ_STATIC_ASSERT((CSS_PROPERTY_PARSE_PROPERTY_MASK &
CSS_PROPERTY_VALUE_PARSER_FUNCTION) == 0,
"didn't leave enough room for the parse property constants");
#define CSS_PROPERTY_VALUE_RESTRICTION_MASK (3<<13)
// The parser (in particular, CSSParserImpl::ParseSingleValueProperty)

View File

@ -1571,8 +1571,10 @@ static const nsEventStates sPseudoClassStates[] = {
nsEventStates(),
nsEventStates()
};
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) ==
nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1);
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(sPseudoClassStates) ==
nsCSSPseudoClasses::ePseudoClass_NotPseudoClass + 1,
"ePseudoClass_NotPseudoClass is no longer at the end of"
"sPseudoClassStates");
// |aDependence| has two functions:
// * when non-null, it indicates that we're processing a negation,

View File

@ -118,7 +118,8 @@ static const PRUint8 gLexTable[] = {
SI, SI, SI, SI, SI, SI, SI, SI, SI, SI, SI, SI, SI, SI, SI, SI,
};
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(gLexTable) == 256);
MOZ_STATIC_ASSERT(NS_ARRAY_LENGTH(gLexTable) == 256,
"gLexTable expected to cover all 2^8 possible PRUint8s");
#undef W
#undef S

View File

@ -861,7 +861,8 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
}
}
else if (eCSSProperty_unicode_bidi == aProperty) {
PR_STATIC_ASSERT(NS_STYLE_UNICODE_BIDI_NORMAL == 0);
MOZ_STATIC_ASSERT(NS_STYLE_UNICODE_BIDI_NORMAL == 0,
"unicode-bidi style constants not as expected");
PRInt32 intValue = GetIntValue();
if (NS_STYLE_UNICODE_BIDI_NORMAL == intValue) {
AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, intValue),
@ -1410,8 +1411,9 @@ nsCSSRect_heap::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
return n;
}
PR_STATIC_ASSERT(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3);
MOZ_STATIC_ASSERT(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
"box side constants not top/right/bottom/left == 0/1/2/3");
/* static */ const nsCSSRect::side_type nsCSSRect::sides[4] = {
&nsCSSRect::mTop,
@ -1774,8 +1776,9 @@ nsCSSCornerSizes::Reset()
}
}
PR_STATIC_ASSERT(NS_CORNER_TOP_LEFT == 0 && NS_CORNER_TOP_RIGHT == 1 && \
NS_CORNER_BOTTOM_RIGHT == 2 && NS_CORNER_BOTTOM_LEFT == 3);
MOZ_STATIC_ASSERT(NS_CORNER_TOP_LEFT == 0 && NS_CORNER_TOP_RIGHT == 1 &&
NS_CORNER_BOTTOM_RIGHT == 2 && NS_CORNER_BOTTOM_LEFT == 3,
"box corner constants not tl/tr/br/bl == 0/1/2/3");
/* static */ const nsCSSCornerSizes::corner_type
nsCSSCornerSizes::corners[4] = {

View File

@ -2726,7 +2726,8 @@ nsComputedDOMStyle::DoGetDirection()
return val;
}
PR_STATIC_ASSERT(NS_STYLE_UNICODE_BIDI_NORMAL == 0);
MOZ_STATIC_ASSERT(NS_STYLE_UNICODE_BIDI_NORMAL == 0,
"unicode-bidi style constants not as expected");
nsIDOMCSSValue*
nsComputedDOMStyle::DoGetUnicodeBidi()
@ -3414,7 +3415,9 @@ nsComputedDOMStyle::GetAbsoluteOffset(mozilla::css::Side aSide)
return val;
}
PR_STATIC_ASSERT((NS_SIDE_TOP == 0) && (NS_SIDE_RIGHT == 1) && (NS_SIDE_BOTTOM == 2) && (NS_SIDE_LEFT == 3));
MOZ_STATIC_ASSERT(NS_SIDE_TOP == 0 && NS_SIDE_RIGHT == 1 &&
NS_SIDE_BOTTOM == 2 && NS_SIDE_LEFT == 3,
"box side constants not as expected for NS_OPPOSITE_SIDE");
#define NS_OPPOSITE_SIDE(s_) mozilla::css::Side(((s_) + 2) & 3)
nsIDOMCSSValue*

View File

@ -46,9 +46,12 @@ nsRuleData::GetPoisonOffset()
// Fill in mValueOffsets such that mValueStorage + mValueOffsets[i]
// will yield the frame poison value for all uninitialized value
// offsets.
PR_STATIC_ASSERT(sizeof(PRUword) == sizeof(size_t));
PR_STATIC_ASSERT(PRUword(-1) > PRUword(0));
PR_STATIC_ASSERT(size_t(-1) > size_t(0));
MOZ_STATIC_ASSERT(sizeof(PRUword) == sizeof(size_t),
"expect PRUword and size_t to be the same size");
MOZ_STATIC_ASSERT(PRUword(-1) > PRUword(0),
"expect PRUword to be unsigned");
MOZ_STATIC_ASSERT(size_t(-1) > size_t(0),
"expect size_t to be unsigned");
PRUword framePoisonValue = nsPresArena::GetPoisonValue();
return size_t(framePoisonValue - PRUword(mValueStorage)) /
sizeof(nsCSSValue);

View File

@ -2681,7 +2681,7 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
aFont->mLanguage);
// -moz-system-font: enum (never inherit!)
PR_STATIC_ASSERT(
MOZ_STATIC_ASSERT(
NS_STYLE_FONT_CAPTION == LookAndFeel::eFont_Caption &&
NS_STYLE_FONT_ICON == LookAndFeel::eFont_Icon &&
NS_STYLE_FONT_MENU == LookAndFeel::eFont_Menu &&
@ -2697,7 +2697,8 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
NS_STYLE_FONT_BUTTON == LookAndFeel::eFont_Button &&
NS_STYLE_FONT_PULL_DOWN_MENU == LookAndFeel::eFont_PullDownMenu &&
NS_STYLE_FONT_LIST == LookAndFeel::eFont_List &&
NS_STYLE_FONT_FIELD == LookAndFeel::eFont_Field);
NS_STYLE_FONT_FIELD == LookAndFeel::eFont_Field,
"LookAndFeel.h system-font constants out of sync with nsStyleConsts.h");
// Fall back to defaultVariableFont.
nsFont systemFont = *defaultVariableFont;
@ -4920,10 +4921,11 @@ struct BackgroundItemComputer<nsCSSValuePairList, nsStyleBackground::Size>
size.*(axis->type) = nsStyleBackground::Size::eAuto;
}
else if (eCSSUnit_Enumerated == specified.GetUnit()) {
PR_STATIC_ASSERT(nsStyleBackground::Size::eContain ==
NS_STYLE_BG_SIZE_CONTAIN);
PR_STATIC_ASSERT(nsStyleBackground::Size::eCover ==
NS_STYLE_BG_SIZE_COVER);
MOZ_STATIC_ASSERT(nsStyleBackground::Size::eContain ==
NS_STYLE_BG_SIZE_CONTAIN &&
nsStyleBackground::Size::eCover ==
NS_STYLE_BG_SIZE_COVER,
"background size constants out of sync");
NS_ABORT_IF_FALSE(specified.GetIntValue() == NS_STYLE_BG_SIZE_CONTAIN ||
specified.GetIntValue() == NS_STYLE_BG_SIZE_COVER,
"invalid enumerated value for size coordinate");

View File

@ -2793,8 +2793,9 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
case eCSSProperty_font_stretch: {
PRInt16 stretch =
static_cast<const nsStyleFont*>(styleStruct)->mFont.stretch;
PR_STATIC_ASSERT(NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED == -4);
PR_STATIC_ASSERT(NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED == 4);
MOZ_STATIC_ASSERT(NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED == -4 &&
NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED == 4,
"font stretch constants not as expected");
if (stretch < NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED ||
stretch > NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED) {
return false;
@ -3017,13 +3018,13 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
case eStyleAnimType_Sides_Right:
case eStyleAnimType_Sides_Bottom:
case eStyleAnimType_Sides_Left: {
PR_STATIC_ASSERT(0 == NS_SIDE_TOP);
PR_STATIC_ASSERT(eStyleAnimType_Sides_Right - eStyleAnimType_Sides_Top
== NS_SIDE_RIGHT);
PR_STATIC_ASSERT(eStyleAnimType_Sides_Bottom - eStyleAnimType_Sides_Top
== NS_SIDE_BOTTOM);
PR_STATIC_ASSERT(eStyleAnimType_Sides_Left - eStyleAnimType_Sides_Top
== NS_SIDE_LEFT);
MOZ_STATIC_ASSERT(
NS_SIDE_TOP == eStyleAnimType_Sides_Top -eStyleAnimType_Sides_Top &&
NS_SIDE_RIGHT == eStyleAnimType_Sides_Right -eStyleAnimType_Sides_Top &&
NS_SIDE_BOTTOM == eStyleAnimType_Sides_Bottom-eStyleAnimType_Sides_Top &&
NS_SIDE_LEFT == eStyleAnimType_Sides_Left -eStyleAnimType_Sides_Top,
"box side constants out of sync with animation side constants");
const nsStyleCoord &coord = static_cast<const nsStyleSides*>(
StyleDataAtOffset(styleStruct, ssOffset))->
Get(mozilla::css::Side(animType - eStyleAnimType_Sides_Top));
@ -3033,16 +3034,17 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
case eStyleAnimType_Corner_TopRight:
case eStyleAnimType_Corner_BottomRight:
case eStyleAnimType_Corner_BottomLeft: {
PR_STATIC_ASSERT(0 == NS_CORNER_TOP_LEFT);
PR_STATIC_ASSERT(eStyleAnimType_Corner_TopRight -
eStyleAnimType_Corner_TopLeft
== NS_CORNER_TOP_RIGHT);
PR_STATIC_ASSERT(eStyleAnimType_Corner_BottomRight -
eStyleAnimType_Corner_TopLeft
== NS_CORNER_BOTTOM_RIGHT);
PR_STATIC_ASSERT(eStyleAnimType_Corner_BottomLeft -
eStyleAnimType_Corner_TopLeft
== NS_CORNER_BOTTOM_LEFT);
MOZ_STATIC_ASSERT(
NS_CORNER_TOP_LEFT == eStyleAnimType_Corner_TopLeft -
eStyleAnimType_Corner_TopLeft &&
NS_CORNER_TOP_RIGHT == eStyleAnimType_Corner_TopRight -
eStyleAnimType_Corner_TopLeft &&
NS_CORNER_BOTTOM_RIGHT == eStyleAnimType_Corner_BottomRight -
eStyleAnimType_Corner_TopLeft &&
NS_CORNER_BOTTOM_LEFT == eStyleAnimType_Corner_BottomLeft -
eStyleAnimType_Corner_TopLeft,
"box corner constants out of sync with animation corner constants");
const nsStyleCorners *corners = static_cast<const nsStyleCorners*>(
StyleDataAtOffset(styleStruct, ssOffset));
PRUint8 fullCorner = animType - eStyleAnimType_Corner_TopLeft;

View File

@ -75,8 +75,11 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
mBits(((PRUint32)aPseudoType) << NS_STYLE_CONTEXT_TYPE_SHIFT),
mRefCnt(0)
{
PR_STATIC_ASSERT((PR_UINT32_MAX >> NS_STYLE_CONTEXT_TYPE_SHIFT) >=
nsCSSPseudoElements::ePseudo_MAX);
// This check has to be done "backward", because if it were written the
// more natural way it wouldn't fail even when it needed to.
MOZ_STATIC_ASSERT((PR_UINT32_MAX >> NS_STYLE_CONTEXT_TYPE_SHIFT) >=
nsCSSPseudoElements::ePseudo_MAX,
"pseudo element bits no longer fit in a PRUint32");
mNextSibling = this;
mPrevSibling = this;

View File

@ -280,7 +280,8 @@ void nsStyleCorners::Reset()
// Validation of NS_SIDE_IS_VERTICAL and NS_HALF_CORNER_IS_X.
#define CASE(side, result) \
PR_STATIC_ASSERT(NS_SIDE_IS_VERTICAL(side) == result)
MOZ_STATIC_ASSERT(NS_SIDE_IS_VERTICAL(side) == result, \
"NS_SIDE_IS_VERTICAL is wrong")
CASE(NS_SIDE_TOP, false);
CASE(NS_SIDE_RIGHT, true);
CASE(NS_SIDE_BOTTOM, false);
@ -288,7 +289,8 @@ CASE(NS_SIDE_LEFT, true);
#undef CASE
#define CASE(corner, result) \
PR_STATIC_ASSERT(NS_HALF_CORNER_IS_X(corner) == result)
MOZ_STATIC_ASSERT(NS_HALF_CORNER_IS_X(corner) == result, \
"NS_HALF_CORNER_IS_X is wrong")
CASE(NS_CORNER_TOP_LEFT_X, true);
CASE(NS_CORNER_TOP_LEFT_Y, false);
CASE(NS_CORNER_TOP_RIGHT_X, true);
@ -301,7 +303,8 @@ CASE(NS_CORNER_BOTTOM_LEFT_Y, false);
// Validation of NS_HALF_TO_FULL_CORNER.
#define CASE(corner, result) \
PR_STATIC_ASSERT(NS_HALF_TO_FULL_CORNER(corner) == result)
MOZ_STATIC_ASSERT(NS_HALF_TO_FULL_CORNER(corner) == result, \
"NS_HALF_TO_FULL_CORNER is wrong")
CASE(NS_CORNER_TOP_LEFT_X, NS_CORNER_TOP_LEFT);
CASE(NS_CORNER_TOP_LEFT_Y, NS_CORNER_TOP_LEFT);
CASE(NS_CORNER_TOP_RIGHT_X, NS_CORNER_TOP_RIGHT);
@ -314,7 +317,8 @@ CASE(NS_CORNER_BOTTOM_LEFT_Y, NS_CORNER_BOTTOM_LEFT);
// Validation of NS_FULL_TO_HALF_CORNER.
#define CASE(corner, vert, result) \
PR_STATIC_ASSERT(NS_FULL_TO_HALF_CORNER(corner, vert) == result)
MOZ_STATIC_ASSERT(NS_FULL_TO_HALF_CORNER(corner, vert) == result, \
"NS_FULL_TO_HALF_CORNER is wrong")
CASE(NS_CORNER_TOP_LEFT, false, NS_CORNER_TOP_LEFT_X);
CASE(NS_CORNER_TOP_LEFT, true, NS_CORNER_TOP_LEFT_Y);
CASE(NS_CORNER_TOP_RIGHT, false, NS_CORNER_TOP_RIGHT_X);
@ -327,7 +331,8 @@ CASE(NS_CORNER_BOTTOM_LEFT, true, NS_CORNER_BOTTOM_LEFT_Y);
// Validation of NS_SIDE_TO_{FULL,HALF}_CORNER.
#define CASE(side, second, result) \
PR_STATIC_ASSERT(NS_SIDE_TO_FULL_CORNER(side, second) == result)
MOZ_STATIC_ASSERT(NS_SIDE_TO_FULL_CORNER(side, second) == result, \
"NS_SIDE_TO_FULL_CORNER is wrong")
CASE(NS_SIDE_TOP, false, NS_CORNER_TOP_LEFT);
CASE(NS_SIDE_TOP, true, NS_CORNER_TOP_RIGHT);
@ -342,7 +347,8 @@ CASE(NS_SIDE_LEFT, true, NS_CORNER_TOP_LEFT);
#undef CASE
#define CASE(side, second, parallel, result) \
PR_STATIC_ASSERT(NS_SIDE_TO_HALF_CORNER(side, second, parallel) == result)
MOZ_STATIC_ASSERT(NS_SIDE_TO_HALF_CORNER(side, second, parallel) == result, \
"NS_SIDE_TO_HALF_CORNER is wrong")
CASE(NS_SIDE_TOP, false, true, NS_CORNER_TOP_LEFT_X);
CASE(NS_SIDE_TOP, false, false, NS_CORNER_TOP_LEFT_Y);
CASE(NS_SIDE_TOP, true, true, NS_CORNER_TOP_RIGHT_X);

View File

@ -69,9 +69,9 @@
#include "imgIContainer.h"
#include "prlog.h"
// Make sure we have enough bits in NS_STYLE_INHERIT_MASK.
PR_STATIC_ASSERT((((1 << nsStyleStructID_Length) - 1) &
~(NS_STYLE_INHERIT_MASK)) == 0);
MOZ_STATIC_ASSERT((((1 << nsStyleStructID_Length) - 1) &
~(NS_STYLE_INHERIT_MASK)) == 0,
"Not enough bits in NS_STYLE_INHERIT_MASK");
inline bool IsFixedUnit(const nsStyleCoord& aCoord, bool aEnumOK)
{
@ -2039,11 +2039,12 @@ void nsTimingFunction::AssignFromKeyword(PRInt32 aTimingFunctionType)
break;
}
PR_STATIC_ASSERT(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE == 0);
PR_STATIC_ASSERT(NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR == 1);
PR_STATIC_ASSERT(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN == 2);
PR_STATIC_ASSERT(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_OUT == 3);
PR_STATIC_ASSERT(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN_OUT == 4);
MOZ_STATIC_ASSERT(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE == 0 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR == 1 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN == 2 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_OUT == 3 &&
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN_OUT == 4,
"transition timing function constants not as expected");
static const float timingFunctionValues[5][4] = {
{ 0.25, 0.10, 0.25, 1.00 }, // ease