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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 #include <memory> | 33 #include <memory> |
34 | 34 |
35 #include "core/dom/DocumentUserGestureToken.h" | 35 #include "core/dom/DocumentUserGestureToken.h" |
36 #include "core/editing/CompositionUnderlineVectorBuilder.h" | 36 #include "core/editing/CompositionUnderlineVectorBuilder.h" |
37 #include "core/editing/EditingUtilities.h" | 37 #include "core/editing/EditingUtilities.h" |
38 #include "core/editing/Editor.h" | 38 #include "core/editing/Editor.h" |
39 #include "core/editing/FrameSelection.h" | 39 #include "core/editing/FrameSelection.h" |
40 #include "core/editing/InputMethodController.h" | 40 #include "core/editing/InputMethodController.h" |
41 #include "core/editing/PlainTextRange.h" | 41 #include "core/editing/PlainTextRange.h" |
| 42 #include "core/exported/WebViewBase.h" |
42 #include "core/frame/FrameView.h" | 43 #include "core/frame/FrameView.h" |
43 #include "core/frame/RemoteFrame.h" | 44 #include "core/frame/RemoteFrame.h" |
44 #include "core/frame/Settings.h" | 45 #include "core/frame/Settings.h" |
45 #include "core/frame/VisualViewport.h" | 46 #include "core/frame/VisualViewport.h" |
46 #include "core/html/HTMLTextAreaElement.h" | 47 #include "core/html/HTMLTextAreaElement.h" |
47 #include "core/input/EventHandler.h" | 48 #include "core/input/EventHandler.h" |
48 #include "core/layout/LayoutView.h" | 49 #include "core/layout/LayoutView.h" |
49 #include "core/layout/api/LayoutViewItem.h" | 50 #include "core/layout/api/LayoutViewItem.h" |
50 #include "core/layout/compositing/PaintLayerCompositor.h" | 51 #include "core/layout/compositing/PaintLayerCompositor.h" |
51 #include "core/page/ContextMenuController.h" | 52 #include "core/page/ContextMenuController.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 WebLocalFrame* local_root) { | 87 WebLocalFrame* local_root) { |
87 DCHECK(client) << "A valid WebWidgetClient must be supplied."; | 88 DCHECK(client) << "A valid WebWidgetClient must be supplied."; |
88 // Pass the WebFrameWidget's self-reference to the caller. | 89 // Pass the WebFrameWidget's self-reference to the caller. |
89 return WebFrameWidgetImpl::Create(client, local_root); | 90 return WebFrameWidgetImpl::Create(client, local_root); |
90 } | 91 } |
91 | 92 |
92 WebFrameWidget* WebFrameWidget::Create(WebWidgetClient* client, | 93 WebFrameWidget* WebFrameWidget::Create(WebWidgetClient* client, |
93 WebView* web_view, | 94 WebView* web_view, |
94 WebLocalFrame* main_frame) { | 95 WebLocalFrame* main_frame) { |
95 DCHECK(client) << "A valid WebWidgetClient must be supplied."; | 96 DCHECK(client) << "A valid WebWidgetClient must be supplied."; |
96 return new WebViewFrameWidget(*client, ToWebViewImpl(*web_view), | 97 return new WebViewFrameWidget(*client, static_cast<WebViewBase&>(*web_view), |
97 ToWebLocalFrameImpl(*main_frame)); | 98 ToWebLocalFrameImpl(*main_frame)); |
98 } | 99 } |
99 | 100 |
100 WebFrameWidgetImpl* WebFrameWidgetImpl::Create(WebWidgetClient* client, | 101 WebFrameWidgetImpl* WebFrameWidgetImpl::Create(WebWidgetClient* client, |
101 WebLocalFrame* local_root) { | 102 WebLocalFrame* local_root) { |
102 DCHECK(client) << "A valid WebWidgetClient must be supplied."; | 103 DCHECK(client) << "A valid WebWidgetClient must be supplied."; |
103 // Pass the WebFrameWidgetImpl's self-reference to the caller. | 104 // Pass the WebFrameWidgetImpl's self-reference to the caller. |
104 return new WebFrameWidgetImpl( | 105 return new WebFrameWidgetImpl( |
105 client, local_root); // SelfKeepAlive is set in constructor. | 106 client, local_root); // SelfKeepAlive is set in constructor. |
106 } | 107 } |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 | 781 |
781 void WebFrameWidgetImpl::HandleMouseLeave(LocalFrame& main_frame, | 782 void WebFrameWidgetImpl::HandleMouseLeave(LocalFrame& main_frame, |
782 const WebMouseEvent& event) { | 783 const WebMouseEvent& event) { |
783 // FIXME: WebWidget doesn't have the method below. | 784 // FIXME: WebWidget doesn't have the method below. |
784 // m_client->setMouseOverURL(WebURL()); | 785 // m_client->setMouseOverURL(WebURL()); |
785 PageWidgetEventHandler::HandleMouseLeave(main_frame, event); | 786 PageWidgetEventHandler::HandleMouseLeave(main_frame, event); |
786 } | 787 } |
787 | 788 |
788 void WebFrameWidgetImpl::HandleMouseDown(LocalFrame& main_frame, | 789 void WebFrameWidgetImpl::HandleMouseDown(LocalFrame& main_frame, |
789 const WebMouseEvent& event) { | 790 const WebMouseEvent& event) { |
790 // TODO(slangley): Remove this downcast to WebViewImpl once we lift this | 791 WebViewBase* view_impl = View(); |
791 // code into core. | |
792 WebViewImpl* view_impl = ToWebViewImpl(View()); | |
793 // If there is a popup open, close it as the user is clicking on the page | 792 // If there is a popup open, close it as the user is clicking on the page |
794 // (outside of the popup). We also save it so we can prevent a click on an | 793 // (outside of the popup). We also save it so we can prevent a click on an |
795 // element from immediately reopening the same popup. | 794 // element from immediately reopening the same popup. |
796 RefPtr<WebPagePopupImpl> page_popup; | 795 RefPtr<WebPagePopupImpl> page_popup; |
797 if (event.button == WebMouseEvent::Button::kLeft) { | 796 if (event.button == WebMouseEvent::Button::kLeft) { |
798 page_popup = view_impl->GetPagePopup(); | 797 page_popup = ToWebPagePopupImpl(view_impl->GetPagePopup()); |
799 view_impl->HidePopups(); | 798 view_impl->HidePopups(); |
800 } | 799 } |
801 | 800 |
802 // Take capture on a mouse down on a plugin so we can send it mouse events. | 801 // Take capture on a mouse down on a plugin so we can send it mouse events. |
803 // If the hit node is a plugin but a scrollbar is over it don't start mouse | 802 // If the hit node is a plugin but a scrollbar is over it don't start mouse |
804 // capture because it will interfere with the scrollbar receiving events. | 803 // capture because it will interfere with the scrollbar receiving events. |
805 IntPoint point(event.PositionInWidget().x, event.PositionInWidget().y); | 804 IntPoint point(event.PositionInWidget().x, event.PositionInWidget().y); |
806 if (event.button == WebMouseEvent::Button::kLeft) { | 805 if (event.button == WebMouseEvent::Button::kLeft) { |
807 point = local_root_->GetFrameView()->RootFrameToContents(point); | 806 point = local_root_->GetFrameView()->RootFrameToContents(point); |
808 HitTestResult result( | 807 HitTestResult result( |
809 local_root_->GetFrame()->GetEventHandler().HitTestResultAtPoint(point)); | 808 local_root_->GetFrame()->GetEventHandler().HitTestResultAtPoint(point)); |
810 result.SetToShadowHostIfInRestrictedShadowRoot(); | 809 result.SetToShadowHostIfInRestrictedShadowRoot(); |
811 Node* hit_node = result.InnerNode(); | 810 Node* hit_node = result.InnerNode(); |
812 | 811 |
813 if (!result.GetScrollbar() && hit_node && hit_node->GetLayoutObject() && | 812 if (!result.GetScrollbar() && hit_node && hit_node->GetLayoutObject() && |
814 hit_node->GetLayoutObject()->IsEmbeddedObject()) { | 813 hit_node->GetLayoutObject()->IsEmbeddedObject()) { |
815 mouse_capture_node_ = hit_node; | 814 mouse_capture_node_ = hit_node; |
816 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); | 815 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); |
817 } | 816 } |
818 } | 817 } |
819 | 818 |
820 PageWidgetEventHandler::HandleMouseDown(main_frame, event); | 819 PageWidgetEventHandler::HandleMouseDown(main_frame, event); |
821 | 820 |
822 if (event.button == WebMouseEvent::Button::kLeft && mouse_capture_node_) | 821 if (event.button == WebMouseEvent::Button::kLeft && mouse_capture_node_) |
823 mouse_capture_gesture_token_ = | 822 mouse_capture_gesture_token_ = |
824 main_frame.GetEventHandler().TakeLastMouseDownGestureToken(); | 823 main_frame.GetEventHandler().TakeLastMouseDownGestureToken(); |
825 | 824 |
826 if (view_impl->GetPagePopup() && page_popup && | 825 if (view_impl->GetPagePopup() && page_popup && |
827 view_impl->GetPagePopup()->HasSamePopupClient(page_popup.Get())) { | 826 ToWebPagePopupImpl(view_impl->GetPagePopup()) |
| 827 ->HasSamePopupClient(page_popup.Get())) { |
828 // That click triggered a page popup that is the same as the one we just | 828 // That click triggered a page popup that is the same as the one we just |
829 // closed. It needs to be closed. | 829 // closed. It needs to be closed. |
830 view_impl->HidePopups(); | 830 view_impl->HidePopups(); |
831 } | 831 } |
832 | 832 |
833 // Dispatch the contextmenu event regardless of if the click was swallowed. | 833 // Dispatch the contextmenu event regardless of if the click was swallowed. |
834 if (!GetPage()->GetSettings().GetShowContextMenuOnMouseUp()) { | 834 if (!GetPage()->GetSettings().GetShowContextMenuOnMouseUp()) { |
835 #if OS(MACOSX) | 835 #if OS(MACOSX) |
836 if (event.button == WebMouseEvent::Button::kRight || | 836 if (event.button == WebMouseEvent::Button::kRight || |
837 (event.button == WebMouseEvent::Button::kLeft && | 837 (event.button == WebMouseEvent::Button::kLeft && |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 const WebMouseWheelEvent& event) { | 895 const WebMouseWheelEvent& event) { |
896 View()->HidePopups(); | 896 View()->HidePopups(); |
897 return PageWidgetEventHandler::HandleMouseWheel(main_frame, event); | 897 return PageWidgetEventHandler::HandleMouseWheel(main_frame, event); |
898 } | 898 } |
899 | 899 |
900 WebInputEventResult WebFrameWidgetImpl::HandleGestureEvent( | 900 WebInputEventResult WebFrameWidgetImpl::HandleGestureEvent( |
901 const WebGestureEvent& event) { | 901 const WebGestureEvent& event) { |
902 DCHECK(client_); | 902 DCHECK(client_); |
903 WebInputEventResult event_result = WebInputEventResult::kNotHandled; | 903 WebInputEventResult event_result = WebInputEventResult::kNotHandled; |
904 bool event_cancelled = false; | 904 bool event_cancelled = false; |
905 // TODO(slangley): Remove this downcast to WebViewImpl once we lift this | 905 |
906 // code into core. | 906 WebViewBase* view_impl = View(); |
907 WebViewImpl* view_impl = ToWebViewImpl(View()); | |
908 switch (event.GetType()) { | 907 switch (event.GetType()) { |
909 case WebInputEvent::kGestureScrollBegin: | 908 case WebInputEvent::kGestureScrollBegin: |
910 case WebInputEvent::kGestureScrollEnd: | 909 case WebInputEvent::kGestureScrollEnd: |
911 case WebInputEvent::kGestureScrollUpdate: | 910 case WebInputEvent::kGestureScrollUpdate: |
912 case WebInputEvent::kGestureTap: | 911 case WebInputEvent::kGestureTap: |
913 case WebInputEvent::kGestureTapUnconfirmed: | 912 case WebInputEvent::kGestureTapUnconfirmed: |
914 case WebInputEvent::kGestureTapDown: | 913 case WebInputEvent::kGestureTapDown: |
915 // Touch pinch zoom and scroll on the page (outside of a popup) must hide | 914 // Touch pinch zoom and scroll on the page (outside of a popup) must hide |
916 // the popup. In case of a touch scroll or pinch zoom, this function is | 915 // the popup. In case of a touch scroll or pinch zoom, this function is |
917 // called with GestureTapDown rather than a GSB/GSU/GSE or GPB/GPU/GPE. | 916 // called with GestureTapDown rather than a GSB/GSU/GSE or GPB/GPU/GPE. |
918 // When we close a popup because of a GestureTapDown, we also save it so | 917 // When we close a popup because of a GestureTapDown, we also save it so |
919 // we can prevent the following GestureTap from immediately reopening the | 918 // we can prevent the following GestureTap from immediately reopening the |
920 // same popup. | 919 // same popup. |
921 view_impl->SetLastHiddenPagePopup(view_impl->GetPagePopup()); | 920 view_impl->SetLastHiddenPagePopup( |
| 921 ToWebPagePopupImpl(view_impl->GetPagePopup())); |
922 View()->HidePopups(); | 922 View()->HidePopups(); |
923 case WebInputEvent::kGestureTapCancel: | 923 case WebInputEvent::kGestureTapCancel: |
924 View()->SetLastHiddenPagePopup(nullptr); | 924 View()->SetLastHiddenPagePopup(nullptr); |
925 case WebInputEvent::kGestureShowPress: | 925 case WebInputEvent::kGestureShowPress: |
926 case WebInputEvent::kGestureDoubleTap: | 926 case WebInputEvent::kGestureDoubleTap: |
927 case WebInputEvent::kGestureTwoFingerTap: | 927 case WebInputEvent::kGestureTwoFingerTap: |
928 case WebInputEvent::kGestureLongPress: | 928 case WebInputEvent::kGestureLongPress: |
929 case WebInputEvent::kGestureLongTap: | 929 case WebInputEvent::kGestureLongTap: |
930 break; | 930 break; |
931 case WebInputEvent::kGestureFlingStart: | 931 case WebInputEvent::kGestureFlingStart: |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 return nullptr; | 1219 return nullptr; |
1220 } | 1220 } |
1221 | 1221 |
1222 LocalFrame* WebFrameWidgetImpl::FocusedLocalFrameAvailableForIme() const { | 1222 LocalFrame* WebFrameWidgetImpl::FocusedLocalFrameAvailableForIme() const { |
1223 if (!ime_accept_events_) | 1223 if (!ime_accept_events_) |
1224 return nullptr; | 1224 return nullptr; |
1225 return FocusedLocalFrameInWidget(); | 1225 return FocusedLocalFrameInWidget(); |
1226 } | 1226 } |
1227 | 1227 |
1228 } // namespace blink | 1228 } // namespace blink |
OLD | NEW |