Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 4082642c7f1c6335700c6e1a64e362ce92d13758
https://github.com/WebKit/WebKit/commit/4082642c7f1c6335700c6e1a64e362ce92d13758
Author: Vitor Roriz <[email protected]>
Date: 2025-10-17 (Fri, 17 Oct 2025)
Changed paths:
M LayoutTests/fast/css/line-height-zoom-get-computed-style.html
M LayoutTests/fast/sub-pixel/zoomed-em-border.html
M LayoutTests/fast/text/line-height-minimumFontSize-zoom.html
M LayoutTests/svg/zoom/page/zoom-replaced-intrinsic-ratio-001.htm
M Source/WebCore/css/CSSToLengthConversionData.h
M Source/WebCore/css/values/primitives/CSSPrimitiveNumericRange.h
M Source/WebCore/platform/graphics/FontCascadeDescription.cpp
M Source/WebCore/platform/graphics/FontDescription.cpp
M Source/WebCore/platform/graphics/FontDescription.h
M Source/WebCore/style/StyleBuilderState.cpp
M Source/WebCore/style/StyleBuilderStateInlines.h
M Source/WebCore/style/StyleFontSizeFunctions.cpp
M Source/WebCore/style/StyleFontSizeFunctions.h
M Source/WebCore/style/StyleResolveForDocument.cpp
M Source/WebCore/style/StyleResolveForFont.cpp
M Source/WebCore/style/StyleResolver.cpp
M Source/WebCore/style/values/inline/StyleLineHeight.cpp
M Source/WebCore/style/values/primitives/StyleLengthResolution.cpp
M Source/WebCore/style/values/primitives/StyleLengthResolution.h
M
Source/WebCore/style/values/primitives/StyleLengthWrapper+CSSValueConversion.h
M
Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+CSSValueConversion.h
M
Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+Conversions.h
M Source/WebCore/style/values/text/StyleWordSpacing.cpp
Log Message:
-----------
[CSS Zoom] Fix font-relative units for unzoomed properties
https://bugs.webkit.org/show_bug.cgi?id=299816
rdar://161590209
Reviewed by Brent Fulgham.
In our current architecture, the computed font size has already zoom applied
to it.
Properties that are tagged as “unzoomed” (assuming evaluation flag is enabled)
will have zoom applied to its value during evaluation. If such a value uses a
font-related unit, we would have double zoom applied. So, for such cases we want
to use the unzoomed computed size (which is basically computedSize / zoom, not
necessarily equal to the specified size).
If we indiscriminately use the unzoomed computed font-size when resolving length
this would break the the resolution for all non-converted “length” properties
(since
evaluate won’t apply zoom for them during style resolution).
Therefore, we need to request the use of the “unzoomed computed font-size”
depending on
the type we are resolving. In order to do that, we propagating RangeZoomOptions
via
CSSToLengthConversionData. In that way, we can request the use of the unzoomed
computed
font size just when the EvaluationTimeZoomEnabled flag is enabled and when
RangeZoomOptions
is RangeZoomOptions::Unzoomed.
Each new unzoomed property will need to set RangeZoomOptions::Unzoomed at
CSSToLengthConversionData in order to font relative units to get evaluated
correctly
from now on.
There are different ways this can be done. Here are some exaples:
1. Via copyWithAdjustedZoom: StyleWordSpacing, uses copyWithAdjustedZoom for
mutating the
original state's CSSToLengthConversionData. This funciton can now receive a
RangeZoomOptions:
```
state.cssToLengthConversionData().copyWithAdjustedZoom(zoom,
CSS::RangeZoomOptions::Unzoomed)
```
2. Via its own copy method. StyleLineHeight already has its own method to
produce a conversion data,
in that case it makes sense to explicitly set it there:
```
CSSToLengthConversionData copyForLineHeight(float zoom) const
{
CSSToLengthConversionData copy(*this);
copy.m_zoom = zoom;
copy.m_propertyToCompute = CSSPropertyLineHeight;
copy.m_rangeZoomOption = CSS::RangeZoomOptions::Unzoomed;
return copy;
}
```
3. If your property uses toStyleFromCSSValue<LineWidth::Length>(state, value),
you might
notice that there are no conversionData propagation. Here, the conversion data
is created
by selectConversionData or by the conversion operator CSSToLengthConversionData
operator().
For those, this patch are already propagates CSS::RangeZoomOptions::Unzoomed
taking advantage
of the existent branches for zoom options there:
Example:
```
selectConversionData(BuilderState& builderState)
{
...
else if constexpr (R.zoomOptions == CSS::RangeZoomOptions::Unzoomed) {
if (shouldUseEvaluationTimeZoom(builderState))
return
builderState.cssToLengthConversionData().copyWithAdjustedZoom(1.0f,
CSS::RangeZoomOptions::Unzoomed);
...
}
```
Note: Ideally we would have a function template that given a type could return
what type of
computed font-size should be used, given that this depends on the StrongTypes
which are
already marked with RangeZoomOptions::Unzoomed. This would require some
complicate generic
templates given that we have to unroll differente lenght wrappers like, for
example:
struct WordSpacing : LengthWrapperBase<LengthPercentage<CSS::AllUnzoomed>>
Length = Style::Length<CSS::NonnegativeUnzoomed>;
Until we do that, I'm propagating it dynamically here.
* LayoutTests/fast/css/line-height-zoom-get-computed-style.html:
* LayoutTests/fast/sub-pixel/zoomed-em-border.html:
* LayoutTests/fast/text/line-height-minimumFontSize-zoom.html:
* LayoutTests/svg/zoom/page/zoom-replaced-intrinsic-ratio-001.htm:
* Source/WebCore/css/CSSToLengthConversionData.h:
(WebCore::CSSToLengthConversionData::rangeZoomOption const):
(WebCore::CSSToLengthConversionData::copyWithAdjustedZoom const):
(WebCore::CSSToLengthConversionData::copyForLineHeight const):
* Source/WebCore/css/values/primitives/CSSPrimitiveNumericRange.h:
* Source/WebCore/platform/graphics/FontCascadeDescription.cpp:
* Source/WebCore/platform/graphics/FontDescription.cpp:
(WebCore::m_enableEvaluationTimeZoom):
(WebCore::m_shouldDisableLigaturesForSpacing): Deleted.
* Source/WebCore/platform/graphics/FontDescription.h:
(WebCore::FontDescription::usedZoomFactor const):
(WebCore::FontDescription::computedSizeForRangeZoomOption const):
(WebCore::FontDescription::unzoomedComputedSize const):
(WebCore::FontDescription::enableEvaluationTimeZoom const):
(WebCore::FontDescription::setComputedSize):
(WebCore::FontDescription::setEnableEvaluationTimeZoom):
* Source/WebCore/style/StyleBuilderState.cpp:
(WebCore::Style::BuilderState::updateFontForSizeChange):
(WebCore::Style::BuilderState::setFontSize):
* Source/WebCore/style/StyleBuilderStateInlines.h:
(WebCore::Style::BuilderState::setFontDescriptionFontSize):
* Source/WebCore/style/StyleFontSizeFunctions.cpp:
(WebCore::Style::computedFontSizeFromSpecifiedSize):
* Source/WebCore/style/StyleFontSizeFunctions.h:
* Source/WebCore/style/StyleResolveForDocument.cpp:
(WebCore::Style::resolveForDocument):
* Source/WebCore/style/StyleResolveForFont.cpp:
(WebCore::Style::fontSizeFromUnresolvedFontSize):
* Source/WebCore/style/StyleResolver.cpp:
(WebCore::Style::Resolver::defaultStyleForElement):
* Source/WebCore/style/values/inline/StyleLineHeight.cpp:
(WebCore::Style::CSSValueConversion<LineHeight>::operator):
* Source/WebCore/style/values/primitives/StyleLengthResolution.cpp:
(WebCore::Style::computeUnzoomedNonCalcLengthDouble):
(WebCore::Style::computeNonCalcLengthDouble):
* Source/WebCore/style/values/primitives/StyleLengthResolution.h:
*
Source/WebCore/style/values/primitives/StyleLengthWrapper+CSSValueConversion.h:
(WebCore::Style::CSSValueConversion<T>::selectConversionData):
*
Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+CSSValueConversion.h:
*
Source/WebCore/style/values/primitives/StylePrimitiveNumericTypes+Conversions.h:
* Source/WebCore/style/values/text/StyleWordSpacing.cpp:
(WebCore::Style::CSSValueConversion<WordSpacing>::operator):
Canonical link: https://commits.webkit.org/301757@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes