Bug 1422538: Inline ServoElementSnapshot::AddAttrs. r?bz
MozReview-Commit-ID: FmCikbv44A5
--- 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);
/**