Bug 1403712: Make some assertions not assert for conditions that may happen mid-unbind. r?bholley draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 28 Sep 2017 14:17:41 +0200
changeset 672164 477d000e7532b414a6031c5513191fdec69e963b
parent 672163 dccd87824efadeb509c0bc9b1a848911e124368d
child 672165 e6a4b0b9adc3f1c25f84c93f49607566f96c8b2c
push id82174
push userbmo:emilio@crisal.io
push dateThu, 28 Sep 2017 20:25:49 +0000
reviewersbholley
bugs1403712
milestone58.0a1
Bug 1403712: Make some assertions not assert for conditions that may happen mid-unbind. r?bholley MozReview-Commit-ID: DNSphdMismy Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
dom/base/Element.cpp
dom/base/nsIDocumentInlines.h
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -4286,16 +4286,17 @@ BitsArePropagated(const Element* aElemen
       return true;
     }
     if (!curr->HasAllFlags(aBits)) {
       return false;
     }
     nsINode* parentNode = curr->GetParentNode();
     curr = curr->GetFlattenedTreeParentElementForStyle();
     MOZ_ASSERT_IF(!curr,
+                  !parentNode || // can only happen mid-unbind.
                   parentNode == aElement->OwnerDoc() ||
                   parentNode == parentNode->OwnerDoc()->GetRootElement());
   }
   return true;
 }
 #endif
 
 static inline void
@@ -4448,17 +4449,20 @@ NoteDirtyElement(Element* aElement, uint
     } else {
       // We didn't find a common ancestor element. That means we're descended
       // from two different document style roots, so the common ancestor is the
       // document.
       doc->SetServoRestyleRoot(doc, existingBits | aBits);
     }
   }
 
+  // See the comment in nsIDocument::SetServoRestyleRoot about the !IsElement()
+  // check there. Same justification here.
   MOZ_ASSERT(aElement == doc->GetServoRestyleRoot() ||
+             !doc->GetServoRestyleRoot()->IsElement() ||
              nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle(
                aElement, doc->GetServoRestyleRoot()));
   MOZ_ASSERT(aElement == doc->GetServoRestyleRoot() ||
              BitsArePropagated(parent, aBits, doc->GetServoRestyleRoot()));
   MOZ_ASSERT(doc->GetServoRestyleRootDirtyBits() & aBits);
 }
 
 void
--- a/dom/base/nsIDocumentInlines.h
+++ b/dom/base/nsIDocumentInlines.h
@@ -83,15 +83,14 @@ nsIDocument::SetServoRestyleRoot(nsINode
   // content unbinding for parents, like fieldset validity stuff and ancestor
   // direction changes off script runners or, alternatively, nulling out the
   // document and parent node _after_ nulling out the children's, and then
   // remove that line.
   MOZ_ASSERT(!mServoRestyleRoot ||
              mServoRestyleRoot == aRoot ||
              !aRoot->IsElement() ||
              nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle(mServoRestyleRoot, aRoot));
-  MOZ_ASSERT(aRoot == aRoot->OwnerDocAsNode() ||
-             (aRoot->IsElement() && aRoot->IsInComposedDoc()));
+  MOZ_ASSERT(aRoot == aRoot->OwnerDocAsNode() || aRoot->IsElement());
   mServoRestyleRoot = aRoot;
   mServoRestyleRootDirtyBits = aDirtyBits;
 }
 
 #endif // nsIDocumentInlines_h