Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1680d5d9e2172a34be5abd2e285a1d038606752e
      
https://github.com/WebKit/WebKit/commit/1680d5d9e2172a34be5abd2e285a1d038606752e
  Author: Sammy Gill <[email protected]>
  Date:   2025-10-31 (Fri, 31 Oct 2025)

  Changed paths:
    M Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp
    M Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp
    M Source/WebCore/rendering/RenderTextControlSingleLine.cpp
    M Source/WebCore/rendering/RenderTheme.cpp
    M Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm
    M Source/WebCore/rendering/mac/RenderThemeMac.mm

  Log Message:
  -----------
  [CSS Zoom] Certain form controls are larger than expected when zoomed in.
https://bugs.webkit.org/show_bug.cgi?id=301754
rdar://163677896

Reviewed by Lily Spiniolas.

In 302241@main and 302229@main we attempted to integrate our new zoom
logic into the existing form control code by factoring out zoom when
setting values on RenderStyle since the existing code was setting those
values with zoom applied. This would result in double zooming since you
would apply zoom when adding the value on RenderStyle and then
evaluating that value during layout. Unfortunately, it seems like I did
not quite get all of the pieces there and there were still some areas of
the code that needed that logic.

After turning on the feature flag, we realized that certain form controls
were still getting more zoom applied making them look larger at certain
scales when compared to trunk. This patch tries to address this by
fixing two main classes of bugs:

1.) Factoring out zoom in more pieces of the code by calling
usedZoomForLength(). This will return the RenderStyle::usedZoom when the
feature flag is enabled and 1.0f if it is not which should result in a
no-op for this divison.

2.) Changing uses of RenderStyle::usedZoom -> RenderStyle::usedZoomForLength
that were added in the previous patches. The reason for this is because
otherwise we would end up with incorrect behavior with the feature flag
disabled. When it is off we want to make sure zoom is still added on
when setting the values on RenderStyle so we need make sure we do not
divide it out.

* Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::adjustMinInlineSize const):
* Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::adjustMinInlineSize const):
Both of these resulted in datetime fields that were wider than expected
when zoomed in. So when we compute the minimum sizes for these elements
we need to divide out the zoom.

* Source/WebCore/rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::layout):
This code modifies the renderers by updating RenderStyle with values
that were computed from layout. Since these values off the renderers are
the used values they should already have zoom applied in so divide them
out here.

* Source/WebCore/rendering/RenderTheme.cpp:
(WebCore::RenderTheme::adjustButtonOrCheckboxOrColorWellOrInnerSpinButtonOrRadioStyle
 const):
This code is unfortunately probably the most confusing. When determining
the *control sizes*, we do not want it to scale the values that it
comptues by the zoom factor (see sizeFromNSControlSize) so we use the
confusingly named usedZoomForComputedStyle to get a zoom of 1.0f if the
feature flag is enabled.

The code below that remains the same and is potentially dividing out the
zoom that was previously set on RenderStyle.

* Source/WebCore/rendering/cocoa/RenderThemeCocoa.mm:
(WebCore::paddingBoxForNumberField):
Divide out zoom for a case that was missed previously.

(WebCore::applyEmPadding):
Fix a case where we were unconditionally using RenderStyle::usedZoom
which is incorrect with the flag disabled.

(WebCore::RenderThemeCocoa::adjustTextFieldStyleForVectorBasedControls const):
Here we are dividing by the zoom factor again even though it is a fixed
value. This is because previously we would always see a padding of 1px
during layout at different scales. To account for this we need to divide
out zoom here so that we get 1px again when multiplying by the zoom.

(WebCore::applyCommonButtonPaddingToStyleForVectorBasedControls):
Fix a case where we were unconditionally using RenderStyle::usedZoom
which is incorrect with the flag disabled.

(WebCore::adjustInputElementButtonStyleForVectorBasedControls):
Divide out zoom for a case that was missed previously.

(WebCore::RenderThemeCocoa::adjustButtonStyleForVectorBasedControls const):
Same case as in adjustTextFieldStyleForVectorBasedControls.

(WebCore::RenderThemeCocoa::paintMenuListButtonDecorationsForVectorBasedControls):
Here we are reverting back to the logic we had previously with respect
to ConversionData. This is because in this code we *want* the conversion
data to use zoom to paint properly. Otherwise we would get small
decorations for the menu lists since they were not getting scaled.

* Source/WebCore/rendering/mac/RenderThemeMac.mm:
(WebCore::RenderThemeMac::adjustListButtonStyle const):
Same case as in adjustTextFieldStyleForVectorBasedControls.

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



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

Reply via email to