Commit d4007b62 authored by Erik Chen's avatar Erik Chen Committed by Commit Bot

Fix ExternalPopupMenu workaround on macOS.

On macOS, ExternalPopupMenu queued a timer event to dispatch an event to the
main frame widget. This is incorrect and assumes that child frame is an
in-process iframe. Instead, the event should be dispatched to the local root
widget.

Change-Id: I9a89496a333c6788621cca305d618900e3c4be88
Bug: 995981
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1775600
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Auto-Submit: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692195}
parent 2fdd9ca8
...@@ -39,12 +39,12 @@ ...@@ -39,12 +39,12 @@
#include "third_party/blink/public/web/web_local_frame_client.h" #include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_menu_item_info.h" #include "third_party/blink/public/web/web_menu_item_info.h"
#include "third_party/blink/public/web/web_popup_menu_info.h" #include "third_party/blink/public/web/web_popup_menu_info.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h" #include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/events/current_input_event.h" #include "third_party/blink/renderer/core/events/current_input_event.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.h" #include "third_party/blink/renderer/core/exported/web_view_impl.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/web_frame_widget_base.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h" #include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/forms/html_option_element.h" #include "third_party/blink/renderer/core/html/forms/html_option_element.h"
#include "third_party/blink/renderer/core/html/forms/html_select_element.h" #include "third_party/blink/renderer/core/html/forms/html_select_element.h"
...@@ -61,11 +61,9 @@ ...@@ -61,11 +61,9 @@
namespace blink { namespace blink {
ExternalPopupMenu::ExternalPopupMenu(LocalFrame& frame, ExternalPopupMenu::ExternalPopupMenu(LocalFrame& frame,
HTMLSelectElement& owner_element, HTMLSelectElement& owner_element)
WebView& web_view)
: owner_element_(owner_element), : owner_element_(owner_element),
local_frame_(frame), local_frame_(frame),
web_view_(web_view),
dispatch_event_timer_(frame.GetTaskRunner(TaskType::kInternalDefault), dispatch_event_timer_(frame.GetTaskRunner(TaskType::kInternalDefault),
this, this,
&ExternalPopupMenu::DispatchEvent), &ExternalPopupMenu::DispatchEvent),
...@@ -133,9 +131,9 @@ void ExternalPopupMenu::Show() { ...@@ -133,9 +131,9 @@ void ExternalPopupMenu::Show() {
} }
void ExternalPopupMenu::DispatchEvent(TimerBase*) { void ExternalPopupMenu::DispatchEvent(TimerBase*) {
DCHECK(web_view_.MainFrameWidget()); WebLocalFrameImpl::FromFrame(local_frame_)
web_view_.MainFrameWidget()->HandleInputEvent( ->FrameWidgetImpl()
blink::WebCoalescedInputEvent(*synthetic_event_)); ->HandleInputEvent(blink::WebCoalescedInputEvent(*synthetic_event_));
synthetic_event_.reset(); synthetic_event_.reset();
} }
...@@ -187,6 +185,7 @@ void ExternalPopupMenu::Update() { ...@@ -187,6 +185,7 @@ void ExternalPopupMenu::Update() {
void ExternalPopupMenu::DisconnectClient() { void ExternalPopupMenu::DisconnectClient() {
Hide(); Hide();
owner_element_ = nullptr; owner_element_ = nullptr;
dispatch_event_timer_.Stop();
} }
void ExternalPopupMenu::DidChangeSelection(int index) {} void ExternalPopupMenu::DidChangeSelection(int index) {}
......
...@@ -44,7 +44,6 @@ class HTMLSelectElement; ...@@ -44,7 +44,6 @@ class HTMLSelectElement;
class LocalFrame; class LocalFrame;
class WebExternalPopupMenu; class WebExternalPopupMenu;
class WebMouseEvent; class WebMouseEvent;
class WebView;
struct WebPopupMenuInfo; struct WebPopupMenuInfo;
// The ExternalPopupMenu is a PopupMenu implementation for macOS and Android. // The ExternalPopupMenu is a PopupMenu implementation for macOS and Android.
...@@ -52,7 +51,7 @@ struct WebPopupMenuInfo; ...@@ -52,7 +51,7 @@ struct WebPopupMenuInfo;
class CORE_EXPORT ExternalPopupMenu final : public PopupMenu, class CORE_EXPORT ExternalPopupMenu final : public PopupMenu,
public WebExternalPopupMenuClient { public WebExternalPopupMenuClient {
public: public:
ExternalPopupMenu(LocalFrame&, HTMLSelectElement&, WebView&); ExternalPopupMenu(LocalFrame&, HTMLSelectElement&);
~ExternalPopupMenu() override; ~ExternalPopupMenu() override;
// Fills |info| with the popup menu information contained in the // Fills |info| with the popup menu information contained in the
...@@ -84,7 +83,6 @@ class CORE_EXPORT ExternalPopupMenu final : public PopupMenu, ...@@ -84,7 +83,6 @@ class CORE_EXPORT ExternalPopupMenu final : public PopupMenu,
Member<HTMLSelectElement> owner_element_; Member<HTMLSelectElement> owner_element_;
Member<LocalFrame> local_frame_; Member<LocalFrame> local_frame_;
WebView& web_view_;
std::unique_ptr<WebMouseEvent> synthetic_event_; std::unique_ptr<WebMouseEvent> synthetic_event_;
TaskRunnerTimer<ExternalPopupMenu> dispatch_event_timer_; TaskRunnerTimer<ExternalPopupMenu> dispatch_event_timer_;
// The actual implementor of the show menu. // The actual implementor of the show menu.
......
...@@ -857,7 +857,7 @@ PopupMenu* ChromeClientImpl::OpenPopupMenu(LocalFrame& frame, ...@@ -857,7 +857,7 @@ PopupMenu* ChromeClientImpl::OpenPopupMenu(LocalFrame& frame,
HTMLSelectElement& select) { HTMLSelectElement& select) {
NotifyPopupOpeningObservers(); NotifyPopupOpeningObservers();
if (WebViewImpl::UseExternalPopupMenus()) if (WebViewImpl::UseExternalPopupMenus())
return MakeGarbageCollected<ExternalPopupMenu>(frame, select, *web_view_); return MakeGarbageCollected<ExternalPopupMenu>(frame, select);
DCHECK(RuntimeEnabledFeatures::PagePopupEnabled()); DCHECK(RuntimeEnabledFeatures::PagePopupEnabled());
return MakeGarbageCollected<InternalPopupMenu>(this, select); return MakeGarbageCollected<InternalPopupMenu>(this, select);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment