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

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

Issue 249613002: [DevTools] Interactive test for DevTools touch emulation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DCHECK Created 6 years, 7 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 | Annotate | Revision Log
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 "content/browser/renderer_host/input/touch_emulator.h" 5 #include "content/browser/renderer_host/input/touch_emulator.h"
6 6
7 #include "content/browser/renderer_host/input/motion_event_web.h" 7 #include "content/browser/renderer_host/input/motion_event_web.h"
8 #include "content/browser/renderer_host/input/web_input_event_util.h" 8 #include "content/browser/renderer_host/input/web_input_event_util.h"
9 #include "content/public/common/content_client.h" 9 #include "content/public/common/content_client.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 bool TouchEmulator::FillTouchEventAndPoint(const WebMouseEvent& mouse_event) { 335 bool TouchEmulator::FillTouchEventAndPoint(const WebMouseEvent& mouse_event) {
336 if (mouse_event.type != WebInputEvent::MouseDown && 336 if (mouse_event.type != WebInputEvent::MouseDown &&
337 mouse_event.type != WebInputEvent::MouseMove && 337 mouse_event.type != WebInputEvent::MouseMove &&
338 mouse_event.type != WebInputEvent::MouseUp) { 338 mouse_event.type != WebInputEvent::MouseUp) {
339 return false; 339 return false;
340 } 340 }
341 341
342 touch_event_.touchesLength = 1; 342 touch_event_.touchesLength = 1;
343 touch_event_.timeStampSeconds = mouse_event.timeStampSeconds; 343 touch_event_.timeStampSeconds = mouse_event.timeStampSeconds;
344 if (!touch_event_.timeStampSeconds) {
345 // Gesture detector does not tolerate null timestamps generated in tests.
346 touch_event_.timeStampSeconds =
347 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
348 }
344 touch_event_.modifiers = mouse_event.modifiers; 349 touch_event_.modifiers = mouse_event.modifiers;
345 350
346 WebTouchPoint& point = touch_event_.touches[0]; 351 WebTouchPoint& point = touch_event_.touches[0];
347 point.id = 0; 352 point.id = 0;
348 point.radiusX = point.radiusY = 1.f; 353 point.radiusX = point.radiusY = 1.f;
349 point.force = 1.f; 354 point.force = 1.f;
350 point.rotationAngle = 0.f; 355 point.rotationAngle = 0.f;
351 point.position.x = mouse_event.x; 356 point.position.x = mouse_event.x;
352 point.screenPosition.x = mouse_event.globalX; 357 point.screenPosition.x = mouse_event.globalX;
353 point.position.y = mouse_event.y; 358 point.position.y = mouse_event.y;
(...skipping 18 matching lines...) Expand all
372 NOTREACHED(); 377 NOTREACHED();
373 } 378 }
374 return true; 379 return true;
375 } 380 }
376 381
377 bool TouchEmulator::InPinchGestureMode() const { 382 bool TouchEmulator::InPinchGestureMode() const {
378 return shift_pressed_ && allow_pinch_; 383 return shift_pressed_ && allow_pinch_;
379 } 384 }
380 385
381 } // namespace content 386 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698