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

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

Issue 247433003: Mark touchcancel events as uncancelable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: avi CR feedback Created 6 years, 8 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/common/input/web_touch_event_traits.h"
9 #include "content/public/common/content_client.h" 10 #include "content/public/common/content_client.h"
10 #include "content/public/common/content_switches.h" 11 #include "content/public/common/content_switches.h"
11 #include "grit/content_resources.h" 12 #include "grit/content_resources.h"
12 #include "third_party/WebKit/public/platform/WebCursorInfo.h" 13 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
13 #include "ui/events/gesture_detection/gesture_config_helper.h" 14 #include "ui/events/gesture_detection/gesture_config_helper.h"
14 #include "ui/gfx/image/image.h" 15 #include "ui/gfx/image/image.h"
15 #include "ui/gfx/screen.h" 16 #include "ui/gfx/screen.h"
16 17
17 using blink::WebGestureEvent; 18 using blink::WebGestureEvent;
18 using blink::WebInputEvent; 19 using blink::WebInputEvent;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 default: 255 default:
255 // Everything else goes through. 256 // Everything else goes through.
256 client_->ForwardGestureEvent(gesture_event); 257 client_->ForwardGestureEvent(gesture_event);
257 } 258 }
258 } 259 }
259 260
260 void TouchEmulator::CancelTouch() { 261 void TouchEmulator::CancelTouch() {
261 if (!touch_active_) 262 if (!touch_active_)
262 return; 263 return;
263 264
264 touch_event_.timeStampSeconds = 265 WebTouchEventTraits::ResetTypeAndTouchStates(
265 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); 266 WebInputEvent::TouchCancel,
266 touch_event_.type = WebInputEvent::TouchCancel; 267 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(),
267 touch_event_.touches[0].state = WebTouchPoint::StateCancelled; 268 &touch_event_);
268 touch_active_ = false; 269 touch_active_ = false;
269 if (gesture_provider_.OnTouchEvent(MotionEventWeb(touch_event_))) 270 if (gesture_provider_.OnTouchEvent(MotionEventWeb(touch_event_)))
270 client_->ForwardTouchEvent(touch_event_); 271 client_->ForwardTouchEvent(touch_event_);
271 } 272 }
272 273
273 void TouchEmulator::UpdateCursor() { 274 void TouchEmulator::UpdateCursor() {
274 if (!enabled_) 275 if (!enabled_)
275 client_->SetCursor(pointer_cursor_); 276 client_->SetCursor(pointer_cursor_);
276 else 277 else
277 client_->SetCursor(InPinchGestureMode() ? pinch_cursor_ : touch_cursor_); 278 client_->SetCursor(InPinchGestureMode() ? pinch_cursor_ : touch_cursor_);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 client_->ForwardGestureEvent(scroll_event); 333 client_->ForwardGestureEvent(scroll_event);
333 } 334 }
334 335
335 bool TouchEmulator::FillTouchEventAndPoint(const WebMouseEvent& mouse_event) { 336 bool TouchEmulator::FillTouchEventAndPoint(const WebMouseEvent& mouse_event) {
336 if (mouse_event.type != WebInputEvent::MouseDown && 337 if (mouse_event.type != WebInputEvent::MouseDown &&
337 mouse_event.type != WebInputEvent::MouseMove && 338 mouse_event.type != WebInputEvent::MouseMove &&
338 mouse_event.type != WebInputEvent::MouseUp) { 339 mouse_event.type != WebInputEvent::MouseUp) {
339 return false; 340 return false;
340 } 341 }
341 342
343 WebInputEvent::Type eventType;
344 switch (mouse_event.type) {
345 case WebInputEvent::MouseDown:
346 eventType = WebInputEvent::TouchStart;
347 touch_active_ = true;
348 break;
349 case WebInputEvent::MouseMove:
350 eventType = WebInputEvent::TouchMove;
351 break;
352 case WebInputEvent::MouseUp:
353 eventType = WebInputEvent::TouchEnd;
354 break;
355 default:
356 eventType = WebInputEvent::Undefined;
357 NOTREACHED();
358 }
342 touch_event_.touchesLength = 1; 359 touch_event_.touchesLength = 1;
343 touch_event_.timeStampSeconds = mouse_event.timeStampSeconds;
344 touch_event_.modifiers = mouse_event.modifiers; 360 touch_event_.modifiers = mouse_event.modifiers;
361 WebTouchEventTraits::ResetTypeAndTouchStates(
362 eventType, mouse_event.timeStampSeconds, &touch_event_);
345 363
346 WebTouchPoint& point = touch_event_.touches[0]; 364 WebTouchPoint& point = touch_event_.touches[0];
347 point.id = 0; 365 point.id = 0;
348 point.radiusX = point.radiusY = 1.f; 366 point.radiusX = point.radiusY = 1.f;
349 point.force = 1.f; 367 point.force = 1.f;
350 point.rotationAngle = 0.f; 368 point.rotationAngle = 0.f;
351 point.position.x = mouse_event.x; 369 point.position.x = mouse_event.x;
352 point.screenPosition.x = mouse_event.globalX; 370 point.screenPosition.x = mouse_event.globalX;
353 point.position.y = mouse_event.y; 371 point.position.y = mouse_event.y;
354 point.screenPosition.y = mouse_event.globalY; 372 point.screenPosition.y = mouse_event.globalY;
355 373
356 switch (mouse_event.type) {
357 case WebInputEvent::MouseDown:
358 touch_event_.type = WebInputEvent::TouchStart;
359 touch_active_ = true;
360 point.state = WebTouchPoint::StatePressed;
361 break;
362 case WebInputEvent::MouseMove:
363 touch_event_.type = WebInputEvent::TouchMove;
364 point.state = WebTouchPoint::StateMoved;
365 break;
366 case WebInputEvent::MouseUp:
367 touch_event_.type = WebInputEvent::TouchEnd;
368 touch_active_ = false;
369 point.state = WebTouchPoint::StateReleased;
370 break;
371 default:
372 NOTREACHED();
373 }
374 return true; 374 return true;
375 } 375 }
376 376
377 bool TouchEmulator::InPinchGestureMode() const { 377 bool TouchEmulator::InPinchGestureMode() const {
378 return shift_pressed_ && allow_pinch_; 378 return shift_pressed_ && allow_pinch_;
379 } 379 }
380 380
381 } // namespace content 381 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698