Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0850a6e3f28536d1e54e16c3f8fa95c4254176cc
https://github.com/WebKit/WebKit/commit/0850a6e3f28536d1e54e16c3f8fa95c4254176cc
Author: Ahmad Saleem <[email protected]>
Date: 2026-01-07 (Wed, 07 Jan 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-display-none-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-quirks-mode-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-standards-mode-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-width-1000px-expected.txt
M
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-display-none-expected.txt
M
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-quirks-mode-expected.txt
M
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-standards-mode-expected.txt
M
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-width-1000px-expected.txt
M Source/WebCore/css/parser/SizesCalcParser.cpp
M Source/WebCore/css/parser/SizesCalcParser.h
Log Message:
-----------
Support min(), max(), and clamp() math functions in sizes attribute
https://bugs.webkit.org/show_bug.cgi?id=304915
rdar://167526292
Reviewed by Antti Koivisto.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
Merge:
https://chromium.googlesource.com/chromium/src.git/+/fe60ab1062ae0a308620ac59009c3669b6259c6a
&
https://chromium.googlesource.com/chromium/src.git/+/eafadb8499839e4afba29dd2cd15ae33a7e85fed
The CSS Values and Units Level 4 specification extends mathematical
functions beyond calc() to include min(), max(), and clamp() [1].
The HTML Standard references these functions in the context of the
sizes attribute on <img> elements [2].
"A <source-size-value> that is a <length> must not be negative, and must
not use CSS functions other than the math functions."
When the 'sizes' attribute involves math functions, it uses a custom
code path to resolve calculations by augmenting the custom parser to handle
min(), max(), and clamp() in addition to the existing calc() support.
For clamp(), the function clamp(MIN, VAL, MAX) is converted to
max(MIN, min(VAL, MAX)) following the CSS specification [3].
[1] https://drafts.csswg.org/css-values-4/#math-function
[2] https://html.spec.whatwg.org/#sizes-attributes
[3] https://www.w3.org/TR/css-values-4/#calc-notation
* Source/WebCore/css/parser/SizesCalcParser.cpp:
(WebCore::SizesCalcParser::handleRightParenthesis):
(WebCore::SizesCalcParser::handleComma):
(WebCore::SizesCalcParser::calcToReversePolishNotation):
(WebCore::operateOnStack):
(WebCore::SizesCalcParser::calculate):
* Source/WebCore/css/parser/SizesCalcParser.h:
> Progressions:
*
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-display-none-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-quirks-mode-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-standards-mode-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-width-1000px-expected.txt:
*
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-display-none-expected.txt:
*
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-quirks-mode-expected.txt:
*
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-standards-mode-expected.txt:
*
LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute-width-1000px-expected.txt:
Canonical link: https://commits.webkit.org/305226@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications