aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 78cb2c33075..6056f1f1e5a 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -5051,6 +5051,35 @@ impl Document {
self.image_animation_manager.borrow_mut()
}
+ pub(crate) fn update_animating_images(&self) {
+ let mut image_animation_manager = self.image_animation_manager.borrow_mut();
+ if !image_animation_manager.image_animations_present() {
+ return;
+ }
+ image_animation_manager
+ .update_active_frames(&self.window, self.current_animation_timeline_value());
+
+ if !self.animations().animations_present() {
+ let next_scheduled_time =
+ image_animation_manager.next_schedule_time(self.current_animation_timeline_value());
+ // TODO: Once we have refresh signal from the compositor,
+ // we should get rid of timer for animated image update.
+ if let Some(next_scheduled_time) = next_scheduled_time {
+ self.schedule_image_animation_update(next_scheduled_time);
+ }
+ }
+ }
+
+ fn schedule_image_animation_update(&self, next_scheduled_time: f64) {
+ let callback = ImageAnimationUpdateCallback {
+ document: Trusted::new(self),
+ };
+ self.global().schedule_callback(
+ OneshotTimerCallback::ImageAnimationUpdate(callback),
+ Duration::from_secs_f64(next_scheduled_time),
+ );
+ }
+
/// <https://html.spec.whatwg.org/multipage/#shared-declarative-refresh-steps>
pub(crate) fn shared_declarative_refresh_steps(&self, content: &[u8]) {
// 1. If document's will declaratively refresh is true, then return.
@@ -6747,6 +6776,21 @@ impl FakeRequestAnimationFrameCallback {
}
}
+/// This is a temporary workaround to update animated images,
+/// we should get rid of this after we have refresh driver #3406
+#[derive(JSTraceable, MallocSizeOf)]
+pub(crate) struct ImageAnimationUpdateCallback {
+ /// The document.
+ #[ignore_malloc_size_of = "non-owning"]
+ document: Trusted<Document>,
+}
+
+impl ImageAnimationUpdateCallback {
+ pub(crate) fn invoke(self, can_gc: CanGc) {
+ with_script_thread(|script_thread| script_thread.update_the_rendering(true, can_gc))
+ }
+}
+
#[derive(JSTraceable, MallocSizeOf)]
pub(crate) enum AnimationFrameCallback {
DevtoolsFramerateTick {