Bug 1285407 - Part 2: We need to call MarkCascadeNeedsUpdate() when the style context is changed. r?birtles draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Mon, 11 Jul 2016 17:28:15 +0900
changeset 386114 8c9daee7dbf9474d7e1940fa9a35491e2d8ad99f
parent 386113 710fed6e08324309a73d78e6d5c07f44185b12e9
child 386115 0ee0933779dd6089853b4a430c5db269a9d749ea
push id22626
push userhiikezoe@mozilla-japan.org
push dateMon, 11 Jul 2016 08:29:02 +0000
reviewersbirtles
bugs1285407
milestone50.0a1
Bug 1285407 - Part 2: We need to call MarkCascadeNeedsUpdate() when the style context is changed. r?birtles MozReview-Commit-ID: 2z2HgSDzhLd
dom/animation/EffectCompositor.cpp
dom/animation/test/chrome/test_running_on_compositor.html
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -227,16 +227,20 @@ EffectCompositor::UpdateEffectProperties
                                          dom::Element* aElement,
                                          CSSPseudoElementType aPseudoType)
 {
   EffectSet* effectSet = EffectSet::GetEffectSet(aElement, aPseudoType);
   if (!effectSet) {
     return;
   }
 
+  // Style context change might cause CSS cascade level,
+  // e.g removing !important, so we should update the cascading result.
+  effectSet->MarkCascadeNeedsUpdate();
+
   for (KeyframeEffectReadOnly* effect : *effectSet) {
     effect->UpdateProperties(aStyleContext);
   }
 }
 
 void
 EffectCompositor::MaybeUpdateAnimationRule(dom::Element* aElement,
                                            CSSPseudoElementType aPseudoType,
--- a/dom/animation/test/chrome/test_running_on_compositor.html
+++ b/dom/animation/test/chrome/test_running_on_compositor.html
@@ -510,10 +510,30 @@ promise_test(function(t) {
   }).then(function() {
     assert_equals(animation.isRunningOnCompositor, omtaEnabled,
                   '100% opacity animation set by using setKeyframes reports ' +
                   'that it is running on the compositor');
   });
 }, '100% opacity animation set up by converting an existing animation with ' +
    'cannot be run on the compositor, is running on the compositor');
 
+promise_test(function(t) {
+  var div = addDiv(t, { style: "opacity: 1 ! important" });
+
+  var animation = div.animate({ opacity: [0, 1] }, 100 * MS_PER_SEC);
+
+  return animation.ready.then(function() {
+    assert_equals(animation.isRunningOnCompositor, false,
+      'Opacity animation on an element which has 100% opacity style with ' +
+      '!important flag reports that it is not running on the compositor');
+    // Clear important flag from the opacity style on the target element.
+    div.style.setProperty("opacity", "1", "");
+    return waitForFrame();
+  }).then(function() {
+    assert_equals(animation.isRunningOnCompositor, omtaEnabled,
+      'Opacity animation reports that it is running on the compositor after '
+      + 'clearing the !important flag');
+  });
+}, 'Clearing *important* opacity style on the target element sends the ' +
+   'animation to the compositor');
+
 </script>
 </body>