Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1f08e982988ac8f614a8dfe55c41050797e2986c
https://github.com/WebKit/WebKit/commit/1f08e982988ac8f614a8dfe55c41050797e2986c
Author: Ahmad Saleem <[email protected]>
Date: 2026-04-17 (Fri, 17 Apr 2026)
Changed paths:
M LayoutTests/fast/text/font-face-empty-string-expected.txt
M LayoutTests/fast/text/font-face-empty-string.html
M LayoutTests/fast/text/font-face-family-expected.txt
M LayoutTests/fast/text/font-face-family.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontface-invalid-family.tentative-expected.txt
M Source/WebCore/css/CSSFontFace.cpp
M Source/WebCore/css/FontFace.cpp
Log Message:
-----------
FontFace family attribute should return the serialization of the parsed value
https://bugs.webkit.org/show_bug.cgi?id=312209
rdar://174698351
Reviewed by Vitor Roriz.
This patch aligns WebKit with Gecko / Firefox and Blink / Gecko.
The CSS Font Loading spec requires that FontFace attributes be set to
"the serialization of the parsed values."
The constructor spec [1] states:
"Parse the family argument, and the members of the descriptors argument,
according to the grammars of the corresponding descriptors of the CSS
@font-face rule. [...] set font face's corresponding attributes to the
serialization of the parsed values."
And the attribute setter spec [2] states:
"On setting, parse the string according to the grammar for the
corresponding @font-face descriptor. If it does not match the grammar,
throw a SyntaxError; otherwise, set the attribute to the serialization
of the parsed value."
The CSSWG resolved [3] that if a FontFace is constructed with an invalid
font-family name, it should be treated as a quoted string rather than
throwing.
Currently, CSSFontFace::family() returns the raw string via stringValue()
instead of the properly serialized form. This means values like
"sans-serif" or "inherit" are returned as-is rather than being quoted per
CSS serialization rules.
Use serializeFontFamily() (which already exists in CSSMarkup.h and is used
by CSSPrimitiveValue::customCSSText()) in CSSFontFace::family() to produce
the correct serialized output. Also remove the empty-string rejection in
FontFace::setFamily().
[1] https://drafts.csswg.org/css-font-loading/#font-face-constructor
[2] https://drafts.csswg.org/css-font-loading/#fontface-interface
[3] https://github.com/w3c/csswg-drafts/issues/6236
*
LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontface-invalid-family.tentative-expected.txt:
Progressions
* Source/WebCore/css/CSSFontFace.cpp:
(WebCore::CSSFontFace::family const):
* Source/WebCore/css/FontFace.cpp:
(WebCore::FontFace::setFamily):
* LayoutTests/fast/text/font-face-empty-string.html: Removed subtest (covered
by WPT)
* LayoutTests/fast/text/font-face-empty-string-expected.txt: Updated
Expectation.
* LayoutTests/fast/text/font-face-family.html: Updated based on new behavior
(matching other browsers)
* LayoutTests/fast/text/font-face-family-expected.txt: Updated Expectation.
Canonical link: https://commits.webkit.org/311478@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications