Bug 1394935: Assert that the new root is always higher up in the tree than the old root. r?bholley draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 31 Aug 2017 09:42:19 +0200
changeset 656813 7e15bea104df62ee4cef9dba0f8509853d20601e
parent 656812 3c5242de5783bfc5f49e56de2aab44ed0b77bce2
child 656814 3134045df751c2d6a251cff182131c8fc4df7ea1
push id77325
push userbmo:emilio@crisal.io
push dateThu, 31 Aug 2017 18:09:13 +0000
reviewersbholley
bugs1394935
milestone57.0a1
Bug 1394935: Assert that the new root is always higher up in the tree than the old root. r?bholley The bug here is that we're clobbering a restyle root with another one which is down in the tree, when calling NoteDirtyElement on the document element with the flags already propagated. This assertion would've catched it earlier, and make it more obvious. MozReview-Commit-ID: 3mucQvr7A1x
dom/base/nsIDocumentInlines.h
--- a/dom/base/nsIDocumentInlines.h
+++ b/dom/base/nsIDocumentInlines.h
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef nsIDocumentInlines_h
 #define nsIDocumentInlines_h
 
+#include "nsContentUtils.h"
 #include "nsIDocument.h"
 #include "mozilla/dom/HTMLBodyElement.h"
 #include "nsStyleSheetService.h"
 
 inline mozilla::dom::HTMLBodyElement*
 nsIDocument::GetBodyElement()
 {
   return static_cast<mozilla::dom::HTMLBodyElement*>(GetHtmlChildElement(nsGkAtoms::body));
@@ -59,15 +60,18 @@ nsIDocument::FindDocStyleSheetInsertionP
 
 inline void
 nsIDocument::SetServoRestyleRoot(nsINode* aRoot, uint32_t aDirtyBits)
 {
   MOZ_ASSERT(aRoot);
   MOZ_ASSERT(aDirtyBits);
   MOZ_ASSERT((aDirtyBits & ~Element::kAllServoDescendantBits) == 0);
 
+  MOZ_ASSERT(!mServoRestyleRoot ||
+             mServoRestyleRoot == aRoot ||
+             nsContentUtils::ContentIsFlattenedTreeDescendantOfForStyle(mServoRestyleRoot, aRoot));
   MOZ_ASSERT(aRoot == aRoot->OwnerDocAsNode() ||
              (aRoot->IsElement() && aRoot->IsInComposedDoc()));
   mServoRestyleRoot = aRoot;
   mServoRestyleRootDirtyBits = aDirtyBits;
 }
 
 #endif // nsIDocumentInlines_h