Bug 1321284 - Part 3: Make Servo-based styling use the "flattened tree parent for style". r=bholley
authorCameron McCormack <cam@mcc.id.au>
Thu, 01 Dec 2016 14:55:49 +0800
changeset 325196 5654f66d96a0b4e9ccc0773c7739dff394715951
parent 325195 25cd51dd7c98aa573180e2318c7ff67e5c443b11
child 325197 f26dabbb6e09780527469670acbc71d923856f8d
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +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
@@ -57,17 +57,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();
 }
 
@@ -87,17 +87,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();
 }