From 5c14835fdcfe302f7e5b85d732ab092676799325 Mon Sep 17 00:00:00 2001 From: Chris Dumez Date: Fri, 16 Dec 2022 16:14:05 -0800 Subject: [PATCH] CSS Keywords should be lowercased during serialization https://bugs.webkit.org/show_bug.cgi?id=249438 Reviewed by Sam Weinig. CSS Keywords should be lowercased during serialization: - https://www.w3.org/TR/cssom-1/#serialize-a-css-component-value * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/color-interpolation-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/pointer-events-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/shape-rendering-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/text-rendering-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-presentation-attribute-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/inheritance-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-computed-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-parsing-valid-expected.txt: Rebaseline WPT tests now that more checks are passing. * Source/WebCore/css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const): Call nameStringForSerialization() instead of nameString() since we are serializing. This makes sure that the identifier is serialized as lowercase. * Source/WebCore/css/typedom/CSSStyleValueFactory.cpp: (WebCore::CSSStyleValueFactory::reifyValue): Per https://drafts.css-houdini.org/css-typed-om-1/#reify-ident, we should create a CSSKeywordValue from the *serialization* of the identifier, which means that the identifier would become lowercase. * Source/WebCore/css/process-css-values.py: (GenerationContext): Generate nameStringForSerialization() which provides the name string of the keyword as lowercase, for the purpose of serialization. Canonical link: https://commits.webkit.org/258024@main --- .../computed-style-expected.txt | 4 +- ...mputed-style-without-renderer-expected.txt | 4 +- .../css/image-rendering-parsing-expected.txt | 8 ++-- .../fast/css/image-rendering-parsing.html | 6 +-- .../css/parsing-text-rendering-expected.txt | 6 +-- .../css/resources/parsing-text-rendering.js | 6 +-- .../color-interpolation-expected.txt | 4 +- .../properties/pointer-events-expected.txt | 6 +-- .../properties/shape-rendering-expected.txt | 4 +- .../properties/text-rendering-expected.txt | 6 +-- ...riable-presentation-attribute-expected.txt | 2 +- .../filter-effects/inheritance-expected.txt | 4 +- ...nterpolation-filters-computed-expected.txt | 4 +- ...olation-filters-parsing-valid-expected.txt | 6 +-- .../parsing/pointer-events-valid-expected.txt | 6 +-- .../svg/painting/inheritance-expected.txt | 10 ++--- .../color-interpolation-computed-expected.txt | 4 +- .../image-rendering-computed-expected.txt | 4 +- .../image-rendering-valid-expected.txt | 4 +- .../shape-rendering-computed-expected.txt | 4 +- .../shape-rendering-valid-expected.txt | 4 +- .../text-rendering-computed-expected.txt | 6 +-- .../parsing/text-rendering-valid-expected.txt | 6 +-- .../css/getComputedStyle-basic-expected.txt | 8 ++-- .../css/shape-rendering-parsing-expected.txt | 4 +- .../svg/css/shape-rendering-parsing.html | 4 +- Source/WebCore/css/CSSPrimitiveValue.cpp | 4 +- Source/WebCore/css/process-css-values.py | 37 ++++++++++++++++++- .../css/typedom/CSSStyleValueFactory.cpp | 5 ++- 29 files changed, 109 insertions(+), 71 deletions(-) diff --git a/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt b/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt index 8c5cf6d7add0..b7025dfd90ae 100644 --- a/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt +++ b/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt @@ -48,8 +48,8 @@ clip: auto; clip-path: none; clip-rule: nonzero; color: rgb(0, 0, 0); -color-interpolation: sRGB; -color-interpolation-filters: linearRGB; +color-interpolation: srgb; +color-interpolation-filters: linearrgb; column-count: auto; column-fill: balance; column-gap: normal; diff --git a/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt b/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt index 0900bd497c3b..53dfd8b27edf 100644 --- a/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt +++ b/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt @@ -47,8 +47,8 @@ clip: auto clip-path: none clip-rule: nonzero color: rgb(0, 0, 0) -color-interpolation: sRGB -color-interpolation-filters: linearRGB +color-interpolation: srgb +color-interpolation-filters: linearrgb column-count: auto column-fill: balance column-gap: normal diff --git a/LayoutTests/fast/css/image-rendering-parsing-expected.txt b/LayoutTests/fast/css/image-rendering-parsing-expected.txt index 51e4b3044db1..06ceb5035182 100644 --- a/LayoutTests/fast/css/image-rendering-parsing-expected.txt +++ b/LayoutTests/fast/css/image-rendering-parsing-expected.txt @@ -19,11 +19,11 @@ PASS div.style.getPropertyCSSValue('image-rendering').cssValueType is CSSValue.C PASS div.style.getPropertyValue('image-rendering') is "-webkit-optimize-contrast" PASS getComputedStyle(div).getPropertyValue('image-rendering') is "crisp-edges" PASS div.style.getPropertyCSSValue('image-rendering').cssValueType is CSSValue.CSS_PRIMITIVE_VALUE -PASS div.style.getPropertyValue('image-rendering') is "optimizeSpeed" -PASS getComputedStyle(div).getPropertyValue('image-rendering') is "optimizeSpeed" +PASS div.style.getPropertyValue('image-rendering') is "optimizespeed" +PASS getComputedStyle(div).getPropertyValue('image-rendering') is "optimizespeed" PASS div.style.getPropertyCSSValue('image-rendering').cssValueType is CSSValue.CSS_PRIMITIVE_VALUE -PASS div.style.getPropertyValue('image-rendering') is "optimizeQuality" -PASS getComputedStyle(div).getPropertyValue('image-rendering') is "optimizeQuality" +PASS div.style.getPropertyValue('image-rendering') is "optimizequality" +PASS getComputedStyle(div).getPropertyValue('image-rendering') is "optimizequality" PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/fast/css/image-rendering-parsing.html b/LayoutTests/fast/css/image-rendering-parsing.html index db74f77a74c3..b9473669b777 100644 --- a/LayoutTests/fast/css/image-rendering-parsing.html +++ b/LayoutTests/fast/css/image-rendering-parsing.html @@ -16,7 +16,7 @@ document.body.appendChild(div); div.setAttribute("style", "image-rendering: " + value); shouldBe("div.style.getPropertyCSSValue('image-rendering').cssValueType", 'CSSValue.CSS_PRIMITIVE_VALUE'); - shouldBeEqualToString("div.style.getPropertyValue('image-rendering')", value); + shouldBeEqualToString("div.style.getPropertyValue('image-rendering')", value.toLowerCase()); shouldBeEqualToString("getComputedStyle(div).getPropertyValue('image-rendering')", computedValue); document.body.removeChild(div); @@ -27,8 +27,8 @@ testImageRendering('pixelated', 'pixelated'); testImageRendering('-webkit-crisp-edges', 'crisp-edges'); testImageRendering('-webkit-optimize-contrast', 'crisp-edges'); -testImageRendering('optimizeSpeed', 'optimizeSpeed'); -testImageRendering('optimizeQuality', 'optimizeQuality'); +testImageRendering('optimizeSpeed', 'optimizespeed'); +testImageRendering('optimizeQuality', 'optimizequality'); successfullyParsed = true; diff --git a/LayoutTests/fast/css/parsing-text-rendering-expected.txt b/LayoutTests/fast/css/parsing-text-rendering-expected.txt index fcaee91b73f9..5c2a375a1ac0 100644 --- a/LayoutTests/fast/css/parsing-text-rendering-expected.txt +++ b/LayoutTests/fast/css/parsing-text-rendering-expected.txt @@ -4,9 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE PASS test("text-rendering: auto;") is "auto" -PASS test("text-rendering: optimizeSpeed;") is "optimizeSpeed" -PASS test("text-rendering: optimizeLegibility;") is "optimizeLegibility" -PASS test("text-rendering: geometricPrecision;") is "geometricPrecision" +PASS test("text-rendering: optimizeSpeed;") is "optimizespeed" +PASS test("text-rendering: optimizeLegibility;") is "optimizelegibility" +PASS test("text-rendering: geometricPrecision;") is "geometricprecision" PASS test("text-rendering: auto auto;") is "" PASS test("text-rendering: optimizeCoconuts;") is "" PASS test("text-rendering: 15;") is "" diff --git a/LayoutTests/fast/css/resources/parsing-text-rendering.js b/LayoutTests/fast/css/resources/parsing-text-rendering.js index 1f15adcf99aa..d9f945841bbc 100644 --- a/LayoutTests/fast/css/resources/parsing-text-rendering.js +++ b/LayoutTests/fast/css/resources/parsing-text-rendering.js @@ -12,9 +12,9 @@ function test(value) } shouldBe('test("text-rendering: auto;")', '"auto"'); -shouldBe('test("text-rendering: optimizeSpeed;")', '"optimizeSpeed"'); -shouldBe('test("text-rendering: optimizeLegibility;")', '"optimizeLegibility"'); -shouldBe('test("text-rendering: geometricPrecision;")', '"geometricPrecision"'); +shouldBe('test("text-rendering: optimizeSpeed;")', '"optimizespeed"'); +shouldBe('test("text-rendering: optimizeLegibility;")', '"optimizelegibility"'); +shouldBe('test("text-rendering: geometricPrecision;")', '"geometricprecision"'); shouldBeEqualToString('test("text-rendering: auto auto;")', ''); shouldBeEqualToString('test("text-rendering: optimizeCoconuts;")', ''); diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/color-interpolation-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/color-interpolation-expected.txt index 1ef5857939c6..bf327063bcc6 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/color-interpolation-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/color-interpolation-expected.txt @@ -5,8 +5,8 @@ PASS Can set 'color-interpolation' to CSS-wide keywords: unset PASS Can set 'color-interpolation' to CSS-wide keywords: revert PASS Can set 'color-interpolation' to var() references: var(--A) PASS Can set 'color-interpolation' to the 'auto' keyword: auto -FAIL Can set 'color-interpolation' to the 'srgb' keyword: srgb assert_equals: expected "srgb" but got "sRGB" -FAIL Can set 'color-interpolation' to the 'linearrgb' keyword: linearrgb assert_equals: expected "linearrgb" but got "linearRGB" +PASS Can set 'color-interpolation' to the 'srgb' keyword: srgb +PASS Can set 'color-interpolation' to the 'linearrgb' keyword: linearrgb PASS Setting 'color-interpolation' to a length: 0px throws TypeError PASS Setting 'color-interpolation' to a length: -3.14em throws TypeError PASS Setting 'color-interpolation' to a length: 3.14cm throws TypeError diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/pointer-events-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/pointer-events-expected.txt index e818b39d570b..7ded4698f09d 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/pointer-events-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/pointer-events-expected.txt @@ -5,9 +5,9 @@ PASS Can set 'pointer-events' to CSS-wide keywords: unset PASS Can set 'pointer-events' to CSS-wide keywords: revert PASS Can set 'pointer-events' to var() references: var(--A) PASS Can set 'pointer-events' to the 'bounding-box' keyword: bounding-box -FAIL Can set 'pointer-events' to the 'visiblepainted' keyword: visiblepainted assert_equals: expected "visiblepainted" but got "visiblePainted" -FAIL Can set 'pointer-events' to the 'visiblefill' keyword: visiblefill assert_equals: expected "visiblefill" but got "visibleFill" -FAIL Can set 'pointer-events' to the 'visiblestroke' keyword: visiblestroke assert_equals: expected "visiblestroke" but got "visibleStroke" +PASS Can set 'pointer-events' to the 'visiblepainted' keyword: visiblepainted +PASS Can set 'pointer-events' to the 'visiblefill' keyword: visiblefill +PASS Can set 'pointer-events' to the 'visiblestroke' keyword: visiblestroke PASS Can set 'pointer-events' to the 'visible' keyword: visible PASS Can set 'pointer-events' to the 'painted' keyword: painted PASS Can set 'pointer-events' to the 'fill' keyword: fill diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/shape-rendering-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/shape-rendering-expected.txt index a4f925239aed..6d7492ebb4fa 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/shape-rendering-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/shape-rendering-expected.txt @@ -5,9 +5,9 @@ PASS Can set 'shape-rendering' to CSS-wide keywords: unset PASS Can set 'shape-rendering' to CSS-wide keywords: revert PASS Can set 'shape-rendering' to var() references: var(--A) PASS Can set 'shape-rendering' to the 'auto' keyword: auto -FAIL Can set 'shape-rendering' to the 'optimizespeed' keyword: optimizespeed assert_equals: expected "optimizespeed" but got "optimizeSpeed" +PASS Can set 'shape-rendering' to the 'optimizespeed' keyword: optimizespeed PASS Can set 'shape-rendering' to the 'crispedges' keyword: crispedges -FAIL Can set 'shape-rendering' to the 'geometricprecision' keyword: geometricprecision assert_equals: expected "geometricprecision" but got "geometricPrecision" +PASS Can set 'shape-rendering' to the 'geometricprecision' keyword: geometricprecision PASS Setting 'shape-rendering' to a length: 0px throws TypeError PASS Setting 'shape-rendering' to a length: -3.14em throws TypeError PASS Setting 'shape-rendering' to a length: 3.14cm throws TypeError diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/text-rendering-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/text-rendering-expected.txt index 75213d40047c..21428d8c8997 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/text-rendering-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/text-rendering-expected.txt @@ -5,9 +5,9 @@ PASS Can set 'text-rendering' to CSS-wide keywords: unset PASS Can set 'text-rendering' to CSS-wide keywords: revert PASS Can set 'text-rendering' to var() references: var(--A) PASS Can set 'text-rendering' to the 'auto' keyword: auto -FAIL Can set 'text-rendering' to the 'optimizespeed' keyword: optimizespeed assert_equals: expected "optimizespeed" but got "optimizeSpeed" -FAIL Can set 'text-rendering' to the 'optimizelegibility' keyword: optimizelegibility assert_equals: expected "optimizelegibility" but got "optimizeLegibility" -FAIL Can set 'text-rendering' to the 'geometricprecision' keyword: geometricprecision assert_equals: expected "geometricprecision" but got "geometricPrecision" +PASS Can set 'text-rendering' to the 'optimizespeed' keyword: optimizespeed +PASS Can set 'text-rendering' to the 'optimizelegibility' keyword: optimizelegibility +PASS Can set 'text-rendering' to the 'geometricprecision' keyword: geometricprecision PASS Setting 'text-rendering' to a length: 0px throws TypeError PASS Setting 'text-rendering' to a length: -3.14em throws TypeError PASS Setting 'text-rendering' to a length: 3.14cm throws TypeError diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-presentation-attribute-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-presentation-attribute-expected.txt index 8f1b3e2e9491..003733c036e3 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-presentation-attribute-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-presentation-attribute-expected.txt @@ -7,7 +7,7 @@ FAIL Testing 'alignment-baseline'. assert_equals: Value Test. expected "baseline FAIL Testing 'baseline-shift'. assert_equals: Value Test. expected "sub" but got "baseline" PASS Testing 'clip-rule'. PASS Testing 'color'. -FAIL Testing 'color-interpolation-filters'. assert_equals: Default value. expected "" but got "linearRGB" +FAIL Testing 'color-interpolation-filters'. assert_equals: Default value. expected "" but got "linearrgb" PASS Testing 'cursor'. PASS Testing 'direction'. FAIL Testing 'display'. assert_equals: Value Test. expected "block" but got "inline" diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/inheritance-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/inheritance-expected.txt index 8b228ec4408d..2e168664af23 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/inheritance-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/inheritance-expected.txt @@ -1,8 +1,8 @@ FAIL Property backdrop-filter has initial value none assert_true: backdrop-filter doesn't seem to be supported in the computed style expected true got false FAIL Property backdrop-filter does not inherit assert_true: expected true got false -FAIL Property color-interpolation-filters has initial value linearrgb assert_equals: expected "linearrgb" but got "linearRGB" -FAIL Property color-interpolation-filters inherits assert_equals: expected "srgb" but got "sRGB" +PASS Property color-interpolation-filters has initial value linearrgb +PASS Property color-interpolation-filters inherits PASS Property filter has initial value none PASS Property filter does not inherit PASS Property flood-color has initial value rgb(0, 0, 0) diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-computed-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-computed-expected.txt index 071b751d693b..368bce0e7e31 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-computed-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-computed-expected.txt @@ -1,5 +1,5 @@ PASS Property color-interpolation-filters value 'auto' -FAIL Property color-interpolation-filters value 'srgb' assert_equals: expected "srgb" but got "sRGB" -FAIL Property color-interpolation-filters value 'linearrgb' assert_equals: expected "linearrgb" but got "linearRGB" +PASS Property color-interpolation-filters value 'srgb' +PASS Property color-interpolation-filters value 'linearrgb' diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-parsing-valid-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-parsing-valid-expected.txt index a7bd580030bb..80956057a39e 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-parsing-valid-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/parsing/color-interpolation-filters-parsing-valid-expected.txt @@ -1,6 +1,6 @@ PASS e.style['color-interpolation-filters'] = "auto" should set the property value -FAIL e.style['color-interpolation-filters'] = "sRGB" should set the property value assert_equals: serialization should be canonical expected "srgb" but got "sRGB" -FAIL e.style['color-interpolation-filters'] = "linearRGB" should set the property value assert_equals: serialization should be canonical expected "linearrgb" but got "linearRGB" -FAIL e.style['color-interpolation-filters'] = "LiNeArRgB" should set the property value assert_equals: serialization should be canonical expected "linearrgb" but got "linearRGB" +PASS e.style['color-interpolation-filters'] = "sRGB" should set the property value +PASS e.style['color-interpolation-filters'] = "linearRGB" should set the property value +PASS e.style['color-interpolation-filters'] = "LiNeArRgB" should set the property value diff --git a/LayoutTests/imported/w3c/web-platform-tests/svg/interact/parsing/pointer-events-valid-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/svg/interact/parsing/pointer-events-valid-expected.txt index c51f9a58658e..ffce85595bb5 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/svg/interact/parsing/pointer-events-valid-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/svg/interact/parsing/pointer-events-valid-expected.txt @@ -1,9 +1,9 @@ PASS e.style['pointer-events'] = "auto" should set the property value PASS e.style['pointer-events'] = "bounding-box" should set the property value -FAIL e.style['pointer-events'] = "visiblePainted" should set the property value assert_equals: serialization should be canonical expected "visiblepainted" but got "visiblePainted" -FAIL e.style['pointer-events'] = "visibleFill" should set the property value assert_equals: serialization should be canonical expected "visiblefill" but got "visibleFill" -FAIL e.style['pointer-events'] = "visibleStroke" should set the property value assert_equals: serialization should be canonical expected "visiblestroke" but got "visibleStroke" +PASS e.style['pointer-events'] = "visiblePainted" should set the property value +PASS e.style['pointer-events'] = "visibleFill" should set the property value +PASS e.style['pointer-events'] = "visibleStroke" should set the property value PASS e.style['pointer-events'] = "visible" should set the property value PASS e.style['pointer-events'] = "painted" should set the property value PASS e.style['pointer-events'] = "fill" should set the property value diff --git a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/inheritance-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/inheritance-expected.txt index 77524209831e..012fd33c82a0 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/inheritance-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/inheritance-expected.txt @@ -29,12 +29,12 @@ PASS Property marker-end has initial value none FAIL Property marker-end inherits assert_equals: expected "url(\"https://example/com/diagram.svg#marker\")" but got "none" PASS Property paint-order has initial value normal FAIL Property paint-order inherits assert_equals: expected "markers stroke" but got "normal" -FAIL Property color-interpolation has initial value srgb assert_equals: expected "srgb" but got "sRGB" -FAIL Property color-interpolation inherits assert_equals: expected "linearrgb" but got "linearRGB" +PASS Property color-interpolation has initial value srgb +PASS Property color-interpolation inherits PASS Property shape-rendering has initial value auto -FAIL Property shape-rendering inherits assert_equals: expected "optimizespeed" but got "optimizeSpeed" +PASS Property shape-rendering inherits PASS Property text-rendering has initial value auto -FAIL Property text-rendering inherits assert_equals: expected "optimizespeed" but got "optimizeSpeed" +PASS Property text-rendering inherits PASS Property image-rendering has initial value auto -FAIL Property image-rendering inherits assert_equals: expected "optimizequality" but got "optimizeQuality" +PASS Property image-rendering inherits diff --git a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/color-interpolation-computed-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/color-interpolation-computed-expected.txt index 81d59014be37..76d4ad9711b4 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/color-interpolation-computed-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/color-interpolation-computed-expected.txt @@ -1,5 +1,5 @@ PASS Property color-interpolation value 'auto' -FAIL Property color-interpolation value 'srgb' assert_equals: expected "srgb" but got "sRGB" -FAIL Property color-interpolation value 'linearrgb' assert_equals: expected "linearrgb" but got "linearRGB" +PASS Property color-interpolation value 'srgb' +PASS Property color-interpolation value 'linearrgb' diff --git a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/image-rendering-computed-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/image-rendering-computed-expected.txt index 76c54f81be07..5fb4293ac1d0 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/image-rendering-computed-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/image-rendering-computed-expected.txt @@ -1,5 +1,5 @@ PASS Property image-rendering value 'auto' -FAIL Property image-rendering value 'optimizequality' assert_equals: expected "optimizequality" but got "optimizeQuality" -FAIL Property image-rendering value 'optimizespeed' assert_equals: expected "optimizespeed" but got "optimizeSpeed" +PASS Property image-rendering value 'optimizequality' +PASS Property image-rendering value 'optimizespeed' diff --git a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/image-rendering-valid-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/image-rendering-valid-expected.txt index 35016355da72..abbdff67c7f7 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/image-rendering-valid-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/image-rendering-valid-expected.txt @@ -1,5 +1,5 @@ PASS e.style['image-rendering'] = "auto" should set the property value -FAIL e.style['image-rendering'] = "optimizequality" should set the property value assert_equals: serialization should be canonical expected "optimizequality" but got "optimizeQuality" -FAIL e.style['image-rendering'] = "optimizespeed" should set the property value assert_equals: serialization should be canonical expected "optimizespeed" but got "optimizeSpeed" +PASS e.style['image-rendering'] = "optimizequality" should set the property value +PASS e.style['image-rendering'] = "optimizespeed" should set the property value diff --git a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/shape-rendering-computed-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/shape-rendering-computed-expected.txt index e55615de9e67..e62a812a27da 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/shape-rendering-computed-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/shape-rendering-computed-expected.txt @@ -1,6 +1,6 @@ PASS Property shape-rendering value 'auto' -FAIL Property shape-rendering value 'optimizespeed' assert_equals: expected "optimizespeed" but got "optimizeSpeed" +PASS Property shape-rendering value 'optimizespeed' PASS Property shape-rendering value 'crispedges' -FAIL Property shape-rendering value 'geometricprecision' assert_equals: expected "geometricprecision" but got "geometricPrecision" +PASS Property shape-rendering value 'geometricprecision' diff --git a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/shape-rendering-valid-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/shape-rendering-valid-expected.txt index 9d7923d1dbc5..5df702b2bdc5 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/shape-rendering-valid-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/shape-rendering-valid-expected.txt @@ -1,6 +1,6 @@ PASS e.style['shape-rendering'] = "auto" should set the property value -FAIL e.style['shape-rendering'] = "optimizespeed" should set the property value assert_equals: serialization should be canonical expected "optimizespeed" but got "optimizeSpeed" +PASS e.style['shape-rendering'] = "optimizespeed" should set the property value PASS e.style['shape-rendering'] = "crispedges" should set the property value -FAIL e.style['shape-rendering'] = "geometricprecision" should set the property value assert_equals: serialization should be canonical expected "geometricprecision" but got "geometricPrecision" +PASS e.style['shape-rendering'] = "geometricprecision" should set the property value diff --git a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/text-rendering-computed-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/text-rendering-computed-expected.txt index 7e7fc4c20a53..02772b9641ed 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/text-rendering-computed-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/text-rendering-computed-expected.txt @@ -1,6 +1,6 @@ PASS Property text-rendering value 'auto' -FAIL Property text-rendering value 'optimizespeed' assert_equals: expected "optimizespeed" but got "optimizeSpeed" -FAIL Property text-rendering value 'optimizelegibility' assert_equals: expected "optimizelegibility" but got "optimizeLegibility" -FAIL Property text-rendering value 'geometricprecision' assert_equals: expected "geometricprecision" but got "geometricPrecision" +PASS Property text-rendering value 'optimizespeed' +PASS Property text-rendering value 'optimizelegibility' +PASS Property text-rendering value 'geometricprecision' diff --git a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/text-rendering-valid-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/text-rendering-valid-expected.txt index 54655ed02c4e..df94a384c24c 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/text-rendering-valid-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/svg/painting/parsing/text-rendering-valid-expected.txt @@ -1,6 +1,6 @@ PASS e.style['text-rendering'] = "auto" should set the property value -FAIL e.style['text-rendering'] = "optimizespeed" should set the property value assert_equals: serialization should be canonical expected "optimizespeed" but got "optimizeSpeed" -FAIL e.style['text-rendering'] = "optimizelegibility" should set the property value assert_equals: serialization should be canonical expected "optimizelegibility" but got "optimizeLegibility" -FAIL e.style['text-rendering'] = "geometricprecision" should set the property value assert_equals: serialization should be canonical expected "geometricprecision" but got "geometricPrecision" +PASS e.style['text-rendering'] = "optimizespeed" should set the property value +PASS e.style['text-rendering'] = "optimizelegibility" should set the property value +PASS e.style['text-rendering'] = "geometricprecision" should set the property value diff --git a/LayoutTests/svg/css/getComputedStyle-basic-expected.txt b/LayoutTests/svg/css/getComputedStyle-basic-expected.txt index 1efcee60e28c..08ff44d4a0c9 100644 --- a/LayoutTests/svg/css/getComputedStyle-basic-expected.txt +++ b/LayoutTests/svg/css/getComputedStyle-basic-expected.txt @@ -94,9 +94,9 @@ rect: style.getPropertyValue(clip-rule) : nonzero rect: style.getPropertyCSSValue(clip-rule) : [object CSSPrimitiveValue] rect: style.getPropertyValue(color) : rgb(0, 0, 0) rect: style.getPropertyCSSValue(color) : [object CSSPrimitiveValue] -rect: style.getPropertyValue(color-interpolation) : sRGB +rect: style.getPropertyValue(color-interpolation) : srgb rect: style.getPropertyCSSValue(color-interpolation) : [object CSSPrimitiveValue] -rect: style.getPropertyValue(color-interpolation-filters) : linearRGB +rect: style.getPropertyValue(color-interpolation-filters) : linearrgb rect: style.getPropertyCSSValue(color-interpolation-filters) : [object CSSPrimitiveValue] rect: style.getPropertyValue(column-count) : auto rect: style.getPropertyCSSValue(column-count) : [object CSSPrimitiveValue] @@ -602,9 +602,9 @@ g: style.getPropertyValue(clip-rule) : nonzero g: style.getPropertyCSSValue(clip-rule) : [object CSSPrimitiveValue] g: style.getPropertyValue(color) : rgb(0, 0, 0) g: style.getPropertyCSSValue(color) : [object CSSPrimitiveValue] -g: style.getPropertyValue(color-interpolation) : sRGB +g: style.getPropertyValue(color-interpolation) : srgb g: style.getPropertyCSSValue(color-interpolation) : [object CSSPrimitiveValue] -g: style.getPropertyValue(color-interpolation-filters) : linearRGB +g: style.getPropertyValue(color-interpolation-filters) : linearrgb g: style.getPropertyCSSValue(color-interpolation-filters) : [object CSSPrimitiveValue] g: style.getPropertyValue(column-count) : auto g: style.getPropertyCSSValue(column-count) : [object CSSPrimitiveValue] diff --git a/LayoutTests/svg/css/shape-rendering-parsing-expected.txt b/LayoutTests/svg/css/shape-rendering-parsing-expected.txt index d19619d1350f..9b2190d2d1c7 100644 --- a/LayoutTests/svg/css/shape-rendering-parsing-expected.txt +++ b/LayoutTests/svg/css/shape-rendering-parsing-expected.txt @@ -6,8 +6,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "auto" PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "crispedges" PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "crispedges" -PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "optimizeSpeed" -PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "geometricPrecision" +PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "optimizespeed" +PASS document.defaultView.getComputedStyle(group, null).shapeRendering is "geometricprecision" PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/svg/css/shape-rendering-parsing.html b/LayoutTests/svg/css/shape-rendering-parsing.html index d8f90abf131c..11b9e2ae895a 100644 --- a/LayoutTests/svg/css/shape-rendering-parsing.html +++ b/LayoutTests/svg/css/shape-rendering-parsing.html @@ -24,10 +24,10 @@ shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "crispedges"); group.setAttribute("shape-rendering", "optimizeSpeed"); -shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "optimizeSpeed"); +shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "optimizespeed"); group.setAttribute("shape-rendering", "geometricPrecision"); -shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "geometricPrecision"); +shouldBeEqualToString("document.defaultView.getComputedStyle(group, null).shapeRendering", "geometricprecision"); var successfullyParsed = true; diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp index ff1740d24990..20a6ebfe706b 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.cpp +++ b/Source/WebCore/css/CSSPrimitiveValue.cpp @@ -1419,7 +1419,9 @@ ALWAYS_INLINE String CSSPrimitiveValue::formatNumberForCustomCSSText() const case CSSUnitType::CSS_URI: return serializeURL(m_value.string); case CSSUnitType::CSS_VALUE_ID: - return nameString(m_value.valueID); + // Per the specification, we should lowercase keywords during serialization: + // https://www.w3.org/TR/cssom-1/#serialize-a-css-component-value + return nameStringForSerialization(m_value.valueID); case CSSUnitType::CSS_PROPERTY_ID: return nameString(m_value.propertyID); case CSSUnitType::CSS_ATTR: diff --git a/Source/WebCore/css/process-css-values.py b/Source/WebCore/css/process-css-values.py index 8a4ebe765bea..f77f5c4b9e09 100755 --- a/Source/WebCore/css/process-css-values.py +++ b/Source/WebCore/css/process-css-values.py @@ -206,7 +206,7 @@ def _generate_gperf_definition(self, *, to): to.write("%%\n") - def _generate_name_string_table(self, *, to): + def _generate_name_string_tables(self, *, to): to.write(f"constexpr ASCIILiteral valueList[] = {{\n") to.write(f" \"\"_s,\n") @@ -215,6 +215,14 @@ def _generate_name_string_table(self, *, to): to.write(f" ASCIILiteral()\n") to.write(f"}};\n") + to.write(f"constexpr ASCIILiteral valueListForSerialization[] = {{\n") + to.write(f" \"\"_s,\n") + + for value in self.values: + to.write(f" \"{value.name_lowercase}\"_s,\n") + + to.write(f" ASCIILiteral()\n") + to.write(f"}};\n") def _generate_lookup_functions(self, *, to): to.write(textwrap.dedent(""" @@ -231,6 +239,15 @@ def _generate_lookup_functions(self, *, to): return valueList[id]; } + // When serializing a CSS keyword, it should be converted to ASCII lowercase. + // https://drafts.csswg.org/cssom/#serialize-a-css-component-value + ASCIILiteral nameLiteralForSerialization(CSSValueID id) + { + if (static_cast(id) >= numCSSValueKeywords) + return { }; + return valueListForSerialization[id]; + } + const AtomString& nameString(CSSValueID id) { if (static_cast(id) >= numCSSValueKeywords) @@ -243,6 +260,20 @@ def _generate_lookup_functions(self, *, to): return string; } + // When serializing a CSS keyword, it should be converted to ASCII lowercase. + // https://drafts.csswg.org/cssom/#serialize-a-css-component-value + const AtomString& nameStringForSerialization(CSSValueID id) + { + if (static_cast(id) >= numCSSValueKeywords) + return nullAtom(); + + static NeverDestroyed> strings; + auto& string = strings.get()[id]; + if (string.isNull()) + string = valueListForSerialization[id]; + return string; + } + """)) def generate_css_value_keywords_gperf(self): @@ -255,7 +286,7 @@ def generate_css_value_keywords_gperf(self): to=output_file ) - self._generate_name_string_table( + self._generate_name_string_tables( to=output_file ) @@ -308,7 +339,9 @@ def _generate_css_value_keywords_h_forward_declarations(self, *, to): to.write(textwrap.dedent("""\ CSSValueID findCSSValueKeyword(const char* characters, unsigned length); ASCIILiteral nameLiteral(CSSValueID); + ASCIILiteral nameLiteralForSerialization(CSSValueID); // Lowercase. const AtomString& nameString(CSSValueID); + const AtomString& nameStringForSerialization(CSSValueID); // Lowercase. struct AllCSSValueKeywordsRange { struct Iterator { diff --git a/Source/WebCore/css/typedom/CSSStyleValueFactory.cpp b/Source/WebCore/css/typedom/CSSStyleValueFactory.cpp index 84a33157fb70..fa6e2f709592 100644 --- a/Source/WebCore/css/typedom/CSSStyleValueFactory.cpp +++ b/Source/WebCore/css/typedom/CSSStyleValueFactory.cpp @@ -253,7 +253,10 @@ ExceptionOr> CSSStyleValueFactory::reifyValue(Ref c case CSSUnitType::CSS_CQMAX: return Ref { CSSNumericFactory::cqmax(primitiveValue->doubleValue()) }; case CSSUnitType::CSS_IDENT: - return static_reference_cast(CSSKeywordValue::rectifyKeywordish(primitiveValue->stringValue())); + // Per the specification, the CSSKeywordValue's value slot should be set to the serialization + // of the identifier. As a result, the identifier will be lowercase: + // https://drafts.css-houdini.org/css-typed-om-1/#reify-ident + return static_reference_cast(CSSKeywordValue::rectifyKeywordish(primitiveValue->cssText())); default: break; }