Skip to content
Permalink
Browse files
Allow setting custom identifiers via the CSS Typed OM API
https://bugs.webkit.org/show_bug.cgi?id=249270

Reviewed by Simon Fraser.

Allow setting custom identifiers via the CSS Typed OM API:
- https://drafts.css-houdini.org/css-typed-om/#reify-ident
- https://w3c.github.io/csswg-drafts/css-values-4/#identifier-value

Previously, we would fail to convert the CSSKeywordValue into a CSSValue if
the identifier is a pre-defined keyword. We now construct a <custom-ident>
CSSPrimitiveValue in this case.

* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/animation-name-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/container-name-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/page-expected.txt:
* Source/WebCore/css/typedom/CSSKeywordValue.cpp:
(WebCore::CSSKeywordValue::toCSSValue const):

Canonical link: https://commits.webkit.org/257859@main
  • Loading branch information
cdumez committed Dec 14, 2022
1 parent fd88fcd commit 66c0e84643e55fdac3b63d8bac7b958abe0d7120
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
@@ -5,7 +5,7 @@ PASS Can set 'animation-name' to CSS-wide keywords: unset
PASS Can set 'animation-name' to CSS-wide keywords: revert
PASS Can set 'animation-name' to var() references: var(--A)
PASS Can set 'animation-name' to the 'none' keyword: none
FAIL Can set 'animation-name' to the 'custom-ident' keyword: custom-ident Invalid values
PASS Can set 'animation-name' to the 'custom-ident' keyword: custom-ident
PASS Setting 'animation-name' to a length throws TypeError
PASS Setting 'animation-name' to a percent throws TypeError
PASS Setting 'animation-name' to a time throws TypeError
@@ -5,7 +5,7 @@ PASS Can set 'container-name' to CSS-wide keywords: unset
PASS Can set 'container-name' to CSS-wide keywords: revert
PASS Can set 'container-name' to var() references: var(--A)
PASS Can set 'container-name' to the 'none' keyword: none
FAIL Can set 'container-name' to the 'my-container' keyword: my-container Invalid values
PASS Can set 'container-name' to the 'my-container' keyword: my-container
PASS Setting 'container-name' to a length throws TypeError
PASS Setting 'container-name' to a percent throws TypeError
PASS Setting 'container-name' to a time throws TypeError
@@ -5,7 +5,7 @@ FAIL Can set 'page' to CSS-wide keywords: unset assert_not_equals: Computed valu
FAIL Can set 'page' to CSS-wide keywords: revert assert_not_equals: Computed value must not be null got disallowed value null
FAIL Can set 'page' to var() references: var(--A) assert_not_equals: Computed value must not be null got disallowed value null
FAIL Can set 'page' to the 'auto' keyword: auto assert_not_equals: Computed value must not be null got disallowed value null
FAIL Can set 'page' to the 'custom-ident' keyword: custom-ident Invalid values
FAIL Can set 'page' to the 'custom-ident' keyword: custom-ident assert_not_equals: Computed value must not be null got disallowed value null
PASS Setting 'page' to a length throws TypeError
PASS Setting 'page' to a percent throws TypeError
PASS Setting 'page' to a time throws TypeError
@@ -78,7 +78,7 @@ RefPtr<CSSValue> CSSKeywordValue::toCSSValue() const
{
auto keyword = cssValueKeywordID(m_value);
if (keyword == CSSValueInvalid)
return nullptr;
return CSSPrimitiveValue::create(m_value, CSSUnitType::CustomIdent);
return CSSPrimitiveValue::createIdentifier(keyword);
}

0 comments on commit 66c0e84

Please sign in to comment.