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

Side by Side 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: fix-builds 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/ui_events_helper.h"
6
7 #include <vector>
8
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
10 #include "ui/base/events/event.h"
11 #include "ui/base/events/event_constants.h"
12
13 namespace {
14
15 int WebModifiersToUIFlags(int modifiers) {
16 int flags = ui::EF_NONE;
17
18 if (modifiers & WebKit::WebInputEvent::ShiftKey)
19 flags |= ui::EF_SHIFT_DOWN;
20 if (modifiers & WebKit::WebInputEvent::ControlKey)
21 flags |= ui::EF_CONTROL_DOWN;
22 if (modifiers & WebKit::WebInputEvent::AltKey)
23 flags |= ui::EF_ALT_DOWN;
24
25 if (modifiers & WebKit::WebInputEvent::LeftButtonDown)
26 flags |= ui::EF_LEFT_MOUSE_BUTTON;
27 if (modifiers & WebKit::WebInputEvent::RightButtonDown)
28 flags |= ui::EF_RIGHT_MOUSE_BUTTON;
29 if (modifiers & WebKit::WebInputEvent::MiddleButtonDown)
30 flags |= ui::EF_MIDDLE_MOUSE_BUTTON;
31
32 if (modifiers & WebKit::WebInputEvent::CapsLockOn)
33 flags |= ui::EF_CAPS_LOCK_DOWN;
34
35 return flags;
36 }
37
38 } // namespace
39
40 namespace content {
41
42 bool MakeUITouchEventsFromWebTouchEvents(const WebKit::WebTouchEvent& touch,
43 ScopedVector<ui::TouchEvent>* list) {
44 ui::EventType type = ui::ET_UNKNOWN;
45 switch (touch.type) {
46 case WebKit::WebInputEvent::TouchStart:
47 type = ui::ET_TOUCH_PRESSED;
48 break;
49 case WebKit::WebInputEvent::TouchEnd:
50 type = ui::ET_TOUCH_RELEASED;
51 break;
52 case WebKit::WebInputEvent::TouchMove:
53 type = ui::ET_TOUCH_MOVED;
54 break;
55 case WebKit::WebInputEvent::TouchCancel:
56 type = ui::ET_TOUCH_CANCELLED;
57 break;
58 default:
59 NOTREACHED();
60 return false;
61 }
62
63 int flags = WebModifiersToUIFlags(touch.modifiers);
64 base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds(
65 static_cast<int64>(touch.timeStampSeconds * 1000000));
66 for (unsigned i = 0; i < touch.touchesLength; ++i) {
67 const WebKit::WebTouchPoint& point = touch.touches[i];
68 ui::TouchEvent* uievent = new ui::TouchEvent(type,
69 gfx::Point(point.position.x, point.position.y),
70 flags,
71 point.id,
72 timestamp,
73 point.radiusX,
74 point.radiusY,
75 point.rotationAngle,
76 point.force);
77 list->push_back(uievent);
78 }
79 return true;
80 }
81
82 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698