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