Bug 1422538: Inline ServoElementSnapshot::AddAttrs. r?bz draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 02 Dec 2017 23:16:31 +0100
changeset 706632 1a135e9207dab5d47687080692d4275b9cffd553
parent 706631 7acf5a4e7e5fb0b32517ab919ae7538b3b7d53f2
child 706633 08ae8ed544f1c633dc86f5030bc450f5d527bb42
push id91862
push userbmo:emilio@crisal.io
push dateSat, 02 Dec 2017 23:34:31 +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);
 
   /**