aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Watson <github@intuitionlibrary.com>2017-06-20 12:42:14 +1000
committerGlenn Watson <github@intuitionlibrary.com>2017-06-20 12:42:14 +1000
commit6c9e3054424913baa11f30d86c272158b2f21c81 (patch)
treebca4f2de4af769d7f900147fc48bebf0bdae0f67
parentc8255922a98996c5aea7eff8eb837682d883aa63 (diff)
downloadservo-6c9e3054424913baa11f30d86c272158b2f21c81.tar.gz
servo-6c9e3054424913baa11f30d86c272158b2f21c81.zip
Ensure that rAF callbacks which don't mutate the DOM, but aren't
yet considered spurious force a reflow / composite / animation tick cycle.
-rw-r--r--components/script/dom/document.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index da3b5db052c..2015a2f919a 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -1596,6 +1596,22 @@ impl Document {
ReflowQueryType::NoQuery,
ReflowReason::RequestAnimationFrame);
+ if spurious && !was_faking_animation_frames {
+ // If the rAF callbacks did not mutate the DOM, then the
+ // reflow call above means that layout will not be invoked,
+ // and therefore no new frame will be sent to the compositor.
+ // If this happens, the compositor will not tick the animation
+ // and the next rAF will never be called! When this happens
+ // for several frames, then the spurious rAF detection below
+ // will kick in and use a timer to tick the callbacks. However,
+ // for the interim frames where we are deciding whether this rAF
+ // is considered spurious, we need to ensure that the layout
+ // and compositor *do* tick the animation.
+ self.window.force_reflow(ReflowGoal::ForDisplay,
+ ReflowQueryType::NoQuery,
+ ReflowReason::RequestAnimationFrame);
+ }
+
// Only send the animation change state message after running any callbacks.
// This means that if the animation callback adds a new callback for
// the next frame (which is the common case), we won't send a NoAnimationCallbacksPresent