Bug 1290335: stylo: Assert the snapshot is taken in ServoRestyleManager::AttributeChanged. draft
authorEmilio Cobos Álvarez <ecoal95@gmail.com>
Mon, 01 Aug 2016 10:34:00 -0700
changeset 396042 685b8b2a006163c26ecd1a879f9540367db05255
parent 396041 f42f9c04298be7d958cd32e79d7588b6e68832ef
child 396043 396714b39e9d50c5596b4673b0700da612f5cde3
push id24903
push userbmo:ealvarez@mozilla.com
push dateWed, 03 Aug 2016 08:18:07 +0000
bugs1290335
milestone51.0a1
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
layout/base/ServoRestyleManager.h
layout/style/ServoElementSnapshot.cpp
--- 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 =