From 2ce8dff175d8cf7a3761bb971b1b9bec8bdc07a8 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 2 Apr 2020 10:05:05 -0700 Subject: [PATCH] fix: undo and redo broken in webviews (#22911) When propagating the undo and redo events from the menu, Chromium was not properly sending the events to the focused WebContents. This fixes that by ensuring that the events are sent to the proper WebContents. --- patches/chromium/.patches | 1 + .../fix_undo_redo_broken_in_webviews.patch | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 patches/chromium/fix_undo_redo_broken_in_webviews.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index d0aada4bd8a..99ac2206dd9 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -93,3 +93,4 @@ gpu_notify_when_dxdiag_request_fails.patch feat_allow_embedders_to_add_observers_on_created_hunspell.patch feat_add_onclose_to_messageport.patch gin_allow_passing_an_objecttemplate_to_objecttemplatebuilder.patch +fix_undo_redo_broken_in_webviews.patch diff --git a/patches/chromium/fix_undo_redo_broken_in_webviews.patch b/patches/chromium/fix_undo_redo_broken_in_webviews.patch new file mode 100644 index 00000000000..7dfe0945106 --- /dev/null +++ b/patches/chromium/fix_undo_redo_broken_in_webviews.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shelley Vohr +Date: Tue, 31 Mar 2020 14:32:33 -0700 +Subject: fix: undo redo broken in webviews + +When propagating the undo and redo events from the menu, Chromium was not +properly sending the events to the focused webcontents on macOS. This fixes +that error. A crbug has been opened at https://bugs.chromium.org/p/chromium/issues/detail?id=1067284 +and this patch will be removed when it has been resolved upstream. + +diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm +index 591305cb57a2f89067b25189b9c33d92858f01a0..a3112cb03bc73eb670631ff429f38414537f19cf 100644 +--- a/content/browser/renderer_host/render_widget_host_view_mac.mm ++++ b/content/browser/renderer_host/render_widget_host_view_mac.mm +@@ -38,6 +38,7 @@ + #include "content/browser/renderer_host/render_widget_host_input_event_router.h" + #import "content/browser/renderer_host/text_input_client_mac.h" + #import "content/browser/renderer_host/ui_events_helper.h" ++#include "content/browser/web_contents/web_contents_impl.h" + #include "content/common/text_input_state.h" + #include "content/common/view_messages.h" + #include "content/public/browser/browser_context.h" +@@ -978,7 +979,12 @@ void CombineTextNodesAndMakeCallback(SpeechCallback callback, + } + + WebContents* RenderWidgetHostViewMac::GetWebContents() { +- return WebContents::FromRenderViewHost(RenderViewHost::From(host())); ++ auto* wc = WebContents::FromRenderViewHost(RenderViewHost::From(host())); ++ if (wc) { ++ WebContentsImpl* web_contents_impl = static_cast(wc); ++ return web_contents_impl->GetFocusedWebContents(); ++ } ++ return wc; + } + + bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange(