Repository navigation
fix(apple): preserve decorations outside clipped views - #238
Merged
Merged
Conversation
houko
force-pushed
the
fix/overflow-decoration-clip
branch
from
November 16, 2026 07:09
311f21d to
55783b7
Compare
houko
force-pushed
the
fix/overflow-decoration-clip
branch
from
November 16, 2026 08:15
55783b7 to
c8bf944
Compare
houko
force-pushed
the
fix/overflow-decoration-clip
branch
2 times, most recently
from
November 16, 2026 09:24
ab8f7e2 to
8f9dce8
Compare
Collaborator
Author
|
Reviewed. Read the full diff against main and checked the following.
|
houko
marked this pull request as ready for review
November 16, 2026 09:24
houko
force-pushed
the
fix/overflow-decoration-clip
branch
from
November 16, 2026 09:32
8f9dce8 to
699d77d
Compare
…can draw The holder clipped corners of different radii with one radius, gave every iOS scroll view a holder framed at its content offset, which stopped its children scrolling with it, and unclipped the own layer of texts, canvases, web and video views whose content is not in the holder. AppKit also masks a view's layer again as clipsToBounds answers on each frame change. Holders now serve plain views, macOS scroll views' containers and images' image layers, with a shape mask for corners that differ (kept across an effect's mask), the styled view answers clipsToBounds false while its holder clips, and holders are released with their views.
Android and Apple's views without a holder clip their own outer shadows and outline with their children; the docs name them, show the inner-view pattern and record the gap in the roadmap.
…pective A holder that clips a view's children answered hit tests where no child is, so a box-none view caught the pointer instead of letting it through, and iOS's header item lookup took the holder for the view. The view's ChildPerspective reached only the flat holder, leaving its children without perspective, a resize fitted the holder to the style before its animated corners, and an image with some corners rounded left its image layer square once the view's own layer stopped clipping. Holders now map hits to their view, take the perspective (scroll containers keep their translation), fit to the style last drawn, and the image layer clips to masked corners that share a radius.
A view that had a clip holder for its shadow or outline kept the holder once they went away, and the holder then took no perspective: the view's own sublayer transform reached only the flat holder, so its children lost Perspective. ClipHolder now takes ChildPerspective from any style, clipping or not, and every holder but a scroll view's container follows each style and resize unclipped, an effect's container included, so the perspective's centre follows the size on macOS, where a layer's anchor is its corner.
The holder that takes a view's children for its clip (or an effect) is registered as the view, so it answered canBecomeKeyView and acceptsFirstResponder for it and AppKit's recalculated key view loop stopped on a pressable, clipped, shadowed card twice. Only the view's own NSView takes the focus now, as the iOS focus methods already require.
houko
force-pushed
the
fix/overflow-decoration-clip
branch
from
November 16, 2026 09:36
699d77d to
ba996c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Apple,
Overflow: HiddensetsmasksToBoundson the styled layer. Core Animation then clips the view's own outer shadows and outline along with its children, while Windows, Linux and the web keep them outside the clip as CSS does (#210).Change
apple.NeedsClipHolder) leaves its own layer unclipped and clips elsewhere:apple.ClipHolder); an effect that hides the holder's children puts that mask back when it ends (apple.HolderMask);clipsToBoundswhenever its frame changes, so a view whose holder clips answers false and the holder true.UIScrollView, where a holder would hold them still) and images or scroll views whose corners differ keep clipping their own decoration, as Android does (setClipToOutlineclips theBoxbackground with its shadows). The common case gets no extra view.canBecomeKeyViewandacceptsFirstResponder, as iOS's focus methods already require, so a pressable clipped card with a shadow stays one stop in the key view loop.NSView/UIView).Perspective(ChildPerspective), which the view's sublayer transform would give only the flat holder, clipping or not: a holder stays once the shadow or outline it clipped for goes away, so every holder but a macOS scroll view's container (an effect's container too) follows each style and resize unclipped. A resize fits it to the style last drawn, animated corners included, and recentres the perspective, as a macOS layer's anchor is its corner.Corners.Uniform), so an image with only its top corners rounded keeps them once its own layer leaves the clip.core.Style.Overflow,docs/public/{en,zh}/layout.md(with the inner-view pattern) andstyles.md,docs/architecture/styles.md; the remaining gaps (Android, the Apple views above) are a roadmap row, soui.Dialog'sBarekeeps its inner clipping view, whose comment now names Android.Verification
go build ./..., Windows/Linux/Android arm64/wasm builds ofcoreandui,go tool nsgo check -target allgo tool nsgo testoninternal/platform/apple,internal/platform/macos,core,ui, and-run 'Layer|Skills|Doc' .; new tests:TestClipHolderClipsToTheCorners,TestShapedCorners,TestViewsClipInAHolderToKeepTheirShadow, andTestViewsClipAsTheirStyleSaysfor the holder'sclipsToBounds. AlsoTestClipHolderTakesThePerspective,TestImageClipsToItsRoundedCorners, macOSTestAHolderIsHitAsItsViewand macOSTestAHolderKeepsThePerspective(a held to unheld transition and a resize), macOSTestAHolderIsNoTabStop(a realNSWindow's recalculated key view loop), each failing without its fix.nsgo test -target macoschecked the corner clipping by pixels; its capture (cacheDisplayInRect:) draws no layer shadows, so shadows were checked from window screenshots.screencaptureof the test window): a box-none, clipped, shadowed overlay lets a press through to the button under it; an image with only its top corners rounded, clipped and shadowed, keeps its square bottom corners and its shadow (before the image fix it showed square top corners too); a clipped, shadowed card withPerspectiveshows its rotated child in perspective (before the holder took it, flat); once its shadow is removed 8 seconds in, the child keeps its perspective (before the holder kept following the style, it turned flat).Fixes #210 in part: the Android parity and the Apple views listed above stay on the roadmap.