Bug 1321284 - Part 3: Make Servo-based styling use the "flattened tree parent for style". r=bholley draft
authorCameron McCormack <cam@mcc.id.au>
Thu, 01 Dec 2016 14:55:49 +0800
changeset 447234 2315408fb39fc52f272731ce0e936ec6ba4ea195
parent 447233 7e0d8f40ce513283f7262dca332fddc1e92ff810
child 447235 d612e27061ec3ccec3c30792127a53bb7010d30c
push id38025
push userbmo:cam@mcc.id.au
push dateSat, 03 Dec 2016 06:57:28 +0000
reviewersbholley
bugs1321284
milestone53.0a1
Bug 1321284 - Part 3: Make Servo-based styling use the "flattened tree parent for style". r=bholley MozReview-Commit-ID: BnW5VZ3xLpG
dom/base/ElementInlines.h
layout/style/ServoBindings.cpp
--- a/dom/base/ElementInlines.h
+++ b/dom/base/ElementInlines.h
@@ -3,16 +3,17 @@
 /* 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 mozilla_dom_ElementInlines_h
 #define mozilla_dom_ElementInlines_h
 
 #include "mozilla/dom/Element.h"
+#include "mozilla/ServoBindings.h"
 #include "nsIContentInlines.h"
 #include "nsIDocument.h"
 
 namespace mozilla {
 namespace dom {
 
 inline void
 Element::RegisterActivityObserver()
@@ -49,34 +50,36 @@ Element::GetFlattenedTreeParentElementFo
 }
 
 inline void
 Element::NoteDirtyDescendantsForServo()
 {
   Element* curr = this;
   while (curr && !curr->HasDirtyDescendantsForServo()) {
     curr->SetHasDirtyDescendantsForServo();
-    curr = curr->GetFlattenedTreeParentElement();
+    curr = curr->GetFlattenedTreeParentElementForStyle();
   }
 
   MOZ_ASSERT(DirtyDescendantsBitIsPropagatedForServo());
 }
 
 #ifdef DEBUG
 inline bool
 Element::DirtyDescendantsBitIsPropagatedForServo()
 {
   Element* curr = this;
   while (curr) {
     if (!curr->HasDirtyDescendantsForServo()) {
       return false;
     }
     nsINode* parentNode = curr->GetParentNode();
-    curr = curr->GetFlattenedTreeParentElement();
-    MOZ_ASSERT_IF(!curr, parentNode == OwnerDoc());
+    curr = curr->GetFlattenedTreeParentElementForStyle();
+    MOZ_ASSERT_IF(!curr,
+                  parentNode == OwnerDoc() ||
+                  parentNode == parentNode->OwnerDoc()->GetRootElement());
   }
   return true;
 }
 #endif
 
 } // namespace dom
 } // namespace mozilla
 
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -62,17 +62,17 @@ bool
 Gecko_NodeIsElement(RawGeckoNodeBorrowed aNode)
 {
   return aNode->IsElement();
 }
 
 RawGeckoNodeBorrowedOrNull
 Gecko_GetParentNode(RawGeckoNodeBorrowed aNode)
 {
-  return aNode->GetFlattenedTreeParentNode();
+  return aNode->GetFlattenedTreeParentNodeForStyle();
 }
 
 RawGeckoNodeBorrowedOrNull
 Gecko_GetFirstChild(RawGeckoNodeBorrowed aNode)
 {
   return aNode->GetFirstChild();
 }
 
@@ -92,17 +92,17 @@ RawGeckoNodeBorrowedOrNull
 Gecko_GetNextSibling(RawGeckoNodeBorrowed aNode)
 {
   return aNode->GetNextSibling();
 }
 
 RawGeckoElementBorrowedOrNull
 Gecko_GetParentElement(RawGeckoElementBorrowed aElement)
 {
-  return aElement->GetFlattenedTreeParentElement();
+  return aElement->GetFlattenedTreeParentElementForStyle();
 }
 
 RawGeckoElementBorrowedOrNull
 Gecko_GetFirstChildElement(RawGeckoElementBorrowed aElement)
 {
   return aElement->GetFirstElementChild();
 }