Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 524b854c9d8aadd91ebba5fa158b9fb46fe5c1a6
      
https://github.com/WebKit/WebKit/commit/524b854c9d8aadd91ebba5fa158b9fb46fe5c1a6
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-05 (Sun, 05 Apr 2026)

  Changed paths:
    M Source/WebCore/css/parser/CSSParserFastPaths.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/CSSParserFastPaths.cpp

  Log Message:
  -----------
  Add modern HSL syntax fast path to CSSParserFastPaths
https://bugs.webkit.org/show_bug.cgi?id=311468

Reviewed by Darin Adler.

The existing HSL fast path only handled the legacy comma-separated syntax
(e.g., hsl(120, 100%, 50%)). Modern CSS uses space-separated syntax
(e.g., hsl(120 100% 50%) or hsl(120 100% 50% / 0.5)), which was falling
through to the full tokenizer and parser.

Rename parseLegacyHSL() to parseHSL() and teach it to handle the modern
space-separated syntax with optional slash-separated alpha, including
support for angle units (deg, rad) and percentage alpha values. The
legacy path is tried first since its comma check is effectively free
when it fails.

Also add API tests for both legacy and modern HSL parsing through
parseSimpleColor(), covering primary colors, black/white, alpha variants,
angle units, hue wrapping, and modern-vs-legacy equivalence, along with
negative tests for malformed modern HSL inputs.

Test: Tools/TestWebKitAPI/Tests/WebCore/CSSParserFastPaths.cpp

* Source/WebCore/css/parser/CSSParserFastPaths.cpp:
(WebCore::parseHSL):
(WebCore::parseNumericColor):
(WebCore::parseColor):
(WebCore::CSSParserFastPaths::parseNamedColor):
(WebCore::isUniversalKeyword):
(WebCore::parseLegacyHSL): Deleted.
* Tools/TestWebKitAPI/Tests/WebCore/CSSParserFastPaths.cpp:
(TestWebKitAPI::TEST(CSSParserFastPaths, ParseLegacyHsl)):
(TestWebKitAPI::TEST(CSSParserFastPaths, ParseModernHsl)):
(TestWebKitAPI::TEST(CSSParserFastPaths, ParseModernHslInvalid)):

Canonical link: https://commits.webkit.org/310603@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to