Bug 1334036 - Part 6: Trigger restyle if important rules are changed. draft
authorBoris Chiou <boris.chiou@gmail.com>
Fri, 19 May 2017 16:04:40 +0800
changeset 581939 aedafdd94b80e36ea1299e5d9b137d61a23f743b
parent 581938 524bb0f8b5cab4886585a46a4a80093a46614785
child 581940 343345a6a709c08c1a726e7f4c9ec866e976b106
push id59916
push userbmo:boris.chiou@gmail.com
push dateSat, 20 May 2017 06:48:29 +0000
bugs1334036
milestone55.0a1
Bug 1334036 - Part 6: Trigger restyle if important rules are changed. If we add/remove important rules, we should call MaybeUpdateCascadeResults() to make sure EffectSet::mPropertiesWithImportantRules is correct, and so we can avoid that these important rules are overridden by animations running on compositor. Currently, we call MaybeUpdateCascadeResults only while iterating elements which needs to be restyled, so we should request a restyle on this element whose important rules are changed. MozReview-Commit-ID: 87MBQrirVto
layout/style/ServoBindings.cpp
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -536,20 +536,32 @@ Gecko_UpdateAnimations(RawGeckoElementBo
     if (aTasks & UpdateAnimationsTasks::CSSTransitions) {
       MOZ_ASSERT(aOldComputedValues);
       const ServoComputedValuesWithParent oldServoValues =
         { aOldComputedValues, nullptr };
       presContext->TransitionManager()->
         UpdateTransitions(const_cast<dom::Element*>(aElement), pseudoType,
                           oldServoValues, servoValues);
     }
+
     if (aTasks & UpdateAnimationsTasks::EffectProperties) {
       presContext->EffectCompositor()->UpdateEffectProperties(
         servoValues, const_cast<dom::Element*>(aElement), pseudoType);
     }
+
+    if (aTasks & UpdateAnimationsTasks::CascadeResults) {
+      // This task will be scheduled if we detected any changes to !important
+      // rules. We post a restyle here so that we can update the cascade
+      // results in the pre-traversal of the next restyle.
+      presContext->EffectCompositor()
+                 ->RequestRestyle(const_cast<Element*>(aElement),
+                                  pseudoType,
+                                  EffectCompositor::RestyleType::Standard,
+                                  EffectCompositor::CascadeLevel::Animations);
+    }
   }
 }
 
 bool
 Gecko_ElementHasAnimations(RawGeckoElementBorrowed aElement)
 {
   nsIAtom* pseudoTag = PseudoTagAndCorrectElementForAnimation(aElement);
   CSSPseudoElementType pseudoType =