pub(crate) struct AnimationManager {
sets: DocumentAnimationSet,
animating_images: Arc<RwLock<AnimatingImages>>,
has_running_animations: Cell<bool>,
rooted_animation_nodes: DomRefCell<FxHashMap<NoTrace<OpaqueNode>, Dom<Node>>>,
rooted_image_nodes: DomRefCell<FxHashMap<NoTrace<OpaqueNode>, Dom<Node>>>,
pending_events: DomRefCell<Vec<TransitionOrAnimationEvent>>,
timeline_value_at_last_dirty: Cell<f64>,
image_callback_timer_id: Cell<Option<TimerId>>,
}Expand description
The set of animations for a document.
Fields§
§sets: DocumentAnimationSetThe map of nodes to their animation states.
animating_images: Arc<RwLock<AnimatingImages>>The set of AnimatingImages which is used to communicate the addition
and removal of animating images from layout.
has_running_animations: Cell<bool>Whether or not we have animations that are running.
rooted_animation_nodes: DomRefCell<FxHashMap<NoTrace<OpaqueNode>, Dom<Node>>>A map of nodes with in-progress CSS transitions or pending events.
rooted_image_nodes: DomRefCell<FxHashMap<NoTrace<OpaqueNode>, Dom<Node>>>A map of nodes with in-progress image animations. This is kept outside
of Self::animating_images as that data structure is shared with layout.
pending_events: DomRefCell<Vec<TransitionOrAnimationEvent>>A list of pending animation-related events.
timeline_value_at_last_dirty: Cell<f64>The timeline value at the last time all animations were marked dirty. This is used to prevent marking animations dirty when the timeline has not changed.
image_callback_timer_id: Cell<Option<TimerId>>The TimerId of the currently scheduled animated image update callback.
Implementations§
Source§impl AnimationManager
impl AnimationManager
pub(crate) fn new() -> Self
pub(crate) fn animating_images(&self) -> Arc<RwLock<AnimatingImages>> ⓘ
pub(crate) fn sets(&self) -> DocumentAnimationSet
pub(crate) fn clear(&self)
pub(crate) fn mark_animating_nodes_as_dirty( &self, no_gc: &NoGC, current_timeline_value: f64, ) -> bool
pub(crate) fn update_for_new_timeline_value(&self, window: &Window, now: f64)
Sourcepub(crate) fn cancel_animations_for_node(&self, node: &Node)
pub(crate) fn cancel_animations_for_node(&self, node: &Node)
Cancel animations for the given node, if any exist.
Sourcepub(crate) fn do_post_reflow_update(&self, window: &Window, now: f64)
pub(crate) fn do_post_reflow_update(&self, window: &Window, now: f64)
This does five things:
- Cancel animations for any nodes that are no longer being rendered or delegating rendering.
- Process any new animations that were discovered after reflow.
- Collect pending events for any animations that changed state.
- Root any nodes with newly animating images
- Schedule an image update for newly animating images
pub(crate) fn update_active_image_animation_frames( &self, window: &Window, now: f64, )
fn root_nodes_with_newly_animating_images(&self)
fn maybe_schedule_image_animation_update(&self, window: &Window, now: f64)
fn duration_to_next_image_animation_frame(&self, now: f64) -> Option<Duration>
fn update_running_animations_presence(&self, window: &Window, new_value: bool)
fn handle_animation_presence_or_pending_events_change(&self, window: &Window)
pub(crate) fn running_animation_count(&self) -> usize
Sourcefn start_pending_animations(
&self,
key: &AnimationSetKey,
set: &mut ElementAnimationSet,
now: f64,
pipeline_id: PipelineId,
)
fn start_pending_animations( &self, key: &AnimationSetKey, set: &mut ElementAnimationSet, now: f64, pipeline_id: PipelineId, )
Walk through the list of pending animations and start all of the ones that have left the delay phase.
Sourcefn finish_running_animations(
&self,
key: &AnimationSetKey,
set: &mut ElementAnimationSet,
now: f64,
pipeline_id: PipelineId,
)
fn finish_running_animations( &self, key: &AnimationSetKey, set: &mut ElementAnimationSet, now: f64, pipeline_id: PipelineId, )
Walk through the list of running animations and remove all of the ones that have ended.
Sourcefn handle_canceled_animations(
&self,
key: &AnimationSetKey,
set: &mut ElementAnimationSet,
now: f64,
pipeline_id: PipelineId,
)
fn handle_canceled_animations( &self, key: &AnimationSetKey, set: &mut ElementAnimationSet, now: f64, pipeline_id: PipelineId, )
Send events for canceled animations. Currently this only handles canceled transitions, but eventually this should handle canceled CSS animations as well.
fn handle_new_animations( &self, key: &AnimationSetKey, set: &mut ElementAnimationSet, now: f64, pipeline_id: PipelineId, )
Sourcefn root_newly_animating_dom_nodes(
&self,
sets: &FxHashMap<AnimationSetKey, ElementAnimationSet>,
)
fn root_newly_animating_dom_nodes( &self, sets: &FxHashMap<AnimationSetKey, ElementAnimationSet>, )
Ensure that all nodes with new animations are rooted. This should be called immediately after a restyle, to ensure that these addresses are still valid.
fn unroot_unused_nodes( &self, sets: &FxHashMap<AnimationSetKey, ElementAnimationSet>, )
fn add_transition_event( &self, key: &AnimationSetKey, transition: &Transition, event_type: TransitionOrAnimationEventType, now: f64, pipeline_id: PipelineId, )
fn add_animation_event( &self, key: &AnimationSetKey, animation: &Animation, event_type: TransitionOrAnimationEventType, now: f64, pipeline_id: PipelineId, )
Sourcepub(crate) fn send_pending_events(&self, window: &Window, cx: &mut JSContext)
pub(crate) fn send_pending_events(&self, window: &Window, cx: &mut JSContext)
An implementation of the final steps of https://drafts.csswg.org/web-animations-1/#update-animations-and-send-events.
Trait Implementations§
Source§impl Default for AnimationManager
impl Default for AnimationManager
Source§fn default() -> AnimationManager
fn default() -> AnimationManager
Source§impl MallocSizeOf for AnimationManager
impl MallocSizeOf for AnimationManager
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl !Freeze for AnimationManager
impl !RefUnwindSafe for AnimationManager
impl !Send for AnimationManager
impl !Sync for AnimationManager
impl Unpin for AnimationManager
impl UnsafeUnpin for AnimationManager
impl !UnwindSafe for AnimationManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more