Add debug MaxDifference() function to style structs and add some asserts in

style context code to catch structs that are returning unexpected or bogus
hints.  Bug 258910, r+sr=dbaron
This commit is contained in:
bzbarsky%mit.edu 2004-10-01 03:33:05 +00:00
Родитель 1fce2635d0
Коммит 432e6d1817
6 изменённых файлов: 536 добавлений и 14 удалений

Просмотреть файл

@ -450,6 +450,8 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
#define DO_STRUCT_DIFFERENCE(struct_) \
PR_BEGIN_MACRO \
NS_ASSERTION(NS_IsHintSubset(nsStyle##struct_::MaxDifference(), maxHint), \
"Struct placed in the wrong maxHint section"); \
const nsStyle##struct_* this##struct_ = \
NS_STATIC_CAST(const nsStyle##struct_*, \
PeekStyleData(NS_GET_STYLESTRUCTID(nsStyle##struct_))); \
@ -460,6 +462,10 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
if (compare && \
!NS_IsHintSubset(maxHint, hint) && \
this##struct_ != other##struct_) { \
NS_ASSERTION(NS_IsHintSubset( \
this##struct_->CalcDifference(*other##struct_), \
nsStyle##struct_::MaxDifference()), \
"CalcDifference() returned bigger hint than MaxDifference()"); \
NS_UpdateHint(hint, this##struct_->CalcDifference(*other##struct_)); \
} \
} \
@ -468,7 +474,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
// We begin by examining those style structs that are capable of
// causing the maximal difference, a FRAMECHANGE.
// FRAMECHANGE Structs: Display, XUL, Content, UserInterface,
// Visibility, Outline, TableBorder, Quotes
// Visibility, Outline, TableBorder, Table, Background, UIReset, Quotes
DO_STRUCT_DIFFERENCE(Display);
DO_STRUCT_DIFFERENCE(XUL);
DO_STRUCT_DIFFERENCE(Column);
@ -477,6 +483,9 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
DO_STRUCT_DIFFERENCE(Visibility);
DO_STRUCT_DIFFERENCE(Outline);
DO_STRUCT_DIFFERENCE(TableBorder);
DO_STRUCT_DIFFERENCE(Table);
DO_STRUCT_DIFFERENCE(Background);
DO_STRUCT_DIFFERENCE(UIReset);
#ifdef MOZ_SVG
DO_STRUCT_DIFFERENCE(SVG);
#endif
@ -490,7 +499,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
// The following structs cause (as their maximal difference) a reflow
// to occur. REFLOW Structs: Font, Margin, Padding, Border, List,
// Position, Text, TextReset, Table,
// Position, Text, TextReset
DO_STRUCT_DIFFERENCE(Font);
DO_STRUCT_DIFFERENCE(Margin);
DO_STRUCT_DIFFERENCE(Padding);
@ -499,17 +508,14 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
DO_STRUCT_DIFFERENCE(Position);
DO_STRUCT_DIFFERENCE(Text);
DO_STRUCT_DIFFERENCE(TextReset);
DO_STRUCT_DIFFERENCE(Table);
// At this point, we know that the worst kind of damage we could do is
// a re-render (i.e., a VISUAL change).
maxHint = NS_STYLE_HINT_VISUAL;
// The following structs cause (as their maximal difference) a
// re-render to occur. VISUAL Structs: Color, Background, UIReset
// re-render to occur. VISUAL Structs: Color
DO_STRUCT_DIFFERENCE(Color);
DO_STRUCT_DIFFERENCE(Background);
DO_STRUCT_DIFFERENCE(UIReset);
#undef DO_STRUCT_DIFFERENCE

Просмотреть файл

@ -104,6 +104,9 @@ struct nsStyleFont : public nsStyleStruct {
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Font)
nsChangeHint CalcDifference(const nsStyleFont& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
static nscoord ZoomText(nsPresContext* aPresContext, nscoord aSize);
@ -128,6 +131,9 @@ struct nsStyleColor : public nsStyleStruct {
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Color)
nsChangeHint CalcDifference(const nsStyleColor& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->AllocateFromShell(sz);
@ -158,6 +164,9 @@ struct nsStyleBackground : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleBackground& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
// On Linux (others?), there is an extra byte being used up by
// inheritance so we only have 3 bytes to fit these 6 things into.
@ -217,6 +226,9 @@ struct nsStyleMargin: public nsStyleStruct {
void RecalcData();
nsChangeHint CalcDifference(const nsStyleMargin& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mMargin; // [reset] length, percent, auto, inherit
@ -250,6 +262,9 @@ struct nsStylePadding: public nsStyleStruct {
void RecalcData();
nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mPadding; // [reset] length, percent, inherit
@ -328,6 +343,9 @@ struct nsStyleBorder: public nsStyleStruct {
PRBool IsBorderSideVisible(PRUint8 aSide) const;
void RecalcData();
nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mBorder; // [reset] length, enum (see nsStyleConsts.h)
nsStyleSides mBorderRadius; // [reset] length, percent, inherit
@ -498,6 +516,9 @@ struct nsStyleOutline: public nsStyleStruct {
void RecalcData();
nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mOutlineRadius; // [reset] length, percent, inherit
// (top=topLeft, right=topRight, bottom=bottomRight, left=bottomLeft)
@ -580,6 +601,9 @@ struct nsStyleList : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleList& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mListStyleType; // [inherited] See nsStyleConsts.h
PRUint8 mListStylePosition; // [inherited]
@ -603,6 +627,9 @@ struct nsStylePosition : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStylePosition& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mOffset; // [reset]
nsStyleCoord mWidth; // [reset] coord, percent, auto, inherit
@ -631,6 +658,9 @@ struct nsStyleTextReset : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleTextReset& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mTextDecoration; // [reset] see nsStyleConsts.h
PRUint8 mUnicodeBidi; // [reset] see nsStyleConsts.h
@ -654,6 +684,9 @@ struct nsStyleText : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleText& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mTextAlign; // [inherited] see nsStyleConsts.h
PRUint8 mTextTransform; // [inherited] see nsStyleConsts.h
@ -686,6 +719,9 @@ struct nsStyleVisibility : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
PRUint8 mVisible; // [inherited]
@ -717,6 +753,9 @@ struct nsStyleDisplay : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleDisplay& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsCOMPtr<nsIURI> mBinding; // [reset]
#if 0
@ -786,6 +825,9 @@ struct nsStyleTable: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleTable& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mLayoutStrategy;// [reset] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_*
PRUint8 mFrame; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_FRAME_*
@ -810,6 +852,9 @@ struct nsStyleTableBorder: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleCoord mBorderSpacingX;// [inherited]
nsStyleCoord mBorderSpacingY;// [inherited]
@ -872,7 +917,9 @@ struct nsStyleQuotes : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleQuotes& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint32 QuotesCount(void) const { return mQuotesCount; } // [inherited]
@ -942,6 +989,9 @@ struct nsStyleContent: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleContent& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint32 ContentCount(void) const { return mContentCount; } // [reset]
@ -1054,6 +1104,9 @@ struct nsStyleUIReset: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleUIReset& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUnichar mKeyEquivalent; // [reset] XXX what type should this be?
PRUint8 mUserSelect; // [reset] (selection-style)
@ -1076,6 +1129,9 @@ struct nsStyleUserInterface: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleUserInterface& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mUserInput; // [inherited]
PRUint8 mUserModify; // [inherited] (modify-content)
@ -1100,6 +1156,9 @@ struct nsStyleXUL : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleXUL& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
float mBoxFlex; // [reset] see nsStyleConsts.h
PRUint32 mBoxOrdinal; // [reset] see nsStyleConsts.h
@ -1125,6 +1184,9 @@ struct nsStyleColumn : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleColumn& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint32 mColumnCount; // [reset] see nsStyleConsts.h
nsStyleCoord mColumnWidth; // [reset]
@ -1160,6 +1222,9 @@ struct nsStyleSVG : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleSVG& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSVGPaint mFill; // [inherited]
float mFillOpacity; // [inherited]
@ -1194,6 +1259,9 @@ struct nsStyleSVGReset : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mDominantBaseline; // [reset] see nsStyleConsts.h
};

Просмотреть файл

@ -230,6 +230,14 @@ nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleFont::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
inline float
TextZoomFor(nsPresContext* aPresContext)
{
@ -351,6 +359,14 @@ nsChangeHint nsStyleMargin::CalcDifference(const nsStyleMargin& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleMargin::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
void
nsStyleMargin::CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const
{
@ -407,6 +423,14 @@ nsChangeHint nsStylePadding::CalcDifference(const nsStylePadding& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStylePadding::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
void
nsStylePadding::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const
{
@ -566,6 +590,14 @@ nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleBorder::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
void
nsStyleBorder::CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const
{
@ -656,6 +688,14 @@ nsChangeHint nsStyleOutline::CalcDifference(const nsStyleOutline& aOther) const
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleOutline::MaxDifference()
{
return NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame);
}
#endif
// --------------------
// nsStyleList
//
@ -691,6 +731,14 @@ nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleList::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
// --------------------
// nsStyleXUL
//
@ -727,6 +775,14 @@ nsChangeHint nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleXUL::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleColumn
//
@ -762,6 +818,15 @@ nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleColumn::MaxDifference()
{
return NS_CombineHint(nsChangeHint_ReconstructFrame,
nsChangeHint_ReflowFrame);
}
#endif
#ifdef MOZ_SVG
// --------------------
// nsStyleSVG
@ -842,6 +907,14 @@ nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleSVG::MaxDifference()
{
return NS_STYLE_HINT_VISUAL;
}
#endif
// --------------------
// nsStyleSVGReset
//
@ -867,6 +940,14 @@ nsChangeHint nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aOther) cons
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleSVGReset::MaxDifference()
{
return NS_STYLE_HINT_VISUAL;
}
#endif
#endif // MOZ_SVG
@ -919,6 +1000,14 @@ nsChangeHint nsStylePosition::CalcDifference(const nsStylePosition& aOther) cons
return nsChangeHint_ReflowFrame;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStylePosition::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
// --------------------
// nsStyleTable
//
@ -956,6 +1045,14 @@ nsChangeHint nsStyleTable::CalcDifference(const nsStyleTable& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleTable::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// -----------------------
// nsStyleTableBorder
@ -1004,6 +1101,14 @@ nsChangeHint nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aOther
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleTableBorder::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleColor
//
@ -1025,6 +1130,14 @@ nsChangeHint nsStyleColor::CalcDifference(const nsStyleColor& aOther) const
return NS_STYLE_HINT_VISUAL;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleColor::MaxDifference()
{
return NS_STYLE_HINT_VISUAL;
}
#endif
// --------------------
// nsStyleBackground
//
@ -1088,6 +1201,14 @@ nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aOther)
return NS_STYLE_HINT_VISUAL;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleBackground::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
PRBool nsStyleBackground::HasFixedBackground() const
{
return mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED &&
@ -1167,6 +1288,15 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
return hint;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleDisplay::MaxDifference()
{
// All the parts of FRAMECHANGE are present above in CalcDifference.
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleVisibility
//
@ -1207,6 +1337,14 @@ nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther)
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleVisibility::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
nsStyleContentData::~nsStyleContentData()
{
if (mType == eStyleContentType_Image) {
@ -1339,6 +1477,14 @@ nsChangeHint nsStyleContent::CalcDifference(const nsStyleContent& aOther) const
return NS_STYLE_HINT_FRAMECHANGE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleContent::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
nsresult nsStyleContent::AllocateContents(PRUint32 aCount)
{
if (aCount != mContentCount) {
@ -1399,6 +1545,14 @@ nsChangeHint nsStyleQuotes::CalcDifference(const nsStyleQuotes& aOther) const
return NS_STYLE_HINT_FRAMECHANGE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleQuotes::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleTextReset
//
@ -1434,6 +1588,14 @@ nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) co
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleTextReset::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
// --------------------
// nsStyleText
//
@ -1470,6 +1632,14 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleText::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
//-----------------------
// nsStyleUserInterface
//
@ -1518,6 +1688,14 @@ nsChangeHint nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aO
return NS_STYLE_HINT_VISUAL;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleUserInterface::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
//-----------------------
// nsStyleUIReset
//
@ -1551,3 +1729,12 @@ nsChangeHint nsStyleUIReset::CalcDifference(const nsStyleUIReset& aOther) const
}
return NS_STYLE_HINT_FRAMECHANGE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleUIReset::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif

Просмотреть файл

@ -450,6 +450,8 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
#define DO_STRUCT_DIFFERENCE(struct_) \
PR_BEGIN_MACRO \
NS_ASSERTION(NS_IsHintSubset(nsStyle##struct_::MaxDifference(), maxHint), \
"Struct placed in the wrong maxHint section"); \
const nsStyle##struct_* this##struct_ = \
NS_STATIC_CAST(const nsStyle##struct_*, \
PeekStyleData(NS_GET_STYLESTRUCTID(nsStyle##struct_))); \
@ -460,6 +462,10 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
if (compare && \
!NS_IsHintSubset(maxHint, hint) && \
this##struct_ != other##struct_) { \
NS_ASSERTION(NS_IsHintSubset( \
this##struct_->CalcDifference(*other##struct_), \
nsStyle##struct_::MaxDifference()), \
"CalcDifference() returned bigger hint than MaxDifference()"); \
NS_UpdateHint(hint, this##struct_->CalcDifference(*other##struct_)); \
} \
} \
@ -468,7 +474,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
// We begin by examining those style structs that are capable of
// causing the maximal difference, a FRAMECHANGE.
// FRAMECHANGE Structs: Display, XUL, Content, UserInterface,
// Visibility, Outline, TableBorder, Quotes
// Visibility, Outline, TableBorder, Table, Background, UIReset, Quotes
DO_STRUCT_DIFFERENCE(Display);
DO_STRUCT_DIFFERENCE(XUL);
DO_STRUCT_DIFFERENCE(Column);
@ -477,6 +483,9 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
DO_STRUCT_DIFFERENCE(Visibility);
DO_STRUCT_DIFFERENCE(Outline);
DO_STRUCT_DIFFERENCE(TableBorder);
DO_STRUCT_DIFFERENCE(Table);
DO_STRUCT_DIFFERENCE(Background);
DO_STRUCT_DIFFERENCE(UIReset);
#ifdef MOZ_SVG
DO_STRUCT_DIFFERENCE(SVG);
#endif
@ -490,7 +499,7 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
// The following structs cause (as their maximal difference) a reflow
// to occur. REFLOW Structs: Font, Margin, Padding, Border, List,
// Position, Text, TextReset, Table,
// Position, Text, TextReset
DO_STRUCT_DIFFERENCE(Font);
DO_STRUCT_DIFFERENCE(Margin);
DO_STRUCT_DIFFERENCE(Padding);
@ -499,17 +508,14 @@ nsStyleContext::CalcStyleDifference(nsStyleContext* aOther)
DO_STRUCT_DIFFERENCE(Position);
DO_STRUCT_DIFFERENCE(Text);
DO_STRUCT_DIFFERENCE(TextReset);
DO_STRUCT_DIFFERENCE(Table);
// At this point, we know that the worst kind of damage we could do is
// a re-render (i.e., a VISUAL change).
maxHint = NS_STYLE_HINT_VISUAL;
// The following structs cause (as their maximal difference) a
// re-render to occur. VISUAL Structs: Color, Background, UIReset
// re-render to occur. VISUAL Structs: Color
DO_STRUCT_DIFFERENCE(Color);
DO_STRUCT_DIFFERENCE(Background);
DO_STRUCT_DIFFERENCE(UIReset);
#undef DO_STRUCT_DIFFERENCE

Просмотреть файл

@ -230,6 +230,14 @@ nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleFont::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
inline float
TextZoomFor(nsPresContext* aPresContext)
{
@ -351,6 +359,14 @@ nsChangeHint nsStyleMargin::CalcDifference(const nsStyleMargin& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleMargin::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
void
nsStyleMargin::CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const
{
@ -407,6 +423,14 @@ nsChangeHint nsStylePadding::CalcDifference(const nsStylePadding& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStylePadding::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
void
nsStylePadding::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const
{
@ -566,6 +590,14 @@ nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleBorder::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
void
nsStyleBorder::CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const
{
@ -656,6 +688,14 @@ nsChangeHint nsStyleOutline::CalcDifference(const nsStyleOutline& aOther) const
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleOutline::MaxDifference()
{
return NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame);
}
#endif
// --------------------
// nsStyleList
//
@ -691,6 +731,14 @@ nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleList::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
// --------------------
// nsStyleXUL
//
@ -727,6 +775,14 @@ nsChangeHint nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleXUL::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleColumn
//
@ -762,6 +818,15 @@ nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleColumn::MaxDifference()
{
return NS_CombineHint(nsChangeHint_ReconstructFrame,
nsChangeHint_ReflowFrame);
}
#endif
#ifdef MOZ_SVG
// --------------------
// nsStyleSVG
@ -842,6 +907,14 @@ nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleSVG::MaxDifference()
{
return NS_STYLE_HINT_VISUAL;
}
#endif
// --------------------
// nsStyleSVGReset
//
@ -867,6 +940,14 @@ nsChangeHint nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aOther) cons
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleSVGReset::MaxDifference()
{
return NS_STYLE_HINT_VISUAL;
}
#endif
#endif // MOZ_SVG
@ -919,6 +1000,14 @@ nsChangeHint nsStylePosition::CalcDifference(const nsStylePosition& aOther) cons
return nsChangeHint_ReflowFrame;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStylePosition::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
// --------------------
// nsStyleTable
//
@ -956,6 +1045,14 @@ nsChangeHint nsStyleTable::CalcDifference(const nsStyleTable& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleTable::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// -----------------------
// nsStyleTableBorder
@ -1004,6 +1101,14 @@ nsChangeHint nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aOther
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleTableBorder::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleColor
//
@ -1025,6 +1130,14 @@ nsChangeHint nsStyleColor::CalcDifference(const nsStyleColor& aOther) const
return NS_STYLE_HINT_VISUAL;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleColor::MaxDifference()
{
return NS_STYLE_HINT_VISUAL;
}
#endif
// --------------------
// nsStyleBackground
//
@ -1088,6 +1201,14 @@ nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aOther)
return NS_STYLE_HINT_VISUAL;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleBackground::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
PRBool nsStyleBackground::HasFixedBackground() const
{
return mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED &&
@ -1167,6 +1288,15 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
return hint;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleDisplay::MaxDifference()
{
// All the parts of FRAMECHANGE are present above in CalcDifference.
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleVisibility
//
@ -1207,6 +1337,14 @@ nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther)
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleVisibility::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
nsStyleContentData::~nsStyleContentData()
{
if (mType == eStyleContentType_Image) {
@ -1339,6 +1477,14 @@ nsChangeHint nsStyleContent::CalcDifference(const nsStyleContent& aOther) const
return NS_STYLE_HINT_FRAMECHANGE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleContent::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
nsresult nsStyleContent::AllocateContents(PRUint32 aCount)
{
if (aCount != mContentCount) {
@ -1399,6 +1545,14 @@ nsChangeHint nsStyleQuotes::CalcDifference(const nsStyleQuotes& aOther) const
return NS_STYLE_HINT_FRAMECHANGE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleQuotes::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleTextReset
//
@ -1434,6 +1588,14 @@ nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) co
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleTextReset::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
// --------------------
// nsStyleText
//
@ -1470,6 +1632,14 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleText::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
//-----------------------
// nsStyleUserInterface
//
@ -1518,6 +1688,14 @@ nsChangeHint nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aO
return NS_STYLE_HINT_VISUAL;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleUserInterface::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
//-----------------------
// nsStyleUIReset
//
@ -1551,3 +1729,12 @@ nsChangeHint nsStyleUIReset::CalcDifference(const nsStyleUIReset& aOther) const
}
return NS_STYLE_HINT_FRAMECHANGE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleUIReset::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif

Просмотреть файл

@ -104,6 +104,9 @@ struct nsStyleFont : public nsStyleStruct {
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Font)
nsChangeHint CalcDifference(const nsStyleFont& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
static nscoord ZoomText(nsPresContext* aPresContext, nscoord aSize);
@ -128,6 +131,9 @@ struct nsStyleColor : public nsStyleStruct {
NS_DEFINE_STATIC_STYLESTRUCTID_ACCESSOR(eStyleStruct_Color)
nsChangeHint CalcDifference(const nsStyleColor& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
return aContext->AllocateFromShell(sz);
@ -158,6 +164,9 @@ struct nsStyleBackground : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleBackground& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
// On Linux (others?), there is an extra byte being used up by
// inheritance so we only have 3 bytes to fit these 6 things into.
@ -217,6 +226,9 @@ struct nsStyleMargin: public nsStyleStruct {
void RecalcData();
nsChangeHint CalcDifference(const nsStyleMargin& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mMargin; // [reset] length, percent, auto, inherit
@ -250,6 +262,9 @@ struct nsStylePadding: public nsStyleStruct {
void RecalcData();
nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mPadding; // [reset] length, percent, inherit
@ -328,6 +343,9 @@ struct nsStyleBorder: public nsStyleStruct {
PRBool IsBorderSideVisible(PRUint8 aSide) const;
void RecalcData();
nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mBorder; // [reset] length, enum (see nsStyleConsts.h)
nsStyleSides mBorderRadius; // [reset] length, percent, inherit
@ -498,6 +516,9 @@ struct nsStyleOutline: public nsStyleStruct {
void RecalcData();
nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mOutlineRadius; // [reset] length, percent, inherit
// (top=topLeft, right=topRight, bottom=bottomRight, left=bottomLeft)
@ -580,6 +601,9 @@ struct nsStyleList : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleList& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mListStyleType; // [inherited] See nsStyleConsts.h
PRUint8 mListStylePosition; // [inherited]
@ -603,6 +627,9 @@ struct nsStylePosition : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStylePosition& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSides mOffset; // [reset]
nsStyleCoord mWidth; // [reset] coord, percent, auto, inherit
@ -631,6 +658,9 @@ struct nsStyleTextReset : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleTextReset& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mTextDecoration; // [reset] see nsStyleConsts.h
PRUint8 mUnicodeBidi; // [reset] see nsStyleConsts.h
@ -654,6 +684,9 @@ struct nsStyleText : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleText& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mTextAlign; // [inherited] see nsStyleConsts.h
PRUint8 mTextTransform; // [inherited] see nsStyleConsts.h
@ -686,6 +719,9 @@ struct nsStyleVisibility : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
PRUint8 mVisible; // [inherited]
@ -717,6 +753,9 @@ struct nsStyleDisplay : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleDisplay& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsCOMPtr<nsIURI> mBinding; // [reset]
#if 0
@ -786,6 +825,9 @@ struct nsStyleTable: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleTable& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mLayoutStrategy;// [reset] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_*
PRUint8 mFrame; // [reset] see nsStyleConsts.h NS_STYLE_TABLE_FRAME_*
@ -810,6 +852,9 @@ struct nsStyleTableBorder: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleCoord mBorderSpacingX;// [inherited]
nsStyleCoord mBorderSpacingY;// [inherited]
@ -872,7 +917,9 @@ struct nsStyleQuotes : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleQuotes& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint32 QuotesCount(void) const { return mQuotesCount; } // [inherited]
@ -942,6 +989,9 @@ struct nsStyleContent: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleContent& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint32 ContentCount(void) const { return mContentCount; } // [reset]
@ -1054,6 +1104,9 @@ struct nsStyleUIReset: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleUIReset& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUnichar mKeyEquivalent; // [reset] XXX what type should this be?
PRUint8 mUserSelect; // [reset] (selection-style)
@ -1076,6 +1129,9 @@ struct nsStyleUserInterface: public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleUserInterface& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mUserInput; // [inherited]
PRUint8 mUserModify; // [inherited] (modify-content)
@ -1100,6 +1156,9 @@ struct nsStyleXUL : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleXUL& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
float mBoxFlex; // [reset] see nsStyleConsts.h
PRUint32 mBoxOrdinal; // [reset] see nsStyleConsts.h
@ -1125,6 +1184,9 @@ struct nsStyleColumn : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleColumn& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint32 mColumnCount; // [reset] see nsStyleConsts.h
nsStyleCoord mColumnWidth; // [reset]
@ -1160,6 +1222,9 @@ struct nsStyleSVG : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleSVG& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
nsStyleSVGPaint mFill; // [inherited]
float mFillOpacity; // [inherited]
@ -1194,6 +1259,9 @@ struct nsStyleSVGReset : public nsStyleStruct {
};
nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
PRUint8 mDominantBaseline; // [reset] see nsStyleConsts.h
};