Bug 1422538: Inline ServoElementSnapshot::AddAttrs. r=bz
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 02 Dec 2017 23:16:31 +0100
changeset 447409 adb6ddd964b192153d84f436d72e2fe68aad4960
parent 447408 db63a1ad3e7db7bf733983de0c38a4f48aeb4caa
child 447410 b9ff136cf8d2ddd9c9b11257c2c25ee6d5117530
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1422538
milestone59.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 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,28 +5,25 @@
  * 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 {
 
-namespace dom {
-class Element;
-} // namespace dom
-
 /**
  * A structure representing a single attribute name and value.
  *
  * This is pretty similar to the private nsAttrAndChildArray::InternalAttr.
  */
 struct ServoAttrSnapshot
 {
   nsAttrName mName;
@@ -100,17 +97,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);
 
   /**