Bug 1422538: Inline ServoElementSnapshot::AddAttrs. r?bz draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 02 Dec 2017 23:16:31 +0100
changeset 706618 7f7857650ae629ef588c5581551c4bd44666516d
parent 706617 2c37a64eb017d31f6e546d7eeb4807509871a895
child 706619 1ad426ef0e782455e70dad33fd540e42e88c7444
push id91859
push userbmo:emilio@crisal.io
push dateSat, 02 Dec 2017 22:33:42 +0000
reviewersbz
bugs1422538
milestone59.0a1
Bug 1422538: Inline ServoElementSnapshot::AddAttrs. r?bz MozReview-Commit-ID: FmCikbv44A5
layout/style/ServoElementSnapshot.cpp
layout/style/ServoElementSnapshot.h
--- a/layout/style/ServoElementSnapshot.cpp
+++ b/layout/style/ServoElementSnapshot.cpp
@@ -23,57 +23,16 @@ ServoElementSnapshot::ServoElementSnapsh
   MOZ_COUNT_CTOR(ServoElementSnapshot);
   mIsHTMLElementInHTMLDocument =
     aElement->IsHTMLElement() && aElement->IsInHTMLDocument();
   mIsInChromeDocument = nsContentUtils::IsChromeDoc(aElement->OwnerDoc());
   mSupportsLangAttr = aElement->SupportsLangAttr();
 }
 
 void
-ServoElementSnapshot::AddAttrs(Element* aElement,
-                               int32_t aNameSpaceID,
-                               nsAtom* 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);
-    const nsAttrValue* attrValue =
-      aElement->GetParsedAttr(attrName->LocalName(), attrName->NamespaceID());
-    mAttrs.AppendElement(ServoAttrSnapshot(*attrName, *attrValue));
-  }
-  mContains |= Flags::Attributes;
-  if (aElement->HasID()) {
-    mContains |= Flags::Id;
-  }
-  if (const nsAttrValue* classValue = aElement->GetClasses()) {
-    mClass = *classValue;
-    mContains |= Flags::MaybeClass;
-  }
-}
-
-void
 ServoElementSnapshot::AddOtherPseudoClassState(Element* aElement)
 {
   MOZ_ASSERT(aElement);
 
   if (HasOtherPseudoClassState()) {
     return;
   }
 
--- a/layout/style/ServoElementSnapshot.h
+++ b/layout/style/ServoElementSnapshot.h
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_ServoElementSnapshot_h
 #define mozilla_ServoElementSnapshot_h
 
 #include "mozilla/EventStates.h"
 #include "mozilla/TypedEnumBits.h"
 #include "mozilla/dom/BorrowedAttrInfo.h"
+#include "mozilla/dom/Element.h"
 #include "nsAttrName.h"
 #include "nsAttrValue.h"
 #include "nsChangeHint.h"
 #include "nsGkAtoms.h"
 #include "nsAtom.h"
 
 namespace mozilla {
 
@@ -100,17 +101,51 @@ public:
   /**
    * 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,
                 int32_t aNameSpaceID,
-                nsAtom* aChangedAttribute);
+                nsAtom* aAttribute)
+  {
+    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);
+      const nsAttrValue* attrValue =
+        aElement->GetParsedAttr(attrName->LocalName(), attrName->NamespaceID());
+      mAttrs.AppendElement(ServoAttrSnapshot(*attrName, *attrValue));
+    }
+    mContains |= Flags::Attributes;
+    if (aElement->HasID()) {
+      mContains |= Flags::Id;
+    }
+    if (const nsAttrValue* classValue = aElement->GetClasses()) {
+      mClass = *classValue;
+      mContains |= Flags::MaybeClass;
+    }
+  }
 
   /**
    * Captures some other pseudo-class matching state not included in
    * EventStates.
    */
   void AddOtherPseudoClassState(Element* aElement);
 
   /**