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

Side by Side Diff: content/browser/renderer_host/input/web_input_event_builders_android.cc

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Rebase Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " 5 #include "content/browser/renderer_host/input/web_input_event_builders_android.h "
6 6
7 #include <android/input.h> 7 #include <android/input.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/events/android/key_event_utils.h" 10 #include "ui/events/android/key_event_utils.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 JNIEnv* env, 76 JNIEnv* env,
77 const base::android::JavaRef<jobject>& android_key_event, 77 const base::android::JavaRef<jobject>& android_key_event,
78 WebInputEvent::Type type, 78 WebInputEvent::Type type,
79 int modifiers, 79 int modifiers,
80 double time_sec, 80 double time_sec,
81 int keycode, 81 int keycode,
82 int scancode, 82 int scancode,
83 int unicode_character, 83 int unicode_character,
84 bool is_system_key) { 84 bool is_system_key) {
85 DCHECK(WebInputEvent::isKeyboardEventType(type)); 85 DCHECK(WebInputEvent::isKeyboardEventType(type));
86 WebKeyboardEvent result; 86 WebKeyboardEvent result(type, modifiers, time_sec);
87 87
88 ui::DomCode dom_code = ui::DomCode::NONE; 88 ui::DomCode dom_code = ui::DomCode::NONE;
89 if (scancode) 89 if (scancode)
90 dom_code = ui::KeycodeConverter::NativeKeycodeToDomCode(scancode); 90 dom_code = ui::KeycodeConverter::NativeKeycodeToDomCode(scancode);
91 result.type = type;
92 result.modifiers = modifiers;
93 result.timeStampSeconds = time_sec;
94 result.windowsKeyCode = ui::LocatedToNonLocatedKeyboardCode( 91 result.windowsKeyCode = ui::LocatedToNonLocatedKeyboardCode(
95 ui::KeyboardCodeFromAndroidKeyCode(keycode)); 92 ui::KeyboardCodeFromAndroidKeyCode(keycode));
96 result.modifiers |= ui::DomCodeToWebInputEventModifiers(dom_code); 93 result.modifiers |= ui::DomCodeToWebInputEventModifiers(dom_code);
97 result.nativeKeyCode = keycode; 94 result.nativeKeyCode = keycode;
98 result.domCode = static_cast<int>(dom_code); 95 result.domCode = static_cast<int>(dom_code);
99 result.domKey = GetDomKeyFromEvent(env, android_key_event, keycode, modifiers, 96 result.domKey = GetDomKeyFromEvent(env, android_key_event, keycode, modifiers,
100 unicode_character); 97 unicode_character);
101 result.unmodifiedText[0] = unicode_character; 98 result.unmodifiedText[0] = unicode_character;
102 if (result.windowsKeyCode == ui::VKEY_RETURN) { 99 if (result.windowsKeyCode == ui::VKEY_RETURN) {
103 // This is the same behavior as GTK: 100 // This is the same behavior as GTK:
(...skipping 15 matching lines...) Expand all
119 int modifiers, 116 int modifiers,
120 int click_count, 117 int click_count,
121 int pointer_id, 118 int pointer_id,
122 float pressure, 119 float pressure,
123 float orientation_rad, 120 float orientation_rad,
124 float tilt_rad, 121 float tilt_rad,
125 int changed_button, 122 int changed_button,
126 int tool_type) { 123 int tool_type) {
127 124
128 DCHECK(WebInputEvent::isMouseEventType(type)); 125 DCHECK(WebInputEvent::isMouseEventType(type));
129 WebMouseEvent result; 126 WebMouseEvent result(type, ui::EventFlagsToWebEventModifiers(modifiers),
127 time_sec);
130 128
131 result.type = type;
132 result.x = window_x; 129 result.x = window_x;
133 result.y = window_y; 130 result.y = window_y;
134 result.windowX = window_x; 131 result.windowX = window_x;
135 result.windowY = window_y; 132 result.windowY = window_y;
136 result.timeStampSeconds = time_sec;
137 result.clickCount = click_count; 133 result.clickCount = click_count;
138 result.modifiers = ui::EventFlagsToWebEventModifiers(modifiers);
139 134
140 ui::SetWebPointerPropertiesFromMotionEventData( 135 ui::SetWebPointerPropertiesFromMotionEventData(
141 result, 136 result,
142 pointer_id, 137 pointer_id,
143 pressure, 138 pressure,
144 orientation_rad, 139 orientation_rad,
145 tilt_rad, 140 tilt_rad,
146 changed_button, 141 changed_button,
147 tool_type); 142 tool_type);
148 143
149 return result; 144 return result;
150 } 145 }
151 146
152 WebMouseWheelEvent WebMouseWheelEventBuilder::Build(float ticks_x, 147 WebMouseWheelEvent WebMouseWheelEventBuilder::Build(float ticks_x,
153 float ticks_y, 148 float ticks_y,
154 float tick_multiplier, 149 float tick_multiplier,
155 double time_sec, 150 double time_sec,
156 int window_x, 151 int window_x,
157 int window_y) { 152 int window_y) {
158 WebMouseWheelEvent result; 153 WebMouseWheelEvent result(WebInputEvent::MouseWheel,
159 154 WebInputEvent::NoModifiers, time_sec);
160 result.type = WebInputEvent::MouseWheel;
161 result.x = window_x; 155 result.x = window_x;
162 result.y = window_y; 156 result.y = window_y;
163 result.windowX = window_x; 157 result.windowX = window_x;
164 result.windowY = window_y; 158 result.windowY = window_y;
165 result.timeStampSeconds = time_sec;
166 result.button = WebMouseEvent::Button::NoButton; 159 result.button = WebMouseEvent::Button::NoButton;
167 result.hasPreciseScrollingDeltas = true; 160 result.hasPreciseScrollingDeltas = true;
168 result.deltaX = ticks_x * tick_multiplier; 161 result.deltaX = ticks_x * tick_multiplier;
169 result.deltaY = ticks_y * tick_multiplier; 162 result.deltaY = ticks_y * tick_multiplier;
170 result.wheelTicksX = ticks_x; 163 result.wheelTicksX = ticks_x;
171 result.wheelTicksY = ticks_y; 164 result.wheelTicksY = ticks_y;
172 165
173 return result; 166 return result;
174 } 167 }
175 168
176 WebGestureEvent WebGestureEventBuilder::Build(WebInputEvent::Type type, 169 WebGestureEvent WebGestureEventBuilder::Build(WebInputEvent::Type type,
177 double time_sec, 170 double time_sec,
178 int x, 171 int x,
179 int y) { 172 int y) {
180 DCHECK(WebInputEvent::isGestureEventType(type)); 173 DCHECK(WebInputEvent::isGestureEventType(type));
181 WebGestureEvent result; 174 WebGestureEvent result(type, WebInputEvent::NoModifiers, time_sec);
182 175
183 result.type = type;
184 result.x = x; 176 result.x = x;
185 result.y = y; 177 result.y = y;
186 result.timeStampSeconds = time_sec;
187 result.sourceDevice = blink::WebGestureDeviceTouchscreen; 178 result.sourceDevice = blink::WebGestureDeviceTouchscreen;
188 179
189 return result; 180 return result;
190 } 181 }
191 182
192 } // namespace content 183 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698