Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: components/html_viewer/touch_handler.cc

Issue 1527183003: Change mojo enums to be scoped enums in the generated C++ bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-equals
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/mus/public/interfaces/input_events.mojom.h" 7 #include "components/mus/public/interfaces/input_events.mojom.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h" 8 #include "third_party/WebKit/public/web/WebInputEvent.h"
9 #include "third_party/WebKit/public/web/WebWidget.h" 9 #include "third_party/WebKit/public/web/WebWidget.h"
10 #include "ui/events/base_event_utils.h" 10 #include "ui/events/base_event_utils.h"
(...skipping 12 matching lines...) Expand all
23 properties->id = event.pointer_data->pointer_id; 23 properties->id = event.pointer_data->pointer_id;
24 if (event.pointer_data->location) { 24 if (event.pointer_data->location) {
25 properties->x = event.pointer_data->location->x; 25 properties->x = event.pointer_data->location->x;
26 properties->y = event.pointer_data->location->y; 26 properties->y = event.pointer_data->location->y;
27 properties->raw_x = event.pointer_data->location->screen_x; 27 properties->raw_x = event.pointer_data->location->screen_x;
28 properties->raw_y = event.pointer_data->location->screen_y; 28 properties->raw_y = event.pointer_data->location->screen_y;
29 } 29 }
30 } 30 }
31 31
32 if (event.pointer_data && event.pointer_data->brush_data && 32 if (event.pointer_data && event.pointer_data->brush_data &&
33 (event.pointer_data->kind == mus::mojom::POINTER_KIND_TOUCH || 33 (event.pointer_data->kind == mus::mojom::PointerKind::TOUCH ||
34 event.pointer_data->kind == mus::mojom::POINTER_KIND_PEN)) { 34 event.pointer_data->kind == mus::mojom::PointerKind::PEN)) {
35 properties->pressure = event.pointer_data->brush_data->pressure; 35 properties->pressure = event.pointer_data->brush_data->pressure;
36 36
37 // TODO(rjkroege): vary orientation for width, height. 37 // TODO(rjkroege): vary orientation for width, height.
38 properties->SetAxesAndOrientation(event.pointer_data->brush_data->width, 38 properties->SetAxesAndOrientation(event.pointer_data->brush_data->width,
39 event.pointer_data->brush_data->height, 39 event.pointer_data->brush_data->height,
40 0.0); 40 0.0);
41 } else { 41 } else {
42 if (event.flags & mus::mojom::EVENT_FLAGS_LEFT_MOUSE_BUTTON || 42 if (event.flags & mus::mojom::kEventFlagLeftMouseButton ||
43 event.flags & mus::mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON || 43 event.flags & mus::mojom::kEventFlagMiddleMouseButton ||
44 event.flags & mus::mojom::EVENT_FLAGS_MIDDLE_MOUSE_BUTTON) { 44 event.flags & mus::mojom::kEventFlagMiddleMouseButton) {
45 properties->pressure = 0.5; 45 properties->pressure = 0.5;
46 } else { 46 } else {
47 properties->pressure = 0.0; 47 properties->pressure = 0.0;
48 } 48 }
49 } 49 }
50 // TODO(sky): Add support for tool_type. 50 // TODO(sky): Add support for tool_type.
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 SetPropertiesFromEvent(event, &properties); 90 SetPropertiesFromEvent(event, &properties);
91 91
92 const base::TimeTicks timestamp( 92 const base::TimeTicks timestamp(
93 base::TimeTicks::FromInternalValue(event.time_stamp)); 93 base::TimeTicks::FromInternalValue(event.time_stamp));
94 if (current_motion_event_.get()) { 94 if (current_motion_event_.get()) {
95 current_motion_event_->set_unique_event_id(ui::GetNextTouchEventId()); 95 current_motion_event_->set_unique_event_id(ui::GetNextTouchEventId());
96 current_motion_event_->set_event_time(timestamp); 96 current_motion_event_->set_event_time(timestamp);
97 } 97 }
98 98
99 switch (event.action) { 99 switch (event.action) {
100 case mus::mojom::EVENT_TYPE_POINTER_DOWN: 100 case mus::mojom::EventType::POINTER_DOWN:
101 if (!current_motion_event_.get()) { 101 if (!current_motion_event_.get()) {
102 current_motion_event_.reset(new ui::MotionEventGeneric( 102 current_motion_event_.reset(new ui::MotionEventGeneric(
103 ui::MotionEvent::ACTION_DOWN, timestamp, properties)); 103 ui::MotionEvent::ACTION_DOWN, timestamp, properties));
104 } else { 104 } else {
105 const int index = 105 const int index =
106 current_motion_event_->FindPointerIndexOfId(properties.id); 106 current_motion_event_->FindPointerIndexOfId(properties.id);
107 if (index != -1) { 107 if (index != -1) {
108 DVLOG(1) << "pointer down and pointer already down id=" 108 DVLOG(1) << "pointer down and pointer already down id="
109 << properties.id; 109 << properties.id;
110 return false; 110 return false;
111 } 111 }
112 current_motion_event_->PushPointer(properties); 112 current_motion_event_->PushPointer(properties);
113 current_motion_event_->set_action(ui::MotionEvent::ACTION_POINTER_DOWN); 113 current_motion_event_->set_action(ui::MotionEvent::ACTION_POINTER_DOWN);
114 current_motion_event_->set_action_index(static_cast<int>(index)); 114 current_motion_event_->set_action_index(static_cast<int>(index));
115 } 115 }
116 return true; 116 return true;
117 117
118 case mus::mojom::EVENT_TYPE_POINTER_UP: { 118 case mus::mojom::EventType::POINTER_UP: {
119 if (!current_motion_event_.get()) { 119 if (!current_motion_event_.get()) {
120 DVLOG(1) << "pointer up with no event, id=" << properties.id; 120 DVLOG(1) << "pointer up with no event, id=" << properties.id;
121 return false; 121 return false;
122 } 122 }
123 const int index = 123 const int index =
124 current_motion_event_->FindPointerIndexOfId(properties.id); 124 current_motion_event_->FindPointerIndexOfId(properties.id);
125 if (index == -1) { 125 if (index == -1) {
126 DVLOG(1) << "pointer up and pointer not down id=" << properties.id; 126 DVLOG(1) << "pointer up and pointer not down id=" << properties.id;
127 return false; 127 return false;
128 } 128 }
129 current_motion_event_->pointer(index) = properties; 129 current_motion_event_->pointer(index) = properties;
130 current_motion_event_->set_action( 130 current_motion_event_->set_action(
131 current_motion_event_->GetPointerCount() == 1 131 current_motion_event_->GetPointerCount() == 1
132 ? ui::MotionEvent::ACTION_UP 132 ? ui::MotionEvent::ACTION_UP
133 : ui::MotionEvent::ACTION_POINTER_UP); 133 : ui::MotionEvent::ACTION_POINTER_UP);
134 current_motion_event_->set_action_index(static_cast<int>(index)); 134 current_motion_event_->set_action_index(static_cast<int>(index));
135 return true; 135 return true;
136 } 136 }
137 137
138 case mus::mojom::EVENT_TYPE_POINTER_MOVE: { 138 case mus::mojom::EventType::POINTER_MOVE: {
139 if (!current_motion_event_.get()) { 139 if (!current_motion_event_.get()) {
140 DVLOG(1) << "pointer move with no event, id=" << properties.id; 140 DVLOG(1) << "pointer move with no event, id=" << properties.id;
141 return false; 141 return false;
142 } 142 }
143 const int index = 143 const int index =
144 current_motion_event_->FindPointerIndexOfId(properties.id); 144 current_motion_event_->FindPointerIndexOfId(properties.id);
145 if (index == -1) { 145 if (index == -1) {
146 DVLOG(1) << "pointer move and pointer not down id=" << properties.id; 146 DVLOG(1) << "pointer move and pointer not down id=" << properties.id;
147 return false; 147 return false;
148 } 148 }
149 current_motion_event_->pointer(index) = properties; 149 current_motion_event_->pointer(index) = properties;
150 current_motion_event_->set_action(ui::MotionEvent::ACTION_MOVE); 150 current_motion_event_->set_action(ui::MotionEvent::ACTION_MOVE);
151 current_motion_event_->set_action_index(static_cast<int>(index)); 151 current_motion_event_->set_action_index(static_cast<int>(index));
152 return true; 152 return true;
153 } 153 }
154 154
155 case mus::mojom::EVENT_TYPE_POINTER_CANCEL: { 155 case mus::mojom::EventType::POINTER_CANCEL: {
156 if (!current_motion_event_.get()) { 156 if (!current_motion_event_.get()) {
157 DVLOG(1) << "canel with no event, id=" << properties.id; 157 DVLOG(1) << "canel with no event, id=" << properties.id;
158 return false; 158 return false;
159 } 159 }
160 const int index = 160 const int index =
161 current_motion_event_->FindPointerIndexOfId(properties.id); 161 current_motion_event_->FindPointerIndexOfId(properties.id);
162 if (index == -1) { 162 if (index == -1) {
163 DVLOG(1) << "cancel and pointer not down id=" << properties.id; 163 DVLOG(1) << "cancel and pointer not down id=" << properties.id;
164 return false; 164 return false;
165 } 165 }
(...skipping 17 matching lines...) Expand all
183 183
184 blink::WebTouchEvent web_event = ui::CreateWebTouchEventFromMotionEvent( 184 blink::WebTouchEvent web_event = ui::CreateWebTouchEventFromMotionEvent(
185 *current_motion_event_, result.did_generate_scroll); 185 *current_motion_event_, result.did_generate_scroll);
186 gesture_provider_.OnTouchEventAck(web_event.uniqueTouchEventId, 186 gesture_provider_.OnTouchEventAck(web_event.uniqueTouchEventId,
187 web_widget_->handleInputEvent(web_event) != 187 web_widget_->handleInputEvent(web_event) !=
188 blink::WebInputEventResult::NotHandled); 188 blink::WebInputEventResult::NotHandled);
189 } 189 }
190 190
191 void TouchHandler::PostProcessMotionEvent(const mus::mojom::Event& event) { 191 void TouchHandler::PostProcessMotionEvent(const mus::mojom::Event& event) {
192 switch (event.action) { 192 switch (event.action) {
193 case mus::mojom::EVENT_TYPE_POINTER_UP: { 193 case mus::mojom::EventType::POINTER_UP: {
194 if (event.pointer_data) { 194 if (event.pointer_data) {
195 const int index = current_motion_event_->FindPointerIndexOfId( 195 const int index = current_motion_event_->FindPointerIndexOfId(
196 event.pointer_data->pointer_id); 196 event.pointer_data->pointer_id);
197 current_motion_event_->RemovePointerAt(index); 197 current_motion_event_->RemovePointerAt(index);
198 } 198 }
199 if (current_motion_event_->GetPointerCount() == 0) 199 if (current_motion_event_->GetPointerCount() == 0)
200 current_motion_event_.reset(); 200 current_motion_event_.reset();
201 break; 201 break;
202 } 202 }
203 203
204 case mus::mojom::EVENT_TYPE_POINTER_CANCEL: 204 case mus::mojom::EventType::POINTER_CANCEL:
205 current_motion_event_.reset(); 205 current_motion_event_.reset();
206 break; 206 break;
207 207
208 default: 208 default:
209 break; 209 break;
210 } 210 }
211 } 211 }
212 212
213 } // namespace html_viewer 213 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/input_events_unittest.cc ('k') | components/html_viewer/web_clipboard_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698