Use a restyle for animation ticks

This change corrects synchronization issues with animations, by
reworking the animation processing model to do a quick restyle and
incremental layout when ticking animations.

While this change adds overhead to animation ticks, the idea is that
this will be the fallback when synchronous behavior is required to
fulfill specification requirements. In the optimistic case, many
animations could be updated and applied off-the-main-thread and then
resynchronized when style information is queried by script.

Fixes #13865.
This commit is contained in:
Martin Robinson 2020-04-30 15:38:56 +02:00
parent 5e44327325
commit b585ce5b1f
39 changed files with 1285 additions and 1662 deletions

View file

@ -9,6 +9,8 @@
#![deny(missing_docs)]
#![deny(unsafe_code)]
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate malloc_size_of;
#[macro_use]
@ -122,8 +124,6 @@ pub enum LayoutControlMsg {
ExitNow,
/// Requests the current epoch (layout counter) from this layout.
GetCurrentEpoch(IpcSender<Epoch>),
/// Asks layout to run another step in its animation.
TickAnimations(ImmutableOrigin),
/// Tells layout about the new scrolling offsets of each scrollable stacking context.
SetScrollStates(Vec<ScrollState>),
/// Requests the current load state of Web fonts. `true` is returned if fonts are still loading
@ -403,7 +403,7 @@ pub enum ConstellationControlMsg {
/// Passes a webdriver command to the script thread for execution
WebDriverScriptCommand(PipelineId, WebDriverScriptCommand),
/// Notifies script thread that all animations are done
TickAllAnimations(PipelineId),
TickAllAnimations(PipelineId, AnimationTickType),
/// Notifies the script thread that a transition or animation related event should be sent.
TransitionOrAnimationEvent {
/// The pipeline id of the layout task that sent this message.
@ -812,13 +812,15 @@ pub struct IFrameLoadInfoWithData {
pub window_size: WindowSizeData,
}
/// Specifies whether the script or layout thread needs to be ticked for animation.
#[derive(Debug, Deserialize, Serialize)]
pub enum AnimationTickType {
/// The script thread.
Script,
/// The layout thread.
Layout,
bitflags! {
#[derive(Deserialize, Serialize)]
/// Specifies if rAF should be triggered and/or CSS Animations and Transitions.
pub struct AnimationTickType: u8 {
/// Trigger a call to requestAnimationFrame.
const REQUEST_ANIMATION_FRAME = 0b001;
/// Trigger restyles for CSS Animations and Transitions.
const CSS_ANIMATIONS_AND_TRANSITIONS = 0b010;
}
}
/// The scroll state of a stacking context.