| 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/input_event.h" | |
| 11 #include "content/common/input_messages.h" | 10 #include "content/common/input_messages.h" |
| 12 #include "third_party/WebKit/public/web/WebInputEvent.h" | 11 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 13 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
| 14 #include "ui/events/latency_info.h" | 13 #include "ui/events/latency_info.h" |
| 15 | 14 |
| 16 using blink::WebInputEvent; | 15 using blink::WebInputEvent; |
| 17 using blink::WebTouchEvent; | 16 using blink::WebTouchEvent; |
| 18 using blink::WebMouseEvent; | 17 using blink::WebMouseEvent; |
| 19 using blink::WebMouseWheelEvent; | 18 using blink::WebMouseWheelEvent; |
| 20 | 19 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 SyntheticGestureTargetBase::SyntheticGestureTargetBase( | 34 SyntheticGestureTargetBase::SyntheticGestureTargetBase( |
| 36 RenderWidgetHostImpl* host) | 35 RenderWidgetHostImpl* host) |
| 37 : host_(host) { | 36 : host_(host) { |
| 38 DCHECK(host); | 37 DCHECK(host); |
| 39 } | 38 } |
| 40 | 39 |
| 41 SyntheticGestureTargetBase::~SyntheticGestureTargetBase() { | 40 SyntheticGestureTargetBase::~SyntheticGestureTargetBase() { |
| 42 } | 41 } |
| 43 | 42 |
| 44 void SyntheticGestureTargetBase::DispatchInputEventToPlatform( | 43 void SyntheticGestureTargetBase::DispatchInputEventToPlatform( |
| 45 const InputEvent& event) { | 44 const WebInputEvent& event) { |
| 46 const WebInputEvent* web_event = event.web_event.get(); | 45 ui::LatencyInfo latency_info; |
| 47 if (WebInputEvent::isTouchEventType(web_event->type)) { | 46 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
| 47 |
| 48 if (WebInputEvent::isTouchEventType(event.type)) { |
| 48 DCHECK(SupportsSyntheticGestureSourceType( | 49 DCHECK(SupportsSyntheticGestureSourceType( |
| 49 SyntheticGestureParams::TOUCH_INPUT)); | 50 SyntheticGestureParams::TOUCH_INPUT)); |
| 50 | 51 |
| 51 const WebTouchEvent* web_touch = | 52 const WebTouchEvent& web_touch = |
| 52 static_cast<const WebTouchEvent*>(web_event); | 53 static_cast<const WebTouchEvent&>(event); |
| 53 DispatchWebTouchEventToPlatform(*web_touch, event.latency_info); | 54 DispatchWebTouchEventToPlatform(web_touch, latency_info); |
| 54 } else if (web_event->type == WebInputEvent::MouseWheel) { | 55 } else if (event.type == WebInputEvent::MouseWheel) { |
| 55 DCHECK(SupportsSyntheticGestureSourceType( | 56 DCHECK(SupportsSyntheticGestureSourceType( |
| 56 SyntheticGestureParams::MOUSE_INPUT)); | 57 SyntheticGestureParams::MOUSE_INPUT)); |
| 57 | 58 |
| 58 const WebMouseWheelEvent* web_wheel = | 59 const WebMouseWheelEvent& web_wheel = |
| 59 static_cast<const WebMouseWheelEvent*>(web_event); | 60 static_cast<const WebMouseWheelEvent&>(event); |
| 60 DispatchWebMouseWheelEventToPlatform(*web_wheel, event.latency_info); | 61 DispatchWebMouseWheelEventToPlatform(web_wheel, latency_info); |
| 61 } else if (WebInputEvent::isMouseEventType(web_event->type)) { | 62 } else if (WebInputEvent::isMouseEventType(event.type)) { |
| 62 DCHECK(SupportsSyntheticGestureSourceType( | 63 DCHECK(SupportsSyntheticGestureSourceType( |
| 63 SyntheticGestureParams::MOUSE_INPUT)); | 64 SyntheticGestureParams::MOUSE_INPUT)); |
| 64 | 65 |
| 65 const WebMouseEvent* web_mouse = | 66 const WebMouseEvent& web_mouse = |
| 66 static_cast<const WebMouseEvent*>(web_event); | 67 static_cast<const WebMouseEvent&>(event); |
| 67 DispatchWebMouseEventToPlatform(*web_mouse, event.latency_info); | 68 DispatchWebMouseEventToPlatform(web_mouse, latency_info); |
| 68 } else { | 69 } else { |
| 69 NOTREACHED(); | 70 NOTREACHED(); |
| 70 } | 71 } |
| 71 } | 72 } |
| 72 | 73 |
| 73 void SyntheticGestureTargetBase::DispatchWebTouchEventToPlatform( | 74 void SyntheticGestureTargetBase::DispatchWebTouchEventToPlatform( |
| 74 const blink::WebTouchEvent& web_touch, | 75 const blink::WebTouchEvent& web_touch, |
| 75 const ui::LatencyInfo& latency_info) { | 76 const ui::LatencyInfo& latency_info) { |
| 76 host_->ForwardTouchEventWithLatencyInfo(web_touch, latency_info); | 77 host_->ForwardTouchEventWithLatencyInfo(web_touch, latency_info); |
| 77 } | 78 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 base::TimeDelta SyntheticGestureTargetBase::PointerAssumedStoppedTime() | 114 base::TimeDelta SyntheticGestureTargetBase::PointerAssumedStoppedTime() |
| 114 const { | 115 const { |
| 115 return base::TimeDelta::FromMilliseconds(kPointerAssumedStoppedTimeMs); | 116 return base::TimeDelta::FromMilliseconds(kPointerAssumedStoppedTimeMs); |
| 116 } | 117 } |
| 117 | 118 |
| 118 int SyntheticGestureTargetBase::GetTouchSlopInDips() const { | 119 int SyntheticGestureTargetBase::GetTouchSlopInDips() const { |
| 119 return kTouchSlopInDips; | 120 return kTouchSlopInDips; |
| 120 } | 121 } |
| 121 | 122 |
| 122 } // namespace content | 123 } // namespace content |
| OLD | NEW |