mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Animation: Aggregate Animated Image Info to Document (#36141)
Signed-off-by: rayguo17 <rayguo17@gmail.com>
This commit is contained in:
parent
53f7c7b1de
commit
ed3dd8fbe0
10 changed files with 145 additions and 9 deletions
29
components/script/image_animation.rs
Normal file
29
components/script/image_animation.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use fxhash::FxHashMap;
|
||||
use script_layout_interface::ImageAnimationState;
|
||||
use style::dom::OpaqueNode;
|
||||
|
||||
#[derive(Clone, Debug, Default, JSTraceable, MallocSizeOf)]
|
||||
pub struct ImageAnimationManager {
|
||||
#[no_trace]
|
||||
pub node_to_image_map: FxHashMap<OpaqueNode, ImageAnimationState>,
|
||||
}
|
||||
|
||||
impl ImageAnimationManager {
|
||||
pub fn new() -> Self {
|
||||
ImageAnimationManager {
|
||||
node_to_image_map: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn take_image_animate_set(&mut self) -> FxHashMap<OpaqueNode, ImageAnimationState> {
|
||||
std::mem::take(&mut self.node_to_image_map)
|
||||
}
|
||||
|
||||
pub fn restore_image_animate_set(&mut self, map: FxHashMap<OpaqueNode, ImageAnimationState>) {
|
||||
let _ = std::mem::replace(&mut self.node_to_image_map, map);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue