Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d8a232e3b659fbd5ab4c08e3b71e510ecc07cd67
https://github.com/WebKit/WebKit/commit/d8a232e3b659fbd5ab4c08e3b71e510ecc07cd67
Author: Vitor Roriz <[email protected]>
Date: 2026-03-25 (Wed, 25 Mar 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-family-computed-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-family-valid-expected.txt
M Source/WebCore/css/CSSMarkup.cpp
M Source/WebCore/css/parser/CSSParserIdioms.h
M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
Log Message:
-----------
serializeFontFamily: Quote font family names that match CSS keywords
https://bugs.webkit.org/show_bug.cgi?id=271626
rdar://125334960
Reviewed by Dan Glastonbury.
Per CSS Fonts 4 [1], font family names that happen to match CSS-wide
keywords (inherit, initial, etc.) or generic family keywords (serif,
sans-serif, etc.) must be quoted during serialization to avoid confusion
with the actual keywords during re-parsing.
serializeFontFamily now checks for both CSS-wide keywords (via
isValidCustomIdentifier) and generic family keywords (via
isGenericFontFamilyKeyword). system-ui is excluded because the parser
always stores it as a CSS_FONT_FAMILY string rather than a CSSValueID,
so we cannot distinguish the generic keyword from a quoted family name.
We ahd to extract the generic font family check is extracted into a thread-safe
isGenericFontFamilyKeyword function in CSSParserIdioms.h, because
genericFontFamily accesses the a NeverDestroyed object only accessible
from the main thread. This is necessary because of OffscreenCanvas
workers.
[1] https://www.w3.org/TR/css-fonts-4/#family-name-syntax
* Source/WebCore/css/parser/CSSParserIdioms.h:
(WebCore::isGenericFontFamilyKeyword):
* Source/WebCore/css/CSSMarkup.cpp:
(WebCore::serializeFontFamily):
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::State::fontString const):
*
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-family-computed-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-family-valid-expected.txt:
Canonical link: https://commits.webkit.org/309959@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications