Bug 1142531: Check more bits in nsStyleContext::MoveTo assertion. r?heycam
MozReview-Commit-ID: 3ovEGQoHZrr
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -309,19 +309,26 @@ void nsStyleContext::RemoveChild(nsStyle
void
nsStyleContext::MoveTo(nsStyleContext* aNewParent)
{
MOZ_ASSERT(aNewParent != mParent);
// This function shouldn't be getting called if the parents have different
// values for some flags in mBits, because if that were the case we would need
- // to recompute those bits for |this|. (TODO: add more flags to |mask|.)
- DebugOnly<uint64_t> mask = NS_STYLE_IN_DISPLAY_NONE_SUBTREE;
+ // to recompute those bits for |this|.
+ DebugOnly<uint64_t> mask = NS_STYLE_HAS_PSEUDO_ELEMENT_DATA |
+ NS_STYLE_IN_DISPLAY_NONE_SUBTREE;
MOZ_ASSERT((mParent->mBits & mask) == (aNewParent->mBits & mask));
+ MOZ_ASSERT((mParent->mBits & NS_STYLE_HAS_TEXT_DECORATION_LINES) ==
+ (aNewParent->mBits & NS_STYLE_HAS_TEXT_DECORATION_LINES) ||
+ ContextHasTextDecorationLine());
+ MOZ_ASSERT((mParent->mBits & NS_STYLE_RELEVANT_LINK_VISITED) ==
+ (aNewParent->mBits & NS_STYLE_RELEVANT_LINK_VISITED) ||
+ IsLinkContext());
// Assertions checking for visited style are just to avoid some tricky
// cases we can't be bothered handling at the moment.
MOZ_ASSERT(!IsStyleIfVisited());
MOZ_ASSERT(!mParent->IsStyleIfVisited());
MOZ_ASSERT(!aNewParent->IsStyleIfVisited());
MOZ_ASSERT(!mStyleIfVisited || mStyleIfVisited->mParent == mParent);
@@ -584,20 +591,17 @@ void
nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
{
// See if we have any text decorations.
// First see if our parent has text decorations. If our parent does, then we inherit the bit.
if (mParent && mParent->HasTextDecorationLines()) {
mBits |= NS_STYLE_HAS_TEXT_DECORATION_LINES;
} else {
// We might have defined a decoration.
- const nsStyleTextReset* text = StyleTextReset();
- uint8_t decorationLine = text->mTextDecorationLine;
- if (decorationLine != NS_STYLE_TEXT_DECORATION_LINE_NONE &&
- decorationLine != NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL) {
+ if (ContextHasTextDecorationLine()) {
mBits |= NS_STYLE_HAS_TEXT_DECORATION_LINES;
}
}
if ((mParent && mParent->HasPseudoElementData()) || mPseudoTag) {
mBits |= NS_STYLE_HAS_PSEUDO_ELEMENT_DATA;
}
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -467,16 +467,23 @@ private:
void AddChild(nsStyleContext* aChild);
void RemoveChild(nsStyleContext* aChild);
void* GetUniqueStyleData(const nsStyleStructID& aSID);
void* CreateEmptyStyleData(const nsStyleStructID& aSID);
void ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup);
+ bool ContextHasTextDecorationLine() {
+ const nsStyleTextReset* text = StyleTextReset();
+ uint8_t decorationLine = text->mTextDecorationLine;
+ return decorationLine != NS_STYLE_TEXT_DECORATION_LINE_NONE &&
+ decorationLine != NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL;
+ }
+
#ifdef DEBUG
struct AutoCheckDependency {
nsStyleContext* mStyleContext;
nsStyleStructID mOuterSID;
AutoCheckDependency(nsStyleContext* aContext, nsStyleStructID aInnerSID)
: mStyleContext(aContext)