Move most animation processing to script

This is preparation for sharing this code with layout_2020 and
implementing selective off-the-main-thread animations.

We still look for nodes not in the flow tree in the layout thread.
This commit is contained in:
Martin Robinson 2020-05-07 18:37:18 +02:00
parent aa9f16ce45
commit 3b0619aedd
21 changed files with 444 additions and 371 deletions

View file

@ -16,6 +16,7 @@ atomic_refcell = "0.1"
canvas_traits = {path = "../canvas_traits"}
crossbeam-channel = "0.4"
euclid = "0.20"
fxhash = "0.2"
gfx_traits = {path = "../gfx_traits"}
html5ever = "0.25"
ipc-channel = "0.14"
@ -25,6 +26,7 @@ malloc_size_of_derive = "0.1"
metrics = {path = "../metrics"}
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
parking_lot = "0.9"
profile_traits = {path = "../profile_traits"}
range = {path = "../range"}
script_traits = {path = "../script_traits"}

View file

@ -7,20 +7,25 @@ use crate::{PendingImage, TrustedNodeAddress};
use app_units::Au;
use crossbeam_channel::{Receiver, Sender};
use euclid::default::{Point2D, Rect};
use fxhash::FxHashMap;
use gfx_traits::Epoch;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use metrics::PaintTimeMetrics;
use msg::constellation_msg::{BackgroundHangMonitorRegister, BrowsingContextId, PipelineId};
use net_traits::image_cache::ImageCache;
use parking_lot::RwLock;
use profile_traits::mem::ReportsChan;
use script_traits::Painter;
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
use script_traits::{ScrollState, UntrustedNodeAddress, WindowSizeData};
use script_traits::{
ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg, ScrollState,
WindowSizeData,
};
use servo_arc::Arc as ServoArc;
use servo_atoms::Atom;
use servo_url::{ImmutableOrigin, ServoUrl};
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use style::animation::ElementAnimationSet;
use style::context::QuirksMode;
use style::dom::OpaqueNode;
use style::invalidation::element::restyle_hints::RestyleHint;
@ -87,9 +92,6 @@ pub enum Msg {
/// Send to layout the precise time when the navigation started.
SetNavigationStart(u64),
/// Request the current number of animations that are running.
GetRunningAnimations(IpcSender<usize>),
}
#[derive(Debug, PartialEq)]
@ -183,8 +185,6 @@ pub struct Reflow {
pub struct ReflowComplete {
/// The list of images that were encountered that are in progress.
pub pending_images: Vec<PendingImage>,
/// The list of nodes that initiated a CSS transition.
pub newly_animating_nodes: Vec<UntrustedNodeAddress>,
}
/// Information needed for a script-initiated reflow.
@ -209,6 +209,8 @@ pub struct ScriptReflow {
pub pending_restyles: Vec<(TrustedNodeAddress, PendingRestyle)>,
/// The current animation timeline value.
pub animation_timeline_value: f64,
/// The set of animations for this document.
pub animations: ServoArc<RwLock<FxHashMap<OpaqueNode, ElementAnimationSet>>>,
}
pub struct LayoutThreadInit {