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

Side by Side 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: Addressing comments 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "web/CompositionUnderlineVectorBuilder.h" 66 #include "web/CompositionUnderlineVectorBuilder.h"
67 #include "web/CompositorMutatorImpl.h" 67 #include "web/CompositorMutatorImpl.h"
68 #include "web/CompositorWorkerProxyClientImpl.h" 68 #include "web/CompositorWorkerProxyClientImpl.h"
69 #include "web/ContextMenuAllowedScope.h" 69 #include "web/ContextMenuAllowedScope.h"
70 #include "web/InspectorOverlay.h" 70 #include "web/InspectorOverlay.h"
71 #include "web/PageOverlay.h" 71 #include "web/PageOverlay.h"
72 #include "web/WebDevToolsAgentImpl.h" 72 #include "web/WebDevToolsAgentImpl.h"
73 #include "web/WebInputEventConversion.h" 73 #include "web/WebInputEventConversion.h"
74 #include "web/WebInputMethodControllerImpl.h" 74 #include "web/WebInputMethodControllerImpl.h"
75 #include "web/WebLocalFrameImpl.h" 75 #include "web/WebLocalFrameImpl.h"
76 #include "web/WebPagePopupImpl.h"
76 #include "web/WebPluginContainerImpl.h" 77 #include "web/WebPluginContainerImpl.h"
77 #include "web/WebRemoteFrameImpl.h" 78 #include "web/WebRemoteFrameImpl.h"
78 #include "web/WebViewFrameWidget.h" 79 #include "web/WebViewFrameWidget.h"
79 80
80 namespace blink { 81 namespace blink {
81 82
82 // WebFrameWidget ------------------------------------------------------------ 83 // WebFrameWidget ------------------------------------------------------------
83 84
84 WebFrameWidget* WebFrameWidget::Create(WebWidgetClient* client, 85 WebFrameWidget* WebFrameWidget::Create(WebWidgetClient* client,
85 WebLocalFrame* local_root) { 86 WebLocalFrame* local_root) {
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 780
780 void WebFrameWidgetImpl::HandleMouseLeave(LocalFrame& main_frame, 781 void WebFrameWidgetImpl::HandleMouseLeave(LocalFrame& main_frame,
781 const WebMouseEvent& event) { 782 const WebMouseEvent& event) {
782 // FIXME: WebWidget doesn't have the method below. 783 // FIXME: WebWidget doesn't have the method below.
783 // m_client->setMouseOverURL(WebURL()); 784 // m_client->setMouseOverURL(WebURL());
784 PageWidgetEventHandler::HandleMouseLeave(main_frame, event); 785 PageWidgetEventHandler::HandleMouseLeave(main_frame, event);
785 } 786 }
786 787
787 void WebFrameWidgetImpl::HandleMouseDown(LocalFrame& main_frame, 788 void WebFrameWidgetImpl::HandleMouseDown(LocalFrame& main_frame,
788 const WebMouseEvent& event) { 789 const WebMouseEvent& event) {
790 // If there is a popup open, close it as the user is clicking on the page
791 // (outside of the popup). We also save it so we can prevent a click on an
792 // element from immediately reopening the same popup.
793 RefPtr<WebPagePopupImpl> page_popup;
794 if (event.button == WebMouseEvent::Button::kLeft) {
795 page_popup = View()->GetPagePopup();
796 View()->HidePopups();
797 }
798
789 // Take capture on a mouse down on a plugin so we can send it mouse events. 799 // Take capture on a mouse down on a plugin so we can send it mouse events.
790 // If the hit node is a plugin but a scrollbar is over it don't start mouse 800 // If the hit node is a plugin but a scrollbar is over it don't start mouse
791 // capture because it will interfere with the scrollbar receiving events. 801 // capture because it will interfere with the scrollbar receiving events.
792 IntPoint point(event.PositionInWidget().x, event.PositionInWidget().y); 802 IntPoint point(event.PositionInWidget().x, event.PositionInWidget().y);
793 if (event.button == WebMouseEvent::Button::kLeft) { 803 if (event.button == WebMouseEvent::Button::kLeft) {
794 point = local_root_->GetFrameView()->RootFrameToContents(point); 804 point = local_root_->GetFrameView()->RootFrameToContents(point);
795 HitTestResult result( 805 HitTestResult result(
796 local_root_->GetFrame()->GetEventHandler().HitTestResultAtPoint(point)); 806 local_root_->GetFrame()->GetEventHandler().HitTestResultAtPoint(point));
797 result.SetToShadowHostIfInRestrictedShadowRoot(); 807 result.SetToShadowHostIfInRestrictedShadowRoot();
798 Node* hit_node = result.InnerNode(); 808 Node* hit_node = result.InnerNode();
799 809
800 if (!result.GetScrollbar() && hit_node && hit_node->GetLayoutObject() && 810 if (!result.GetScrollbar() && hit_node && hit_node->GetLayoutObject() &&
801 hit_node->GetLayoutObject()->IsEmbeddedObject()) { 811 hit_node->GetLayoutObject()->IsEmbeddedObject()) {
802 mouse_capture_node_ = hit_node; 812 mouse_capture_node_ = hit_node;
803 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); 813 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this);
804 } 814 }
805 } 815 }
806 816
807 PageWidgetEventHandler::HandleMouseDown(main_frame, event); 817 PageWidgetEventHandler::HandleMouseDown(main_frame, event);
808 818
809 if (event.button == WebMouseEvent::Button::kLeft && mouse_capture_node_) 819 if (event.button == WebMouseEvent::Button::kLeft && mouse_capture_node_)
810 mouse_capture_gesture_token_ = 820 mouse_capture_gesture_token_ =
811 main_frame.GetEventHandler().TakeLastMouseDownGestureToken(); 821 main_frame.GetEventHandler().TakeLastMouseDownGestureToken();
812 822
823 if (View()->GetPagePopup() && page_popup &&
824 View()->GetPagePopup()->HasSamePopupClient(page_popup.Get())) {
825 // That click triggered a page popup that is the same as the one we just
826 // closed. It needs to be closed.
827 View()->HidePopups();
828 }
829
813 // Dispatch the contextmenu event regardless of if the click was swallowed. 830 // Dispatch the contextmenu event regardless of if the click was swallowed.
814 if (!GetPage()->GetSettings().GetShowContextMenuOnMouseUp()) { 831 if (!GetPage()->GetSettings().GetShowContextMenuOnMouseUp()) {
815 #if OS(MACOSX) 832 #if OS(MACOSX)
816 if (event.button == WebMouseEvent::Button::kRight || 833 if (event.button == WebMouseEvent::Button::kRight ||
817 (event.button == WebMouseEvent::Button::kLeft && 834 (event.button == WebMouseEvent::Button::kLeft &&
818 event.GetModifiers() & WebMouseEvent::kControlKey)) 835 event.GetModifiers() & WebMouseEvent::kControlKey))
819 MouseContextMenu(event); 836 MouseContextMenu(event);
820 #else 837 #else
821 if (event.button == WebMouseEvent::Button::kRight) 838 if (event.button == WebMouseEvent::Button::kRight)
822 MouseContextMenu(event); 839 MouseContextMenu(event);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 // Dispatch the contextmenu event regardless of if the click was swallowed. 883 // Dispatch the contextmenu event regardless of if the click was swallowed.
867 // On Mac/Linux, we handle it on mouse down, not up. 884 // On Mac/Linux, we handle it on mouse down, not up.
868 if (event.button == WebMouseEvent::Button::kRight) 885 if (event.button == WebMouseEvent::Button::kRight)
869 MouseContextMenu(event); 886 MouseContextMenu(event);
870 } 887 }
871 } 888 }
872 889
873 WebInputEventResult WebFrameWidgetImpl::HandleMouseWheel( 890 WebInputEventResult WebFrameWidgetImpl::HandleMouseWheel(
874 LocalFrame& main_frame, 891 LocalFrame& main_frame,
875 const WebMouseWheelEvent& event) { 892 const WebMouseWheelEvent& event) {
893 View()->HidePopups();
876 return PageWidgetEventHandler::HandleMouseWheel(main_frame, event); 894 return PageWidgetEventHandler::HandleMouseWheel(main_frame, event);
877 } 895 }
878 896
879 WebInputEventResult WebFrameWidgetImpl::HandleGestureEvent( 897 WebInputEventResult WebFrameWidgetImpl::HandleGestureEvent(
880 const WebGestureEvent& event) { 898 const WebGestureEvent& event) {
881 DCHECK(client_); 899 DCHECK(client_);
882 WebInputEventResult event_result = WebInputEventResult::kNotHandled; 900 WebInputEventResult event_result = WebInputEventResult::kNotHandled;
883 bool event_cancelled = false; 901 bool event_cancelled = false;
884 switch (event.GetType()) { 902 switch (event.GetType()) {
885 case WebInputEvent::kGestureScrollBegin: 903 case WebInputEvent::kGestureScrollBegin:
886 case WebInputEvent::kGestureScrollEnd: 904 case WebInputEvent::kGestureScrollEnd:
887 case WebInputEvent::kGestureScrollUpdate: 905 case WebInputEvent::kGestureScrollUpdate:
888 case WebInputEvent::kGestureTap: 906 case WebInputEvent::kGestureTap:
889 case WebInputEvent::kGestureTapUnconfirmed: 907 case WebInputEvent::kGestureTapUnconfirmed:
890 case WebInputEvent::kGestureTapDown: 908 case WebInputEvent::kGestureTapDown:
909 // Touch pinch zoom and scroll on the page (outside of a popup) must hide
910 // the popup. In case of a touch scroll or pinch zoom, this function is
911 // called with GestureTapDown rather than a GSB/GSU/GSE or GPB/GPU/GPE.
912 // When we close a popup because of a GestureTapDown, we also save it so
913 // we can prevent the following GestureTap from immediately reopening the
914 // same popup.
915 View()->SetLastHiddenPagePopup(View()->GetPagePopup());
916 View()->HidePopups();
917 case WebInputEvent::kGestureTapCancel:
918 View()->SetLastHiddenPagePopup(nullptr);
891 case WebInputEvent::kGestureShowPress: 919 case WebInputEvent::kGestureShowPress:
892 case WebInputEvent::kGestureTapCancel:
893 case WebInputEvent::kGestureDoubleTap: 920 case WebInputEvent::kGestureDoubleTap:
894 case WebInputEvent::kGestureTwoFingerTap: 921 case WebInputEvent::kGestureTwoFingerTap:
895 case WebInputEvent::kGestureLongPress: 922 case WebInputEvent::kGestureLongPress:
896 case WebInputEvent::kGestureLongTap: 923 case WebInputEvent::kGestureLongTap:
897 break; 924 break;
898 case WebInputEvent::kGestureFlingStart: 925 case WebInputEvent::kGestureFlingStart:
899 case WebInputEvent::kGestureFlingCancel: 926 case WebInputEvent::kGestureFlingCancel:
900 client_->DidHandleGestureEvent(event, event_cancelled); 927 client_->DidHandleGestureEvent(event, event_cancelled);
901 return WebInputEventResult::kNotHandled; 928 return WebInputEventResult::kNotHandled;
902 default: 929 default:
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 return nullptr; 1205 return nullptr;
1179 } 1206 }
1180 1207
1181 LocalFrame* WebFrameWidgetImpl::FocusedLocalFrameAvailableForIme() const { 1208 LocalFrame* WebFrameWidgetImpl::FocusedLocalFrameAvailableForIme() const {
1182 if (!ime_accept_events_) 1209 if (!ime_accept_events_)
1183 return nullptr; 1210 return nullptr;
1184 return FocusedLocalFrameInWidget(); 1211 return FocusedLocalFrameInWidget();
1185 } 1212 }
1186 1213
1187 } // namespace blink 1214 } // namespace blink
OLDNEW
« 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