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

Side by Side Diff: content/browser/renderer_host/web_input_event_factory_android.cc

Issue 19776016: Add files. Does not compile yet! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk links, may not work correctly Created 7 years, 5 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) 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/web_input_event_factory_android.h"
6
7 #include "third_party/WebKit/public/web/WebInputEvent.h"
8 #include "ui/base/keycodes/keyboard_codes_posix.h"
9 #include "ui/base/keycodes/keyboard_code_conversion.h"
10
11 namespace content {
12
13 using WebKit::WebInputEvent;
14 using WebKit::WebKeyboardEvent;
15 using WebKit::WebGestureEvent;
16 using WebKit::WebMouseEvent;
17 using WebKit::WebMouseWheelEvent;
18
19 WebKeyboardEvent WebInputEventFactory::keyboardEvent(WebInputEvent::Type type,
20 int modifiers,
21 double time_sec,
22 int keycode,
23 int unicodeCharacter,
24 bool isSystemKey) {
25 WebKeyboardEvent result;
26
27 result.type = type;
28 result.modifiers = modifiers;
29 result.timeStampSeconds = time_sec;
30 int windows_key_code = ui::GetCharacterFromKeyCode(keycode, modifiers);
31 //int windows_key_code = WebCore::windowsKeyCodeForKeyEvent(keycode);
32 //result.windowsKeyCode =
33 // WebKeyboardEvent::windowsKeyCodeWithoutLocation(windows_key_code);
34 //result.modifiers |=
35 // WebKeyboardEvent::locationModifiersFromWindowsKeyCode(windows_key_code);
36 result.nativeKeyCode = keycode;
37 result.unmodifiedText[0] = unicodeCharacter;
38 if (result.windowsKeyCode == ui::VKEY_RETURN) {
39 // This is the same behavior as GTK:
40 // We need to treat the enter key as a key press of character \r. This
41 // is apparently just how webkit handles it and what it expects.
42 result.unmodifiedText[0] = '\r';
43 }
44 result.text[0] = result.unmodifiedText[0];
45 result.setKeyIdentifierFromWindowsKeyCode();
46 result.isSystemKey = isSystemKey;
47
48 return result;
49 }
50
51 WebMouseEvent WebInputEventFactory::mouseEvent(MouseEventType type,
52 WebMouseEvent::Button button,
53 double time_sec,
54 int windowX,
55 int windowY,
56 int modifiers,
57 int clickCount) {
58 WebMouseEvent result;
59
60 result.x = windowX;
61 result.y = windowY;
62 result.windowX = windowX;
63 result.windowY = windowY;
64 result.timeStampSeconds = time_sec;
65 result.clickCount = clickCount;
66 result.modifiers = modifiers;
67
68 switch (type) {
69 case MouseEventTypeDown:
70 result.type = WebInputEvent::MouseDown;
71 result.button = button;
72 break;
73 case MouseEventTypeUp:
74 result.type = WebInputEvent::MouseUp;
75 result.button = button;
76 break;
77 case MouseEventTypeMove:
78 result.type = WebInputEvent::MouseMove;
79 result.button = WebMouseEvent::ButtonNone;
80 break;
81 }
82 ;
83
84 return result;
85 }
86
87 // WebMouseWheelEvent
88 // ------------------------------------------------------------
89
90 WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(
91 MouseWheelDirectionType direction,
92 double time_sec,
93 int windowX,
94 int windowY) {
95 WebMouseWheelEvent result;
96
97 result.type = WebInputEvent::MouseWheel;
98 result.x = windowX;
99 result.y = windowY;
100 result.windowX = windowX;
101 result.windowY = windowY;
102 result.time_sec = time_sec;
103 result.button = WebMouseEvent::ButtonNone;
104
105 // The below choices are matched from GTK.
106 static const float scrollbarPixelsPerTick = 160.0f / 3.0f;
107
108 switch (direction) {
109 case MouseWheelDirectionTypeUp:
110 result.deltaY = scrollbarPixelsPerTick;
111 result.wheelTicksY = 1;
112 break;
113 case MouseWheelDirectionTypeDown:
114 result.deltaY = -scrollbarPixelsPerTick;
115 result.wheelTicksY = -1;
116 break;
117 case MouseWheelDirectionTypeLeft:
118 result.deltaX = scrollbarPixelsPerTick;
119 result.wheelTicksX = 1;
120 break;
121 case MouseWheelDirectionTypeRight:
122 result.deltaX = -scrollbarPixelsPerTick;
123 result.wheelTicksX = -1;
124 break;
125 }
126
127 return result;
128 }
129
130 // WebGestureEvent ------------------------------------------------------------
131
132 // FIXME: remove this obsolete version
133 WebGestureEvent WebInputEventFactory::gestureEvent(WebInputEvent::Type type,
134 double time_sec,
135 int x,
136 int y,
137 float,
138 float,
139 int modifiers) {
140 return gestureEvent(type, time_sec, x, y, modifiers);
141 }
142
143 WebGestureEvent WebInputEventFactory::gestureEvent(WebInputEvent::Type type,
144 double time_sec,
145 int x,
146 int y,
147 int modifiers) {
148 WebGestureEvent result;
149
150 result.type = type;
151 result.x = x;
152 result.y = y;
153 result.time_sec = time_sec;
154 result.modifiers = modifiers;
155
156 return result;
157 }
158
159 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698