aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/properties/gecko.mako.rs25
-rw-r--r--components/style/properties/longhands/box.mako.rs14
-rw-r--r--components/style/properties/properties.mako.rs2
-rw-r--r--components/style/stylist.rs8
-rw-r--r--components/style/values/computed/box.rs10
-rw-r--r--components/style/values/computed/mod.rs2
-rw-r--r--components/style/values/mod.rs1
-rw-r--r--components/style/values/specified/box.rs58
-rw-r--r--components/style/values/specified/mod.rs2
9 files changed, 108 insertions, 14 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 86cdeefa982..bc0a78183a8 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -1049,7 +1049,7 @@ fn static_assert() {
% if member:
ours.m${gecko_ffi_name}.${member} = others.m${gecko_ffi_name}.${member};
% else:
- ours.m${gecko_ffi_name} = others.m${gecko_ffi_name};
+ ours.m${gecko_ffi_name} = others.m${gecko_ffi_name}.clone();
% endif
}
}
@@ -1183,7 +1183,7 @@ fn static_assert() {
<% skip_box_longhands= """display
animation-name animation-delay animation-duration
animation-direction animation-fill-mode animation-play-state
- animation-iteration-count animation-timing-function
+ animation-iteration-count animation-timeline animation-timing-function
clear transition-duration transition-delay
transition-timing-function transition-property
-webkit-line-clamp""" %>
@@ -1445,6 +1445,27 @@ fn static_assert() {
${impl_copy_animation_value('iteration_count', 'IterationCount')}
${impl_animation_or_transition_timing_function('animation')}
+ pub fn set_animation_timeline<I>(&mut self, v: I)
+ where
+ I: IntoIterator<Item = longhands::animation_timeline::computed_value::single_value::T>,
+ I::IntoIter: ExactSizeIterator
+ {
+ let v = v.into_iter();
+ debug_assert_ne!(v.len(), 0);
+ let input_len = v.len();
+ self.gecko.mAnimations.ensure_len(input_len);
+
+ self.gecko.mAnimationTimelineCount = input_len as u32;
+ for (gecko, servo) in self.gecko.mAnimations.iter_mut().take(input_len as usize).zip(v) {
+ gecko.mTimeline = servo;
+ }
+ }
+ pub fn animation_timeline_at(&self, index: usize) -> values::specified::box_::AnimationTimeline {
+ self.gecko.mAnimations[index].mTimeline.clone()
+ }
+ ${impl_animation_count('timeline', 'Timeline')}
+ ${impl_copy_animation_value('timeline', 'Timeline')}
+
#[allow(non_snake_case)]
pub fn set__webkit_line_clamp(&mut self, v: longhands::_webkit_line_clamp::computed_value::T) {
self.gecko.mLineClamp = match v {
diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs
index c8942fdc6ff..bcb51524e12 100644
--- a/components/style/properties/longhands/box.mako.rs
+++ b/components/style/properties/longhands/box.mako.rs
@@ -320,6 +320,20 @@ ${helpers.predefined_type(
rule_types_allowed=DEFAULT_RULES_EXCEPT_KEYFRAME,
)}
+${helpers.predefined_type(
+ "animation-timeline",
+ "AnimationTimeline",
+ "computed::AnimationTimeline::auto()",
+ engines="gecko",
+ initial_specified_value="specified::AnimationTimeline::auto()",
+ vector=True,
+ need_index=True,
+ animation_value_type="none",
+ gecko_pref="layout.css.scroll-linked-animations.enabled",
+ spec="https://drafts.csswg.org/css-animations-2/#propdef-animation-timeline",
+ rule_types_allowed=DEFAULT_RULES_EXCEPT_KEYFRAME,
+)}
+
<% transform_extra_prefixes = "moz:layout.css.prefixes.transforms webkit" %>
${helpers.predefined_type(
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index 67183062e2f..7d19785ea80 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -2921,7 +2921,7 @@ pub mod style_structs {
}
/// Returns true if animation properties are equal between styles, but without
- /// considering keyframe data.
+ /// considering keyframe data and animation-timeline.
#[cfg(feature = "servo")]
pub fn animations_equals(&self, other: &Self) -> bool {
self.animation_name_iter().eq(other.animation_name_iter()) &&
diff --git a/components/style/stylist.rs b/components/style/stylist.rs
index 9ef10073de9..ddcf77140e7 100644
--- a/components/style/stylist.rs
+++ b/components/style/stylist.rs
@@ -2301,8 +2301,12 @@ impl CascadeData {
},
#[cfg(feature = "gecko")]
CssRule::ScrollTimeline(..) => {
- // TODO: Bug 1676784: set the timeline into animation.
- }
+ // TODO: Bug 1676791: set the timeline into animation.
+ // https://phabricator.services.mozilla.com/D126452
+ //
+ // Note: Bug 1733260: we may drop @scroll-timeline rule once this spec issue
+ // https://github.com/w3c/csswg-drafts/issues/6674 gets landed.
+ },
#[cfg(feature = "gecko")]
CssRule::FontFace(ref rule) => {
self.extra_data.add_font_face(rule);
diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs
index 22f5e306976..ce467343005 100644
--- a/components/style/values/computed/box.rs
+++ b/components/style/values/computed/box.rs
@@ -11,14 +11,12 @@ use crate::values::generics::box_::Perspective as GenericPerspective;
use crate::values::generics::box_::VerticalAlign as GenericVerticalAlign;
use crate::values::specified::box_ as specified;
-pub use crate::values::specified::box_::Clear as SpecifiedClear;
-pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin};
-pub use crate::values::specified::box_::{Contain, Display, Float as SpecifiedFloat, Overflow};
-pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox, OverscrollBehavior};
pub use crate::values::specified::box_::{
- ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType,
+ AnimationName, AnimationTimeline, Appearance, BreakBetween, BreakWithin,
+ Clear as SpecifiedClear, Contain, Display, Float as SpecifiedFloat, Overflow, OverflowAnchor,
+ OverflowClipBox, OverscrollBehavior, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness,
+ ScrollSnapType, TouchAction, TransitionProperty, WillChange,
};
-pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
/// A computed value for the `vertical-align` property.
pub type VerticalAlign = GenericVerticalAlign<LengthPercentage>;
diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index 49fc7b8bd33..955a1b93877 100644
--- a/components/style/values/computed/mod.rs
+++ b/components/style/values/computed/mod.rs
@@ -44,7 +44,7 @@ pub use self::basic_shape::FillRule;
pub use self::border::{BorderCornerRadius, BorderRadius, BorderSpacing};
pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
pub use self::border::{BorderImageSlice, BorderImageWidth};
-pub use self::box_::{AnimationIterationCount, AnimationName, Contain};
+pub use self::box_::{AnimationIterationCount, AnimationName, AnimationTimeline, Contain};
pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
pub use self::box_::{Display, Overflow, OverflowAnchor, TransitionProperty};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs
index 777b81e1da8..b8e7f1f3b8b 100644
--- a/components/style/values/mod.rs
+++ b/components/style/values/mod.rs
@@ -472,6 +472,7 @@ impl ToCss for CustomIdent {
#[derive(
Clone, Debug, MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem,
)]
+#[repr(C, u8)]
pub enum TimelineOrKeyframesName {
/// <custom-ident>
Ident(CustomIdent),
diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs
index 35552513cab..c81a3913b54 100644
--- a/components/style/values/specified/box.rs
+++ b/components/style/values/specified/box.rs
@@ -13,7 +13,7 @@ use crate::values::generics::box_::Perspective as GenericPerspective;
use crate::values::generics::box_::{GenericVerticalAlign, VerticalAlignKeyword};
use crate::values::specified::length::{LengthPercentage, NonNegativeLength};
use crate::values::specified::{AllowQuirks, Number};
-use crate::values::{CustomIdent, KeyframesName};
+use crate::values::{CustomIdent, KeyframesName, TimelineName};
use crate::Atom;
use cssparser::Parser;
use num_traits::FromPrimitive;
@@ -762,6 +762,62 @@ impl Parse for AnimationName {
}
}
+/// A value for the <single-animation-timeline>.
+///
+/// https://drafts.csswg.org/css-animations-2/#typedef-single-animation-timeline
+/// cbindgen:private-default-tagged-enum-constructor=false
+#[derive(
+ Clone,
+ Debug,
+ Eq,
+ Hash,
+ MallocSizeOf,
+ PartialEq,
+ SpecifiedValueInfo,
+ ToComputedValue,
+ ToCss,
+ ToResolvedValue,
+ ToShmem,
+)]
+#[repr(C, u8)]
+pub enum AnimationTimeline {
+ /// Use default timeline. The animation’s timeline is a DocumentTimeline.
+ Auto,
+ /// The animation is not associated with a timeline.
+ None,
+ /// The scroll-timeline name
+ Timeline(TimelineName),
+}
+
+impl AnimationTimeline {
+ /// Returns the `auto` value.
+ pub fn auto() -> Self {
+ Self::Auto
+ }
+}
+
+impl Parse for AnimationTimeline {
+ fn parse<'i, 't>(
+ context: &ParserContext,
+ input: &mut Parser<'i, 't>,
+ ) -> Result<Self, ParseError<'i>> {
+ // We are using the same parser for TimelineName and KeyframesName, but animation-timeline
+ // accepts "auto", so need to manually parse this. (We can not derive Parse because
+ // TimelineName excludes only "none" keyword.)
+ // FIXME: Bug 1733260: we may drop None based on the spec issue:
+ // Note: https://github.com/w3c/csswg-drafts/issues/6674.
+ if input.try_parse(|i| i.expect_ident_matching("auto")).is_ok() {
+ return Ok(Self::Auto);
+ }
+
+ if input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
+ return Ok(Self::None);
+ }
+
+ TimelineName::parse(context, input).map(AnimationTimeline::Timeline)
+ }
+}
+
/// https://drafts.csswg.org/css-scroll-snap-1/#snap-axis
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index d5ea7f8d9cc..64bc063960e 100644
--- a/components/style/values/specified/mod.rs
+++ b/components/style/values/specified/mod.rs
@@ -36,7 +36,7 @@ pub use self::basic_shape::FillRule;
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
-pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
+pub use self::box_::{AnimationIterationCount, AnimationName, AnimationTimeline, Contain, Display};
pub use self::box_::{Appearance, BreakBetween, BreakWithin};
pub use self::box_::{Clear, Float, Overflow, OverflowAnchor};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};