Bug 1368240: Record whether an snapshot is recording a class attribute change or id change. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 09 Jun 2017 17:16:29 +0200
changeset 363656 e2c830394d47b4be291527136f95947704e06fd9
parent 363655 77cf36250272fcd1f27d27e669e0e6d7e3638324
child 363657 2addc637dc89ebd08555324abadd27a1f30b99b7
push id32023
push userkwierso@gmail.com
push dateWed, 14 Jun 2017 01:09:52 +0000
treeherdermozilla-central@6bea8e940b9c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1368240
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368240: Record whether an snapshot is recording a class attribute change or id change. r=heycam I'll use this information in order to get fewer dependencies out of the dependency set. MozReview-Commit-ID: 5HlmKmSNO8p
layout/base/ServoRestyleManager.cpp
layout/style/ServoElementSnapshot.cpp
layout/style/ServoElementSnapshot.h
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -796,17 +796,17 @@ ServoRestyleManager::AttributeWillChange
 {
   MOZ_ASSERT(!mInStyleRefresh);
 
   if (!aElement->HasServoData()) {
     return;
   }
 
   ServoElementSnapshot& snapshot = SnapshotFor(aElement);
-  snapshot.AddAttrs(aElement);
+  snapshot.AddAttrs(aElement, aNameSpaceID, aAttribute);
 
   if (AttributeInfluencesOtherPseudoClassState(aElement, aAttribute)) {
     snapshot.AddOtherPseudoClassState(aElement);
   }
 
   if (Element* parent = aElement->GetFlattenedTreeParentElementForStyle()) {
     parent->NoteDirtyDescendantsForServo();
   }
--- a/layout/style/ServoElementSnapshot.cpp
+++ b/layout/style/ServoElementSnapshot.cpp
@@ -11,34 +11,51 @@
 
 namespace mozilla {
 
 ServoElementSnapshot::ServoElementSnapshot(const Element* aElement)
   : mState(0)
   , mContains(Flags(0))
   , mIsTableBorderNonzero(false)
   , mIsMozBrowserFrame(false)
+  , mClassAttributeChanged(false)
+  , mIdAttributeChanged(false)
+  , mOtherAttributeChanged(false)
 {
   MOZ_COUNT_CTOR(ServoElementSnapshot);
   mIsHTMLElementInHTMLDocument =
     aElement->IsHTMLElement() && aElement->IsInHTMLDocument();
   mIsInChromeDocument = nsContentUtils::IsChromeDoc(aElement->OwnerDoc());
   mSupportsLangAttr = aElement->SupportsLangAttr();
 }
 
 ServoElementSnapshot::~ServoElementSnapshot()
 {
   MOZ_COUNT_DTOR(ServoElementSnapshot);
 }
 
 void
-ServoElementSnapshot::AddAttrs(Element* aElement)
+ServoElementSnapshot::AddAttrs(Element* aElement,
+                               int32_t aNameSpaceID,
+                               nsIAtom* aAttribute)
 {
   MOZ_ASSERT(aElement);
 
+  if (aNameSpaceID == kNameSpaceID_None) {
+    if (aAttribute == nsGkAtoms::_class) {
+      mClassAttributeChanged = true;
+    } else if (aAttribute == nsGkAtoms::id) {
+      mIdAttributeChanged = true;
+    } else {
+      mOtherAttributeChanged = true;
+    }
+  } else {
+    mOtherAttributeChanged = true;
+  }
+
   if (HasAttrs()) {
     return;
   }
 
   uint32_t attrCount = aElement->GetAttrCount();
   const nsAttrName* attrName;
   for (uint32_t i = 0; i < attrCount; ++i) {
     attrName = aElement->GetAttrNameAt(i);
--- a/layout/style/ServoElementSnapshot.h
+++ b/layout/style/ServoElementSnapshot.h
@@ -89,18 +89,23 @@ public:
     if (!HasAny(Flags::State)) {
       mState = aState.ServoValue();
       mContains |= Flags::State;
     }
   }
 
   /**
    * Captures the given element attributes (if not previously captured).
+   *
+   * The attribute name and namespace are used to note which kind of attribute
+   * has changed.
    */
-  void AddAttrs(Element* aElement);
+  void AddAttrs(Element* aElement,
+                int32_t aNameSpaceID,
+                nsIAtom* aChangedAttribute);
 
   /**
    * Captures some other pseudo-class matching state not included in
    * EventStates.
    */
   void AddOtherPseudoClassState(Element* aElement);
 
   /**
@@ -170,13 +175,16 @@ private:
   nsTArray<ServoAttrSnapshot> mAttrs;
   ServoStateType mState;
   Flags mContains;
   bool mIsHTMLElementInHTMLDocument : 1;
   bool mIsInChromeDocument : 1;
   bool mSupportsLangAttr : 1;
   bool mIsTableBorderNonzero : 1;
   bool mIsMozBrowserFrame : 1;
+  bool mClassAttributeChanged : 1;
+  bool mIdAttributeChanged : 1;
+  bool mOtherAttributeChanged : 1;
 };
 
 } // namespace mozilla
 
 #endif