commit 15807166d066eefe7dd4c53c6be7ec8b93347969 parent 53df932c3d25e57cb8bb2eed1118b891c2aa78e3 Author: Jan Varga <jvarga@igalia.com> Date: Wed, 10 Dec 2025 20:22:58 +0000 Bug 1990419 - Enable derive_fields for GenericLengthPercentageOrAuto; r=emilio,firefox-style-system-reviewers This patch enables derive_fields for GenericLengthPercentageOrAuto, allowing reification of <length> values into CSSNumericValue objects for the column-width property. Differential Revision: https://phabricator.services.mozilla.com/D271889 Diffstat:
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/layout/style/typedom/CSSUnitValue.cpp b/layout/style/typedom/CSSUnitValue.cpp @@ -71,8 +71,16 @@ void CSSUnitValue::ToCssTextWithProperty(const CSSPropertyId& aPropertyId, // this logic to a dedicated FromTyped trait or similar infrastructure that // can validate and construct internal representations in a property-aware // and fully spec-compliant manner. See bug 2005142 - const bool isValueOutOfRange = - aPropertyId.mId == eCSSProperty_perspective && mValue < 0; + const bool isValueOutOfRange = [](NonCustomCSSPropertyId aId, double aValue) { + switch (aId) { + case eCSSProperty_perspective: + case eCSSProperty_column_width: + return aValue < 0; + + default: + return false; + } + }(aPropertyId.mId, mValue); if (isValueOutOfRange) { aDest.Append("calc("_ns); diff --git a/servo/components/style/values/generics/length.rs b/servo/components/style/values/generics/length.rs @@ -39,6 +39,7 @@ use style_traits::{CssWriter, SpecifiedValueInfo}; )] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[repr(C, u8)] +#[typed_value(derive_fields)] pub enum GenericLengthPercentageOrAuto<LengthPercent> { LengthPercentage(LengthPercent), Auto, diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/column-width.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/column-width.html.ini @@ -3,9 +3,6 @@ [Can set 'column-width' to var() references: ] expected: FAIL - [Can set 'column-width' to a length: ] - expected: FAIL - [Setting 'column-width' to a percent: throws TypeError] expected: FAIL