diff options
author | Martin Robinson <mrobinson@igalia.com> | 2020-04-21 16:32:53 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2020-04-22 17:23:26 +0200 |
commit | 453b252a655f82fd6405dea753f5a9363b414035 (patch) | |
tree | 980e417444dff612a40e891e1cecf8d6c2c46cc0 /components/script_traits | |
parent | 99cd30eaad786f7c0a113979e8a9f6b4d0250fec (diff) | |
download | servo-453b252a655f82fd6405dea753f5a9363b414035.tar.gz servo-453b252a655f82fd6405dea753f5a9363b414035.zip |
Add support for canceling CSS transitions
This change adds support for canceling CSS transitions when a property
is no longer transitionable or when an element becomes styled with
display:none. Support for canceling and replacing CSS transitions when
the end value changes is still pending. This change also takes advantage
of updating the constellation message to fix a bug where transition
events could be sent for closed pipelines.
Fixes #15079.
Diffstat (limited to 'components/script_traits')
-rw-r--r-- | components/script_traits/lib.rs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 41056f3f6f2..7eb60241f5d 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -282,6 +282,16 @@ pub enum UpdatePipelineIdReason { Traversal, } +/// The type of transition event to trigger. +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub enum TransitionEventType { + /// The transition has ended by reaching the end of its animation. + TransitionEnd, + /// The transition ended early for some reason, such as the property + /// no longer being transitionable or being replaced by another transition. + TransitionCancel, +} + /// Messages sent from the constellation or layout to the script thread. #[derive(Deserialize, Serialize)] pub enum ConstellationControlMsg { @@ -368,8 +378,19 @@ pub enum ConstellationControlMsg { WebDriverScriptCommand(PipelineId, WebDriverScriptCommand), /// Notifies script thread that all animations are done TickAllAnimations(PipelineId), - /// Notifies the script thread of a transition end - TransitionEnd(UntrustedNodeAddress, String, f64), + /// Notifies the script thread that a transition related event should be sent. + TransitionEvent { + /// The pipeline id of the layout task that sent this message. + pipeline_id: PipelineId, + /// The type of transition event this should trigger. + event_type: TransitionEventType, + /// The address of the node which owns this transition. + node: UntrustedNodeAddress, + /// The property name of the property that is transitioning. + property_name: String, + /// The elapsed time property to send with this transition event. + elapsed_time: f64, + }, /// Notifies the script thread that a new Web font has been loaded, and thus the page should be /// reflowed. WebFontLoaded(PipelineId), @@ -429,7 +450,7 @@ impl fmt::Debug for ConstellationControlMsg { FocusIFrame(..) => "FocusIFrame", WebDriverScriptCommand(..) => "WebDriverScriptCommand", TickAllAnimations(..) => "TickAllAnimations", - TransitionEnd(..) => "TransitionEnd", + TransitionEvent { .. } => "TransitionEvent", WebFontLoaded(..) => "WebFontLoaded", DispatchIFrameLoadEvent { .. } => "DispatchIFrameLoadEvent", DispatchStorageEvent(..) => "DispatchStorageEvent", |