Move nsStyleStruct MaxDifference methods inline, and make them available unconditionally rather than DEBUG-only. (Bug 779968, patch 1) r=bzbarsky

This commit is contained in:
L. David Baron 2012-09-07 10:13:36 -07:00
parent d826f4497a
commit 396c3c4bb2
2 changed files with 83 additions and 268 deletions

View File

@ -174,14 +174,6 @@ nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aOther) const
return CalcFontDifference(mFont, aOther.mFont);
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleFont::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
/* static */ nscoord
nsStyleFont::ZoomText(nsPresContext *aPresContext, nscoord aSize)
{
@ -293,16 +285,6 @@ nsChangeHint nsStyleMargin::CalcDifference(const nsStyleMargin& aOther) const
nsChangeHint_NeedDirtyReflow));
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleMargin::MaxDifference()
{
return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
nsChangeHint_NeedDirtyReflow));
}
#endif
nsStylePadding::nsStylePadding() {
MOZ_COUNT_CTOR(nsStylePadding);
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
@ -359,15 +341,6 @@ nsChangeHint nsStylePadding::CalcDifference(const nsStylePadding& aOther) const
nsChangeHint_ClearDescendantIntrinsics);
}
#ifdef DEBUG
/* static */
nsChangeHint nsStylePadding::MaxDifference()
{
return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
nsChangeHint_ClearDescendantIntrinsics);
}
#endif
nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
: mBorderColors(nullptr),
mBoxShadow(nullptr),
@ -563,14 +536,6 @@ nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
return shadowDifference;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleBorder::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
void
nsStyleBorder::TrackImage(nsPresContext* aContext)
{
@ -669,14 +634,6 @@ 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
//
@ -716,14 +673,6 @@ nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleList::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleXUL
//
@ -764,14 +713,6 @@ 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
//
@ -826,14 +767,6 @@ nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleColumn::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleSVG
//
@ -1002,16 +935,6 @@ nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
return hint;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleSVG::MaxDifference()
{
return NS_CombineHint(NS_CombineHint(nsChangeHint_UpdateEffects,
nsChangeHint_ReflowFrame),
nsChangeHint_RepaintFrame);
}
#endif
// --------------------
// nsStyleSVGReset
//
@ -1074,16 +997,6 @@ nsChangeHint nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aOther) cons
return hint;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleSVGReset::MaxDifference()
{
return NS_CombineHint(NS_CombineHint(nsChangeHint_UpdateEffects,
nsChangeHint_ReflowFrame),
nsChangeHint_RepaintFrame);
}
#endif
// nsStyleSVGPaint implementation
nsStyleSVGPaint::~nsStyleSVGPaint()
{
@ -1254,16 +1167,6 @@ nsChangeHint nsStylePosition::CalcDifference(const nsStylePosition& aOther) cons
return hint;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStylePosition::MaxDifference()
{
return NS_CombineHint(NS_STYLE_HINT_REFLOW,
nsChangeHint(nsChangeHint_RecomputePosition |
nsChangeHint_UpdateOverflow));
}
#endif
/* static */ bool
nsStylePosition::WidthCoordDependsOnContainer(const nsStyleCoord &aCoord)
{
@ -1310,14 +1213,6 @@ nsChangeHint nsStyleTable::CalcDifference(const nsStyleTable& aOther) const
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleTable::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// -----------------------
// nsStyleTableBorder
@ -1369,14 +1264,6 @@ nsChangeHint nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aOther
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleTableBorder::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
// --------------------
// nsStyleColor
//
@ -1400,14 +1287,6 @@ nsChangeHint nsStyleColor::CalcDifference(const nsStyleColor& aOther) const
return NS_STYLE_HINT_VISUAL;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleColor::MaxDifference()
{
return NS_STYLE_HINT_VISUAL;
}
#endif
// --------------------
// nsStyleGradient
//
@ -1900,14 +1779,6 @@ nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aOther)
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleBackground::MaxDifference()
{
return NS_CombineHint(nsChangeHint_UpdateEffects, NS_STYLE_HINT_VISUAL);
}
#endif
bool nsStyleBackground::HasFixedBackground() const
{
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, this) {
@ -2384,19 +2255,6 @@ 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 nsChangeHint(NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_UpdateOpacityLayer |
nsChangeHint_UpdateTransformLayer |
nsChangeHint_UpdateOverflow |
nsChangeHint_AddOrRemoveTransform);
}
#endif
// --------------------
// nsStyleVisibility
//
@ -2439,14 +2297,6 @@ nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther)
return hint;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleVisibility::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
nsStyleContentData::~nsStyleContentData()
{
NS_ABORT_IF_FALSE(!mImageTracked,
@ -2675,14 +2525,6 @@ nsChangeHint nsStyleContent::CalcDifference(const nsStyleContent& aOther) const
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleContent::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
nsresult nsStyleContent::AllocateContents(uint32_t aCount)
{
// We need to run the destructors of the elements of mContents, so we
@ -2776,14 +2618,6 @@ 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
//
@ -2854,14 +2688,6 @@ nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) co
return NS_STYLE_HINT_REFLOW;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleTextReset::MaxDifference()
{
return NS_STYLE_HINT_REFLOW;
}
#endif
// Allowed to return one of NS_STYLE_HINT_NONE, NS_STYLE_HINT_REFLOW
// or NS_STYLE_HINT_VISUAL. Currently we just return NONE or REFLOW, though.
// XXXbz can this not return a more specific hint? If that's ever
@ -2958,14 +2784,6 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
return CalcShadowDifference(mTextShadow, aOther.mTextShadow);
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleText::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif
//-----------------------
// nsStyleUserInterface
//
@ -3057,14 +2875,6 @@ nsChangeHint nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aO
return hint;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleUserInterface::MaxDifference()
{
return nsChangeHint(nsChangeHint_UpdateCursor | NS_STYLE_HINT_FRAMECHANGE);
}
#endif
void
nsStyleUserInterface::CopyCursorArrayFrom(const nsStyleUserInterface& aSource)
{
@ -3122,12 +2932,3 @@ nsChangeHint nsStyleUIReset::CalcDifference(const nsStyleUIReset& aOther) const
return NS_STYLE_HINT_VISUAL;
return NS_STYLE_HINT_NONE;
}
#ifdef DEBUG
/* static */
nsChangeHint nsStyleUIReset::MaxDifference()
{
return NS_STYLE_HINT_FRAMECHANGE;
}
#endif

View File

@ -84,9 +84,9 @@ public:
}
nsChangeHint CalcDifference(const nsStyleFont& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_REFLOW;
}
static bool ForceCompare() { return false; }
static nsChangeHint CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2);
@ -290,9 +290,9 @@ struct nsStyleColor {
}
nsChangeHint CalcDifference(const nsStyleColor& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_VISUAL;
}
static bool ForceCompare() { return false; }
void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
@ -319,9 +319,9 @@ struct nsStyleBackground {
void Destroy(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStyleBackground& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_CombineHint(nsChangeHint_UpdateEffects, NS_STYLE_HINT_VISUAL);
}
static bool ForceCompare() { return true; }
struct Position;
@ -540,9 +540,11 @@ struct nsStyleMargin {
void RecalcData();
nsChangeHint CalcDifference(const nsStyleMargin& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
nsChangeHint_NeedDirtyReflow));
}
static bool ForceCompare() { return true; }
nsStyleSides mMargin; // [reset] coord, percent, calc, auto
@ -575,9 +577,10 @@ struct nsStylePadding {
void RecalcData();
nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
nsChangeHint_ClearDescendantIntrinsics);
}
static bool ForceCompare() { return true; }
nsStyleSides mPadding; // [reset] coord, percent, calc
@ -740,9 +743,9 @@ struct nsStyleBorder {
void Destroy(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStyleBorder& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_REFLOW;
}
// ForceCompare is true, because a change to our border-style might
// change border-width on descendants (requiring reflow of those)
// but not our own border-width (thus not requiring us to reflow).
@ -965,9 +968,9 @@ struct nsStyleOutline {
void RecalcData(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStyleOutline& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame);
}
static bool ForceCompare() { return false; }
nsStyleCorners mOutlineRadius; // [reset] coord, percent, calc
@ -1051,9 +1054,9 @@ struct nsStyleList {
}
nsChangeHint CalcDifference(const nsStyleList& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
imgIRequest* GetListStyleImage() const { return mListStyleImage; }
@ -1089,9 +1092,11 @@ struct nsStylePosition {
}
nsChangeHint CalcDifference(const nsStylePosition& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_CombineHint(NS_STYLE_HINT_REFLOW,
nsChangeHint(nsChangeHint_RecomputePosition |
nsChangeHint_UpdateOverflow));
}
static bool ForceCompare() { return true; }
nsStyleSides mOffset; // [reset] coord, percent, calc, auto
@ -1272,9 +1277,9 @@ struct nsStyleTextReset {
}
nsChangeHint CalcDifference(const nsStyleTextReset& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_REFLOW;
}
static bool ForceCompare() { return false; }
nsStyleCoord mVerticalAlign; // [reset] coord, percent, calc, enum (see nsStyleConsts.h)
@ -1303,9 +1308,9 @@ struct nsStyleText {
}
nsChangeHint CalcDifference(const nsStyleText& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
uint8_t mTextAlign; // [inherited] see nsStyleConsts.h
@ -1379,9 +1384,9 @@ struct nsStyleVisibility {
}
nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
uint8_t mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*
@ -1578,9 +1583,14 @@ struct nsStyleDisplay {
}
nsChangeHint CalcDifference(const nsStyleDisplay& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
// All the parts of FRAMECHANGE are present in CalcDifference.
return nsChangeHint(NS_STYLE_HINT_FRAMECHANGE |
nsChangeHint_UpdateOpacityLayer |
nsChangeHint_UpdateTransformLayer |
nsChangeHint_UpdateOverflow |
nsChangeHint_AddOrRemoveTransform);
}
static bool ForceCompare() { return true; }
// We guarantee that if mBinding is non-null, so are mBinding->GetURI() and
@ -1735,9 +1745,9 @@ struct nsStyleTable {
}
nsChangeHint CalcDifference(const nsStyleTable& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
uint8_t mLayoutStrategy;// [reset] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_*
@ -1761,9 +1771,9 @@ struct nsStyleTableBorder {
}
nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
nscoord mBorderSpacingX;// [inherited]
@ -1851,9 +1861,9 @@ struct nsStyleQuotes {
void CopyFrom(const nsStyleQuotes& aSource);
nsChangeHint CalcDifference(const nsStyleQuotes& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
uint32_t QuotesCount(void) const { return mQuotesCount; } // [inherited]
@ -1919,9 +1929,9 @@ struct nsStyleContent {
void Destroy(nsPresContext* aContext);
nsChangeHint CalcDifference(const nsStyleContent& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
uint32_t ContentCount(void) const { return mContentCount; } // [reset]
@ -2024,9 +2034,9 @@ struct nsStyleUIReset {
}
nsChangeHint CalcDifference(const nsStyleUIReset& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
uint8_t mUserSelect; // [reset] (selection-style)
@ -2078,9 +2088,9 @@ struct nsStyleUserInterface {
}
nsChangeHint CalcDifference(const nsStyleUserInterface& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return nsChangeHint(nsChangeHint_UpdateCursor | NS_STYLE_HINT_FRAMECHANGE);
}
static bool ForceCompare() { return false; }
uint8_t mUserInput; // [inherited]
@ -2114,9 +2124,9 @@ struct nsStyleXUL {
}
nsChangeHint CalcDifference(const nsStyleXUL& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
float mBoxFlex; // [reset] see nsStyleConsts.h
@ -2142,9 +2152,9 @@ struct nsStyleColumn {
}
nsChangeHint CalcDifference(const nsStyleColumn& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_STYLE_HINT_FRAMECHANGE;
}
static bool ForceCompare() { return false; }
uint32_t mColumnCount; // [reset] see nsStyleConsts.h
@ -2220,9 +2230,11 @@ struct nsStyleSVG {
}
nsChangeHint CalcDifference(const nsStyleSVG& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_CombineHint(NS_CombineHint(nsChangeHint_UpdateEffects,
nsChangeHint_ReflowFrame),
nsChangeHint_RepaintFrame);
}
static bool ForceCompare() { return true; }
nsStyleSVGPaint mFill; // [inherited]
@ -2276,9 +2288,11 @@ struct nsStyleSVGReset {
}
nsChangeHint CalcDifference(const nsStyleSVGReset& aOther) const;
#ifdef DEBUG
static nsChangeHint MaxDifference();
#endif
static nsChangeHint MaxDifference() {
return NS_CombineHint(NS_CombineHint(nsChangeHint_UpdateEffects,
nsChangeHint_ReflowFrame),
nsChangeHint_RepaintFrame);
}
static bool ForceCompare() { return true; }
nsCOMPtr<nsIURI> mClipPath; // [reset]