Bug 1142531: Check more bits in nsStyleContext::MoveTo assertion. r?heycam draft
authorL. David Baron <dbaron@dbaron.org>
Sun, 13 Mar 2016 19:48:15 -0700
changeset 339876 ff898cfeb5a769b5825a74a959402b58f63b6eea
parent 339874 f0c0480732d36153e8839c7f17394d45f679f87d
child 516060 4d2ce8305df43b2bd5a2401978e7a5b72ea37d19
push id12812
push userdbaron@mozilla.com
push dateMon, 14 Mar 2016 02:48:34 +0000
reviewersheycam
bugs1142531
milestone48.0a1
Bug 1142531: Check more bits in nsStyleContext::MoveTo assertion. r?heycam MozReview-Commit-ID: 3ovEGQoHZrr
layout/style/nsStyleContext.cpp
layout/style/nsStyleContext.h
--- 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)