Bug 1290335: stylo: Assert the snapshot is taken in ServoRestyleManager::AttributeChanged.
Also fixes an embarrassing typo in the implementation of
ServoElementSnapshot::AddAttrs.
MozReview-Commit-ID: 7LHZVLo6j60
--- a/layout/base/ServoRestyleManager.h
+++ b/layout/base/ServoRestyleManager.h
@@ -61,20 +61,22 @@ public:
nsresult ContentStateChanged(nsIContent* aContent,
EventStates aStateMask);
void AttributeWillChange(dom::Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType,
const nsAttrValue* aNewValue);
- // XXXbholley: We should assert that the element is already snapshotted.
void AttributeChanged(dom::Element* aElement, int32_t aNameSpaceID,
nsIAtom* aAttribute, int32_t aModType,
- const nsAttrValue* aOldValue) {}
+ const nsAttrValue* aOldValue)
+ {
+ MOZ_ASSERT(SnapshotForElement(aElement)->HasAttrs());
+ }
nsresult ReparentStyleContext(nsIFrame* aFrame);
nsresult ProcessRestyledFrames(nsStyleChangeList& aChangeList);
void FlushOverflowChangedTracker();
bool HasPendingRestyles() { return !mModifiedElements.IsEmpty(); }
protected:
--- a/layout/style/ServoElementSnapshot.cpp
+++ b/layout/style/ServoElementSnapshot.cpp
@@ -20,17 +20,17 @@ ServoElementSnapshot::ServoElementSnapsh
aElement->IsHTMLElement() && aElement->IsInHTMLDocument();
}
void
ServoElementSnapshot::AddAttrs(Element* aElement)
{
MOZ_ASSERT(aElement);
- if (!HasAny(Flags::Attributes)) {
+ if (HasAny(Flags::Attributes)) {
return;
}
uint32_t attrCount = aElement->GetAttrCount();
const nsAttrName* attrName;
for (uint32_t i = 0; i < attrCount; ++i) {
attrName = aElement->GetAttrNameAt(i);
const nsAttrValue* attrValue =