Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6837975fd86fc866326e75a257130ef353bf8376
https://github.com/WebKit/WebKit/commit/6837975fd86fc866326e75a257130ef353bf8376
Author: Antti Koivisto <[email protected]>
Date: 2026-09-17 (Thu, 17 Sep 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-height-interpolation-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-height-interpolation.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-interpolation-expansion-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-width-interpolation-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-width-interpolation.html
M Source/WebCore/Sources.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/style/StyleInterpolationFunctions.h
M Source/WebCore/style/calc/StyleCalculationTree+Copy.cpp
M Source/WebCore/style/calc/StyleCalculationTree+Copy.h
A Source/WebCore/style/calc/StyleCalculationTree+Substitution.cpp
A Source/WebCore/style/calc/StyleCalculationTree+Substitution.h
M Source/WebCore/style/calc/StyleCalculationTree.cpp
M Source/WebCore/style/calc/StyleCalculationTree.h
A
Source/WebCore/style/values/primitives/StyleCalcSizeValue+Interpolation.cpp
A Source/WebCore/style/values/primitives/StyleCalcSizeValue+Interpolation.h
M
Source/WebCore/style/values/primitives/StylePrimitiveNumericOrKeyword+Blending.h
A Source/WebCore/style/values/primitives/StyleSizeOrKeyword+Blending.h
M Source/WebCore/style/values/primitives/StyleSizeOrKeyword.h
Log Message:
-----------
[css-values-5 calc-size()] Blending support
https://bugs.webkit.org/show_bug.cgi?id=324323
rdar://187560387
Reviewed by Sam Weinig.
Interpolate calc-size() values per
https://drafts.csswg.org/css-values-5/#interpolate-calc-size
The "prepare for interpolation" step first modifies the `from` and `to` values
to a form where they have
the same basis. If this succeeds then a normal (1-p)*from + p*to interpolation
function is generated
for the calc-sum portion of the function.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-height-interpolation.html:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-width-interpolation.html:
Import wpt 596596550, which corrects these to expect a keyword and
calc-size(<length>, size) to
interpolate. See https://github.com/w3c/csswg-drafts/issues/14499.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-height-interpolation-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-interpolation-expansion-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/calc-size-width-interpolation-expected.txt:
A keyword basis still needs layout to resolve `size`, so only the values
resolving to a length or a
percentage progress. Two subtests go the other way: `0` to
`calc-size(max-content, size)` at -0.25 now
interpolates to a max-content basis that layout cannot resolve, where the
discrete path happened to
return the from value.
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/style/StyleInterpolationFunctions.h:
Pulls in the calc-size() specialization, this being where property blending is
instantiated.
* Source/WebCore/style/calc/StyleCalculationTree+Copy.cpp:
* Source/WebCore/style/calc/StyleCalculationTree+Copy.h:
Expose copying a single Child, which is what substitution inserts.
* Source/WebCore/style/calc/StyleCalculationTree+Substitution.cpp: Added.
(WebCore::Style::Calculation::mapLeaves):
Rebuilds a tree, replacing each leaf with the result of a functor. Mirrors the
shape of copy().
(WebCore::Style::Calculation::accumulateOverChildren):
(WebCore::Style::Calculation::countSizeLeaves):
(WebCore::Style::Calculation::substituteSize):
Nesting multiplies the calculation by the number of `size` keywords in it at
every level, so the
node count is predicted first and an expansion that would be far too big is
never built.
(WebCore::Style::Calculation::dePercentify):
Restates a percentage basis in terms of the 100% it becomes, which is what
keeps interpolation
linear rather than quadratic.
(WebCore::Style::Calculation::contains):
(WebCore::Style::Calculation::containsSize):
(WebCore::Style::Calculation::containsPercentage):
* Source/WebCore/style/calc/StyleCalculationTree+Substitution.h: Copied from
Source/WebCore/style/calc/StyleCalculationTree+Copy.h.
* Source/WebCore/style/values/primitives/StyleCalcSizeValue+Interpolation.cpp:
Added.
(WebCore::Style::hundredPercent):
(WebCore::Style::prepareForInterpolation):
Folds the basis into the calculation until it is a keyword, `any` or 100%,
leaving two values whose
bases can be compared.
(WebCore::Style::interpolatedBasis):
(WebCore::Style::preparedBasisForKeyword):
(WebCore::Style::makeCalcSizeValue):
* Source/WebCore/style/values/primitives/StyleCalcSizeValue+Interpolation.h:
Added.
*
Source/WebCore/style/values/primitives/StylePrimitiveNumericOrKeyword+Blending.h:
(WebCore::Style::NumericOrKeywordBlending::canBlend):
(WebCore::Style::NumericOrKeywordBlending::requiresInterpolationForAccumulativeIteration):
(WebCore::Style::NumericOrKeywordBlending::blend):
Split out of Blending<> so the sizing types can reuse it for the values that
are not a calc-size().
* Source/WebCore/style/values/primitives/StyleSizeOrKeyword+Blending.h: Added.
(WebCore::Style::Blending<StyleType>::canBlend):
(WebCore::Style::Blending<StyleType>::requiresInterpolationForAccumulativeIteration):
(WebCore::Style::Blending<StyleType>::blend):
Takes over from NumericOrKeywordBlending whenever either side is a calc-size(),
delegating back for
anything else. Reports a calc-size() as not blendable under composition, which
is what blend() does.
* Source/WebCore/style/calc/StyleCalculationTree.cpp:
* Source/WebCore/style/calc/StyleCalculationTree.h:
(WebCore::Style::Calculation::computeNodeCount):
Sits beside computeDepth(), since substitution multiplies a tree rather than
deepening it and the two
bound different things.
(WebCore::Style::Blending<StyleType>::involvesCalcSize):
(WebCore::Style::Blending<StyleType>::prepare):
Upgrades a <length-percentage> to calc-size(any, value) and a bare
<size-keyword> to
calc-size(keyword, size). Whether the two combine is then decided from the
prepared bases alone.
(WebCore::Style::Blending<StyleType>::preparePair):
(WebCore::Style::Blending<StyleType>::blendCalcSize):
Returns the endpoints as they were written, keeping them out of the blended
calculation.
* Source/WebCore/style/values/primitives/StyleSizeOrKeyword.h:
Makes SizeOrKeywordDerived a refinement of LengthPercentageOrKeywordDerived, so
that a Blending<>
specialization constrained on it is more specialized than the one constrained
on that rather than
ambiguous with it.
Canonical link: https://commits.webkit.org/321330@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications