diff options
Diffstat (limited to 'components/shared/script_layout/lib.rs')
-rw-r--r-- | components/shared/script_layout/lib.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/components/shared/script_layout/lib.rs b/components/shared/script_layout/lib.rs index 9c70394b0fd..3001f9ce77d 100644 --- a/components/shared/script_layout/lib.rs +++ b/components/shared/script_layout/lib.rs @@ -24,10 +24,12 @@ use euclid::Size2D; use euclid::default::{Point2D, Rect}; use fnv::FnvHashMap; use fonts::{FontContext, SystemFontServiceProxy}; +use fxhash::FxHashMap; use ipc_channel::ipc::IpcSender; use libc::c_void; use malloc_size_of_derive::MallocSizeOf; use net_traits::image_cache::{ImageCache, PendingImageId}; +use pixels::Image; use profile_traits::mem::Report; use profile_traits::time; use script_traits::{InitialScriptState, LoadData, Painter, ScriptThreadMessage}; @@ -400,6 +402,8 @@ pub struct ReflowResult { /// to communicate them with the Constellation and also the `Window` /// element of their content pages. pub iframe_sizes: IFrameSizes, + /// The mapping of node to animated image, need to be returned to ImageAnimationManager + pub node_to_image_animation_map: FxHashMap<OpaqueNode, ImageAnimationState>, } /// Information needed for a script-initiated reflow. @@ -427,6 +431,8 @@ pub struct ReflowRequest { pub animation_timeline_value: f64, /// The set of animations for this document. pub animations: DocumentAnimationSet, + /// The set of image animations. + pub node_to_image_animation_map: FxHashMap<OpaqueNode, ImageAnimationState>, /// The theme for the window pub theme: PrefersColorScheme, } @@ -501,3 +507,25 @@ pub fn node_id_from_scroll_id(id: usize) -> Option<usize> { } None } + +#[derive(Clone, Debug, MallocSizeOf)] +pub struct ImageAnimationState { + #[ignore_malloc_size_of = "Arc is hard"] + image: Arc<Image>, + active_frame: usize, + last_update_time: f64, +} + +impl ImageAnimationState { + pub fn new(image: Arc<Image>) -> Self { + Self { + image, + active_frame: 0, + last_update_time: 0., + } + } + + pub fn image_key(&self) -> Option<ImageKey> { + self.image.id + } +} |