Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8be326aecef7fb3b3086f012e035a7471212c03f
https://github.com/WebKit/WebKit/commit/8be326aecef7fb3b3086f012e035a7471212c03f
Author: Chris Dumez <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-function-zero-fallback-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-function-zero-fallback.html
M Source/WebCore/css/calc/CSSCalcTree+Parser.cpp
Log Message:
-----------
anchor()/anchor-size() crash on a function-form zero fallback
https://bugs.webkit.org/show_bug.cgi?id=317470
Reviewed by Darin Adler.
The unitless-zero quirk lets a bare '0' stand in for a <length> fallback in
anchor() and anchor-size(). consumeAnchorFallback() handled this by extracting
the value with std::get<Number>() whenever the fallback had number type. But a
math function that resolves to a unitless zero (calc(0), min(0, 0), ...) also
has number type, and consumeValueWithoutSimplifyingRootCalc() wraps such a
function-produced leaf in a Sum node rather than leaving it a bare Number. So
std::get<Number>() was applied to a variant holding a Sum, throwing
std::bad_variant_access and aborting the process at parse time (e.g.
width: anchor-size(width, calc(0))).
Extract the Number with std::get_if<> and bail if the fallback is not a bare
<number> leaf, so a function-form zero is rejected as an invalid fallback
instead of aborting. A bare '0' and a <length> remain valid fallbacks.
Test:
imported/w3c/web-platform-tests/css/css-anchor-position/anchor-function-zero-fallback.html
This test is crashing in shipping Safari but passing in Chrome and Firefox.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-function-zero-fallback-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-function-zero-fallback.html:
Added.
* Source/WebCore/css/calc/CSSCalcTree+Parser.cpp:
(WebCore::CSSCalc::consumeAnchorFallback):
Canonical link: https://commits.webkit.org/315535@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications