Skip to content

refactor: simplify content_view_ hit-test transparency on macOS#51626

Merged
VerteDinde merged 1 commit into
42-x-yfrom
backport/51617-to-42-x-y
May 14, 2026
Merged

refactor: simplify content_view_ hit-test transparency on macOS#51626
VerteDinde merged 1 commit into
42-x-yfrom
backport/51617-to-42-x-y

Conversation

@VerteDinde

Copy link
Copy Markdown
Member

Backport of #51617 to 42-x-y.

Replaces the RootViewMacTargeterDelegate (from #51586) with a ContentViewTargeterDelegate that overrides DoesIntersectRect on content_view_ itself. This is a smaller, more correct fix that doesn't duplicate upstream logic or thread a platform-specific flag through cross-platform headers.

See #51617 for full rationale.

Notes: none

Backport of #51617 to 42-x-y.

Replace the RootViewMac-level TargetForRect override added in #51586 with
a DoesIntersectRect override on content_view_'s own targeter, restoring
the structure of #50330 but fixing its actual defect.

The original bug (#51576) was that ContentViewTargeterDelegate::TargetForRect
returned nullptr when no descendant covered the hit rect, violating the
ViewTargeterDelegate contract. RootView::UpdateCursor and
RootView::HandleMouseEnteredOrMoved dereference GetEventHandlerForPoint()
without null checks, so the nullptr crashed with SIGSEGV when a right-click
in a -webkit-app-region: drag region disabled the HTCAPTION early-exit.

#51586 fixed the crash by moving the transparency logic to RootViewMac and
re-implementing the parent targeter's child-walk loop so it could skip
content_view_ and return a sibling instead. That re-implementation duplicates
~25 lines of upstream logic with a subtle rounding divergence
(ToEnclosedRectIgnoringError vs ToEnclosingRect), and threads a new
content_view_hit_test_transparent_ flag through the platform-neutral
NativeWindow/BrowserWindow headers.

The same fall-through can be achieved with the existing hit-test hook:
override DoesIntersectRect on content_view_ to return false when no
visible, processable child intersects the rect. The parent's default
TargetForRect loop already skips children whose HitTestRect is false, so
hit-testing naturally continues to the WebContentsView sibling and resolves
to its NativeViewHost (kSubView) without ever returning nullptr from
TargetForRect or re-implementing the walk.

This reverts the NativeWindow flag, the BrowserWindow constructor change,
and the RootViewMacTargeterDelegate, leaving the fix entirely in
native_window_mac.mm at the same install site as #50330.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label May 14, 2026
@trop trop Bot added 42-x-y backport This is a backport PR labels May 14, 2026
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label May 14, 2026
@VerteDinde VerteDinde merged commit 9604c46 into 42-x-y May 14, 2026
79 checks passed
@VerteDinde VerteDinde deleted the backport/51617-to-42-x-y branch May 14, 2026 22:13
@release-clerk

release-clerk Bot commented May 14, 2026

Copy link
Copy Markdown

No Release Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants