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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/gesture_event_packet.cc
diff --git a/content/browser/renderer_host/input/gesture_event_packet.cc b/content/browser/renderer_host/input/gesture_event_packet.cc
new file mode 100644
index 0000000000000000000000000000000000000000..31a5fca6b26389391e5c44bb232ea6ba29c706f0
--- /dev/null
+++ b/content/browser/renderer_host/input/gesture_event_packet.cc
@@ -0,0 +1,65 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/input/gesture_event_packet.h"
+
+#include "base/logging.h"
+
+using blink::WebGestureEvent;
+using blink::WebInputEvent;
+using blink::WebTouchEvent;
+using blink::WebTouchPoint;
+
+namespace content {
+namespace {
+
+bool IsTouchSequenceStart(const WebTouchEvent& event) {
+ if (event.type != WebInputEvent::TouchStart)
+ return false;
+ if (!event.touchesLength)
+ return false;
+ for (size_t i = 0; i < event.touchesLength; i++) {
+ if (event.touches[i].state != WebTouchPoint::StatePressed)
+ return false;
+ }
+ return true;
+}
+
+GestureEventPacket::GestureSource
+ToGestureSource(const WebTouchEvent& event) {
+ return IsTouchSequenceStart(event) ? GestureEventPacket::TOUCH_BEGIN
+ : GestureEventPacket::TOUCH;
+}
+
+} // namespace
+
+GestureEventPacket::GestureEventPacket()
+ : gesture_count_(0),
+ gesture_source_(INVALID) {}
+
+GestureEventPacket::GestureEventPacket(GestureSource source)
+ : gesture_count_(0),
+ gesture_source_(source) {
+ DCHECK_NE(gesture_source_, INVALID);
+}
+
+GestureEventPacket::~GestureEventPacket() {}
+
+void GestureEventPacket::Push(const blink::WebGestureEvent& gesture) {
+ CHECK_LT(gesture_count_, static_cast<size_t>(kMaxGesturesPerTouch));
+ gestures_[gesture_count_++] = gesture;
+}
+
+GestureEventPacket GestureEventPacket::FromTouch(const WebTouchEvent& event) {
+ return GestureEventPacket(ToGestureSource(event));
+}
+
+GestureEventPacket GestureEventPacket::FromTouchTimeout(
+ const WebGestureEvent& event) {
+ GestureEventPacket packet(TOUCH_TIMEOUT);
+ packet.Push(event);
+ return packet;
+}
+
+} // namespace content
« 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