commit 423614a5d22daaca3b38d67e7992b9bc64ff463f
parent e155129069c8c8fed793ec5349b874a6a3474443
Author: Jan Varga <jan.varga@gmail.com>
Date: Mon, 20 Oct 2025 05:08:20 +0000
Bug 1991631 - Demonstrate ToTyped derive on enum with non-unit variant (clip-path); r=firefox-style-system-reviewers,dshin
This patch demonstrates the new field-handling support in the ToTyped derive
using the clip-path property, which contains both unit and data-carrying
variants.
The change enables derive_fields for this enum and exercises the use of
are reified. This validates that the derive correctly skips or marks variants
for follow-up work when reification is not yet implemented.
Differential Revision: https://phabricator.services.mozilla.com/D268164
Diffstat:
2 files changed, 9 insertions(+), 21 deletions(-)
diff --git a/servo/components/style/values/generics/basic_shape.rs b/servo/components/style/values/generics/basic_shape.rs
@@ -32,8 +32,10 @@ use style_traits::{CssWriter, ToCss};
ToCss,
ToResolvedValue,
ToShmem,
+ ToTyped,
)]
#[repr(u8)]
+#[typed_value(derive_fields)]
pub enum ShapeGeometryBox {
/// Depending on which kind of element this style value applied on, the
/// default value of the reference-box can be different. For an HTML
@@ -83,6 +85,7 @@ fn is_default_box_for_clip_path(b: &ShapeGeometryBox) -> bool {
ToCss,
ToResolvedValue,
ToShmem,
+ ToTyped,
)]
#[repr(u8)]
pub enum ShapeBox {
@@ -117,11 +120,17 @@ impl Default for ShapeBox {
)]
#[animation(no_bound(U))]
#[repr(u8)]
+#[typed_value(derive_fields)]
pub enum GenericClipPath<BasicShape, U> {
#[animation(error)]
None,
#[animation(error)]
+ // XXX This will likely change to skip since it seems Typed OM Level 1
+ // won't be updated to cover this case even though there's some preparation
+ // in WPT tests for this.
+ #[typed_value(todo)]
Url(U),
+ #[typed_value(skip)]
Shape(
Box<BasicShape>,
#[css(skip_if = "is_default_box_for_clip_path")] ShapeGeometryBox,
diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/clip-path.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/clip-path.html.ini
@@ -3,27 +3,6 @@
[Can set 'clip-path' to var() references: ]
expected: FAIL
- [Can set 'clip-path' to the 'fill-box' keyword: ]
- expected: FAIL
-
- [Can set 'clip-path' to the 'stroke-box' keyword: ]
- expected: FAIL
-
- [Can set 'clip-path' to the 'view-box' keyword: ]
- expected: FAIL
-
- [Can set 'clip-path' to the 'margin-box' keyword: ]
- expected: FAIL
-
- [Can set 'clip-path' to the 'border-box' keyword: ]
- expected: FAIL
-
- [Can set 'clip-path' to the 'padding-box' keyword: ]
- expected: FAIL
-
- [Can set 'clip-path' to the 'content-box' keyword: ]
- expected: FAIL
-
[Setting 'clip-path' to a length: throws TypeError]
expected: FAIL