Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 #include "web/CompositionUnderlineVectorBuilder.h" | 64 #include "web/CompositionUnderlineVectorBuilder.h" |
| 65 #include "web/CompositorMutatorImpl.h" | 65 #include "web/CompositorMutatorImpl.h" |
| 66 #include "web/CompositorWorkerProxyClientImpl.h" | 66 #include "web/CompositorWorkerProxyClientImpl.h" |
| 67 #include "web/ContextMenuAllowedScope.h" | 67 #include "web/ContextMenuAllowedScope.h" |
| 68 #include "web/InspectorOverlay.h" | 68 #include "web/InspectorOverlay.h" |
| 69 #include "web/PageOverlay.h" | 69 #include "web/PageOverlay.h" |
| 70 #include "web/WebDevToolsAgentImpl.h" | 70 #include "web/WebDevToolsAgentImpl.h" |
| 71 #include "web/WebInputEventConversion.h" | 71 #include "web/WebInputEventConversion.h" |
| 72 #include "web/WebInputMethodControllerImpl.h" | 72 #include "web/WebInputMethodControllerImpl.h" |
| 73 #include "web/WebLocalFrameImpl.h" | 73 #include "web/WebLocalFrameImpl.h" |
| 74 #include "web/WebPagePopupImpl.h" | |
| 74 #include "web/WebPluginContainerImpl.h" | 75 #include "web/WebPluginContainerImpl.h" |
| 75 #include "web/WebRemoteFrameImpl.h" | 76 #include "web/WebRemoteFrameImpl.h" |
| 76 #include "web/WebViewFrameWidget.h" | 77 #include "web/WebViewFrameWidget.h" |
| 77 #include "wtf/AutoReset.h" | 78 #include "wtf/AutoReset.h" |
| 78 #include "wtf/PtrUtil.h" | 79 #include "wtf/PtrUtil.h" |
| 79 | 80 |
| 80 namespace blink { | 81 namespace blink { |
| 81 | 82 |
| 82 // WebFrameWidget ------------------------------------------------------------ | 83 // WebFrameWidget ------------------------------------------------------------ |
| 83 | 84 |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 | 762 |
| 762 void WebFrameWidgetImpl::handleMouseLeave(LocalFrame& mainFrame, | 763 void WebFrameWidgetImpl::handleMouseLeave(LocalFrame& mainFrame, |
| 763 const WebMouseEvent& event) { | 764 const WebMouseEvent& event) { |
| 764 // FIXME: WebWidget doesn't have the method below. | 765 // FIXME: WebWidget doesn't have the method below. |
| 765 // m_client->setMouseOverURL(WebURL()); | 766 // m_client->setMouseOverURL(WebURL()); |
| 766 PageWidgetEventHandler::handleMouseLeave(mainFrame, event); | 767 PageWidgetEventHandler::handleMouseLeave(mainFrame, event); |
| 767 } | 768 } |
| 768 | 769 |
| 769 void WebFrameWidgetImpl::handleMouseDown(LocalFrame& mainFrame, | 770 void WebFrameWidgetImpl::handleMouseDown(LocalFrame& mainFrame, |
| 770 const WebMouseEvent& event) { | 771 const WebMouseEvent& event) { |
| 772 // If there is a popup open, close it as the user is clicking on the page | |
| 773 // (outside of the popup). We also save it so we can prevent a click on an | |
| 774 // element from immediately reopening the same popup. | |
| 775 RefPtr<WebPagePopupImpl> pagePopup; | |
| 776 if (event.button == WebMouseEvent::Button::Left) { | |
| 777 pagePopup = view()->pagePopup(); | |
| 778 view()->hidePopups(); | |
| 779 } | |
|
EhsanK
2017/04/07 16:16:12
There is a DCHECK(!m_pagePopup) which I could add
| |
| 780 | |
| 771 // Take capture on a mouse down on a plugin so we can send it mouse events. | 781 // Take capture on a mouse down on a plugin so we can send it mouse events. |
| 772 // If the hit node is a plugin but a scrollbar is over it don't start mouse | 782 // If the hit node is a plugin but a scrollbar is over it don't start mouse |
| 773 // capture because it will interfere with the scrollbar receiving events. | 783 // capture because it will interfere with the scrollbar receiving events. |
| 774 IntPoint point(event.positionInWidget().x, event.positionInWidget().y); | 784 IntPoint point(event.positionInWidget().x, event.positionInWidget().y); |
| 775 if (event.button == WebMouseEvent::Button::Left) { | 785 if (event.button == WebMouseEvent::Button::Left) { |
| 776 point = m_localRoot->frameView()->rootFrameToContents(point); | 786 point = m_localRoot->frameView()->rootFrameToContents(point); |
| 777 HitTestResult result( | 787 HitTestResult result( |
| 778 m_localRoot->frame()->eventHandler().hitTestResultAtPoint(point)); | 788 m_localRoot->frame()->eventHandler().hitTestResultAtPoint(point)); |
| 779 result.setToShadowHostIfInRestrictedShadowRoot(); | 789 result.setToShadowHostIfInRestrictedShadowRoot(); |
| 780 Node* hitNode = result.innerNode(); | 790 Node* hitNode = result.innerNode(); |
| 781 | 791 |
| 782 if (!result.scrollbar() && hitNode && hitNode->layoutObject() && | 792 if (!result.scrollbar() && hitNode && hitNode->layoutObject() && |
| 783 hitNode->layoutObject()->isEmbeddedObject()) { | 793 hitNode->layoutObject()->isEmbeddedObject()) { |
| 784 m_mouseCaptureNode = hitNode; | 794 m_mouseCaptureNode = hitNode; |
| 785 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); | 795 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); |
| 786 } | 796 } |
| 787 } | 797 } |
| 788 | 798 |
| 789 PageWidgetEventHandler::handleMouseDown(mainFrame, event); | 799 PageWidgetEventHandler::handleMouseDown(mainFrame, event); |
| 790 | 800 |
| 791 if (event.button == WebMouseEvent::Button::Left && m_mouseCaptureNode) | 801 if (event.button == WebMouseEvent::Button::Left && m_mouseCaptureNode) |
| 792 m_mouseCaptureGestureToken = | 802 m_mouseCaptureGestureToken = |
| 793 mainFrame.eventHandler().takeLastMouseDownGestureToken(); | 803 mainFrame.eventHandler().takeLastMouseDownGestureToken(); |
| 794 | 804 |
| 805 if (view()->pagePopup() && pagePopup && | |
| 806 view()->pagePopup()->hasSamePopupClient(pagePopup.get())) { | |
| 807 // That click triggered a page popup that is the same as the one we just | |
| 808 // closed. It needs to be closed. | |
| 809 view()->hidePopups(); | |
| 810 } | |
| 811 | |
| 795 // Dispatch the contextmenu event regardless of if the click was swallowed. | 812 // Dispatch the contextmenu event regardless of if the click was swallowed. |
| 796 if (!page()->settings().getShowContextMenuOnMouseUp()) { | 813 if (!page()->settings().getShowContextMenuOnMouseUp()) { |
| 797 #if OS(MACOSX) | 814 #if OS(MACOSX) |
| 798 if (event.button == WebMouseEvent::Button::Right || | 815 if (event.button == WebMouseEvent::Button::Right || |
| 799 (event.button == WebMouseEvent::Button::Left && | 816 (event.button == WebMouseEvent::Button::Left && |
| 800 event.modifiers() & WebMouseEvent::ControlKey)) | 817 event.modifiers() & WebMouseEvent::ControlKey)) |
| 801 mouseContextMenu(event); | 818 mouseContextMenu(event); |
| 802 #else | 819 #else |
| 803 if (event.button == WebMouseEvent::Button::Right) | 820 if (event.button == WebMouseEvent::Button::Right) |
| 804 mouseContextMenu(event); | 821 mouseContextMenu(event); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 // Dispatch the contextmenu event regardless of if the click was swallowed. | 865 // Dispatch the contextmenu event regardless of if the click was swallowed. |
| 849 // On Mac/Linux, we handle it on mouse down, not up. | 866 // On Mac/Linux, we handle it on mouse down, not up. |
| 850 if (event.button == WebMouseEvent::Button::Right) | 867 if (event.button == WebMouseEvent::Button::Right) |
| 851 mouseContextMenu(event); | 868 mouseContextMenu(event); |
| 852 } | 869 } |
| 853 } | 870 } |
| 854 | 871 |
| 855 WebInputEventResult WebFrameWidgetImpl::handleMouseWheel( | 872 WebInputEventResult WebFrameWidgetImpl::handleMouseWheel( |
| 856 LocalFrame& mainFrame, | 873 LocalFrame& mainFrame, |
| 857 const WebMouseWheelEvent& event) { | 874 const WebMouseWheelEvent& event) { |
| 875 view()->hidePopups(); | |
|
EhsanK
2017/04/07 16:16:12
Unless there is a handler on the page, this won't
| |
| 858 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); | 876 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); |
| 859 } | 877 } |
| 860 | 878 |
| 861 WebInputEventResult WebFrameWidgetImpl::handleGestureEvent( | 879 WebInputEventResult WebFrameWidgetImpl::handleGestureEvent( |
| 862 const WebGestureEvent& event) { | 880 const WebGestureEvent& event) { |
| 863 DCHECK(m_client); | 881 DCHECK(m_client); |
| 864 WebInputEventResult eventResult = WebInputEventResult::NotHandled; | 882 WebInputEventResult eventResult = WebInputEventResult::NotHandled; |
| 865 bool eventCancelled = false; | 883 bool eventCancelled = false; |
| 866 switch (event.type()) { | 884 switch (event.type()) { |
| 867 case WebInputEvent::GestureScrollBegin: | 885 case WebInputEvent::GestureScrollBegin: |
| 868 case WebInputEvent::GestureScrollEnd: | 886 case WebInputEvent::GestureScrollEnd: |
| 869 case WebInputEvent::GestureScrollUpdate: | 887 case WebInputEvent::GestureScrollUpdate: |
| 870 case WebInputEvent::GestureTap: | 888 case WebInputEvent::GestureTap: |
| 871 case WebInputEvent::GestureTapUnconfirmed: | 889 case WebInputEvent::GestureTapUnconfirmed: |
| 872 case WebInputEvent::GestureTapDown: | 890 case WebInputEvent::GestureTapDown: |
| 891 // Touch pinch zoom and scroll on the page (outside of a popup) must hide | |
| 892 // the popup. In case of a touch scroll or pinch zoom, this function is | |
| 893 // called with GestureTapDown rather than a GSB/GSU/GSE or GPB/GPU/GPE. | |
| 894 // When we close a popup because of a GestureTapDown, we also save it so | |
| 895 // we can prevent the following GestureTap from immediately reopening the | |
| 896 // same popup. | |
| 897 view()->setLastHiddenPagePopup(view()->pagePopup()); | |
| 898 view()->hidePopups(); | |
| 899 case WebInputEvent::GestureTapCancel: | |
| 900 view()->setLastHiddenPagePopup(nullptr); | |
| 873 case WebInputEvent::GestureShowPress: | 901 case WebInputEvent::GestureShowPress: |
| 874 case WebInputEvent::GestureTapCancel: | |
| 875 case WebInputEvent::GestureDoubleTap: | 902 case WebInputEvent::GestureDoubleTap: |
| 876 case WebInputEvent::GestureTwoFingerTap: | 903 case WebInputEvent::GestureTwoFingerTap: |
| 877 case WebInputEvent::GestureLongPress: | 904 case WebInputEvent::GestureLongPress: |
| 878 case WebInputEvent::GestureLongTap: | 905 case WebInputEvent::GestureLongTap: |
| 879 break; | 906 break; |
| 880 case WebInputEvent::GestureFlingStart: | 907 case WebInputEvent::GestureFlingStart: |
| 881 case WebInputEvent::GestureFlingCancel: | 908 case WebInputEvent::GestureFlingCancel: |
| 882 m_client->didHandleGestureEvent(event, eventCancelled); | 909 m_client->didHandleGestureEvent(event, eventCancelled); |
| 883 return WebInputEventResult::NotHandled; | 910 return WebInputEventResult::NotHandled; |
| 884 default: | 911 default: |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 return nullptr; | 1185 return nullptr; |
| 1159 } | 1186 } |
| 1160 | 1187 |
| 1161 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { | 1188 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { |
| 1162 if (!m_imeAcceptEvents) | 1189 if (!m_imeAcceptEvents) |
| 1163 return nullptr; | 1190 return nullptr; |
| 1164 return focusedLocalFrameInWidget(); | 1191 return focusedLocalFrameInWidget(); |
| 1165 } | 1192 } |
| 1166 | 1193 |
| 1167 } // namespace blink | 1194 } // namespace blink |
| OLD | NEW |