Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 761924a0502321e047299221e9ef26096458dc8b
https://github.com/WebKit/WebKit/commit/761924a0502321e047299221e9ef26096458dc8b
Author: Sammy Gill <[email protected]>
Date: 2025-10-22 (Wed, 22 Oct 2025)
Changed paths:
A LayoutTests/fast/css/line-height-calc-zoomed-expected.html
A LayoutTests/fast/css/line-height-calc-zoomed.html
M Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h
M Source/WebCore/rendering/RenderBox.cpp
M Source/WebCore/rendering/RenderFlexibleBox.cpp
M Source/WebCore/rendering/RenderGrid.cpp
M Source/WebCore/rendering/RenderReplaced.cpp
M Source/WebCore/rendering/style/RenderStyle.cpp
M Source/WebCore/style/StyleBuilderCustom.h
M Source/WebCore/style/StyleExtractorCustom.h
M Source/WebCore/style/calc/StyleCalculationTree+Evaluation.cpp
M Source/WebCore/style/calc/StyleCalculationTree+Evaluation.h
M Source/WebCore/style/calc/StyleCalculationValue.cpp
M Source/WebCore/style/calc/StyleCalculationValue.h
M Source/WebCore/style/values/images/StyleGradient.cpp
M Source/WebCore/style/values/inline/StyleLineHeight.cpp
M Source/WebCore/style/values/primitives/StyleLengthWrapperData.cpp
M Source/WebCore/style/values/primitives/StyleLengthWrapperData.h
M Source/WebCore/style/values/primitives/StylePrimitiveNumeric.h
M
Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+Evaluation.h
M Source/WebCore/style/values/scroll-snap/StyleScrollPadding.cpp
M Source/WebCore/style/values/text-decoration/StyleTextUnderlineOffset.cpp
M Source/WebCore/svg/SVGLengthContext.cpp
Log Message:
-----------
[Style] Apply zoom to lengths within calc when evaluating.
https://bugs.webkit.org/show_bug.cgi?id=301219
rdar://problem/163141549
Reviewed by Sam Weinig.
Before we can start evaluting Preferred, Minimum, and Maximum Sizes at
use time with zoom we need to be able to support evaluating calc
expressions with zoom since any length values within the expression
should be affected by zoom. For example, something like
width: calc(50% + 100px) will need to have the used zoom multiplied into
the 100px.
We can do this in a similar manner to how we force callers to pass in a
ZoomFactor to various Length types when evaluating their values. The
Style Evaluation code will then call into the Calculation's evaluate API
with the passed in zoom factor. This requires us to plumb the ZoomFactor
through this codepath when evaluating different Calc nodes and using it
when applicable. The other half of this patch is then mostly applying
Style::ZoomNeeded { } at different call sites to mark which types still
need to become Unzoomed and have an actual ZoomFactor passed in.
* LayoutTests/fast/css/line-height-calc-zoomed-expected.html: Added.
* LayoutTests/fast/css/line-height-calc-zoomed.html: Added.
* Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h:
(WebCore::Layout::InlineLevelBox::preferredLineHeight const):
Here we can actually pass in the usedZoom since line-height is already
Unzoomed.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::computePercentageLogicalHeightGeneric const):
Note here we separate out the percent and calc logic since we need to
now treat these differently. Percentages still do not have zoom applied
to them but calc expressions will now have the used zoom applied to
their lengths. This is done in a few different area of the code but I am
only going to note it here.
(WebCore::RenderBox::computeOutOfFlowPositionedLogicalWidthUsing const):
* Source/WebCore/rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::computeMainSizeFromAspectRatioUsing const):
* Source/WebCore/rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeAutoRepeatTracksCount const):
* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::paint):
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::computeLineHeight const):
(WebCore::RenderStyle::computedStrokeWidth const):
* Source/WebCore/style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyValueFontSize):
* Source/WebCore/style/StyleExtractorCustom.h:
(WebCore::Style::PropertyExtractorAdaptor<CSSPropertyLineHeight>::computedValue
const):
* Source/WebCore/style/calc/StyleCalculationTree+Evaluation.cpp:
(WebCore::Style::Calculation::evaluate):
* Source/WebCore/style/calc/StyleCalculationTree+Evaluation.h:
* Source/WebCore/style/calc/StyleCalculationValue.cpp:
(WebCore::Style::Calculation::Value::evaluate const):
* Source/WebCore/style/calc/StyleCalculationValue.h:
Plumbing for the zoom factor through all the different evaluate
implementations. This should only get applied to lengths so in many
cases we do not need to use it.
* Source/WebCore/style/values/primitives/StyleLengthWrapperData.h:
(WebCore::Style::LengthWrapperData::minimumValueForLengthWrapperDataWithLazyMaximum
const):
(WebCore::Style::LengthWrapperData::valueForLengthWrapperDataWithLazyMaximum
const):
* Source/WebCore/style/values/primitives/StylePrimitiveNumeric.h:
*
Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+Evaluation.h:
When called on a type that is Unzoomed we will pass in the ZoomFactor
that they gave us, but in the other case we will just use a
Style::ZoomFactor { 1.0f, 1.0f, } so that the calc value is unaffected.
* Source/WebCore/style/values/scroll-snap/StyleScrollPadding.cpp:
(WebCore::Style::LayoutUnit>::operator):
(WebCore::Style::float>::operator):
* Source/WebCore/style/values/text-decoration/StyleTextUnderlineOffset.cpp:
(WebCore::Style::TextUnderlineOffset::resolve const):
* Source/WebCore/svg/SVGLengthContext.cpp:
(WebCore::SVGLengthContext::valueForSizeType):
Canonical link: https://commits.webkit.org/301968@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications