Animation: update image active frame when update the rendering (#36286)

When no CSS animation exist, register timer for image animation, update
animated image active image frame as part of update_the_rendering, mark
node as dirty if the corresponding image need update. Added unit test to
test ImageAnimationState.

Part of https://github.com/servo/servo/issues/36057, the last step to
let the Animated Image "Move".

Testing: Introduced new WPT RefTest for animated image, but fail because
of https://github.com/servo/servo/issues/36931. New unit test for
`ImageAnimationState`.
Fixes: https://github.com/servo/servo/issues/22903
https://github.com/servo/servo/issues/36057

[Try](https://github.com/rayguo17/servo/actions/runs/14724729664)

---------

Signed-off-by: rayguo17 <rayguo17@gmail.com>
This commit is contained in:
TIN TUN AUNG 2025-05-23 11:13:35 +08:00 committed by GitHub
parent 2353c0089f
commit 23ce7b31ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 313 additions and 8 deletions

View file

@ -24,7 +24,9 @@ use crate::dom::bindings::refcounted::Trusted;
use crate::dom::bindings::reflector::{DomGlobal, DomObject};
use crate::dom::bindings::root::Dom;
use crate::dom::bindings::str::DOMString;
use crate::dom::document::{FakeRequestAnimationFrameCallback, RefreshRedirectDue};
use crate::dom::document::{
FakeRequestAnimationFrameCallback, ImageAnimationUpdateCallback, RefreshRedirectDue,
};
use crate::dom::eventsource::EventSourceTimeoutCallback;
use crate::dom::globalscope::GlobalScope;
#[cfg(feature = "testbinding")]
@ -83,6 +85,7 @@ pub(crate) enum OneshotTimerCallback {
TestBindingCallback(TestBindingCallback),
FakeRequestAnimationFrame(FakeRequestAnimationFrameCallback),
RefreshRedirectDue(RefreshRedirectDue),
ImageAnimationUpdate(ImageAnimationUpdateCallback),
}
impl OneshotTimerCallback {
@ -95,6 +98,7 @@ impl OneshotTimerCallback {
OneshotTimerCallback::TestBindingCallback(callback) => callback.invoke(),
OneshotTimerCallback::FakeRequestAnimationFrame(callback) => callback.invoke(can_gc),
OneshotTimerCallback::RefreshRedirectDue(callback) => callback.invoke(can_gc),
OneshotTimerCallback::ImageAnimationUpdate(callback) => callback.invoke(can_gc),
}
}
}