Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: aab8f084ccb25fe22d7a9bc646fb33681d4cbcb8
      
https://github.com/WebKit/WebKit/commit/aab8f084ccb25fe22d7a9bc646fb33681d4cbcb8
  Author: Antti Koivisto <[email protected]>
  Date:   2026-09-15 (Tue, 15 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-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/interpolate-size-logical-properties-interpolation-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/interpolate-size-max-height-composition-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/interpolate-size-max-height-interpolation-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/interpolate-size-max-width-composition-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/interpolate-size-max-width-interpolation-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/interpolate-size-min-height-composition-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/interpolate-size-min-height-interpolation-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/interpolate-size-min-width-composition-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/animation/interpolate-size-min-width-interpolation-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-flex-basis-on-column-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-flex-basis-on-row-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-height-box-sizing-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-height-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-typed-om-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-width-box-sizing-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-width-expected.txt
    M Source/WebCore/Headers.cmake
    M Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBox.cpp
    M Source/WebCore/rendering/RenderBox.h
    M Source/WebCore/rendering/RenderGrid.cpp
    M Source/WebCore/rendering/RenderReplaced.cpp
    M Source/WebCore/rendering/RenderTable.cpp
    M Source/WebCore/style/StyleExtractorCustom.h
    M Source/WebCore/style/calc/StyleCalculationTree+Conversion.cpp
    M Source/WebCore/style/calc/StyleCalculationTree+Evaluation.cpp
    M Source/WebCore/style/calc/StyleCalculationTree+Evaluation.h
    M Source/WebCore/style/calc/StyleCalculationTree.cpp
    M Source/WebCore/style/calc/StyleCalculationTree.h
    M Source/WebCore/style/calc/StyleCalculationValue.cpp
    M Source/WebCore/style/calc/StyleCalculationValue.h
    R Source/WebCore/style/calc/StyleCalculationValueMap.cpp
    R Source/WebCore/style/calc/StyleCalculationValueMap.h
    A Source/WebCore/style/values/primitives/StyleCalcSizeValue+Evaluation.h
    A Source/WebCore/style/values/primitives/StyleCalcSizeValue+Serialization.h
    A Source/WebCore/style/values/primitives/StyleCalcSizeValue.cpp
    A Source/WebCore/style/values/primitives/StyleCalcSizeValue.h
    M Source/WebCore/style/values/primitives/StylePrimitiveData.cpp
    M Source/WebCore/style/values/primitives/StylePrimitiveData.h
    M Source/WebCore/style/values/primitives/StylePrimitiveNumeric.h
    M Source/WebCore/style/values/primitives/StylePrimitiveNumericOrKeyword.h
    M 
Source/WebCore/style/values/primitives/StyleSizeOrKeyword+CSSValueConversion.h
    M Source/WebCore/style/values/primitives/StyleSizeOrKeyword.h
    A Source/WebCore/style/values/primitives/StyleUnevaluatedCalcSize.cpp
    A Source/WebCore/style/values/primitives/StyleUnevaluatedCalcSize.h
    A Source/WebCore/style/values/primitives/StyleValueHandleMap.h

  Log Message:
  -----------
  [css-values-5 calc-size()] Keep unresolved size values in computed style
https://bugs.webkit.org/show_bug.cgi?id=324154
rdar://187378902

Reviewed by Sam Weinig.

Keep `size` values in calc-size() unresolved when constructing the computed 
style representation
so they can be resolved at used value time. This is achieved by adding a 
Style::Calculation::Size node
to represent unresolved sizes in the calculation tree.

The patch also adds a new Style::PrimitiveNumericOrKeywordOrOptionalCalcSize 
value base used by both SizeOrKeyword
and the plain PrimitiveNumericOrKeyword. This allows code sharing and exact 
typing without increasing
object sizes.

Evaluation against keyword bases is not yet implemented.

* 
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:

Some of the interpolation tests go PASS->FAIL because blending is not 
implemented. Passes were spurious.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-flex-basis-on-column-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-flex-basis-on-row-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-height-box-sizing-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-height-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-typed-om-expected.txt:

All ten computed value serializations pass now, including size surviving inside 
sign().

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-width-box-sizing-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-size/calc-size-width-expected.txt:
* Source/WebCore/Headers.cmake:
* Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations:
StylePrimitiveData.cpp no longer calls into the calculation value map directly.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::isSelfCollapsingBlock const):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computeContentAndScrollbarLogicalHeightUsing const):
A percentage basis against an indefinite containing block leaves the function 
behaving as the basis
does. Percentages in the calculation resolve against zero instead.

(WebCore::RenderBox::computePercentageLogicalHeight const):
(WebCore::RenderBox::computeOutOfFlowPositionedLogicalWidthUsing const):
* Source/WebCore/rendering/RenderBox.h:
* Source/WebCore/rendering/RenderGrid.cpp:
(WebCore::RenderGrid::availableSpaceForGutters const):
isSpecified() is true for calc-size, so these switches must produce a value 
rather than drop into
the catch-all.

* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeReplacedLogicalWidthUsing const):
(WebCore::RenderReplaced::computeReplacedLogicalHeightUsingGeneric const):
* Source/WebCore/rendering/RenderTable.cpp:
(WebCore::RenderTable::convertStyleLogicalHeightToComputedHeight):
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::FlexFormattingContext::computeCrossSizeForFlexItem):

* Source/WebCore/style/StyleExtractorCustom.h:
* Source/WebCore/style/calc/StyleCalculationTree+Conversion.cpp:
(WebCore::Style::Calculation::toCSS):
(WebCore::Style::Calculation::toStyle):
size is the one symbol the tree can hold. The others must be gone by conversion 
time.

* Source/WebCore/style/calc/StyleCalculationTree+Evaluation.cpp:
(WebCore::Style::Calculation::evaluate):
A number is dimensionless, so stop applying zoom to it. This was unreachable 
while every length
tree folded to a single dimension, which size now prevents.

* Source/WebCore/style/calc/StyleCalculationTree+Evaluation.h:
EvaluationOptions replaces the loose percent resolution length and zoom pair so 
the resolved basis
can sit alongside them.

* Source/WebCore/style/calc/StyleCalculationTree.cpp:
(WebCore::Style::Calculation::operator<<):
* Source/WebCore/style/calc/StyleCalculationTree.h:
Size carries no value of its own because it stands for the used value of the 
basis.

* Source/WebCore/style/calc/StyleCalculationValue.cpp:
(WebCore::Style::Calculation::Value::evaluate const):
The existing overload forwards to the new one, so callers are unchanged.

* Source/WebCore/style/calc/StyleCalculationValue.h:
* Source/WebCore/style/calc/StyleCalculationValueMap.cpp: Removed.
* Source/WebCore/style/values/primitives/StyleCalcSizeValue+Evaluation.h: Added.

* Source/WebCore/style/values/primitives/StyleUnevaluatedCalcSize.h: Added.
* Source/WebCore/style/values/primitives/StyleUnevaluatedCalcSize.cpp: Added.
(WebCore::Style::UnevaluatedCalcSize::evaluate):
Clamps to the range carried by the type, as UnevaluatedCalculation does.

(WebCore::Style::calcSizeBasisKeyword):
(WebCore::Style::calcSizeHasPercentage):
Let the size predicates ask about a calc-size() without constructing an 
UnevaluatedCalcSize,
whose Ref would run a destructor in the callers annotated NODELETE.

* Source/WebCore/style/values/primitives/StyleCalcSizeValue+Serialization.h: 
Added.
(WebCore::Style::Serialize<Ref<CalcSizeValue>>::operator()):
(WebCore::Style::CSSValueCreation<Ref<CalcSizeValue>>::operator()):
* Source/WebCore/style/values/primitives/StyleCalcSizeValue.cpp: Added.
(WebCore::Style::CalcSizeValue::create):
(WebCore::Style::CalcSizeValue::CalcSizeValue):
(WebCore::Style::CalcSizeValue::basisKeyword const):
The keyword the value behaves as, for everything the spec delegates to the 
basis.

(WebCore::Style::CalcSizeValue::copy const):
(WebCore::Style::CalcSizeValue::operator== const):
(WebCore::Style::toCSSCalcSizeFunction):
Rebuilds the CSS side rather than serializing directly, keeping output in step 
with the parser and
giving serialization and CSSValue creation one path.

(WebCore::Style::evaluateCalcSize):
Resolves the basis, binds it to size, then resolves the calculation, clamping 
the result the way a
plain calc() is clamped.

(WebCore::Style::operator<<):
* Source/WebCore/style/values/primitives/StyleCalcSizeValue.h: Added.
(WebCore::Style::CalcSizeValue::basisHasPercentage const):
* Source/WebCore/style/values/primitives/StylePrimitiveData.cpp:
(WebCore::Style::PrimitiveData::PrimitiveData):
(WebCore::Style::PrimitiveData::nonNanCalcSizeValue const):
Out of line like nonNanCalculatedValue, so the header never passes the forward 
declared
CalcSizeValue as a call argument.

(WebCore::Style::PrimitiveData::calculationValue const):
(WebCore::Style::PrimitiveData::calcSizeValue const):
A second handle bearing kind. It indexes its own map, so the kind must never be 
confused with
Calculation.

(WebCore::Style::PrimitiveData::ref const):
(WebCore::Style::PrimitiveData::deref const):
(WebCore::Style::PrimitiveData::isCalcSizeEqual const):
* Source/WebCore/style/values/primitives/StylePrimitiveData.h:
(WebCore::Style::PrimitiveData::value const):
(WebCore::Style::PrimitiveData::usesHandle const):
(WebCore::Style::PrimitiveData::operator=):
(WebCore::Style::PrimitiveData::initialize):
(WebCore::Style::PrimitiveData::operator== const):
(WebCore::Style::PrimitiveData::minimumValueForPrimitiveDataWithLazyMaximum 
const):
(WebCore::Style::PrimitiveData::valueForPrimitiveDataWithLazyMaximum const):
* Source/WebCore/style/values/primitives/StylePrimitiveNumeric.h:
* Source/WebCore/style/values/primitives/StylePrimitiveNumericOrKeyword.h:
(WebCore::Style::PrimitiveNumericOrKeywordOrOptionalCalcSize::holdsAlternative 
const):
(WebCore::Style::PrimitiveNumericOrKeywordOrOptionalCalcSize::visitCalcSizeBasisKeyword):
A keyword basis answers to its keyword, so the definiteness predicates in flex 
and grid keep
agreeing with what switchOn() dispatches.

The alternative index is independent of the kind that says how to read the 
union, so calc-size takes
an index ahead of the keywords and reuses the handle slot. Nothing grows.

* 
Source/WebCore/style/values/primitives/StyleSizeOrKeyword+CSSValueConversion.h:
(WebCore::Style::asUnevaluatedCalc):
(WebCore::Style::toStyleCalculation):
(WebCore::Style::toStyleCalcSizeValue):
Normalizes the prefixed keyword spellings so only canonical ones are stored.

(WebCore::Style::convertCalcSizeForCSSValueConversion):
* Source/WebCore/style/values/primitives/StyleSizeOrKeyword.h:
(WebCore::Style::SizeOrKeyword::isCalcSize const):
(WebCore::Style::SizeOrKeyword::isSpecified const):
(WebCore::Style::SizeOrKeyword::isPercentOrCalculated const):
A calc-size() resolves against the containing block whenever a percentage 
appears anywhere in it.

A calc-size() with a non-keyword basis is a definite size, and conversion only 
stores one for such a
basis.

* Source/WebCore/style/values/primitives/StyleValueHandleMap.h: Renamed from 
Source/WebCore/style/calc/StyleCalculationValueMap.h.
(WebCore::Style::ValueHandleMap::singleton):
A static local per instantiation, so each value type gets its own map.

(WebCore::Style::ValueHandleMap::Entry::Entry):
(WebCore::Style::ValueHandleMap<ValueType>::insert):
(WebCore::Style::ValueHandleMap<ValueType>::get const):
(WebCore::Style::ValueHandleMap<ValueType>::ref):
(WebCore::Style::ValueHandleMap<ValueType>::deref):

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



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

Reply via email to