Bug 1956645 - Parse and serialize view-transition-class. r=view-transitions-reviewers,firefox-style-system-reviewers,emilio

Parse and serialize `view-transition-class: none | <custom-ident>+`.
This property will be used after we extend `<pt-name-selector>` to
`<pt-name-and-class-selector>` for named view transition pseudo-elements.
Will do this in Bug 1956646. Also, we will handle the class matching in
Bug 1964949.

Differential Revision: https://phabricator.services.mozilla.com/D249681
This commit is contained in:
Boris Chiou
2025-05-18 19:22:21 +00:00
committed by bchiou@mozilla.com
parent ff334e1329
commit 912b3b586b
16 changed files with 142 additions and 58 deletions

View File

@@ -439,3 +439,16 @@ ${helpers.predefined_type(
affects="",
enabled_in="ua",
)}
${helpers.predefined_type(
"view-transition-class",
"ViewTransitionClass",
"computed::ViewTransitionClass::none()",
engines="gecko servo",
servo_pref="layout.unimplemented",
animation_type="discrete",
gecko_pref="dom.viewTransitions.enabled",
spec="https://drafts.csswg.org/css-view-transitions-2/#view-transition-class-prop",
affects="",
enabled_in="ua",
)}

View File

@@ -13,7 +13,8 @@ use style_traits::{CssWriter, ToCss};
pub use crate::values::specified::animation::{
AnimationComposition, AnimationDirection, AnimationFillMode, AnimationName, AnimationPlayState,
ScrollAxis, TimelineName, TransitionBehavior, TransitionProperty, ViewTransitionName,
ScrollAxis, TimelineName, TransitionBehavior, TransitionProperty, ViewTransitionClass,
ViewTransitionName,
};
/// A computed value for the `animation-duration` property.

View File

@@ -43,7 +43,8 @@ pub use self::angle::Angle;
pub use self::animation::{
AnimationComposition, AnimationDirection, AnimationDuration, AnimationFillMode,
AnimationIterationCount, AnimationName, AnimationPlayState, AnimationTimeline, ScrollAxis,
TimelineName, TransitionBehavior, TransitionProperty, ViewTimelineInset, ViewTransitionName,
TimelineName, TransitionBehavior, TransitionProperty, ViewTimelineInset, ViewTransitionClass,
ViewTransitionName,
};
pub use self::background::{BackgroundRepeat, BackgroundSize};
pub use self::basic_shape::FillRule;

View File

@@ -731,3 +731,58 @@ impl ToCss for ViewTransitionName {
serialize_atom_identifier(&self.0, dest)
}
}
/// The view-transition-class: `none | <custom-ident>+`.
///
/// https://drafts.csswg.org/css-view-transitions-2/#view-transition-class-prop
///
/// Empty slice represents `none`.
#[derive(
Clone,
Debug,
Eq,
Hash,
PartialEq,
MallocSizeOf,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(C)]
#[value_info(other_values = "none")]
pub struct ViewTransitionClass(
#[css(iterable, if_empty = "none")]
#[ignore_malloc_size_of = "Arc"]
crate::ArcSlice<CustomIdent>,
);
impl ViewTransitionClass {
/// Returns the default value, `none`. We use the default slice (i.e. empty) to represent it.
pub fn none() -> Self {
Self(Default::default())
}
/// Returns whether this is the `none` value.
pub fn is_none(&self) -> bool {
self.0.is_empty()
}
}
impl Parse for ViewTransitionClass {
fn parse<'i, 't>(
_: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
use style_traits::{Separator, Space};
if input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
return Ok(Self::none());
}
Ok(Self(crate::ArcSlice::from_iter(
Space::parse(input, |i| CustomIdent::parse(i, &["none"]))?.into_iter(),
)))
}
}

View File

@@ -31,7 +31,8 @@ pub use self::angle::{AllowUnitlessZeroAngle, Angle};
pub use self::animation::{
AnimationComposition, AnimationDirection, AnimationDuration, AnimationFillMode,
AnimationIterationCount, AnimationName, AnimationPlayState, AnimationTimeline, ScrollAxis,
TimelineName, TransitionBehavior, TransitionProperty, ViewTimelineInset, ViewTransitionName,
TimelineName, TransitionBehavior, TransitionProperty, ViewTimelineInset, ViewTransitionClass,
ViewTransitionName,
};
pub use self::background::{BackgroundRepeat, BackgroundSize};
pub use self::basic_shape::FillRule;

View File

@@ -325,6 +325,7 @@ include = [
"XTextScale",
"Zoom",
"TransitionProperty",
"ViewTransitionClass",
"ViewTransitionName",
"Inset",
"AnchorFunction",