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

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

Issue 2639623002: Fixed Android text selection by redefining |button| value. (Closed)
Patch Set: Fixed WebPointerProperties comment. Created 3 years, 10 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"
11 #include "ui/events/android/motion_event_android.h" 11 #include "ui/events/android/motion_event_android.h"
12 #include "ui/events/blink/blink_event_util.h" 12 #include "ui/events/blink/blink_event_util.h"
13 #include "ui/events/event_constants.h"
13 #include "ui/events/keycodes/dom/dom_code.h" 14 #include "ui/events/keycodes/dom/dom_code.h"
14 #include "ui/events/keycodes/dom/keycode_converter.h" 15 #include "ui/events/keycodes/dom/keycode_converter.h"
15 #include "ui/events/keycodes/keyboard_code_conversion.h" 16 #include "ui/events/keycodes/keyboard_code_conversion.h"
16 #include "ui/events/keycodes/keyboard_code_conversion_android.h" 17 #include "ui/events/keycodes/keyboard_code_conversion_android.h"
17 #include "ui/events/keycodes/keyboard_codes_posix.h" 18 #include "ui/events/keycodes/keyboard_codes_posix.h"
18 19
19 using blink::WebInputEvent; 20 using blink::WebInputEvent;
20 using blink::WebKeyboardEvent; 21 using blink::WebKeyboardEvent;
21 using blink::WebGestureEvent; 22 using blink::WebGestureEvent;
22 using blink::WebMouseEvent; 23 using blink::WebMouseEvent;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // We need to treat the enter key as a key press of character \r. This 104 // We need to treat the enter key as a key press of character \r. This
104 // is apparently just how webkit handles it and what it expects. 105 // is apparently just how webkit handles it and what it expects.
105 result.unmodifiedText[0] = '\r'; 106 result.unmodifiedText[0] = '\r';
106 } 107 }
107 result.text[0] = result.unmodifiedText[0]; 108 result.text[0] = result.unmodifiedText[0];
108 result.isSystemKey = is_system_key; 109 result.isSystemKey = is_system_key;
109 110
110 return result; 111 return result;
111 } 112 }
112 113
113 WebMouseEvent WebMouseEventBuilder::Build( 114 WebMouseEvent WebMouseEventBuilder::Build(WebInputEvent::Type type,
114 WebInputEvent::Type type, 115 double time_sec,
115 double time_sec, 116 int window_x,
116 int window_x, 117 int window_y,
117 int window_y, 118 int modifiers,
118 int modifiers, 119 int click_count,
119 int click_count, 120 int pointer_id,
120 int pointer_id, 121 float pressure,
121 float pressure, 122 float orientation_rad,
122 float orientation_rad, 123 float tilt_rad,
123 float tilt_rad, 124 int action_button,
124 int changed_button, 125 int tool_type) {
125 int tool_type) {
126
127 DCHECK(WebInputEvent::isMouseEventType(type)); 126 DCHECK(WebInputEvent::isMouseEventType(type));
128 WebMouseEvent result(type, ui::EventFlagsToWebEventModifiers(modifiers), 127 WebMouseEvent result(type, ui::EventFlagsToWebEventModifiers(modifiers),
129 time_sec); 128 time_sec);
130 129
131 result.x = window_x; 130 result.x = window_x;
132 result.y = window_y; 131 result.y = window_y;
133 result.windowX = window_x; 132 result.windowX = window_x;
134 result.windowY = window_y; 133 result.windowY = window_y;
135 result.clickCount = click_count; 134 result.clickCount = click_count;
136 135
137 ui::SetWebPointerPropertiesFromMotionEventData( 136 int button = action_button;
138 result, 137 // For events other than MouseDown/Up, action_button is not defined. So we are
139 pointer_id, 138 // determining |button| value from |modifiers| as is done in other platforms.
140 pressure, 139 if (type != WebInputEvent::MouseDown && type != WebInputEvent::MouseUp) {
141 orientation_rad, 140 if (modifiers & ui::EF_LEFT_MOUSE_BUTTON)
142 tilt_rad, 141 button = ui::MotionEvent::BUTTON_PRIMARY;
143 changed_button, 142 else if (modifiers & ui::EF_MIDDLE_MOUSE_BUTTON)
144 tool_type); 143 button = ui::MotionEvent::BUTTON_TERTIARY;
144 else if (modifiers & ui::EF_RIGHT_MOUSE_BUTTON)
145 button = ui::MotionEvent::BUTTON_SECONDARY;
146 else
147 button = 0;
148 }
149
150 ui::SetWebPointerPropertiesFromMotionEventData(result, pointer_id, pressure,
151 orientation_rad, tilt_rad,
152 button, tool_type);
145 153
146 return result; 154 return result;
147 } 155 }
148 156
149 WebMouseWheelEvent WebMouseWheelEventBuilder::Build(float ticks_x, 157 WebMouseWheelEvent WebMouseWheelEventBuilder::Build(float ticks_x,
150 float ticks_y, 158 float ticks_y,
151 float tick_multiplier, 159 float tick_multiplier,
152 double time_sec, 160 double time_sec,
153 int window_x, 161 int window_x,
154 int window_y) { 162 int window_y) {
(...skipping 21 matching lines...) Expand all
176 WebGestureEvent result(type, WebInputEvent::NoModifiers, time_sec); 184 WebGestureEvent result(type, WebInputEvent::NoModifiers, time_sec);
177 185
178 result.x = x; 186 result.x = x;
179 result.y = y; 187 result.y = y;
180 result.sourceDevice = blink::WebGestureDeviceTouchscreen; 188 result.sourceDevice = blink::WebGestureDeviceTouchscreen;
181 189
182 return result; 190 return result;
183 } 191 }
184 192
185 } // namespace content 193 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698