OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/html_viewer/touch_handler.h" | 5 #include "components/html_viewer/touch_handler.h" |
6 | 6 |
7 #include "third_party/WebKit/public/web/WebInputEvent.h" | 7 #include "third_party/WebKit/public/web/WebInputEvent.h" |
8 #include "third_party/WebKit/public/web/WebView.h" | 8 #include "third_party/WebKit/public/web/WebView.h" |
| 9 #include "ui/events/base_event_utils.h" |
9 #include "ui/events/blink/blink_event_util.h" | 10 #include "ui/events/blink/blink_event_util.h" |
10 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 11 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
11 #include "ui/events/gesture_detection/motion_event_generic.h" | 12 #include "ui/events/gesture_detection/motion_event_generic.h" |
12 #include "ui/mojo/events/input_events.mojom.h" | 13 #include "ui/mojo/events/input_events.mojom.h" |
13 | 14 |
14 namespace html_viewer { | 15 namespace html_viewer { |
15 namespace { | 16 namespace { |
16 | 17 |
17 void SetPropertiesFromEvent(const mojo::Event& event, | 18 void SetPropertiesFromEvent(const mojo::Event& event, |
18 ui::PointerProperties* properties) { | 19 ui::PointerProperties* properties) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 web_view_->handleInputEvent(web_gesture); | 64 web_view_->handleInputEvent(web_gesture); |
64 } | 65 } |
65 | 66 |
66 bool TouchHandler::UpdateMotionEvent(const mojo::Event& event) { | 67 bool TouchHandler::UpdateMotionEvent(const mojo::Event& event) { |
67 ui::PointerProperties properties; | 68 ui::PointerProperties properties; |
68 SetPropertiesFromEvent(event, &properties); | 69 SetPropertiesFromEvent(event, &properties); |
69 | 70 |
70 const base::TimeTicks timestamp( | 71 const base::TimeTicks timestamp( |
71 base::TimeTicks::FromInternalValue(event.time_stamp)); | 72 base::TimeTicks::FromInternalValue(event.time_stamp)); |
72 if (current_motion_event_.get()) { | 73 if (current_motion_event_.get()) { |
73 current_motion_event_->set_id(current_motion_event_->GetId() + 1); | 74 current_motion_event_->set_unique_event_id(ui::GetNextTouchEventId()); |
74 current_motion_event_->set_event_time(timestamp); | 75 current_motion_event_->set_event_time(timestamp); |
75 } | 76 } |
76 | 77 |
77 switch (event.action) { | 78 switch (event.action) { |
78 case mojo::EVENT_TYPE_POINTER_DOWN: | 79 case mojo::EVENT_TYPE_POINTER_DOWN: |
79 if (!current_motion_event_.get()) { | 80 if (!current_motion_event_.get()) { |
80 current_motion_event_.reset(new ui::MotionEventGeneric( | 81 current_motion_event_.reset(new ui::MotionEventGeneric( |
81 ui::MotionEvent::ACTION_DOWN, timestamp, properties)); | 82 ui::MotionEvent::ACTION_DOWN, timestamp, properties)); |
82 } else { | 83 } else { |
83 const int index = | 84 const int index = |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 case mojo::EVENT_TYPE_POINTER_CANCEL: | 179 case mojo::EVENT_TYPE_POINTER_CANCEL: |
179 current_motion_event_.reset(); | 180 current_motion_event_.reset(); |
180 break; | 181 break; |
181 | 182 |
182 default: | 183 default: |
183 break; | 184 break; |
184 } | 185 } |
185 } | 186 } |
186 | 187 |
187 } // namespace html_viewer | 188 } // namespace html_viewer |
OLD | NEW |