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

Unified Diff: content/browser/renderer_host/ui_events_helper.cc

Issue 11188012: gesture recognizer: Remove the touch-event queue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 8 years, 2 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
« no previous file with comments | « content/browser/renderer_host/ui_events_helper.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/ui_events_helper.cc
diff --git a/content/browser/renderer_host/ui_events_helper.cc b/content/browser/renderer_host/ui_events_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c6ddf16cb1441cabbff2964fb29ec463d881ffb9
--- /dev/null
+++ b/content/browser/renderer_host/ui_events_helper.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2012 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/ui_events_helper.h"
+
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
+#include "ui/base/events/event.h"
+#include "ui/base/events/event_constants.h"
+
+namespace {
+
+int WebModifiersToUIFlags(int modifiers) {
+ int flags = ui::EF_NONE;
+
+ if (modifiers & WebKit::WebInputEvent::ShiftKey)
+ flags |= ui::EF_SHIFT_DOWN;
+ if (modifiers & WebKit::WebInputEvent::ControlKey)
+ flags |= ui::EF_CONTROL_DOWN;
+ if (modifiers & WebKit::WebInputEvent::AltKey)
+ flags |= ui::EF_ALT_DOWN;
+
+ if (modifiers & WebKit::WebInputEvent::LeftButtonDown)
+ flags |= ui::EF_LEFT_MOUSE_BUTTON;
+ if (modifiers & WebKit::WebInputEvent::RightButtonDown)
+ flags |= ui::EF_RIGHT_MOUSE_BUTTON;
+ if (modifiers & WebKit::WebInputEvent::MiddleButtonDown)
+ flags |= ui::EF_MIDDLE_MOUSE_BUTTON;
+
+ if (modifiers & WebKit::WebInputEvent::CapsLockOn)
+ flags |= ui::EF_CAPS_LOCK_DOWN;
+
+ return flags;
+}
+
+} // namespace
+
+namespace content {
+
+bool MakeUITouchEventsFromWebTouchEvents(const WebKit::WebTouchEvent& touch,
+ ScopedVector<ui::TouchEvent>* list) {
+ ui::EventType type = ui::ET_UNKNOWN;
+ switch (touch.type) {
+ case WebKit::WebInputEvent::TouchStart:
+ type = ui::ET_TOUCH_PRESSED;
+ break;
+ case WebKit::WebInputEvent::TouchEnd:
+ type = ui::ET_TOUCH_RELEASED;
+ break;
+ case WebKit::WebInputEvent::TouchMove:
+ type = ui::ET_TOUCH_MOVED;
+ break;
+ case WebKit::WebInputEvent::TouchCancel:
+ type = ui::ET_TOUCH_CANCELLED;
+ break;
+ default:
+ NOTREACHED();
+ return false;
+ }
+
+ int flags = WebModifiersToUIFlags(touch.modifiers);
+ base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds(
+ static_cast<int64>(touch.timeStampSeconds * 1000000));
+ for (unsigned i = 0; i < touch.touchesLength; ++i) {
+ const WebKit::WebTouchPoint& point = touch.touches[i];
+ ui::TouchEvent* uievent = new ui::TouchEvent(type,
+ gfx::Point(point.position.x, point.position.y),
+ flags,
+ point.id,
+ timestamp,
+ point.radiusX,
+ point.radiusY,
+ point.rotationAngle,
+ point.force);
+ list->push_back(uievent);
+ }
+ return true;
+}
+
+} // namespace content
« no previous file with comments | « content/browser/renderer_host/ui_events_helper.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698