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/WebWidget.h" | 8 #include "third_party/WebKit/public/web/WebWidget.h" |
9 #include "ui/events/base_event_utils.h" | 9 #include "ui/events/base_event_utils.h" |
10 #include "ui/events/blink/blink_event_util.h" | 10 #include "ui/events/blink/blink_event_util.h" |
11 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 11 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
12 #include "ui/events/gesture_detection/motion_event_generic.h" | 12 #include "ui/events/gesture_detection/motion_event_generic.h" |
13 #include "ui/mojo/events/input_events.mojom.h" | 13 #include "ui/mojo/events/input_events.mojom.h" |
14 | 14 |
15 namespace html_viewer { | 15 namespace html_viewer { |
16 namespace { | 16 namespace { |
17 | 17 |
| 18 // TODO(rjkroege): Gesture recognition currently happens in the html_viewer. |
| 19 // In phase2, it will be relocated to MUS. Update this code at that time. |
18 void SetPropertiesFromEvent(const mojo::Event& event, | 20 void SetPropertiesFromEvent(const mojo::Event& event, |
19 ui::PointerProperties* properties) { | 21 ui::PointerProperties* properties) { |
20 properties->id = event.pointer_data->pointer_id; | 22 properties->id = event.pointer_data->pointer_id; |
21 properties->x = event.pointer_data->x; | 23 properties->x = event.pointer_data->location->x; |
22 properties->y = event.pointer_data->y; | 24 properties->y = event.pointer_data->location->y; |
23 properties->raw_x = event.pointer_data->screen_x; | 25 properties->raw_x = event.pointer_data->location->screen_x; |
24 properties->raw_y = event.pointer_data->screen_y; | 26 properties->raw_y = event.pointer_data->location->screen_y; |
25 properties->pressure = event.pointer_data->pressure; | 27 |
26 properties->SetAxesAndOrientation(event.pointer_data->radius_major, | 28 if (event.pointer_data->kind == mojo::POINTER_KIND_TOUCH || |
27 event.pointer_data->radius_minor, | 29 event.pointer_data->kind == mojo::POINTER_KIND_PEN) { |
28 event.pointer_data->orientation); | 30 properties->pressure = event.pointer_data->brush_data->pressure; |
| 31 |
| 32 // TODO(rjkroege): vary orientation for width, height. |
| 33 properties->SetAxesAndOrientation(event.pointer_data->brush_data->width, |
| 34 event.pointer_data->brush_data->height, |
| 35 0.0); |
| 36 } else { |
| 37 if (event.flags & mojo::EVENT_FLAGS_LEFT_MOUSE_BUTTON || |
| 38 event.flags & mojo::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON || |
| 39 event.flags & mojo::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON) { |
| 40 properties->pressure = 0.5; |
| 41 } else { |
| 42 properties->pressure = 0.0; |
| 43 } |
| 44 } |
29 // TODO(sky): Add support for tool_type. | 45 // TODO(sky): Add support for tool_type. |
30 } | 46 } |
31 | 47 |
32 } // namespace | 48 } // namespace |
33 | 49 |
34 TouchHandler::TouchHandler(blink::WebWidget* web_widget) | 50 TouchHandler::TouchHandler(blink::WebWidget* web_widget) |
35 : web_widget_(web_widget), | 51 : web_widget_(web_widget), |
36 gesture_provider_(ui::GetGestureProviderConfig( | 52 gesture_provider_(ui::GetGestureProviderConfig( |
37 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 53 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
38 this) { | 54 this) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 case mojo::EVENT_TYPE_POINTER_CANCEL: | 196 case mojo::EVENT_TYPE_POINTER_CANCEL: |
181 current_motion_event_.reset(); | 197 current_motion_event_.reset(); |
182 break; | 198 break; |
183 | 199 |
184 default: | 200 default: |
185 break; | 201 break; |
186 } | 202 } |
187 } | 203 } |
188 | 204 |
189 } // namespace html_viewer | 205 } // namespace html_viewer |
OLD | NEW |