From 9264f540dda81c594db7aac1e31f8c4087e50755 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 22 Aug 2025 12:02:52 +0100 Subject: [PATCH] LibWeb/CSS: Correct definition of CSSNumericType What I thought was a spec issue was actually a combination of my own misunderstanding and a bug in our IDL generator. With that bug fixed, I can correct this to how it is in the spec. --- Libraries/LibWeb/CSS/CSSNumericValue.h | 16 ++++++++-------- Libraries/LibWeb/CSS/CSSNumericValue.idl | 17 ++++++++--------- .../add-two-types.tentative.txt | 13 ++++++------- .../create-a-type.tentative.txt | 18 +++++++++--------- .../numeric-objects/cssMathInvert-type.txt | 8 ++++---- .../numeric-objects/cssMathNegate-type.txt | 6 +++--- ...mericvalue-multiply-two-types.tentative.txt | 15 +++++++-------- 7 files changed, 45 insertions(+), 48 deletions(-) diff --git a/Libraries/LibWeb/CSS/CSSNumericValue.h b/Libraries/LibWeb/CSS/CSSNumericValue.h index 739ef8980fc..f23c54d028b 100644 --- a/Libraries/LibWeb/CSS/CSSNumericValue.h +++ b/Libraries/LibWeb/CSS/CSSNumericValue.h @@ -15,14 +15,14 @@ namespace Web::CSS { struct CSSNumericType { - WebIDL::Long length {}; - WebIDL::Long angle {}; - WebIDL::Long time {}; - WebIDL::Long frequency {}; - WebIDL::Long resolution {}; - WebIDL::Long flex {}; - WebIDL::Long percent {}; - Optional percent_hint {}; + Optional length; + Optional angle; + Optional time; + Optional frequency; + Optional resolution; + Optional flex; + Optional percent; + Optional percent_hint; }; // https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue diff --git a/Libraries/LibWeb/CSS/CSSNumericValue.idl b/Libraries/LibWeb/CSS/CSSNumericValue.idl index 3bc3b5c5ede..b8b1742d7af 100644 --- a/Libraries/LibWeb/CSS/CSSNumericValue.idl +++ b/Libraries/LibWeb/CSS/CSSNumericValue.idl @@ -12,16 +12,15 @@ enum CSSNumericBaseType { }; // https://drafts.css-houdini.org/css-typed-om-1/#dictdef-cssnumerictype -// AD-HOC: We give these default values and mark percentHint as nullable. https://github.com/w3c/css-houdini-drafts/issues/1149 dictionary CSSNumericType { - long length = 0; - long angle = 0; - long time = 0; - long frequency = 0; - long resolution = 0; - long flex = 0; - long percent = 0; - CSSNumericBaseType? percentHint; + long length; + long angle; + long time; + long frequency; + long resolution; + long flex; + long percent; + CSSNumericBaseType percentHint; }; // https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/numeric-objects/add-two-types.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/numeric-objects/add-two-types.tentative.txt index 5b7c89e2c20..460673bb4a6 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/numeric-objects/add-two-types.tentative.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/numeric-objects/add-two-types.tentative.txt @@ -2,12 +2,11 @@ Harness status: OK Found 7 tests -2 Pass -5 Fail +7 Pass Pass Adding two types with different non-null percent hints throws TypeError -Fail Adding two types with the same nonzero values returns same type -Fail Adding two types with empty maps with returns empty map -Fail Adding a type with percent returns type with percent hint +Pass Adding two types with the same nonzero values returns same type +Pass Adding two types with empty maps with returns empty map +Pass Adding a type with percent returns type with percent hint Pass Adding a type with percent 2 returns type with percent hint throws TypeError -Fail Adding a type with a percent hint returns a type with the percent hint -Fail Adding two types with the same percent hint returns a type with the percent hint \ No newline at end of file +Pass Adding a type with a percent hint returns a type with the percent hint +Pass Adding two types with the same percent hint returns a type with the percent hint \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/numeric-objects/create-a-type.tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/numeric-objects/create-a-type.tentative.txt index 35ea44eaa4f..8fb138765cf 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/numeric-objects/create-a-type.tentative.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/numeric-objects/create-a-type.tentative.txt @@ -2,12 +2,12 @@ Harness status: OK Found 8 tests -8 Fail -Fail Creating a type from "number" returns {} -Fail Creating a type from "percent" returns { percent: 1 } -Fail Creating a type from returns { length: 1 } -Fail Creating a type from returns { angle: 1 } -Fail Creating a type from