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 @@
#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_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/events/current_input_event.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_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/html/forms/html_option_element.h"
#include "third_party/blink/renderer/core/html/forms/html_select_element.h"
......@@ -61,11 +61,9 @@
namespace blink {
ExternalPopupMenu::ExternalPopupMenu(LocalFrame& frame,
HTMLSelectElement& owner_element,
WebView& web_view)
HTMLSelectElement& owner_element)
: owner_element_(owner_element),
local_frame_(frame),
web_view_(web_view),
dispatch_event_timer_(frame.GetTaskRunner(TaskType::kInternalDefault),
this,
&ExternalPopupMenu::DispatchEvent),
......@@ -133,9 +131,9 @@ void ExternalPopupMenu::Show() {
}
void ExternalPopupMenu::DispatchEvent(TimerBase*) {
DCHECK(web_view_.MainFrameWidget());
web_view_.MainFrameWidget()->HandleInputEvent(
blink::WebCoalescedInputEvent(*synthetic_event_));
WebLocalFrameImpl::FromFrame(local_frame_)
->FrameWidgetImpl()
->HandleInputEvent(blink::WebCoalescedInputEvent(*synthetic_event_));
synthetic_event_.reset();
}
......@@ -187,6 +185,7 @@ void ExternalPopupMenu::Update() {
void ExternalPopupMenu::DisconnectClient() {
Hide();
owner_element_ = nullptr;
dispatch_event_timer_.Stop();
}
void ExternalPopupMenu::DidChangeSelection(int index) {}
......
......@@ -44,7 +44,6 @@ class HTMLSelectElement;
class LocalFrame;
class WebExternalPopupMenu;
class WebMouseEvent;
class WebView;
struct WebPopupMenuInfo;
// The ExternalPopupMenu is a PopupMenu implementation for macOS and Android.
......@@ -52,7 +51,7 @@ struct WebPopupMenuInfo;
class CORE_EXPORT ExternalPopupMenu final : public PopupMenu,
public WebExternalPopupMenuClient {
public:
ExternalPopupMenu(LocalFrame&, HTMLSelectElement&, WebView&);
ExternalPopupMenu(LocalFrame&, HTMLSelectElement&);
~ExternalPopupMenu() override;
// Fills |info| with the popup menu information contained in the
......@@ -84,7 +83,6 @@ class CORE_EXPORT ExternalPopupMenu final : public PopupMenu,
Member<HTMLSelectElement> owner_element_;
Member<LocalFrame> local_frame_;
WebView& web_view_;
std::unique_ptr<WebMouseEvent> synthetic_event_;
TaskRunnerTimer<ExternalPopupMenu> dispatch_event_timer_;
// The actual implementor of the show menu.
......
......@@ -857,7 +857,7 @@ PopupMenu* ChromeClientImpl::OpenPopupMenu(LocalFrame& frame,
HTMLSelectElement& select) {
NotifyPopupOpeningObservers();
if (WebViewImpl::UseExternalPopupMenus())
return MakeGarbageCollected<ExternalPopupMenu>(frame, select, *web_view_);
return MakeGarbageCollected<ExternalPopupMenu>(frame, select);
DCHECK(RuntimeEnabledFeatures::PagePopupEnabled());
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