From 25448ed3024720e7b829e8135fa046dfc05304d2 Mon Sep 17 00:00:00 2001 From: ananta <ananta@chromium.org> Date: Thu, 12 Mar 2015 16:05:54 -0700 Subject: Don't forward mouse leaves to the renderer process if the mouse leave was generated due to a selection popup. This typically happens if a select box is displayed or any popup for that matter. Sending the mouse leave to the renderer process for the original view confuses sites which use the mouseleave as a trigger to dismiss the popup. This is on the same lines as the original code in render_widget_host_view_win.cc. With this fix moz.com exhibits the same behavior in Chrome and Firefox where in the select dropdown is selectable with the mouse and is dismissed when we move away from the popup window. BUG=461291 R=cpu Review URL: https://codereview.chromium.org/1004543004 Cr-Commit-Position: refs/heads/master@{#320401} --- .../renderer_host/render_widget_host_view_aura.cc | 43 +++++++++++++--------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'content') diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index b6bd563..874e34b 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -231,11 +231,14 @@ BOOL CALLBACK DismissOwnedPopups(HWND window, LPARAM arg) { } #endif -bool CanRendererHandleEvent(const ui::MouseEvent* event, bool mouse_locked) { +bool CanRendererHandleEvent(const ui::MouseEvent* event, + bool mouse_locked, + bool selection_popup) { if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) return false; - if (mouse_locked && (event->type() == ui::ET_MOUSE_EXITED)) + if ((mouse_locked || selection_popup) && + (event->type() == ui::ET_MOUSE_EXITED)) return false; #if defined(OS_WIN) @@ -1935,8 +1938,10 @@ void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { synthetic_move_sent_ = true; window_->MoveCursorTo(center); } + bool is_selection_popup = popup_child_host_view_ && + popup_child_host_view_->NeedsInputGrab(); // Forward event to renderer. - if (CanRendererHandleEvent(event, mouse_locked_) && + if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && !(event->flags() & ui::EF_FROM_TOUCH)) { host_->ForwardMouseEvent(mouse_event); // Ensure that we get keyboard focus on mouse down as a plugin window @@ -1986,20 +1991,24 @@ void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) host_->ForwardWheelEvent(mouse_wheel_event); - } else if (CanRendererHandleEvent(event, mouse_locked_) && - !(event->flags() & ui::EF_FROM_TOUCH)) { - // Confirm existing composition text on mouse press, to make sure - // the input caret won't be moved with an ongoing composition text. - if (event->type() == ui::ET_MOUSE_PRESSED) - FinishImeCompositionSession(); - - blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); - ModifyEventMovementAndCoords(&mouse_event); - host_->ForwardMouseEvent(mouse_event); - // Ensure that we get keyboard focus on mouse down as a plugin window may - // have grabbed keyboard focus. - if (event->type() == ui::ET_MOUSE_PRESSED) - SetKeyboardFocus(); + } else { + bool is_selection_popup = popup_child_host_view_ && + popup_child_host_view_->NeedsInputGrab(); + if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && + !(event->flags() & ui::EF_FROM_TOUCH)) { + // Confirm existing composition text on mouse press, to make sure + // the input caret won't be moved with an ongoing composition text. + if (event->type() == ui::ET_MOUSE_PRESSED) + FinishImeCompositionSession(); + + blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); + ModifyEventMovementAndCoords(&mouse_event); + host_->ForwardMouseEvent(mouse_event); + // Ensure that we get keyboard focus on mouse down as a plugin window may + // have grabbed keyboard focus. + if (event->type() == ui::ET_MOUSE_PRESSED) + SetKeyboardFocus(); + } } switch (event->type()) { -- cgit v1.1