OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input/synthetic_gesture_target_base.h" | 5 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" |
6 | 6 |
7 #include "content/browser/renderer_host/render_widget_host_impl.h" | 7 #include "content/browser/renderer_host/render_widget_host_impl.h" |
8 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 8 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
9 #include "content/browser/renderer_host/ui_events_helper.h" | 9 #include "content/browser/renderer_host/ui_events_helper.h" |
10 #include "content/common/input/web_input_event_traits.h" | 10 #include "content/common/input/web_input_event_traits.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 "type", WebInputEventTraits::GetName(event.type)); | 49 "type", WebInputEventTraits::GetName(event.type)); |
50 | 50 |
51 ui::LatencyInfo latency_info; | 51 ui::LatencyInfo latency_info; |
52 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 52 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
53 | 53 |
54 if (WebInputEvent::isTouchEventType(event.type)) { | 54 if (WebInputEvent::isTouchEventType(event.type)) { |
55 const WebTouchEvent& web_touch = | 55 const WebTouchEvent& web_touch = |
56 static_cast<const WebTouchEvent&>(event); | 56 static_cast<const WebTouchEvent&>(event); |
57 | 57 |
58 // Check that all touch pointers are within the content bounds. | 58 // Check that all touch pointers are within the content bounds. |
59 if (web_touch.type == WebInputEvent::TouchStart) { | 59 for (unsigned i = 0; i < web_touch.touchesLength; i++) |
60 for (unsigned i = 0; i < web_touch.touchesLength; i++) | 60 CHECK(web_touch.touches[i].state != WebTouchPoint::StatePressed || |
61 CHECK(web_touch.touches[i].state != WebTouchPoint::StatePressed || | 61 PointIsWithinContents(web_touch.touches[i].position.x, |
62 PointIsWithinContents(web_touch.touches[i].position.x, | 62 web_touch.touches[i].position.y)) |
63 web_touch.touches[i].position.y)) | 63 << "Touch coordinates are not within content bounds on TouchStart."; |
64 << "Touch coordinates are not within content bounds on TouchStart."; | |
65 } | |
66 | 64 |
67 DispatchWebTouchEventToPlatform(web_touch, latency_info); | 65 DispatchWebTouchEventToPlatform(web_touch, latency_info); |
68 } else if (event.type == WebInputEvent::MouseWheel) { | 66 } else if (event.type == WebInputEvent::MouseWheel) { |
69 const WebMouseWheelEvent& web_wheel = | 67 const WebMouseWheelEvent& web_wheel = |
70 static_cast<const WebMouseWheelEvent&>(event); | 68 static_cast<const WebMouseWheelEvent&>(event); |
71 CHECK(PointIsWithinContents(web_wheel.x, web_wheel.y)) | 69 CHECK(PointIsWithinContents(web_wheel.x, web_wheel.y)) |
72 << "Mouse wheel position is not within content bounds."; | 70 << "Mouse wheel position is not within content bounds."; |
73 DispatchWebMouseWheelEventToPlatform(web_wheel, latency_info); | 71 DispatchWebMouseWheelEventToPlatform(web_wheel, latency_info); |
74 } else if (WebInputEvent::isMouseEventType(event.type)) { | 72 } else if (WebInputEvent::isMouseEventType(event.type)) { |
75 const WebMouseEvent& web_mouse = | 73 const WebMouseEvent& web_mouse = |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return 0.0f; | 127 return 0.0f; |
130 } | 128 } |
131 | 129 |
132 bool SyntheticGestureTargetBase::PointIsWithinContents(int x, int y) const { | 130 bool SyntheticGestureTargetBase::PointIsWithinContents(int x, int y) const { |
133 gfx::Rect bounds = host_->GetView()->GetViewBounds(); | 131 gfx::Rect bounds = host_->GetView()->GetViewBounds(); |
134 bounds -= bounds.OffsetFromOrigin(); // Translate the bounds to (0,0). | 132 bounds -= bounds.OffsetFromOrigin(); // Translate the bounds to (0,0). |
135 return bounds.Contains(x, y); | 133 return bounds.Contains(x, y); |
136 } | 134 } |
137 | 135 |
138 } // namespace content | 136 } // namespace content |
OLD | NEW |