Bug 1295111 part 2 - Add static_assert to ensure that is updated properly. r=dbaron
MozReview-Commit-ID: G2RNUcXs4yQ
--- a/layout/base/RestyleManagerBase.cpp
+++ b/layout/base/RestyleManagerBase.cpp
@@ -150,16 +150,18 @@ RestyleManagerBase::ChangeHintToString(n
"UpdateSubtreeOverflow", "UpdatePostTransformOverflow",
"UpdateParentOverflow",
"ChildrenOnlyTransform", "RecomputePosition", "AddOrRemoveTransform",
"BorderStyleNoneChange", "UpdateTextPath", "SchedulePaint",
"NeutralChange", "InvalidateRenderingObservers",
"ReflowChangesSizeOrPosition", "UpdateComputedBSize",
"UpdateUsesOpacity", "UpdateBackgroundPosition"
};
+ static_assert(nsChangeHint_AllHints == (1 << ArrayLength(names)) - 1,
+ "Name list doesn't match change hints.");
uint32_t hint = aHint & ((1 << ArrayLength(names)) - 1);
uint32_t rest = aHint & ~((1 << ArrayLength(names)) - 1);
if (hint == nsChangeHint_Hints_NotHandledForDescendants) {
result.AppendLiteral("nsChangeHint_Hints_NotHandledForDescendants");
hint = 0;
any = true;
} else {
if ((hint & NS_STYLE_HINT_REFLOW) == NS_STYLE_HINT_REFLOW) {
--- a/layout/base/nsChangeHint.h
+++ b/layout/base/nsChangeHint.h
@@ -201,19 +201,25 @@ enum nsChangeHint {
* Indicates that the 'background-position' property changed.
* Regular frames can invalidate these changes using DLBI, but
* for some frame types we need to repaint the whole frame because
* the frame does not build individual background image display items
* for each background layer.
*/
nsChangeHint_UpdateBackgroundPosition = 1 << 26,
- // IMPORTANT NOTE: When adding new hints, consider whether you need to
- // add them to NS_HintsNotHandledForDescendantsIn() below. Please also
- // add them to RestyleManager::ChangeHintToString.
+ // IMPORTANT NOTE: When adding new hints, consider whether you need
+ // to add them to NS_HintsNotHandledForDescendantsIn() below. Please
+ // also add them to RestyleManager::ChangeHintToString and modify
+ // nsChangeHint_AllHints below accordingly.
+
+ /**
+ * Dummy hint value for all hints. It exists for compile time check.
+ */
+ nsChangeHint_AllHints = (1 << 27) - 1,
};
// Redefine these operators to return nothing. This will catch any use
// of these operators on hints. We should not be using these operators
// on nsChangeHints
inline void operator<(nsChangeHint s1, nsChangeHint s2) {}
inline void operator>(nsChangeHint s1, nsChangeHint s2) {}
inline void operator!=(nsChangeHint s1, nsChangeHint s2) {}
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -1215,16 +1215,18 @@ nsStyleContext::CalcStyleDifferenceInter
}
}
if (change) {
hint |= nsChangeHint_RepaintFrame;
}
}
+ MOZ_ASSERT(NS_IsHintSubset(hint, nsChangeHint_AllHints),
+ "Added a new hint without bumping AllHints?");
return hint & ~nsChangeHint_NeutralChange;
}
nsChangeHint
nsStyleContext::CalcStyleDifference(nsStyleContext* aNewContext,
nsChangeHint aParentHintsNotHandledForDescendants,
uint32_t* aEqualStructs,
uint32_t* aSamePointerStructs)