Skip to content

Commit

Permalink
chore: fix crash on missing RenderWidgetHostView
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Apr 24, 2023
1 parent b626be5 commit 04cf758
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,21 @@ - (void)redispatchContextMenuEvent:(NSEvent*)event {
(event.modifierFlags & NSEventModifierFlagControl)));
content::WebContents* contents =
inspectableWebContentsView_->inspectable_web_contents()->GetWebContents();

electron::api::WebContents* api_contents =
electron::api::WebContents::From(contents);
if (api_contents) {
// Temporarily pretend that the WebContents is fully non-draggable while we
// re-send the mouse event. This allows the re-dispatched event to "land"
// on the WebContents, instead of "falling through" back to the window.
api_contents->SetForceNonDraggable(true);
BaseView* contentsView = (BaseView*)contents->GetRenderWidgetHostView()
->GetNativeView()
.GetNativeNSView();
[contentsView mouseEvent:event];
api_contents->SetForceNonDraggable(false);
auto* rwhv = contents->GetRenderWidgetHostView();
if (rwhv) {
api_contents->SetForceNonDraggable(true);
BaseView* contentsView =
(BaseView*)rwhv->GetNativeView().GetNativeNSView();
[contentsView mouseEvent:event];
api_contents->SetForceNonDraggable(false);
}
}
}

Expand Down

0 comments on commit 04cf758

Please sign in to comment.