Bug 1321284 - Part 3: Make Servo-based styling use the "flattened tree parent for style". r=bholley
MozReview-Commit-ID: BnW5VZ3xLpG
--- 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();
}