Bug 1321284 - Part 4.1: Add function to determine if we need to traverse from a given node for restyling. r=bholley
authorCameron McCormack <cam@mcc.id.au>
Fri, 02 Dec 2016 16:54:43 +0800
changeset 325198 a52bb1232e77717d0ad7d5cd58245940f67e9570
parent 325197 f26dabbb6e09780527469670acbc71d923856f8d
child 325199 1cb9bcc84d128984a3018c9dce2378264c471ff4
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbholley
bugs1321284
milestone53.0a1
Bug 1321284 - Part 4.1: Add function to determine if we need to traverse from a given node for restyling. r=bholley MozReview-Commit-ID: 3MaLp9AOJKm
dom/base/Element.h
dom/base/ElementInlines.h
layout/style/ServoBindingList.h
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -414,16 +414,18 @@ public:
     SetFlags(NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
   }
 
   void UnsetHasDirtyDescendantsForServo() {
     MOZ_ASSERT(IsStyledByServo());
     UnsetFlags(NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
   }
 
+  inline bool ShouldTraverseForServo();
+
   inline void NoteDirtyDescendantsForServo();
 
 #ifdef DEBUG
   inline bool DirtyDescendantsBitIsPropagatedForServo();
 #endif
 
   bool HasServoData() {
 #ifdef MOZ_STYLO
--- a/dom/base/ElementInlines.h
+++ b/dom/base/ElementInlines.h
@@ -44,16 +44,22 @@ Element::GetFlattenedTreeParentElementFo
   nsINode* parentNode = GetFlattenedTreeParentNodeForStyle();
   if MOZ_LIKELY(parentNode && parentNode->IsElement()) {
     return parentNode->AsElement();
   }
 
   return nullptr;
 }
 
+inline bool
+Element::ShouldTraverseForServo()
+{
+  return HasDirtyDescendantsForServo() || Servo_Element_ShouldTraverse(this);
+}
+
 inline void
 Element::NoteDirtyDescendantsForServo()
 {
   Element* curr = this;
   while (curr && !curr->HasDirtyDescendantsForServo()) {
     curr->SetHasDirtyDescendantsForServo();
     curr = curr->GetFlattenedTreeParentElementForStyle();
   }
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -15,16 +15,17 @@
  *
  * Users of this list should define a macro
  * SERVO_BINDING_FUNC(name_, return_, ...)
  * before including this file.
  */
 
 // Element data
 SERVO_BINDING_FUNC(Servo_Element_ClearData, void, RawGeckoElementBorrowed node)
+SERVO_BINDING_FUNC(Servo_Element_ShouldTraverse, bool, RawGeckoElementBorrowed node)
 
 // Styleset and Stylesheet management
 SERVO_BINDING_FUNC(Servo_StyleSheet_Empty, RawServoStyleSheetStrong,
                    mozilla::css::SheetParsingMode parsing_mode)
 SERVO_BINDING_FUNC(Servo_StyleSheet_FromUTF8Bytes, RawServoStyleSheetStrong,
                    const nsACString* data,
                    mozilla::css::SheetParsingMode parsing_mode,
                    const nsACString* base_url,