Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(593)

Unified Diff: third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp

Issue 2804813002: Hide popups when handling mouse down, mouse wheel, or gesture tap in a WebFrameWidget (Closed)
Patch Set: (Try to) Dismiss popup on scroll and gesture tap Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp b/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp
index fa53cf4be94d6f5fdaa592e667ebd34d4fd8f577..01a078ea4b88185a0ffcf3b7326df471788eec3d 100644
--- a/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp
+++ b/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp
@@ -71,6 +71,7 @@
#include "web/WebInputEventConversion.h"
#include "web/WebInputMethodControllerImpl.h"
#include "web/WebLocalFrameImpl.h"
+#include "web/WebPagePopupImpl.h"
#include "web/WebPluginContainerImpl.h"
#include "web/WebRemoteFrameImpl.h"
#include "web/WebViewFrameWidget.h"
@@ -768,6 +769,15 @@ void WebFrameWidgetImpl::handleMouseLeave(LocalFrame& mainFrame,
void WebFrameWidgetImpl::handleMouseDown(LocalFrame& mainFrame,
const WebMouseEvent& event) {
+ // If there is a popup open, close it as the user is clicking on the page
+ // (outside of the popup). We also save it so we can prevent a click on an
+ // element from immediately reopening the same popup.
+ RefPtr<WebPagePopupImpl> pagePopup;
+ if (event.button == WebMouseEvent::Button::Left) {
+ pagePopup = view()->pagePopup();
+ view()->hidePopups();
+ }
EhsanK 2017/04/07 16:16:12 There is a DCHECK(!m_pagePopup) which I could add
+
// Take capture on a mouse down on a plugin so we can send it mouse events.
// If the hit node is a plugin but a scrollbar is over it don't start mouse
// capture because it will interfere with the scrollbar receiving events.
@@ -792,6 +802,13 @@ void WebFrameWidgetImpl::handleMouseDown(LocalFrame& mainFrame,
m_mouseCaptureGestureToken =
mainFrame.eventHandler().takeLastMouseDownGestureToken();
+ if (view()->pagePopup() && pagePopup &&
+ view()->pagePopup()->hasSamePopupClient(pagePopup.get())) {
+ // That click triggered a page popup that is the same as the one we just
+ // closed. It needs to be closed.
+ view()->hidePopups();
+ }
+
// Dispatch the contextmenu event regardless of if the click was swallowed.
if (!page()->settings().getShowContextMenuOnMouseUp()) {
#if OS(MACOSX)
@@ -855,6 +872,7 @@ void WebFrameWidgetImpl::handleMouseUp(LocalFrame& mainFrame,
WebInputEventResult WebFrameWidgetImpl::handleMouseWheel(
LocalFrame& mainFrame,
const WebMouseWheelEvent& event) {
+ view()->hidePopups();
EhsanK 2017/04/07 16:16:12 Unless there is a handler on the page, this won't
return PageWidgetEventHandler::handleMouseWheel(mainFrame, event);
}
@@ -870,8 +888,17 @@ WebInputEventResult WebFrameWidgetImpl::handleGestureEvent(
case WebInputEvent::GestureTap:
case WebInputEvent::GestureTapUnconfirmed:
case WebInputEvent::GestureTapDown:
- case WebInputEvent::GestureShowPress:
+ // Touch pinch zoom and scroll on the page (outside of a popup) must hide
+ // the popup. In case of a touch scroll or pinch zoom, this function is
+ // called with GestureTapDown rather than a GSB/GSU/GSE or GPB/GPU/GPE.
+ // When we close a popup because of a GestureTapDown, we also save it so
+ // we can prevent the following GestureTap from immediately reopening the
+ // same popup.
+ view()->setLastHiddenPagePopup(view()->pagePopup());
+ view()->hidePopups();
case WebInputEvent::GestureTapCancel:
+ view()->setLastHiddenPagePopup(nullptr);
+ case WebInputEvent::GestureShowPress:
case WebInputEvent::GestureDoubleTap:
case WebInputEvent::GestureTwoFingerTap:
case WebInputEvent::GestureLongPress:
« no previous file with comments | « chrome/browser/site_per_process_interactive_browsertest.cc ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698