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

Side by Side Diff: sky/viewer/converters/input_event_types.cc

Issue 876853005: Add wheel support to sky-scrollable (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add missing files Created 5 years, 10 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
« no previous file with comments | « sky/framework/sky-scrollable.sky ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sky/viewer/converters/input_event_types.h" 5 #include "sky/viewer/converters/input_event_types.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "mojo/services/input_events/public/interfaces/input_event_constants.moj om.h" 9 #include "mojo/services/input_events/public/interfaces/input_event_constants.moj om.h"
10 #include "sky/engine/public/platform/WebInputEvent.h" 10 #include "sky/engine/public/platform/WebInputEvent.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 event->gesture_data->scale / device_pixel_ratio; 158 event->gesture_data->scale / device_pixel_ratio;
159 break; 159 break;
160 default: 160 default:
161 NOTIMPLEMENTED() << "Received unexpected event: " << event->action; 161 NOTIMPLEMENTED() << "Received unexpected event: " << event->action;
162 break; 162 break;
163 } 163 }
164 164
165 web_event->x = event->location_data->in_view_location->x / device_pixel_ratio; 165 web_event->x = event->location_data->in_view_location->x / device_pixel_ratio;
166 web_event->y = event->location_data->in_view_location->y / device_pixel_ratio; 166 web_event->y = event->location_data->in_view_location->y / device_pixel_ratio;
167 167
168 // TODO(erg): Remove this null check as parallel to above.
169 if (!event->location_data->screen_location.is_null()) {
170 web_event->globalX =
171 event->location_data->screen_location->x / device_pixel_ratio;
172 web_event->globalY =
173 event->location_data->screen_location->y / device_pixel_ratio;
174 }
175
176 return web_event.Pass(); 168 return web_event.Pass();
177 } 169 }
178 170
179 scoped_ptr<blink::WebInputEvent> BuildWebKeyboardEvent( 171 scoped_ptr<blink::WebInputEvent> BuildWebKeyboardEvent(
180 const mojo::EventPtr& event, 172 const mojo::EventPtr& event,
181 float device_pixel_ratio) { 173 float device_pixel_ratio) {
182 scoped_ptr<blink::WebKeyboardEvent> web_event(new blink::WebKeyboardEvent); 174 scoped_ptr<blink::WebKeyboardEvent> web_event(new blink::WebKeyboardEvent);
183 175
184 web_event->modifiers = EventFlagsToWebInputEventModifiers(event->flags); 176 web_event->modifiers = EventFlagsToWebInputEventModifiers(event->flags);
185 web_event->timeStampMS = 177 web_event->timeStampMS =
(...skipping 11 matching lines...) Expand all
197 NOTREACHED(); 189 NOTREACHED();
198 } 190 }
199 191
200 web_event->key = event->key_data->windows_key_code; 192 web_event->key = event->key_data->windows_key_code;
201 web_event->charCode = event->key_data->text; 193 web_event->charCode = event->key_data->text;
202 web_event->unmodifiedCharCode = event->key_data->unmodified_text; 194 web_event->unmodifiedCharCode = event->key_data->unmodified_text;
203 195
204 return web_event.Pass(); 196 return web_event.Pass();
205 } 197 }
206 198
199 scoped_ptr<blink::WebInputEvent> BuildWebWheelEvent(
200 const mojo::EventPtr& event, float device_pixel_ratio) {
201 scoped_ptr<blink::WebWheelEvent> web_event(new blink::WebWheelEvent);
202
203 web_event->modifiers = EventFlagsToWebInputEventModifiers(event->flags);
204 web_event->timeStampMS =
205 base::TimeDelta::FromInternalValue(event->time_stamp).InMillisecondsF();
206
207 web_event->type = blink::WebInputEvent::WheelEvent;
208
209 const auto& location = event->location_data->in_view_location;
210 web_event->x = location->x / device_pixel_ratio;
211 web_event->y = location->y / device_pixel_ratio;
212
213 web_event->offsetX = event->wheel_data->x_offset / device_pixel_ratio;
214 web_event->offsetY = event->wheel_data->y_offset / device_pixel_ratio;
215
216 return web_event.Pass();
217 }
218
207 } // namespace 219 } // namespace
208 220
209 scoped_ptr<blink::WebInputEvent> ConvertEvent(const mojo::EventPtr& event, 221 scoped_ptr<blink::WebInputEvent> ConvertEvent(const mojo::EventPtr& event,
210 float device_pixel_ratio) { 222 float device_pixel_ratio) {
211 if (event->action == mojo::EVENT_TYPE_TOUCH_RELEASED || 223 if (event->action == mojo::EVENT_TYPE_TOUCH_RELEASED ||
212 event->action == mojo::EVENT_TYPE_TOUCH_PRESSED || 224 event->action == mojo::EVENT_TYPE_TOUCH_PRESSED ||
213 event->action == mojo::EVENT_TYPE_TOUCH_MOVED || 225 event->action == mojo::EVENT_TYPE_TOUCH_MOVED ||
214 event->action == mojo::EVENT_TYPE_TOUCH_CANCELLED || 226 event->action == mojo::EVENT_TYPE_TOUCH_CANCELLED ||
215 event->action == mojo::EVENT_TYPE_MOUSE_DRAGGED || 227 event->action == mojo::EVENT_TYPE_MOUSE_DRAGGED ||
216 event->action == mojo::EVENT_TYPE_MOUSE_PRESSED || 228 event->action == mojo::EVENT_TYPE_MOUSE_PRESSED ||
(...skipping 18 matching lines...) Expand all
235 event->action == mojo::EVENT_TYPE_GESTURE_SWIPE || 247 event->action == mojo::EVENT_TYPE_GESTURE_SWIPE ||
236 event->action == mojo::EVENT_TYPE_GESTURE_SHOW_PRESS || 248 event->action == mojo::EVENT_TYPE_GESTURE_SHOW_PRESS ||
237 event->action == mojo::EVENT_TYPE_GESTURE_WIN8_EDGE_SWIPE || 249 event->action == mojo::EVENT_TYPE_GESTURE_WIN8_EDGE_SWIPE ||
238 event->action == mojo::EVENT_TYPE_SCROLL_FLING_START || 250 event->action == mojo::EVENT_TYPE_SCROLL_FLING_START ||
239 event->action == mojo::EVENT_TYPE_SCROLL_FLING_CANCEL) { 251 event->action == mojo::EVENT_TYPE_SCROLL_FLING_CANCEL) {
240 return BuildWebGestureEvent(event, device_pixel_ratio); 252 return BuildWebGestureEvent(event, device_pixel_ratio);
241 } else if ((event->action == mojo::EVENT_TYPE_KEY_PRESSED || 253 } else if ((event->action == mojo::EVENT_TYPE_KEY_PRESSED ||
242 event->action == mojo::EVENT_TYPE_KEY_RELEASED) && 254 event->action == mojo::EVENT_TYPE_KEY_RELEASED) &&
243 event->key_data) { 255 event->key_data) {
244 return BuildWebKeyboardEvent(event, device_pixel_ratio); 256 return BuildWebKeyboardEvent(event, device_pixel_ratio);
257 } else if (event->action == mojo::EVENT_TYPE_MOUSEWHEEL &&
258 event->wheel_data) {
259 return BuildWebWheelEvent(event, device_pixel_ratio);
245 } 260 }
246 261
247 return scoped_ptr<blink::WebInputEvent>(); 262 return scoped_ptr<blink::WebInputEvent>();
248 } 263 }
249 264
250 } // namespace mojo 265 } // namespace mojo
OLDNEW
« no previous file with comments | « sky/framework/sky-scrollable.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698