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

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

Issue 120513005: [Android] Perform eager gesture recognition on MotionEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More testing Created 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/input/gesture_event_packet.h"
6
7 #include "base/logging.h"
8
9 using blink::WebGestureEvent;
10 using blink::WebInputEvent;
11 using blink::WebTouchEvent;
12 using blink::WebTouchPoint;
13
14 namespace content {
15 namespace {
16
17 bool IsTouchSequenceStart(const WebTouchEvent& event) {
18 if (event.type != WebInputEvent::TouchStart)
19 return false;
20 if (!event.touchesLength)
21 return false;
22 for (size_t i = 0; i < event.touchesLength; i++) {
23 if (event.touches[i].state != WebTouchPoint::StatePressed)
24 return false;
25 }
26 return true;
27 }
28
29 GestureEventPacket::GestureSource
30 ToGestureSource(const WebTouchEvent& event) {
31 return IsTouchSequenceStart(event) ? GestureEventPacket::TOUCH_BEGIN
32 : GestureEventPacket::TOUCH;
33 }
34
35 } // namespace
36
37 GestureEventPacket::GestureEventPacket()
38 : gesture_count_(0),
39 gesture_source_(INVALID) {}
40
41 GestureEventPacket::GestureEventPacket(GestureSource source)
42 : gesture_count_(0),
43 gesture_source_(source) {
44 DCHECK_NE(gesture_source_, INVALID);
45 }
46
47 GestureEventPacket::~GestureEventPacket() {}
48
49 void GestureEventPacket::Push(const blink::WebGestureEvent& gesture) {
50 CHECK_LT(gesture_count_, static_cast<size_t>(kMaxGesturesPerTouch));
51 gestures_[gesture_count_++] = gesture;
52 }
53
54 GestureEventPacket GestureEventPacket::FromTouch(const WebTouchEvent& event) {
55 return GestureEventPacket(ToGestureSource(event));
56 }
57
58 GestureEventPacket GestureEventPacket::FromTouchTimeout(
59 const WebGestureEvent& event) {
60 GestureEventPacket packet(TOUCH_TIMEOUT);
61 packet.Push(event);
62 return packet;
63 }
64
65 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/gesture_event_packet.h ('k') | content/browser/renderer_host/input/gesture_event_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698