OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 "x", mouse_event.x, "y", mouse_event.y); | 896 "x", mouse_event.x, "y", mouse_event.y); |
897 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 897 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
898 return; | 898 return; |
899 | 899 |
900 if (CommandLine::ForCurrentProcess()->HasSwitch( | 900 if (CommandLine::ForCurrentProcess()->HasSwitch( |
901 switches::kSimulateTouchScreenWithMouse)) { | 901 switches::kSimulateTouchScreenWithMouse)) { |
902 SimulateTouchGestureWithMouse(mouse_event); | 902 SimulateTouchGestureWithMouse(mouse_event); |
903 return; | 903 return; |
904 } | 904 } |
905 | 905 |
906 // Avoid spamming the renderer with mouse move events. It is important | 906 if (mouse_event.type == WebInputEvent::MouseDown && |
907 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our | 907 gesture_event_filter_->GetTapSuppressionController()-> |
908 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way | |
909 // more WM_MOUSEMOVE events than we wish to send to the renderer. | |
910 if (mouse_event.type == WebInputEvent::MouseMove) { | |
911 if (mouse_move_pending_) { | |
912 if (!next_mouse_move_.get()) { | |
913 next_mouse_move_.reset(new WebMouseEvent(mouse_event)); | |
914 } else { | |
915 // Accumulate movement deltas. | |
916 int x = next_mouse_move_->movementX; | |
917 int y = next_mouse_move_->movementY; | |
918 *next_mouse_move_ = mouse_event; | |
919 next_mouse_move_->movementX += x; | |
920 next_mouse_move_->movementY += y; | |
921 } | |
922 return; | |
923 } | |
924 mouse_move_pending_ = true; | |
925 } else if (mouse_event.type == WebInputEvent::MouseDown) { | |
926 if (gesture_event_filter_->GetTapSuppressionController()-> | |
927 ShouldDeferMouseDown(mouse_event)) | 908 ShouldDeferMouseDown(mouse_event)) |
928 return; | 909 return; |
929 OnUserGesture(); | 910 if (mouse_event.type == WebInputEvent::MouseUp && |
930 } else if (mouse_event.type == WebInputEvent::MouseUp) { | 911 gesture_event_filter_->GetTapSuppressionController()-> |
931 if (gesture_event_filter_->GetTapSuppressionController()-> | |
932 ShouldSuppressMouseUp()) | 912 ShouldSuppressMouseUp()) |
933 return; | 913 return; |
934 } | |
935 | 914 |
936 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent), false); | 915 ForwardMouseEventImmediately(mouse_event); |
937 } | 916 } |
938 | 917 |
939 void RenderWidgetHostImpl::OnPointerEventActivate() { | 918 void RenderWidgetHostImpl::OnPointerEventActivate() { |
940 } | 919 } |
941 | 920 |
942 void RenderWidgetHostImpl::ForwardWheelEvent( | 921 void RenderWidgetHostImpl::ForwardWheelEvent( |
943 const WebMouseWheelEvent& wheel_event) { | 922 const WebMouseWheelEvent& wheel_event) { |
944 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardWheelEvent"); | 923 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardWheelEvent"); |
945 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 924 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
946 return; | 925 return; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 961 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
983 return; | 962 return; |
984 | 963 |
985 if (!IsInOverscrollGesture() && | 964 if (!IsInOverscrollGesture() && |
986 !gesture_event_filter_->ShouldForward(gesture_event)) | 965 !gesture_event_filter_->ShouldForward(gesture_event)) |
987 return; | 966 return; |
988 | 967 |
989 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); | 968 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); |
990 } | 969 } |
991 | 970 |
| 971 // Forwards MouseEvent without passing it through TapSuppressionController |
| 972 void RenderWidgetHostImpl::ForwardMouseEventImmediately( |
| 973 const WebMouseEvent& mouse_event) { |
| 974 TRACE_EVENT2("renderer_host", |
| 975 "RenderWidgetHostImpl::ForwardMouseEventImmediately", |
| 976 "x", mouse_event.x, "y", mouse_event.y); |
| 977 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
| 978 return; |
| 979 |
| 980 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 981 switches::kSimulateTouchScreenWithMouse)) { |
| 982 SimulateTouchGestureWithMouse(mouse_event); |
| 983 return; |
| 984 } |
| 985 |
| 986 // Avoid spamming the renderer with mouse move events. It is important |
| 987 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our |
| 988 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way |
| 989 // more WM_MOUSEMOVE events than we wish to send to the renderer. |
| 990 if (mouse_event.type == WebInputEvent::MouseMove) { |
| 991 if (mouse_move_pending_) { |
| 992 if (!next_mouse_move_.get()) { |
| 993 next_mouse_move_.reset(new WebMouseEvent(mouse_event)); |
| 994 } else { |
| 995 // Accumulate movement deltas. |
| 996 int x = next_mouse_move_->movementX; |
| 997 int y = next_mouse_move_->movementY; |
| 998 *next_mouse_move_ = mouse_event; |
| 999 next_mouse_move_->movementX += x; |
| 1000 next_mouse_move_->movementY += y; |
| 1001 } |
| 1002 return; |
| 1003 } |
| 1004 mouse_move_pending_ = true; |
| 1005 } else if (mouse_event.type == WebInputEvent::MouseDown) { |
| 1006 OnUserGesture(); |
| 1007 } |
| 1008 |
| 1009 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent), false); |
| 1010 } |
| 1011 |
992 void RenderWidgetHostImpl::ForwardTouchEventImmediately( | 1012 void RenderWidgetHostImpl::ForwardTouchEventImmediately( |
993 const WebKit::WebTouchEvent& touch_event) { | 1013 const WebKit::WebTouchEvent& touch_event) { |
994 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); | 1014 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); |
995 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 1015 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
996 return; | 1016 return; |
997 | 1017 |
998 ForwardInputEvent(touch_event, sizeof(WebKit::WebTouchEvent), false); | 1018 ForwardInputEvent(touch_event, sizeof(WebKit::WebTouchEvent), false); |
999 } | 1019 } |
1000 | 1020 |
1001 void RenderWidgetHostImpl::ForwardGestureEventImmediately( | 1021 void RenderWidgetHostImpl::ForwardGestureEventImmediately( |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 return; | 2341 return; |
2322 | 2342 |
2323 OnRenderAutoResized(new_size); | 2343 OnRenderAutoResized(new_size); |
2324 } | 2344 } |
2325 | 2345 |
2326 void RenderWidgetHostImpl::DetachDelegate() { | 2346 void RenderWidgetHostImpl::DetachDelegate() { |
2327 delegate_ = NULL; | 2347 delegate_ = NULL; |
2328 } | 2348 } |
2329 | 2349 |
2330 } // namespace content | 2350 } // namespace content |
OLD | NEW |