| 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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 | 780 |
| 781 void WebFrameWidgetImpl::HandleMouseLeave(LocalFrame& main_frame, | 781 void WebFrameWidgetImpl::HandleMouseLeave(LocalFrame& main_frame, |
| 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 |
| 791 // code into core. |
| 792 WebViewImpl* view_impl = ToWebViewImpl(View()); |
| 790 // 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 |
| 791 // (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 |
| 792 // element from immediately reopening the same popup. | 795 // element from immediately reopening the same popup. |
| 793 RefPtr<WebPagePopupImpl> page_popup; | 796 RefPtr<WebPagePopupImpl> page_popup; |
| 794 if (event.button == WebMouseEvent::Button::kLeft) { | 797 if (event.button == WebMouseEvent::Button::kLeft) { |
| 795 page_popup = View()->GetPagePopup(); | 798 page_popup = view_impl->GetPagePopup(); |
| 796 View()->HidePopups(); | 799 view_impl->HidePopups(); |
| 797 } | 800 } |
| 798 | 801 |
| 799 // 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. |
| 800 // 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 |
| 801 // capture because it will interfere with the scrollbar receiving events. | 804 // capture because it will interfere with the scrollbar receiving events. |
| 802 IntPoint point(event.PositionInWidget().x, event.PositionInWidget().y); | 805 IntPoint point(event.PositionInWidget().x, event.PositionInWidget().y); |
| 803 if (event.button == WebMouseEvent::Button::kLeft) { | 806 if (event.button == WebMouseEvent::Button::kLeft) { |
| 804 point = local_root_->GetFrameView()->RootFrameToContents(point); | 807 point = local_root_->GetFrameView()->RootFrameToContents(point); |
| 805 HitTestResult result( | 808 HitTestResult result( |
| 806 local_root_->GetFrame()->GetEventHandler().HitTestResultAtPoint(point)); | 809 local_root_->GetFrame()->GetEventHandler().HitTestResultAtPoint(point)); |
| 807 result.SetToShadowHostIfInRestrictedShadowRoot(); | 810 result.SetToShadowHostIfInRestrictedShadowRoot(); |
| 808 Node* hit_node = result.InnerNode(); | 811 Node* hit_node = result.InnerNode(); |
| 809 | 812 |
| 810 if (!result.GetScrollbar() && hit_node && hit_node->GetLayoutObject() && | 813 if (!result.GetScrollbar() && hit_node && hit_node->GetLayoutObject() && |
| 811 hit_node->GetLayoutObject()->IsEmbeddedObject()) { | 814 hit_node->GetLayoutObject()->IsEmbeddedObject()) { |
| 812 mouse_capture_node_ = hit_node; | 815 mouse_capture_node_ = hit_node; |
| 813 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); | 816 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); |
| 814 } | 817 } |
| 815 } | 818 } |
| 816 | 819 |
| 817 PageWidgetEventHandler::HandleMouseDown(main_frame, event); | 820 PageWidgetEventHandler::HandleMouseDown(main_frame, event); |
| 818 | 821 |
| 819 if (event.button == WebMouseEvent::Button::kLeft && mouse_capture_node_) | 822 if (event.button == WebMouseEvent::Button::kLeft && mouse_capture_node_) |
| 820 mouse_capture_gesture_token_ = | 823 mouse_capture_gesture_token_ = |
| 821 main_frame.GetEventHandler().TakeLastMouseDownGestureToken(); | 824 main_frame.GetEventHandler().TakeLastMouseDownGestureToken(); |
| 822 | 825 |
| 823 if (View()->GetPagePopup() && page_popup && | 826 if (view_impl->GetPagePopup() && page_popup && |
| 824 View()->GetPagePopup()->HasSamePopupClient(page_popup.Get())) { | 827 view_impl->GetPagePopup()->HasSamePopupClient(page_popup.Get())) { |
| 825 // 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 |
| 826 // closed. It needs to be closed. | 829 // closed. It needs to be closed. |
| 827 View()->HidePopups(); | 830 view_impl->HidePopups(); |
| 828 } | 831 } |
| 829 | 832 |
| 830 // Dispatch the contextmenu event regardless of if the click was swallowed. | 833 // Dispatch the contextmenu event regardless of if the click was swallowed. |
| 831 if (!GetPage()->GetSettings().GetShowContextMenuOnMouseUp()) { | 834 if (!GetPage()->GetSettings().GetShowContextMenuOnMouseUp()) { |
| 832 #if OS(MACOSX) | 835 #if OS(MACOSX) |
| 833 if (event.button == WebMouseEvent::Button::kRight || | 836 if (event.button == WebMouseEvent::Button::kRight || |
| 834 (event.button == WebMouseEvent::Button::kLeft && | 837 (event.button == WebMouseEvent::Button::kLeft && |
| 835 event.GetModifiers() & WebMouseEvent::kControlKey)) | 838 event.GetModifiers() & WebMouseEvent::kControlKey)) |
| 836 MouseContextMenu(event); | 839 MouseContextMenu(event); |
| 837 #else | 840 #else |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 const WebMouseWheelEvent& event) { | 895 const WebMouseWheelEvent& event) { |
| 893 View()->HidePopups(); | 896 View()->HidePopups(); |
| 894 return PageWidgetEventHandler::HandleMouseWheel(main_frame, event); | 897 return PageWidgetEventHandler::HandleMouseWheel(main_frame, event); |
| 895 } | 898 } |
| 896 | 899 |
| 897 WebInputEventResult WebFrameWidgetImpl::HandleGestureEvent( | 900 WebInputEventResult WebFrameWidgetImpl::HandleGestureEvent( |
| 898 const WebGestureEvent& event) { | 901 const WebGestureEvent& event) { |
| 899 DCHECK(client_); | 902 DCHECK(client_); |
| 900 WebInputEventResult event_result = WebInputEventResult::kNotHandled; | 903 WebInputEventResult event_result = WebInputEventResult::kNotHandled; |
| 901 bool event_cancelled = false; | 904 bool event_cancelled = false; |
| 905 // TODO(slangley): Remove this downcast to WebViewImpl once we lift this |
| 906 // code into core. |
| 907 WebViewImpl* view_impl = ToWebViewImpl(View()); |
| 902 switch (event.GetType()) { | 908 switch (event.GetType()) { |
| 903 case WebInputEvent::kGestureScrollBegin: | 909 case WebInputEvent::kGestureScrollBegin: |
| 904 case WebInputEvent::kGestureScrollEnd: | 910 case WebInputEvent::kGestureScrollEnd: |
| 905 case WebInputEvent::kGestureScrollUpdate: | 911 case WebInputEvent::kGestureScrollUpdate: |
| 906 case WebInputEvent::kGestureTap: | 912 case WebInputEvent::kGestureTap: |
| 907 case WebInputEvent::kGestureTapUnconfirmed: | 913 case WebInputEvent::kGestureTapUnconfirmed: |
| 908 case WebInputEvent::kGestureTapDown: | 914 case WebInputEvent::kGestureTapDown: |
| 909 // 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 |
| 910 // 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 |
| 911 // 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. |
| 912 // 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 |
| 913 // we can prevent the following GestureTap from immediately reopening the | 919 // we can prevent the following GestureTap from immediately reopening the |
| 914 // same popup. | 920 // same popup. |
| 915 View()->SetLastHiddenPagePopup(View()->GetPagePopup()); | 921 view_impl->SetLastHiddenPagePopup(view_impl->GetPagePopup()); |
| 916 View()->HidePopups(); | 922 View()->HidePopups(); |
| 917 case WebInputEvent::kGestureTapCancel: | 923 case WebInputEvent::kGestureTapCancel: |
| 918 View()->SetLastHiddenPagePopup(nullptr); | 924 View()->SetLastHiddenPagePopup(nullptr); |
| 919 case WebInputEvent::kGestureShowPress: | 925 case WebInputEvent::kGestureShowPress: |
| 920 case WebInputEvent::kGestureDoubleTap: | 926 case WebInputEvent::kGestureDoubleTap: |
| 921 case WebInputEvent::kGestureTwoFingerTap: | 927 case WebInputEvent::kGestureTwoFingerTap: |
| 922 case WebInputEvent::kGestureLongPress: | 928 case WebInputEvent::kGestureLongPress: |
| 923 case WebInputEvent::kGestureLongTap: | 929 case WebInputEvent::kGestureLongTap: |
| 924 break; | 930 break; |
| 925 case WebInputEvent::kGestureFlingStart: | 931 case WebInputEvent::kGestureFlingStart: |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 return nullptr; | 1219 return nullptr; |
| 1214 } | 1220 } |
| 1215 | 1221 |
| 1216 LocalFrame* WebFrameWidgetImpl::FocusedLocalFrameAvailableForIme() const { | 1222 LocalFrame* WebFrameWidgetImpl::FocusedLocalFrameAvailableForIme() const { |
| 1217 if (!ime_accept_events_) | 1223 if (!ime_accept_events_) |
| 1218 return nullptr; | 1224 return nullptr; |
| 1219 return FocusedLocalFrameInWidget(); | 1225 return FocusedLocalFrameInWidget(); |
| 1220 } | 1226 } |
| 1221 | 1227 |
| 1222 } // namespace blink | 1228 } // namespace blink |
| OLD | NEW |