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

Side by Side Diff: Source/web/android/WebInputEventFactory.cpp

Issue 27462002: Remove web/{android, gtk, win} (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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
« no previous file with comments | « Source/web/WebInputEventFactoryWin.cpp ('k') | Source/web/gtk/WebInputEventFactory.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "WebInputEventFactory.h"
33
34 #include "WebInputEvent.h"
35 #include "core/platform/chromium/KeyCodeConversion.h"
36 #include "core/platform/chromium/KeyboardCodes.h"
37 #include "wtf/Assertions.h"
38
39 namespace WebKit {
40
41 WebKeyboardEvent WebInputEventFactory::keyboardEvent(WebInputEvent::Type type,
42 int modifiers,
43 double timeStampSeconds,
44 int keycode,
45 WebUChar unicodeCharacter,
46 bool isSystemKey)
47 {
48 WebKeyboardEvent result;
49
50 result.type = type;
51 result.modifiers = modifiers;
52 result.timeStampSeconds = timeStampSeconds;
53 int windowsKeyCode = WebCore::windowsKeyCodeForKeyEvent(keycode);
54 result.windowsKeyCode = WebKeyboardEvent::windowsKeyCodeWithoutLocation(wind owsKeyCode);
55 result.modifiers |= WebKeyboardEvent::locationModifiersFromWindowsKeyCode(wi ndowsKeyCode);
56 result.nativeKeyCode = keycode;
57 result.unmodifiedText[0] = unicodeCharacter;
58 if (result.windowsKeyCode == WebCore::VKEY_RETURN) {
59 // This is the same behavior as GTK:
60 // We need to treat the enter key as a key press of character \r. This
61 // is apparently just how webkit handles it and what it expects.
62 result.unmodifiedText[0] = '\r';
63 }
64 result.text[0] = result.unmodifiedText[0];
65 result.setKeyIdentifierFromWindowsKeyCode();
66 result.isSystemKey = isSystemKey;
67
68 return result;
69 }
70
71 WebMouseEvent WebInputEventFactory::mouseEvent(MouseEventType type,
72 WebMouseEvent::Button button,
73 double timeStampSeconds,
74 int windowX,
75 int windowY,
76 int modifiers,
77 int clickCount)
78 {
79 WebMouseEvent result;
80
81 result.x = windowX;
82 result.y = windowY;
83 result.windowX = windowX;
84 result.windowY = windowY;
85 result.timeStampSeconds = timeStampSeconds;
86 result.clickCount = clickCount;
87 result.modifiers = modifiers;
88
89 switch (type) {
90 case MouseEventTypeDown:
91 result.type = WebInputEvent::MouseDown;
92 result.button = button;
93 break;
94 case MouseEventTypeUp:
95 result.type = WebInputEvent::MouseUp;
96 result.button = button;
97 break;
98 case MouseEventTypeMove:
99 result.type = WebInputEvent::MouseMove;
100 result.button = WebMouseEvent::ButtonNone;
101 break;
102 };
103
104 return result;
105 }
106
107 // WebMouseWheelEvent ---------------------------------------------------------- --
108
109 WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(MouseWheelDirectionType direction,
110 double timeStampSeconds ,
111 int windowX,
112 int windowY)
113 {
114 WebMouseWheelEvent result;
115
116 result.type = WebInputEvent::MouseWheel;
117 result.x = windowX;
118 result.y = windowY;
119 result.windowX = windowX;
120 result.windowY = windowY;
121 result.timeStampSeconds = timeStampSeconds;
122 result.button = WebMouseEvent::ButtonNone;
123
124 // The below choices are matched from GTK.
125 static const float scrollbarPixelsPerTick = 160.0f / 3.0f;
126
127 switch (direction) {
128 case MouseWheelDirectionTypeUp:
129 result.deltaY = scrollbarPixelsPerTick;
130 result.wheelTicksY = 1;
131 break;
132 case MouseWheelDirectionTypeDown:
133 result.deltaY = -scrollbarPixelsPerTick;
134 result.wheelTicksY = -1;
135 break;
136 case MouseWheelDirectionTypeLeft:
137 result.deltaX = scrollbarPixelsPerTick;
138 result.wheelTicksX = 1;
139 break;
140 case MouseWheelDirectionTypeRight:
141 result.deltaX = -scrollbarPixelsPerTick;
142 result.wheelTicksX = -1;
143 break;
144 }
145
146 return result;
147 }
148
149 // WebGestureEvent ------------------------------------------------------------
150
151 // FIXME: remove this obsolete version
152 WebGestureEvent WebInputEventFactory::gestureEvent(WebInputEvent::Type type,
153 double timeStampSeconds,
154 int x,
155 int y,
156 float,
157 float,
158 int modifiers) {
159 return gestureEvent(type, timeStampSeconds, x, y, modifiers);
160 }
161
162 WebGestureEvent WebInputEventFactory::gestureEvent(WebInputEvent::Type type,
163 double timeStampSeconds,
164 int x,
165 int y,
166 int modifiers)
167 {
168 WebGestureEvent result;
169
170 result.type = type;
171 result.x = x;
172 result.y = y;
173 result.timeStampSeconds = timeStampSeconds;
174 result.modifiers = modifiers;
175
176 return result;
177 }
178
179 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/web/WebInputEventFactoryWin.cpp ('k') | Source/web/gtk/WebInputEventFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698