Skip to content

Enable zooming outline: auto - #61077

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
annevk:eng/Enable-zooming-outline-auto
Mar 25, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
annevk:eng/Enable-zooming-outline-auto

Conversation

@annevk

@annevk annevk commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

bd74c28

Enable zooming outline: auto
https://bugs.webkit.org/show_bug.cgi?id=310434
rdar://173068660

Reviewed by Simon Fraser.

The outline: auto focus ring would never change in size. This placed it
outside the CSS coordinate system which could get awkward/ugly when
combined with outline-offset, which does participate in the CSS
coordinate system.

To address this we need to account for two types of zoom, "page zoom"
(Cmd+) and "page scale" (pinch). The changes in GraphicsContextCocoa
take care these. We repurpose some of the logic from scaledBlurRadius()
to handle rotation and skew correctly, but go for the larger value so
the focus ring is sufficiently large in all directions. That's also why
we go from 0 to 1: to ensure there's a focus ring visible.

Most of the other changes are about forwarding the
relevant "page zoom" factor to the graphics layer.

Finally, the change in RenderStyle takes fixes a bug where we pass the
zoomed outline-width value to platformFocusRingWidthOffset() which
operates on un-zoomed values. This results in an outline snug to a
border getting an ever larger gap as you page zoom.

Tests: fast/css/mac/outline-auto-zoom.html
       fast/css/outline-auto-zoom-canvas.html

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

3711ee7

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ⏳ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2   🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl   🧪 ios-wk2   🧪 api-mac ✅ 🧪 api-wpe ⏳ 🛠 vision-apple
✅ 🧪 ios-wk2-wpt   🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
  🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🛠 🧪 unsafe-merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@annevk annevk self-assigned this Mar 21, 2026
@annevk annevk added the CSS Cascading Style Sheets implementation label Mar 21, 2026
@webkit-early-warning-system

This comment was marked as outdated.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 21, 2026
@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label Mar 24, 2026
@annevk
annevk force-pushed the eng/Enable-zooming-outline-auto branch from b5261ae to 7c8164c Compare March 24, 2026 18:09
@webkit-early-warning-system

This comment was marked as outdated.

@annevk
annevk marked this pull request as ready for review March 24, 2026 18:12
<canvas id="canvas1" width="100" height="100">
<button id="btn1" tabindex="0">X</button>
</canvas>
<canvas id="canvas2" width="100" height="100" style="zoom: 2">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zoom style on the canvas is one thing, but I'd me more interested to see a test that draws the focus ring after ctx.scale(2, 2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, also added a more esoteric transform test.

Comment thread LayoutTests/fast/css/outline-auto-zoom-canvas.html
Comment thread Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm Outdated
// zoomFactor covers CSS zoom / page zoom (Cmd+/-). The user-to-base CTM ratio covers page scale (pinch-to-zoom).
auto oldBaseCTM = CGContextGetBaseCTM(platformContext);
auto userToBase = CGAffineTransformConcat(CGContextGetCTM(platformContext), CGAffineTransformInvert(oldBaseCTM));
auto ctmScale = std::max(std::abs(userToBase.a), std::abs(userToBase.d));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should follow scaledBlurRadius which does something more complex (maybe to handle rotations/skews?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer. Created a shared abstraction.

Comment thread Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm Outdated
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 24, 2026
@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label Mar 25, 2026
@annevk
annevk force-pushed the eng/Enable-zooming-outline-auto branch from 7c8164c to 1358421 Compare March 25, 2026 07:56
@webkit-early-warning-system

This comment was marked as outdated.

@annevk
annevk requested a review from smfr March 25, 2026 08:07
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Mar 25, 2026
@annevk annevk removed the merging-blocked Applied to prevent a change from being merged label Mar 25, 2026
@annevk
annevk force-pushed the eng/Enable-zooming-outline-auto branch from 1358421 to 078da3f Compare March 25, 2026 08:15
Comment thread LayoutTests/fast/css/outline-auto-zoom-canvas-rotated-scale.html Outdated
Comment thread Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm Outdated
@annevk
annevk force-pushed the eng/Enable-zooming-outline-auto branch from 078da3f to 3711ee7 Compare March 25, 2026 16:17
@annevk annevk added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Mar 25, 2026
https://bugs.webkit.org/show_bug.cgi?id=310434
rdar://173068660

Reviewed by Simon Fraser.

The outline: auto focus ring would never change in size. This placed it
outside the CSS coordinate system which could get awkward/ugly when
combined with outline-offset, which does participate in the CSS
coordinate system.

To address this we need to account for two types of zoom, "page zoom"
(Cmd+) and "page scale" (pinch). The changes in GraphicsContextCocoa
take care these. We repurpose some of the logic from scaledBlurRadius()
to handle rotation and skew correctly, but go for the larger value so
the focus ring is sufficiently large in all directions. That's also why
we go from 0 to 1: to ensure there's a focus ring visible.

Most of the other changes are about forwarding the
relevant "page zoom" factor to the graphics layer.

Finally, the change in RenderStyle takes fixes a bug where we pass the
zoomed outline-width value to platformFocusRingWidthOffset() which
operates on un-zoomed values. This results in an outline snug to a
border getting an ever larger gap as you page zoom.

Tests: fast/css/mac/outline-auto-zoom.html
       fast/css/outline-auto-zoom-canvas.html

Canonical link: https://commits.webkit.org/309926@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/Enable-zooming-outline-auto branch from 3711ee7 to bd74c28 Compare March 25, 2026 18:06
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 309926@main (bd74c28): https://commits.webkit.org/309926@main

Reviewed commits have been landed. Closing PR #61077 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit bd74c28 into WebKit:main Mar 25, 2026
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Mar 25, 2026
@annevk
annevk deleted the eng/Enable-zooming-outline-auto branch March 25, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CSS Cascading Style Sheets implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants