Skip to main content

cdp_driver/protocol/
animation.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! The `Animation` domain.
5//!
6//! Types, command parameters and event payloads for the `Animation`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9//!
10//! This domain is experimental and may change without notice.
11
12use serde::{Deserialize, Serialize};
13
14/// Animation instance.
15#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
16pub struct Animation {
17    /// `Animation`'s id.
18    pub id: String,
19    /// `Animation`'s name.
20    pub name: String,
21    /// `Animation`'s internal paused state.
22    #[serde(rename = "pausedState")]
23    pub paused_state: bool,
24    /// `Animation`'s play state.
25    #[serde(rename = "playState")]
26    pub play_state: String,
27    /// `Animation`'s playback rate.
28    #[serde(rename = "playbackRate")]
29    pub playback_rate: f64,
30    /// `Animation`'s start time. Milliseconds for time based animations and
31    /// percentage \[0 - 100\] for scroll driven animations (i.e. when
32    /// viewOrScrollTimeline exists).
33    #[serde(rename = "startTime")]
34    pub start_time: f64,
35    /// `Animation`'s current time.
36    #[serde(rename = "currentTime")]
37    pub current_time: f64,
38    /// Animation type of `Animation`.
39    pub r#type: AnimationType,
40    /// `Animation`'s source animation node.
41    #[serde(default, skip_serializing_if = "Option::is_none")]
42    pub source: Option<AnimationEffect>,
43    /// A unique ID for `Animation` representing the sources that triggered this
44    /// CSS animation/transition.
45    #[serde(rename = "cssId", default, skip_serializing_if = "Option::is_none")]
46    pub css_id: Option<String>,
47    /// View or scroll timeline
48    #[serde(
49        rename = "viewOrScrollTimeline",
50        default,
51        skip_serializing_if = "Option::is_none"
52    )]
53    pub view_or_scroll_timeline: Option<ViewOrScrollTimeline>,
54}
55
56/// The values `type` accepts on `Animation`.
57#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
58pub enum AnimationType {
59    /// `CSSTransition`
60    #[serde(rename = "CSSTransition")]
61    CssTransition,
62    /// `CSSAnimation`
63    #[serde(rename = "CSSAnimation")]
64    CssAnimation,
65    /// `WebAnimation`
66    WebAnimation,
67    /// A value this vendored schema does not list. Chrome adds values ahead of
68    /// the published protocol, so an unrecognised one is kept as it arrived
69    /// rather than failing the payload it came in.
70    #[serde(untagged)]
71    Unrecognized(String),
72}
73
74/// Timeline instance
75#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
76pub struct ViewOrScrollTimeline {
77    /// Scroll container node
78    #[serde(
79        rename = "sourceNodeId",
80        default,
81        skip_serializing_if = "Option::is_none"
82    )]
83    pub source_node_id: Option<crate::protocol::dom::BackendNodeId>,
84    /// Represents the starting scroll position of the timeline as a length offset
85    /// in pixels from scroll origin.
86    #[serde(
87        rename = "startOffset",
88        default,
89        skip_serializing_if = "Option::is_none"
90    )]
91    pub start_offset: Option<f64>,
92    /// Represents the ending scroll position of the timeline as a length offset
93    /// in pixels from scroll origin.
94    #[serde(rename = "endOffset", default, skip_serializing_if = "Option::is_none")]
95    pub end_offset: Option<f64>,
96    /// The element whose principal box's visibility in the scrollport defined the
97    /// progress of the timeline. Does not exist for animations with
98    /// ScrollTimeline
99    #[serde(
100        rename = "subjectNodeId",
101        default,
102        skip_serializing_if = "Option::is_none"
103    )]
104    pub subject_node_id: Option<crate::protocol::dom::BackendNodeId>,
105    /// Orientation of the scroll
106    pub axis: crate::protocol::dom::ScrollOrientation,
107}
108
109/// AnimationEffect instance
110#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
111pub struct AnimationEffect {
112    /// `AnimationEffect`'s delay.
113    pub delay: f64,
114    /// `AnimationEffect`'s end delay.
115    #[serde(rename = "endDelay")]
116    pub end_delay: f64,
117    /// `AnimationEffect`'s iteration start.
118    #[serde(rename = "iterationStart")]
119    pub iteration_start: f64,
120    /// `AnimationEffect`'s iterations. Omitted if the value is infinite.
121    #[serde(default, skip_serializing_if = "Option::is_none")]
122    pub iterations: Option<f64>,
123    /// `AnimationEffect`'s iteration duration. Milliseconds for time based
124    /// animations and percentage \[0 - 100\] for scroll driven animations (i.e.
125    /// when viewOrScrollTimeline exists).
126    pub duration: f64,
127    /// `AnimationEffect`'s playback direction.
128    pub direction: String,
129    /// `AnimationEffect`'s fill mode.
130    pub fill: String,
131    /// `AnimationEffect`'s target node.
132    #[serde(
133        rename = "backendNodeId",
134        default,
135        skip_serializing_if = "Option::is_none"
136    )]
137    pub backend_node_id: Option<crate::protocol::dom::BackendNodeId>,
138    /// `AnimationEffect`'s keyframes.
139    #[serde(
140        rename = "keyframesRule",
141        default,
142        skip_serializing_if = "Option::is_none"
143    )]
144    pub keyframes_rule: Option<KeyframesRule>,
145    /// `AnimationEffect`'s timing function.
146    pub easing: String,
147}
148
149/// Keyframes Rule
150#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
151pub struct KeyframesRule {
152    /// CSS keyframed animation's name.
153    #[serde(default, skip_serializing_if = "Option::is_none")]
154    pub name: Option<String>,
155    /// List of animation keyframes.
156    pub keyframes: Vec<KeyframeStyle>,
157}
158
159/// Keyframe Style
160#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
161pub struct KeyframeStyle {
162    /// Keyframe's time offset.
163    pub offset: String,
164    /// `AnimationEffect`'s timing function.
165    pub easing: String,
166}
167
168/// Disables animation domain notifications.
169///
170/// Parameters of `Animation.disable`.
171#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
172pub struct DisableParams {}
173
174impl crate::typed::Command for DisableParams {
175    const METHOD: &'static str = "Animation.disable";
176    type Returns = crate::typed::NoReturns;
177}
178
179/// Enables animation domain notifications.
180///
181/// Parameters of `Animation.enable`.
182#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
183pub struct EnableParams {}
184
185impl crate::typed::Command for EnableParams {
186    const METHOD: &'static str = "Animation.enable";
187    type Returns = crate::typed::NoReturns;
188}
189
190/// Returns the current time of the an animation.
191///
192/// Parameters of `Animation.getCurrentTime`.
193#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
194pub struct GetCurrentTimeParams {
195    /// Id of animation.
196    pub id: String,
197}
198
199/// What `Animation.getCurrentTime` answers with.
200#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
201pub struct GetCurrentTimeReturns {
202    /// Current time of the page.
203    #[serde(rename = "currentTime")]
204    pub current_time: f64,
205}
206
207impl crate::typed::Command for GetCurrentTimeParams {
208    const METHOD: &'static str = "Animation.getCurrentTime";
209    type Returns = GetCurrentTimeReturns;
210}
211
212/// Gets the playback rate of the document timeline.
213///
214/// Parameters of `Animation.getPlaybackRate`.
215#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
216pub struct GetPlaybackRateParams {}
217
218/// What `Animation.getPlaybackRate` answers with.
219#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
220pub struct GetPlaybackRateReturns {
221    /// Playback rate for animations on page.
222    #[serde(rename = "playbackRate")]
223    pub playback_rate: f64,
224}
225
226impl crate::typed::Command for GetPlaybackRateParams {
227    const METHOD: &'static str = "Animation.getPlaybackRate";
228    type Returns = GetPlaybackRateReturns;
229}
230
231/// Releases a set of animations to no longer be manipulated.
232///
233/// Parameters of `Animation.releaseAnimations`.
234#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
235pub struct ReleaseAnimationsParams {
236    /// List of animation ids to seek.
237    pub animations: Vec<String>,
238}
239
240impl crate::typed::Command for ReleaseAnimationsParams {
241    const METHOD: &'static str = "Animation.releaseAnimations";
242    type Returns = crate::typed::NoReturns;
243}
244
245/// Gets the remote object of the Animation.
246///
247/// Parameters of `Animation.resolveAnimation`.
248#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
249pub struct ResolveAnimationParams {
250    /// Animation id.
251    #[serde(rename = "animationId")]
252    pub animation_id: String,
253}
254
255/// What `Animation.resolveAnimation` answers with.
256#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
257pub struct ResolveAnimationReturns {
258    /// Corresponding remote object.
259    #[serde(rename = "remoteObject")]
260    pub remote_object: crate::protocol::runtime::RemoteObject,
261}
262
263impl crate::typed::Command for ResolveAnimationParams {
264    const METHOD: &'static str = "Animation.resolveAnimation";
265    type Returns = ResolveAnimationReturns;
266}
267
268/// Seek a set of animations to a particular time within each animation.
269///
270/// Parameters of `Animation.seekAnimations`.
271#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
272pub struct SeekAnimationsParams {
273    /// List of animation ids to seek.
274    pub animations: Vec<String>,
275    /// Set each animation to the same time.
276    #[serde(
277        rename = "currentTime",
278        default,
279        skip_serializing_if = "Option::is_none"
280    )]
281    pub current_time: Option<f64>,
282    /// Set each animation to a different time. If set, should have the same
283    /// length as animations. Exactly one of currentTime or currentTimes should be
284    /// set.
285    #[serde(
286        rename = "currentTimes",
287        default,
288        skip_serializing_if = "Option::is_none"
289    )]
290    pub current_times: Option<Vec<f64>>,
291}
292
293impl crate::typed::Command for SeekAnimationsParams {
294    const METHOD: &'static str = "Animation.seekAnimations";
295    type Returns = crate::typed::NoReturns;
296}
297
298/// Sets the paused state of a set of animations.
299///
300/// Parameters of `Animation.setPaused`.
301#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
302pub struct SetPausedParams {
303    /// Animations to set the pause state of.
304    pub animations: Vec<String>,
305    /// Paused state to set to.
306    pub paused: bool,
307}
308
309impl crate::typed::Command for SetPausedParams {
310    const METHOD: &'static str = "Animation.setPaused";
311    type Returns = crate::typed::NoReturns;
312}
313
314/// Sets the playback rate of the document timeline.
315///
316/// Parameters of `Animation.setPlaybackRate`.
317#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
318pub struct SetPlaybackRateParams {
319    /// Playback rate for animations on page
320    #[serde(rename = "playbackRate")]
321    pub playback_rate: f64,
322}
323
324impl crate::typed::Command for SetPlaybackRateParams {
325    const METHOD: &'static str = "Animation.setPlaybackRate";
326    type Returns = crate::typed::NoReturns;
327}
328
329/// Sets the timing of an animation node.
330///
331/// Parameters of `Animation.setTiming`.
332#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
333pub struct SetTimingParams {
334    /// Animation id.
335    #[serde(rename = "animationId")]
336    pub animation_id: String,
337    /// Duration of the animation.
338    pub duration: f64,
339    /// Delay of the animation.
340    pub delay: f64,
341}
342
343impl crate::typed::Command for SetTimingParams {
344    const METHOD: &'static str = "Animation.setTiming";
345    type Returns = crate::typed::NoReturns;
346}
347
348/// Event for when an animation has been cancelled.
349///
350/// Payload of the `Animation.animationCanceled` event.
351#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
352pub struct AnimationCanceledEvent {
353    /// Id of the animation that was cancelled.
354    pub id: String,
355}
356
357impl crate::typed::Event for AnimationCanceledEvent {
358    const METHOD: &'static str = "Animation.animationCanceled";
359}
360
361/// Event for each animation that has been created.
362///
363/// Payload of the `Animation.animationCreated` event.
364#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
365pub struct AnimationCreatedEvent {
366    /// Id of the animation that was created.
367    pub id: String,
368}
369
370impl crate::typed::Event for AnimationCreatedEvent {
371    const METHOD: &'static str = "Animation.animationCreated";
372}
373
374/// Event for animation that has been started.
375///
376/// Payload of the `Animation.animationStarted` event.
377#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
378pub struct AnimationStartedEvent {
379    /// Animation that was started.
380    pub animation: Animation,
381}
382
383impl crate::typed::Event for AnimationStartedEvent {
384    const METHOD: &'static str = "Animation.animationStarted";
385}
386
387/// Event for animation that has been updated.
388///
389/// Payload of the `Animation.animationUpdated` event.
390#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
391pub struct AnimationUpdatedEvent {
392    /// Animation that was updated.
393    pub animation: Animation,
394}
395
396impl crate::typed::Event for AnimationUpdatedEvent {
397    const METHOD: &'static str = "Animation.animationUpdated";
398}