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

Side by Side Diff: content/browser/renderer_host/input/web_input_event_util.cc

Issue 182383007: Make the ContentGestureProvider a ui::FilteredGestureProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lower similarity Created 6 years, 9 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 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/web_input_event_util.h" 5 #include "content/browser/renderer_host/input/web_input_event_util.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "ui/events/gesture_detection/gesture_event_data.h"
8 #include "ui/events/gesture_detection/motion_event.h" 9 #include "ui/events/gesture_detection/motion_event.h"
9 10
11 using blink::WebGestureEvent;
10 using blink::WebInputEvent; 12 using blink::WebInputEvent;
11 using blink::WebTouchEvent; 13 using blink::WebTouchEvent;
12 using blink::WebTouchPoint; 14 using blink::WebTouchPoint;
13 using ui::MotionEvent; 15 using ui::MotionEvent;
14 16
15 namespace { 17 namespace {
16 18
17 const char* GetKeyIdentifier(ui::KeyboardCode key_code) { 19 const char* GetKeyIdentifier(ui::KeyboardCode key_code) {
18 switch (key_code) { 20 switch (key_code) {
19 case ui::VKEY_MENU: 21 case ui::VKEY_MENU:
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 std::min(event.GetPointerCount(), 227 std::min(event.GetPointerCount(),
226 static_cast<size_t>(WebTouchEvent::touchesLengthCap)); 228 static_cast<size_t>(WebTouchEvent::touchesLengthCap));
227 DCHECK_GT(result.touchesLength, 0U); 229 DCHECK_GT(result.touchesLength, 0U);
228 230
229 for (size_t i = 0; i < result.touchesLength; ++i) 231 for (size_t i = 0; i < result.touchesLength; ++i)
230 result.touches[i] = CreateWebTouchPoint(event, i, scale); 232 result.touches[i] = CreateWebTouchPoint(event, i, scale);
231 233
232 return result; 234 return result;
233 } 235 }
234 236
237 WebGestureEvent CreateWebGestureEventFromGestureEventData(
238 const ui::GestureEventData& data,
239 float scale) {
240 WebGestureEvent gesture;
241 gesture.x = data.x * scale;
242 gesture.y = data.y * scale;
243 gesture.timeStampSeconds = (data.time - base::TimeTicks()).InSecondsF();
244 gesture.sourceDevice = WebGestureEvent::Touchscreen;
245
246 switch (data.type) {
247 case ui::ET_GESTURE_SHOW_PRESS:
248 gesture.type = WebInputEvent::GestureShowPress;
249 gesture.data.showPress.width = data.details.show_press.width * scale;
250 gesture.data.showPress.width = data.details.show_press.width * scale;
251 break;
252 case ui::ET_GESTURE_DOUBLE_TAP:
253 gesture.type = WebInputEvent::GestureDoubleTap;
254 break;
255 case ui::ET_GESTURE_TAP:
256 gesture.type = WebInputEvent::GestureTap;
257 gesture.data.tap.tapCount = data.details.tap.tap_count;
258 gesture.data.tap.width = data.details.tap.width * scale;
259 gesture.data.tap.height = data.details.tap.height * scale;
260 break;
261 case ui::ET_GESTURE_TAP_UNCONFIRMED:
262 gesture.type = WebInputEvent::GestureTapUnconfirmed;
263 gesture.data.tap.tapCount = data.details.tap.tap_count;
264 gesture.data.tap.width = data.details.tap.width * scale;
265 gesture.data.tap.height = data.details.tap.height * scale;
266 break;
267 case ui::ET_GESTURE_LONG_PRESS:
268 gesture.type = WebInputEvent::GestureLongPress;
269 gesture.data.longPress.width = data.details.long_press.width * scale;
270 gesture.data.longPress.height = data.details.long_press.height * scale;
271 break;
272 case ui::ET_GESTURE_LONG_TAP:
273 gesture.type = WebInputEvent::GestureLongTap;
274 gesture.data.longPress.width = data.details.long_press.width * scale;
275 gesture.data.longPress.height = data.details.long_press.height * scale;
276 break;
277 case ui::ET_GESTURE_SCROLL_BEGIN:
278 gesture.type = WebInputEvent::GestureScrollBegin;
279 gesture.data.scrollBegin.deltaXHint =
280 data.details.scroll_begin.delta_x_hint * scale;
281 gesture.data.scrollBegin.deltaYHint =
282 data.details.scroll_begin.delta_y_hint * scale;
283 break;
284 case ui::ET_GESTURE_SCROLL_UPDATE:
285 gesture.type = WebInputEvent::GestureScrollUpdate;
286 gesture.data.scrollUpdate.deltaX =
287 data.details.scroll_update.delta_x * scale;
288 gesture.data.scrollUpdate.deltaY =
289 data.details.scroll_update.delta_y * scale;
290 gesture.data.scrollUpdate.velocityX =
291 data.details.scroll_update.velocity_x * scale;
292 gesture.data.scrollUpdate.velocityY =
293 data.details.scroll_update.velocity_y * scale;
294 break;
295 case ui::ET_GESTURE_SCROLL_END:
296 gesture.type = WebInputEvent::GestureScrollEnd;
297 break;
298 case ui::ET_SCROLL_FLING_START:
299 gesture.type = WebInputEvent::GestureFlingStart;
300 gesture.data.flingStart.velocityX =
301 data.details.fling_start.velocity_x * scale;
302 gesture.data.flingStart.velocityY =
303 data.details.fling_start.velocity_y * scale;
304 break;
305 case ui::ET_SCROLL_FLING_CANCEL:
306 gesture.type = WebInputEvent::GestureFlingCancel;
307 break;
308 case ui::ET_GESTURE_PINCH_BEGIN:
309 gesture.type = WebInputEvent::GesturePinchBegin;
310 break;
311 case ui::ET_GESTURE_PINCH_UPDATE:
312 gesture.type = WebInputEvent::GesturePinchUpdate;
313 gesture.data.pinchUpdate.scale = data.details.pinch_update.scale;
314 break;
315 case ui::ET_GESTURE_PINCH_END:
316 gesture.type = WebInputEvent::GesturePinchEnd;
317 break;
318 case ui::ET_GESTURE_TAP_CANCEL:
319 gesture.type = WebInputEvent::GestureTapCancel;
320 break;
321 case ui::ET_GESTURE_TAP_DOWN:
322 gesture.type = WebInputEvent::GestureTapDown;
323 gesture.data.tapDown.width = data.details.tap_down.width * scale;
324 gesture.data.tapDown.height = data.details.tap_down.height * scale;
325 break;
326 default:
327 NOTREACHED() << "ui::EventType provided wasn't a valid gesture event.";
328 break;
329 }
330
331 return gesture;
332 }
333
235 } // namespace content 334 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/web_input_event_util.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698