Bug 1362549 - Assert against accessing the attributes of a snapshot that doesn't have attributes saved. r=emilio

MozReview-Commit-ID: 8BsnTF6uIGM
This commit is contained in:
Bobby Holley 2017-05-05 13:48:53 -07:00
parent e8eb9f05e3
commit a8f10f24ec
2 changed files with 6 additions and 4 deletions

View File

@ -32,7 +32,7 @@ ServoElementSnapshot::AddAttrs(Element* aElement)
{
MOZ_ASSERT(aElement);
if (HasAny(Flags::Attributes)) {
if (HasAttrs()) {
return;
}

View File

@ -70,9 +70,9 @@ public:
explicit ServoElementSnapshot(const Element* aElement);
~ServoElementSnapshot();
bool HasAttrs() { return HasAny(Flags::Attributes); }
bool HasAttrs() const { return HasAny(Flags::Attributes); }
bool HasState() { return HasAny(Flags::State); }
bool HasState() const { return HasAny(Flags::State); }
/**
* Captures the given state (if not previously captured).
@ -95,6 +95,7 @@ public:
*/
BorrowedAttrInfo GetAttrInfoAt(uint32_t aIndex) const
{
MOZ_ASSERT(HasAttrs());
if (aIndex >= mAttrs.Length()) {
return BorrowedAttrInfo(nullptr, nullptr);
}
@ -109,6 +110,7 @@ public:
const nsAttrValue* GetParsedAttr(nsIAtom* aLocalName,
int32_t aNamespaceID) const
{
MOZ_ASSERT(HasAttrs());
uint32_t i, len = mAttrs.Length();
if (aNamespaceID == kNameSpaceID_None) {
// This should be the common case so lets make an optimized loop
@ -135,7 +137,7 @@ public:
return mIsInChromeDocument;
}
bool HasAny(Flags aFlags) { return bool(mContains & aFlags); }
bool HasAny(Flags aFlags) const { return bool(mContains & aFlags); }
private:
// TODO: Profile, a 1 or 2 element AutoTArray could be worth it, given we know