Compare commits

...

1 Commits

Author SHA1 Message Date
Shelley Vohr
eb82d5366d build: remove macos hittest workaround patch
CL:6574464 changed BridgedContentView::hitTest: to use GetHitTestResult(), which
returns kRootView for any non-null, non-NativeViewHost view — causing
BridgedContentView to absorb all web content mouse events. In BrowserWindow,
content_view_ sits in front of the sibling WebContentsView and covers the full
client area, so it was always found first, breaking all loadURL page interaction.

Fix this by installing a ContentViewTargeterDelegate on content_view_ in
NativeWindowMac::SetContentView that returns nullptr (instead of the view itself)
when no children cover the target point. This makes GetHitTestResult return kOther,
allowing hitTest: to fall through to [super hitTest:] and find
RenderWidgetHostViewCocoa. This also removes the now-unnecessary chromium
partial-revert patch that worked around the same issue.
2026-03-18 12:25:32 +01:00
3 changed files with 51 additions and 33 deletions

View File

@@ -128,7 +128,6 @@ fix_win32_synchronous_spellcheck.patch
chore_grandfather_in_electron_views_and_delegates.patch
refactor_patch_electron_permissiontypes_into_blink.patch
revert_views_remove_desktopwindowtreehostwin_window_enlargement.patch
build_partial_revert_mac_fullscreen_top_chrome_mouse_events.patch
fix_add_macos_memory_query_fallback_to_avoid_crash.patch
fix_resolve_dynamic_background_material_update_issue_on_windows_11.patch
feat_add_support_for_embedder_snapshot_validation.patch

View File

@@ -1,31 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Keeley Hammond <khammond@slack-corp.com>
Date: Wed, 25 Jun 2025 10:21:31 -0400
Subject: build: partially revert Mac fullscreen top-chrome mouse events
Reverts "mac: fix missing mouse up and down event in fullscreen top-chrome".
This CL caused all interactions to fail when loading a page via loadURL
on Mac. This patch can be removed when upstream is fixed, or when a better
solution is put in place.
This reverts commit 8c004781dde7d42d9a3fed8cafcaa4929943dd69.
diff --git a/components/remote_cocoa/app_shim/bridged_content_view.mm b/components/remote_cocoa/app_shim/bridged_content_view.mm
index c8e9717e6612291256d0c12613d5d1cf927b890b..7359eb46eb40933d2ec9bd664ec87139af5260df 100644
--- a/components/remote_cocoa/app_shim/bridged_content_view.mm
+++ b/components/remote_cocoa/app_shim/bridged_content_view.mm
@@ -305,14 +305,6 @@ - (NSView*)hitTest:(NSPoint)point {
return nil;
}
- // Send event to views::RootView.
- if (hitTestResult == remote_cocoa::mojom::HitTestResult::kRootView) {
- // Most commonly this NSView is NSWindow's contentView. However in immersive
- // fullscreen, the view may be a subview of another AppKit-owned view in the
- // titlebar.
- return self;
- }
-
return [super hitTest:point];
}

View File

@@ -45,6 +45,8 @@
#include "ui/gl/gpu_switching_manager.h"
#include "ui/views/background.h"
#include "ui/views/cocoa/native_widget_mac_ns_window_host.h"
#include "ui/views/view_targeter.h"
#include "ui/views/view_targeter_delegate.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/native_frame_view_mac.h"
@@ -112,6 +114,43 @@ struct Converter<electron::NativeWindowMac::VisualEffectState> {
} // namespace gin
namespace {
// A ViewTargeterDelegate installed on content_view_ to make it event-
// transparent when no children cover the target point.
//
// In BrowserWindow, the WebContentsView is added as a sibling of content_view_
// at a lower Z-order (behind it) so that user-added child views paint above
// the web content. However, views::ViewTargeterDelegate::TargetForRect
// iterates children front-to-back and returns the first child whose
// HitTestRect() is true. content_view_ covers the full window area, so the
// WebContentsView (and its NativeViewHost) is never reached.
//
// Chromium's BridgedContentView::hitTest: uses GetHitTestResult() to classify
// the result: NativeViewHost → kSubView (routes to RenderWidgetHostViewCocoa);
// anything else non-null → kRootView (BridgedContentView absorbs the event,
// breaking all web content interaction with loadURL); null → kOther (falls
// through to [super hitTest:] which finds RenderWidgetHostViewCocoa directly).
//
// By returning nullptr instead of root when no children cover the target rect,
// GetEventHandlerForPoint propagates null up the chain → GetHitTestResult
// returns kOther → hitTest: falls through to [super hitTest:] → NSView walk
// finds RenderWidgetHostViewCocoa → web content interaction works correctly.
class ContentViewTargeterDelegate : public views::ViewTargeterDelegate {
public:
views::View* TargetForRect(views::View* root,
const gfx::Rect& rect) override {
views::View* result =
views::ViewTargeterDelegate::TargetForRect(root, rect);
// The default TargetForRect returns |root| when no children cover |rect|.
// Return nullptr instead so event routing falls through to the sibling
// WebContentsView and finds RenderWidgetHostViewCocoa.
return result == root ? nullptr : result;
}
};
} // namespace
namespace electron {
NativeWindowMac::~NativeWindowMac() = default;
@@ -315,7 +354,7 @@ NativeWindowMac::NativeWindowMac(const int32_t base_window_id,
// by calls to other APIs.
SetMaximizable(maximizable);
// Default content view.
// Default content view (replaced by BaseWindow::SetContentView).
SetContentView(new views::View());
AddContentViewLayers();
@@ -329,6 +368,17 @@ void NativeWindowMac::SetContentView(views::View* view) {
root_view->RemoveChildView(content_view());
set_content_view(view);
// Install event-transparent targeting on content_view_. In BrowserWindow,
// content_view_ sits in front of the sibling WebContentsView (higher Z-order)
// so user-added child views paint above web content. This targeter makes
// content_view_ event-transparent when no children cover the target point,
// returning nullptr instead of itself so GetHitTestResult produces kOther
// and BridgedContentView::hitTest: falls through to [super hitTest:] which
// finds RenderWidgetHostViewCocoa for web content mouse events.
view->SetEventTargeter(std::make_unique<views::ViewTargeter>(
std::make_unique<ContentViewTargeterDelegate>()));
root_view->AddChildViewRaw(content_view());
root_view->DeprecatedLayoutImmediately();