Bug 1421507 - Throttle animations in position:fixed element that the element is out of view. r=boris,tnikkel
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 05 Jan 2018 10:30:46 +0900
changeset 449645 d9cef5fcc2bbc62131a6506fa97a72391b394fb7
parent 449644 7fb87e5f9a622b144013d7be5533de064baa95b6
child 449646 ba79a634141b50e99b2aee7853111a232c1a3597
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris, tnikkel
bugs1421507
milestone59.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 1421507 - Throttle animations in position:fixed element that the element is out of view. r=boris,tnikkel MozReview-Commit-ID: jLvrcVhTKW
dom/animation/test/mozilla/file_restyles.html
layout/generic/nsFrame.cpp
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -1184,16 +1184,62 @@ waitForAllPaints(() => {
       is(markers.length, 0,
          'CSS animation on an out-of-view position absolute element should ' +
          'be throttled');
 
       await ensureElementRemoval(div);
     }
   );
 
+  add_task(
+    async function throttling_animations_in_out_of_view_position_fixed_element() {
+      if (!offscreenThrottlingEnabled) {
+        return;
+      }
+
+      var parentDiv = addDiv(null,
+                             { style: 'position: fixed; top: -1000px;' });
+      var targetDiv = addDiv(null,
+                             { style: 'animation: background-color 100s;' });
+      parentDiv.appendChild(targetDiv);
+
+      var animation = targetDiv.getAnimations()[0];
+      await animation.ready;
+
+      var markers = await observeStyling(5);
+      is(markers.length, 0,
+         'CSS animation on an out-of-view position:fixed element should be ' +
+         'throttled');
+
+      await ensureElementRemoval(parentDiv);
+    }
+  );
+
+  add_task(
+    async function throttling_animations_on_out_of_view_position_fixed_element() {
+      if (!offscreenThrottlingEnabled) {
+        return;
+      }
+
+      var div = addDiv(null,
+                       { style: 'animation: background-color 100s; ' +
+                                'position: fixed; top: -1000px;' });
+
+      var animation = div.getAnimations()[0];
+      await animation.ready;
+
+      var markers = await observeStyling(5);
+      is(markers.length, 0,
+         'CSS animation on an out-of-view position:fixed element should be ' +
+         'throttled');
+
+      await ensureElementRemoval(div);
+    }
+  );
+
   add_task_if_omta_enabled(
     async function no_restyling_for_compositor_animation_on_unrelated_style_change() {
       var div = addDiv(null);
       var animation = div.animate({ opacity: [0, 1] }, 100 * MS_PER_SEC);
 
       await animation.ready;
       ok(SpecialPowers.wrap(animation).isRunningOnCompositor,
          'The opacity animation is running on the compositor');
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -10962,16 +10962,17 @@ nsIFrame::GetPseudoElement(CSSPseudoElem
 static bool
 IsFrameScrolledOutOfView(nsIFrame* aTarget,
                          const nsRect& aTargetRect,
                          nsIFrame* aParent)
 {
   nsIScrollableFrame* scrollableFrame =
     nsLayoutUtils::GetNearestScrollableFrame(aParent,
       nsLayoutUtils::SCROLLABLE_SAME_DOC |
+      nsLayoutUtils::SCROLLABLE_FIXEDPOS_FINDS_ROOT |
       nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
   if (!scrollableFrame) {
     return false;
   }
 
   nsIFrame *scrollableParent = do_QueryFrame(scrollableFrame);
 
   nsRect transformedRect =