Skip to content
Browse files
font-variant-alternates: historical-forms doesn't reflect properly …
…via StylePropertyMap

Reviewed by Tim Nguyen.

`font-variant-alternates: historical-forms` doesn't reflect properly via
StylePropertyMap. Even though `historical-forms` is a supported keyword for
this CSS property [1], we wouldn't get a CSSKeywordValue when reading the
property value back. The issue is that we convert to a FontVariantAlternates
internally and then back to a CSSValue. The function to convert back to a
CSSValue (fontVariantAlternatesPropertyValue) was only handling the `normal`
keyword but not the `historical-forms` one.


* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/font-variant-alternates-expected.txt:
* Source/WebCore/css/ComputedStyleExtractor.cpp:

Canonical link:
  • Loading branch information
cdumez committed Dec 15, 2022
1 parent 6198c51 commit 37f48652e37e505cc21a3a655d024de17fcc02ce
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
@@ -0,0 +1,15 @@
Testing for the font-variant-alternates computed values

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". = 'historical-forms swash(flowing)';
PASS getComputedStyle(target).fontVariantAlternates is "historical-forms swash(flowing)" = 'historical-forms';
PASS getComputedStyle(target).fontVariantAlternates is "historical-forms" = 'normal';
PASS getComputedStyle(target).fontVariantAlternates is "normal"
PASS successfullyParsed is true


@@ -0,0 +1,22 @@
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<div id="target"></div>
description("Testing for the font-variant-alternates computed values");

const target = document.getElementById("target");
evalAndLog(" = 'historical-forms swash(flowing)';");
shouldBeEqualToString("getComputedStyle(target).fontVariantAlternates", "historical-forms swash(flowing)");

evalAndLog(" = 'historical-forms';");
shouldBeEqualToString("getComputedStyle(target).fontVariantAlternates", "historical-forms");

evalAndLog(" = 'normal';");
shouldBeEqualToString("getComputedStyle(target).fontVariantAlternates", "normal");
@@ -5,7 +5,7 @@ PASS Can set 'font-variant-alternates' to CSS-wide keywords: unset
PASS Can set 'font-variant-alternates' to CSS-wide keywords: revert
PASS Can set 'font-variant-alternates' to var() references: var(--A)
PASS Can set 'font-variant-alternates' to the 'normal' keyword: normal
FAIL Can set 'font-variant-alternates' to the 'historical-forms' keyword: historical-forms assert_equals: expected "CSSKeywordValue" but got "CSSStyleValue"
PASS Can set 'font-variant-alternates' to the 'historical-forms' keyword: historical-forms
PASS Setting 'font-variant-alternates' to a length: 0px throws TypeError
PASS Setting 'font-variant-alternates' to a length: -3.14em throws TypeError
PASS Setting 'font-variant-alternates' to a length: 3.14cm throws TypeError
@@ -1473,10 +1473,19 @@ static Ref<CSSValue> fontVariantNumericPropertyValue(FontVariantNumericFigure fi
return valueList;

static FontVariantAlternatesValues historicalFormsValues()
FontVariantAlternatesValues values;
values.historicalForms = true;
return values;

static Ref<CSSValue> fontVariantAlternatesPropertyValue(FontVariantAlternates alternates)
if (alternates.isNormal())
return CSSValuePool::singleton().createIdentifierValue(CSSValueNormal);
if (alternates.values() == historicalFormsValues())
return CSSValuePool::singleton().createIdentifierValue(CSSValueHistoricalForms);

return CSSFontVariantAlternatesValue::create(WTFMove(alternates));

0 comments on commit 37f4865

Please sign in to comment.