Bug 1294299 part 13 - Post restyle event with style attribute hint for style change. r=heycam
authorXidorn Quan <me@upsuper.org>
Thu, 03 Nov 2016 14:41:02 +1100
changeset 363695 fcbd28c7f79e70376d9e51629611acc8771ee8f6
parent 363694 0f673f5c6b3ff41994db1deff7a9fae542a1f5a1
child 363696 4148e7b3d684e9a4b936d8d13d42c4ad09d92d4c
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1294299
milestone52.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 1294299 part 13 - Post restyle event with style attribute hint for style change. r=heycam MozReview-Commit-ID: 8quLmF0xaxv
layout/base/ServoRestyleManager.cpp
layout/base/ServoRestyleManager.h
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -30,16 +30,22 @@ ServoRestyleManager::PostRestyleEvent(El
       MOZ_UNLIKELY(PresContext()->PresShell()->IsDestroying())) {
     return;
   }
 
   if (aRestyleHint == 0 && !aMinChangeHint && !HasPendingRestyles()) {
     return; // Nothing to do.
   }
 
+  // XXX This is a temporary hack to make style attribute change works.
+  //     In the future, we should be able to use this hint directly.
+  if (aRestyleHint & eRestyle_StyleAttribute) {
+    aRestyleHint |= eRestyle_Subtree;
+  }
+
   // Note that unlike in Servo, we don't mark elements as dirty until we process
   // the restyle hints in ProcessPendingRestyles.
   if (aRestyleHint || aMinChangeHint) {
     ServoElementSnapshot* snapshot = SnapshotForElement(aElement);
     snapshot->AddExplicitRestyleHint(aRestyleHint);
     snapshot->AddExplicitChangeHint(aMinChangeHint);
   }
 
@@ -502,16 +508,27 @@ ServoRestyleManager::AttributeWillChange
                                          int32_t aNameSpaceID,
                                          nsIAtom* aAttribute, int32_t aModType,
                                          const nsAttrValue* aNewValue)
 {
   ServoElementSnapshot* snapshot = SnapshotForElement(aElement);
   snapshot->AddAttrs(aElement);
 }
 
+void
+ServoRestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID,
+                                      nsIAtom* aAttribute, int32_t aModType,
+                                      const nsAttrValue* aOldValue)
+{
+  MOZ_ASSERT(SnapshotForElement(aElement)->HasAttrs());
+  if (aAttribute == nsGkAtoms::style) {
+    PostRestyleEvent(aElement, eRestyle_StyleAttribute, nsChangeHint(0));
+  }
+}
+
 nsresult
 ServoRestyleManager::ReparentStyleContext(nsIFrame* aFrame)
 {
   NS_WARNING("stylo: ServoRestyleManager::ReparentStyleContext not implemented");
   return NS_OK;
 }
 
 ServoElementSnapshot*
--- a/layout/base/ServoRestyleManager.h
+++ b/layout/base/ServoRestyleManager.h
@@ -68,20 +68,17 @@ public:
   void AttributeWillChange(dom::Element* aElement,
                            int32_t aNameSpaceID,
                            nsIAtom* aAttribute,
                            int32_t aModType,
                            const nsAttrValue* aNewValue);
 
   void AttributeChanged(dom::Element* aElement, int32_t aNameSpaceID,
                         nsIAtom* aAttribute, int32_t aModType,
-                        const nsAttrValue* aOldValue)
-  {
-    MOZ_ASSERT(SnapshotForElement(aElement)->HasAttrs());
-  }
+                        const nsAttrValue* aOldValue);
 
   nsresult ReparentStyleContext(nsIFrame* aFrame);
 
   bool HasPendingRestyles()
   {
     return !mModifiedElements.IsEmpty() ||
            PresContext()->Document()->HasDirtyDescendantsForServo();
   }