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

Side by Side Diff: webkit/tools/test_shell/event_sending_controller.cc

Issue 1818: Bulk fixes to get Mac Test Shell more compile-happy. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This file contains the definition for EventSendingController. 5 // This file contains the definition for EventSendingController.
6 // 6 //
7 // Some notes about drag and drop handling: 7 // Some notes about drag and drop handling:
8 // Windows drag and drop goes through a system call to DoDragDrop. At that 8 // Windows drag and drop goes through a system call to DoDragDrop. At that
9 // point, program control is given to Windows which then periodically makes 9 // point, program control is given to Windows which then periodically makes
10 // callbacks into the webview. This won't work for layout tests, so instead, 10 // callbacks into the webview. This won't work for layout tests, so instead,
11 // we queue up all the mouse move and mouse up events. When the test tries to 11 // we queue up all the mouse move and mouse up events. When the test tries to
12 // start a drag (by calling EvenSendingController::DoDragDrop), we take the 12 // start a drag (by calling EvenSendingController::DoDragDrop), we take the
13 // events in the queue and replay them. 13 // events in the queue and replay them.
14 // The behavior of queueing events and replaying them can be disabled by a 14 // The behavior of queueing events and replaying them can be disabled by a
15 // layout test by setting eventSender.dragMode to false. 15 // layout test by setting eventSender.dragMode to false.
16 16
17 #include "webkit/tools/test_shell/event_sending_controller.h" 17 #include "webkit/tools/test_shell/event_sending_controller.h"
18 18
19 #if defined(OS_WIN)
19 #include <objidl.h> 20 #include <objidl.h>
21 #endif
20 #include <queue> 22 #include <queue>
21 23
22 #include "base/ref_counted.h" 24 #include "base/ref_counted.h"
23 #include "base/string_util.h" 25 #include "base/string_util.h"
26 #include "base/time.h"
24 #include "webkit/glue/webview.h" 27 #include "webkit/glue/webview.h"
25 #include "webkit/tools/test_shell/test_shell.h" 28 #include "webkit/tools/test_shell/test_shell.h"
26 29
27 // TODO(mpcomplete): layout before each event? 30 // TODO(mpcomplete): layout before each event?
28 // TODO(mpcomplete): do we need modifiers for mouse events? 31 // TODO(mpcomplete): do we need modifiers for mouse events?
29 32
30 TestShell* EventSendingController::shell_ = NULL; 33 TestShell* EventSendingController::shell_ = NULL;
31 gfx::Point EventSendingController::last_mouse_pos_; 34 gfx::Point EventSendingController::last_mouse_pos_;
32 WebMouseEvent::Button EventSendingController::pressed_button_ = 35 WebMouseEvent::Button EventSendingController::pressed_button_ =
33 WebMouseEvent::BUTTON_NONE; 36 WebMouseEvent::BUTTON_NONE;
34 37
35 namespace { 38 namespace {
36 39
40 #if defined(OS_WIN)
37 static scoped_refptr<IDataObject> drag_data_object; 41 static scoped_refptr<IDataObject> drag_data_object;
42 #elif defined(OS_MACOSX)
43 // Throughout this file, drag support is #ifdef-ed out. TODO(port): Add it in
44 // for the Mac.
45 #endif
38 static bool replaying_saved_events = false; 46 static bool replaying_saved_events = false;
39 static std::queue<WebMouseEvent> mouse_event_queue; 47 static std::queue<WebMouseEvent> mouse_event_queue;
40 48
41 // Time and place of the last mouse up event. 49 // Time and place of the last mouse up event.
42 static double last_click_time_sec = 0; 50 static double last_click_time_sec = 0;
43 static gfx::Point last_click_pos; 51 static gfx::Point last_click_pos;
44 static int click_count = 0; 52 static int click_count = 0;
45 53
46 // maximum distance (in space and time) for a mouse click 54 // maximum distance (in space and time) for a mouse click
47 // to register as a double or triple click 55 // to register as a double or triple click
48 static const double kMultiClickTimeSec = 1; 56 static const double kMultiClickTimeSec = 1;
49 static const int kMultiClickRadiusPixels = 5; 57 static const int kMultiClickRadiusPixels = 5;
50 58
51 inline bool outside_multiclick_radius(const gfx::Point &a, const gfx::Point &b) { 59 inline bool outside_multiclick_radius(const gfx::Point &a, const gfx::Point &b) {
52 return ((a.x() - b.x()) * (a.x() - b.x()) + (a.y() - b.y()) * (a.y() - b.y())) > 60 return ((a.x() - b.x()) * (a.x() - b.x()) + (a.y() - b.y()) * (a.y() - b.y())) >
53 kMultiClickRadiusPixels * kMultiClickRadiusPixels; 61 kMultiClickRadiusPixels * kMultiClickRadiusPixels;
54 } 62 }
55 63
56 // Used to offset the time the event hander things an event happened. This is 64 // Used to offset the time the event hander things an event happened. This is
57 // done so tests can run without a delay, but bypass checks that are time 65 // done so tests can run without a delay, but bypass checks that are time
58 // dependent (e.g., dragging has a timeout vs selection). 66 // dependent (e.g., dragging has a timeout vs selection).
59 static uint32 time_offset_ms = 0; 67 static uint32 time_offset_ms = 0;
60 68
61 double GetCurrentEventTimeSec() { 69 double GetCurrentEventTimeSec() {
62 return (GetTickCount() + time_offset_ms) / 1000.0; 70 return (TimeTicks::Now().ToInternalValue()
71 / Time::kMicrosecondsPerMillisecond +
72 time_offset_ms) / 1000.0;
63 } 73 }
64 74
65 void AdvanceEventTime(int32 delta_ms) { 75 void AdvanceEventTime(int32 delta_ms) {
66 time_offset_ms += delta_ms; 76 time_offset_ms += delta_ms;
67 } 77 }
68 78
69 void InitMouseEvent(WebInputEvent::Type t, WebMouseEvent::Button b, 79 void InitMouseEvent(WebInputEvent::Type t, WebMouseEvent::Button b,
70 const gfx::Point& pos, WebMouseEvent* e) { 80 const gfx::Point& pos, WebMouseEvent* e) {
71 e->type = t; 81 e->type = t;
72 e->button = b; 82 e->button = b;
(...skipping 10 matching lines...) Expand all
83 std::vector<std::wstring> args = arg->ToStringVector(); 93 std::vector<std::wstring> args = arg->ToStringVector();
84 for (std::vector<std::wstring>::iterator i = args.begin(); 94 for (std::vector<std::wstring>::iterator i = args.begin();
85 i != args.end(); ++i) { 95 i != args.end(); ++i) {
86 const wchar_t* arg_string = (*i).c_str(); 96 const wchar_t* arg_string = (*i).c_str();
87 if (!wcscmp(arg_string, L"ctrlKey")) { 97 if (!wcscmp(arg_string, L"ctrlKey")) {
88 event->modifiers |= WebInputEvent::CTRL_KEY; 98 event->modifiers |= WebInputEvent::CTRL_KEY;
89 } else if (!wcscmp(arg_string, L"shiftKey")) { 99 } else if (!wcscmp(arg_string, L"shiftKey")) {
90 event->modifiers |= WebInputEvent::SHIFT_KEY; 100 event->modifiers |= WebInputEvent::SHIFT_KEY;
91 } else if (!wcscmp(arg_string, L"altKey")) { 101 } else if (!wcscmp(arg_string, L"altKey")) {
92 event->modifiers |= WebInputEvent::ALT_KEY; 102 event->modifiers |= WebInputEvent::ALT_KEY;
103 #if defined(OS_WIN)
93 event->system_key = true; 104 event->system_key = true;
105 #endif
94 } else if (!wcscmp(arg_string, L"metaKey")) { 106 } else if (!wcscmp(arg_string, L"metaKey")) {
95 event->modifiers |= WebInputEvent::META_KEY; 107 event->modifiers |= WebInputEvent::META_KEY;
96 } 108 }
97 } 109 }
98 } 110 }
99 111
100 } // anonymous namespace 112 } // anonymous namespace
101 113
102 EventSendingController::EventSendingController(TestShell* shell) { 114 EventSendingController::EventSendingController(TestShell* shell) {
103 // Set static shell_ variable since we can't do it in an initializer list. 115 // Set static shell_ variable since we can't do it in an initializer list.
(...skipping 18 matching lines...) Expand all
122 BindMethod("textZoomIn", &EventSendingController::textZoomIn); 134 BindMethod("textZoomIn", &EventSendingController::textZoomIn);
123 BindMethod("textZoomOut", &EventSendingController::textZoomOut); 135 BindMethod("textZoomOut", &EventSendingController::textZoomOut);
124 136
125 // When set to true (the default value), we batch mouse move and mouse up 137 // When set to true (the default value), we batch mouse move and mouse up
126 // events so we can simulate drag & drop. 138 // events so we can simulate drag & drop.
127 BindProperty("dragMode", &dragMode); 139 BindProperty("dragMode", &dragMode);
128 } 140 }
129 141
130 void EventSendingController::Reset() { 142 void EventSendingController::Reset() {
131 // The test should have finished a drag and the mouse button state. 143 // The test should have finished a drag and the mouse button state.
144 #if defined(OS_WIN)
132 DCHECK(!drag_data_object); 145 DCHECK(!drag_data_object);
133 drag_data_object = NULL; 146 drag_data_object = NULL;
147 #endif
134 pressed_button_ = WebMouseEvent::BUTTON_NONE; 148 pressed_button_ = WebMouseEvent::BUTTON_NONE;
135 dragMode.Set(true); 149 dragMode.Set(true);
136 last_click_time_sec = 0; 150 last_click_time_sec = 0;
137 click_count = 0; 151 click_count = 0;
138 } 152 }
139 153
140 /* static */ WebView* EventSendingController::webview() { 154 /* static */ WebView* EventSendingController::webview() {
141 return shell_->webView(); 155 return shell_->webView();
142 } 156 }
143 157
158 #if defined(OS_WIN)
144 /* static */ void EventSendingController::DoDragDrop(IDataObject* data_obj) { 159 /* static */ void EventSendingController::DoDragDrop(IDataObject* data_obj) {
145 drag_data_object = data_obj; 160 drag_data_object = data_obj;
146 161
147 DWORD effect = 0; 162 DWORD effect = 0;
148 POINTL screen_ptl = {0, 0}; 163 POINTL screen_ptl = {0, 0};
149 TestWebViewDelegate* delegate = shell_->delegate(); 164 TestWebViewDelegate* delegate = shell_->delegate();
150 delegate->drop_delegate()->DragEnter(drag_data_object, MK_LBUTTON, 165 delegate->drop_delegate()->DragEnter(drag_data_object, MK_LBUTTON,
151 screen_ptl, &effect); 166 screen_ptl, &effect);
152 167
153 // Finish processing events. 168 // Finish processing events.
154 ReplaySavedEvents(); 169 ReplaySavedEvents();
155 } 170 }
171 #endif
156 172
157 // static 173 // static
158 WebMouseEvent::Button EventSendingController::GetButtonTypeFromSingleArg( 174 WebMouseEvent::Button EventSendingController::GetButtonTypeFromSingleArg(
159 const CppArgumentList& args) { 175 const CppArgumentList& args) {
160 if (args.size() > 0 && args[0].isNumber()) { 176 if (args.size() > 0 && args[0].isNumber()) {
161 int button_code = args[0].ToInt32(); 177 int button_code = args[0].ToInt32();
162 if (button_code == 1) 178 if (button_code == 1)
163 return WebMouseEvent::BUTTON_MIDDLE; 179 return WebMouseEvent::BUTTON_MIDDLE;
164 else if (button_code == 2) 180 else if (button_code == 2)
165 return WebMouseEvent::BUTTON_RIGHT; 181 return WebMouseEvent::BUTTON_RIGHT;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 228 }
213 229
214 last_click_time_sec = event.timestamp_sec; 230 last_click_time_sec = event.timestamp_sec;
215 last_click_pos = gfx::Point(event.x, event.y); 231 last_click_pos = gfx::Point(event.x, event.y);
216 } 232 }
217 233
218 /* static */ void EventSendingController::DoMouseUp(const WebMouseEvent& e) { 234 /* static */ void EventSendingController::DoMouseUp(const WebMouseEvent& e) {
219 webview()->HandleInputEvent(&e); 235 webview()->HandleInputEvent(&e);
220 pressed_button_ = WebMouseEvent::BUTTON_NONE; 236 pressed_button_ = WebMouseEvent::BUTTON_NONE;
221 237
238 #if defined(OS_WIN)
222 // If we're in a drag operation, complete it. 239 // If we're in a drag operation, complete it.
223 if (drag_data_object) { 240 if (drag_data_object) {
224 TestWebViewDelegate* delegate = shell_->delegate(); 241 TestWebViewDelegate* delegate = shell_->delegate();
225 // Get screen mouse position. 242 // Get screen mouse position.
226 POINT screen_pt = { static_cast<LONG>(e.x), 243 POINT screen_pt = { static_cast<LONG>(e.x),
227 static_cast<LONG>(e.y) }; 244 static_cast<LONG>(e.y) };
228 ClientToScreen(shell_->webViewWnd(), &screen_pt); 245 ClientToScreen(shell_->webViewWnd(), &screen_pt);
229 POINTL screen_ptl = { screen_pt.x, screen_pt.y }; 246 POINTL screen_ptl = { screen_pt.x, screen_pt.y };
230 247
231 DWORD effect = 0; 248 DWORD effect = 0;
232 delegate->drop_delegate()->DragOver(0, screen_ptl, &effect); 249 delegate->drop_delegate()->DragOver(0, screen_ptl, &effect);
233 HRESULT hr = delegate->drag_delegate()->QueryContinueDrag(0, 0); 250 HRESULT hr = delegate->drag_delegate()->QueryContinueDrag(0, 0);
234 if (hr == DRAGDROP_S_DROP && effect != DROPEFFECT_NONE) { 251 if (hr == DRAGDROP_S_DROP && effect != DROPEFFECT_NONE) {
235 DWORD effect = 0; 252 DWORD effect = 0;
236 delegate->drop_delegate()->Drop(drag_data_object.get(), 0, screen_ptl, 253 delegate->drop_delegate()->Drop(drag_data_object.get(), 0, screen_ptl,
237 &effect); 254 &effect);
238 } else { 255 } else {
239 delegate->drop_delegate()->DragLeave(); 256 delegate->drop_delegate()->DragLeave();
240 } 257 }
241 drag_data_object = NULL; 258 drag_data_object = NULL;
242 } 259 }
260 #endif
243 } 261 }
244 262
245 void EventSendingController::mouseMoveTo( 263 void EventSendingController::mouseMoveTo(
246 const CppArgumentList& args, CppVariant* result) { 264 const CppArgumentList& args, CppVariant* result) {
247 result->SetNull(); 265 result->SetNull();
248 266
249 if (args.size() >= 2 && args[0].isNumber() && args[1].isNumber()) { 267 if (args.size() >= 2 && args[0].isNumber() && args[1].isNumber()) {
250 webview()->Layout(); 268 webview()->Layout();
251 269
252 WebMouseEvent event; 270 WebMouseEvent event;
253 last_mouse_pos_.SetPoint(args[0].ToInt32(), args[1].ToInt32()); 271 last_mouse_pos_.SetPoint(args[0].ToInt32(), args[1].ToInt32());
254 InitMouseEvent(WebInputEvent::MOUSE_MOVE, pressed_button_, 272 InitMouseEvent(WebInputEvent::MOUSE_MOVE, pressed_button_,
255 last_mouse_pos_, &event); 273 last_mouse_pos_, &event);
256 274
257 if (drag_mode() && pressed_button_ != WebMouseEvent::BUTTON_NONE && 275 if (drag_mode() && pressed_button_ != WebMouseEvent::BUTTON_NONE &&
258 !replaying_saved_events) { 276 !replaying_saved_events) {
259 mouse_event_queue.push(event); 277 mouse_event_queue.push(event);
260 } else { 278 } else {
261 DoMouseMove(event); 279 DoMouseMove(event);
262 } 280 }
263 } 281 }
264 } 282 }
265 283
266 /* static */ void EventSendingController::DoMouseMove(const WebMouseEvent& e) { 284 /* static */ void EventSendingController::DoMouseMove(const WebMouseEvent& e) {
267 webview()->HandleInputEvent(&e); 285 webview()->HandleInputEvent(&e);
268 286
287 #if defined(OS_WIN)
269 if (pressed_button_ != WebMouseEvent::BUTTON_NONE && drag_data_object) { 288 if (pressed_button_ != WebMouseEvent::BUTTON_NONE && drag_data_object) {
270 TestWebViewDelegate* delegate = shell_->delegate(); 289 TestWebViewDelegate* delegate = shell_->delegate();
271 // Get screen mouse position. 290 // Get screen mouse position.
272 POINT screen_pt = { static_cast<LONG>(e.x), 291 POINT screen_pt = { static_cast<LONG>(e.x),
273 static_cast<LONG>(e.y) }; 292 static_cast<LONG>(e.y) };
274 ClientToScreen(shell_->webViewWnd(), &screen_pt); 293 ClientToScreen(shell_->webViewWnd(), &screen_pt);
275 POINTL screen_ptl = { screen_pt.x, screen_pt.y }; 294 POINTL screen_ptl = { screen_pt.x, screen_pt.y };
276 295
277 HRESULT hr = delegate->drag_delegate()->QueryContinueDrag(0, MK_LBUTTON); 296 HRESULT hr = delegate->drag_delegate()->QueryContinueDrag(0, MK_LBUTTON);
278 DWORD effect = 0; 297 DWORD effect = 0;
279 delegate->drop_delegate()->DragOver(MK_LBUTTON, screen_ptl, &effect); 298 delegate->drop_delegate()->DragOver(MK_LBUTTON, screen_ptl, &effect);
280 299
281 delegate->drag_delegate()->GiveFeedback(effect); 300 delegate->drag_delegate()->GiveFeedback(effect);
282 } 301 }
302 #endif
283 } 303 }
284 304
285 void EventSendingController::keyDown( 305 void EventSendingController::keyDown(
286 const CppArgumentList& args, CppVariant* result) { 306 const CppArgumentList& args, CppVariant* result) {
287 result->SetNull(); 307 result->SetNull();
288 308
289 static const int kPercentVirtualKeyCode = 0x25; 309 static const int kPercentVirtualKeyCode = 0x25;
290 static const int kAmpersandVirtualKeyCode = 0x26; 310 static const int kAmpersandVirtualKeyCode = 0x26;
291 311
292 static const int kLeftParenthesesVirtualKeyCode = 0x28; 312 static const int kLeftParenthesesVirtualKeyCode = 0x28;
293 static const int kRightParenthesesVirtualKeyCode = 0x29; 313 static const int kRightParenthesesVirtualKeyCode = 0x29;
294 314
315 #if defined(OS_WIN)
295 static const int kLeftCurlyBracketVirtualKeyCode = 0x7B; 316 static const int kLeftCurlyBracketVirtualKeyCode = 0x7B;
296 static const int kRightCurlyBracketVirtualKeyCode = 0x7D; 317 static const int kRightCurlyBracketVirtualKeyCode = 0x7D;
318 #endif
297 319
298 bool generate_char = false; 320 bool generate_char = false;
299 321
300 if (args.size() >= 1 && args[0].isString()) { 322 if (args.size() >= 1 && args[0].isString()) {
301 // TODO(mpcomplete): I'm not exactly sure how we should convert the string 323 // TODO(mpcomplete): I'm not exactly sure how we should convert the string
302 // to a key event. This seems to work in the cases I tested. 324 // to a key event. This seems to work in the cases I tested.
303 // TODO(mpcomplete): Should we also generate a KEY_UP? 325 // TODO(mpcomplete): Should we also generate a KEY_UP?
304 std::wstring code_str = UTF8ToWide(args[0].ToString()); 326 std::wstring code_str = UTF8ToWide(args[0].ToString());
305 327
306 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when 328 // Convert \n -> VK_RETURN. Some layout tests use \n to mean "Enter", when
307 // Windows uses \r for "Enter". 329 // Windows uses \r for "Enter".
308 wchar_t code; 330 wchar_t code;
309 bool needs_shift_key_modifier = false; 331 bool needs_shift_key_modifier = false;
332 #if defined(OS_WIN)
310 if (L"\n" == code_str) { 333 if (L"\n" == code_str) {
311 generate_char = true; 334 generate_char = true;
312 code = VK_RETURN; 335 code = VK_RETURN;
313 } else if (L"rightArrow" == code_str) { 336 } else if (L"rightArrow" == code_str) {
314 code = VK_RIGHT; 337 code = VK_RIGHT;
315 } else if (L"downArrow" == code_str) { 338 } else if (L"downArrow" == code_str) {
316 code = VK_DOWN; 339 code = VK_DOWN;
317 } else if (L"leftArrow" == code_str) { 340 } else if (L"leftArrow" == code_str) {
318 code = VK_LEFT; 341 code = VK_LEFT;
319 } else if (L"upArrow" == code_str) { 342 } else if (L"upArrow" == code_str) {
320 code = VK_UP; 343 code = VK_UP;
321 } else if (L"delete" == code_str) { 344 } else if (L"delete" == code_str) {
322 code = VK_BACK; 345 code = VK_BACK;
323 } else { 346 }
347 #elif defined(OS_MACOSX)
348 // I don't quite understand this code enough to change the way it works. As
349 // for the keycodes, they were documented once in Inside Macintosh and
350 // haven't been documented since, either on paper or in a header. The
351 // reference I'm going by is http://www.meandmark.com/keycodes.html .
352 // TODO(avi): Find someone who knows keyboard handling in WebCore and have
353 // them take a look at this.
354 if (L"\n" == code_str) {
355 generate_char = true;
356 code = 0x24;
357 } else if (L"rightArrow" == code_str) {
358 code = 0x7C;
359 } else if (L"downArrow" == code_str) {
360 code = 0x7D;
361 } else if (L"leftArrow" == code_str) {
362 code = 0x7B;
363 } else if (L"upArrow" == code_str) {
364 code = 0x7E;
365 } else if (L"delete" == code_str) {
366 code = 0x33;
367 }
368 #endif
369 else {
324 DCHECK(code_str.length() == 1); 370 DCHECK(code_str.length() == 1);
325 code = code_str[0]; 371 code = code_str[0];
326 needs_shift_key_modifier = NeedsShiftModifer(code); 372 needs_shift_key_modifier = NeedsShiftModifer(code);
327 generate_char = true; 373 generate_char = true;
328 } 374 }
329 375
330 // NOTE(jnd):For one keydown event, we need to generate 376 // NOTE(jnd):For one keydown event, we need to generate
331 // keyDown/keyUp pair, refer EventSender.cpp in 377 // keyDown/keyUp pair, refer EventSender.cpp in
332 // WebKit/WebKitTools/DumpRenderTree/win. We may also need 378 // WebKit/WebKitTools/DumpRenderTree/win. We may also need
333 // to generate a keyChar event in certain cases. 379 // to generate a keyChar event in certain cases.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 event_char.key_data = kAmpersandVirtualKeyCode; 417 event_char.key_data = kAmpersandVirtualKeyCode;
372 break; 418 break;
373 case '9': 419 case '9':
374 event_char.key_code = kLeftParenthesesVirtualKeyCode; 420 event_char.key_code = kLeftParenthesesVirtualKeyCode;
375 event_char.key_data = kLeftParenthesesVirtualKeyCode; 421 event_char.key_data = kLeftParenthesesVirtualKeyCode;
376 break; 422 break;
377 case '0': 423 case '0':
378 event_char.key_code = kRightParenthesesVirtualKeyCode; 424 event_char.key_code = kRightParenthesesVirtualKeyCode;
379 event_char.key_data = kRightParenthesesVirtualKeyCode; 425 event_char.key_data = kRightParenthesesVirtualKeyCode;
380 break; 426 break;
427 #if defined(OS_WIN)
381 // '[{' for US 428 // '[{' for US
382 case VK_OEM_4: 429 case VK_OEM_4:
383 event_char.key_code = kLeftCurlyBracketVirtualKeyCode; 430 event_char.key_code = kLeftCurlyBracketVirtualKeyCode;
384 event_char.key_data = kLeftCurlyBracketVirtualKeyCode; 431 event_char.key_data = kLeftCurlyBracketVirtualKeyCode;
385 break; 432 break;
386 // ']}' for US 433 // ']}' for US
387 case VK_OEM_6: 434 case VK_OEM_6:
388 event_char.key_code = kRightCurlyBracketVirtualKeyCode; 435 event_char.key_code = kRightCurlyBracketVirtualKeyCode;
389 event_char.key_data = kRightCurlyBracketVirtualKeyCode; 436 event_char.key_data = kRightCurlyBracketVirtualKeyCode;
390 break; 437 break;
438 #endif
391 default: 439 default:
392 break; 440 break;
393 } 441 }
394 } 442 }
395 event_char.type = WebInputEvent::CHAR; 443 event_char.type = WebInputEvent::CHAR;
396 webview()->HandleInputEvent(&event_char); 444 webview()->HandleInputEvent(&event_char);
397 } 445 }
398 446
399 webview()->HandleInputEvent(&event_up); 447 webview()->HandleInputEvent(&event_up);
400 } 448 }
401 } 449 }
402 450
403 bool EventSendingController::NeedsShiftModifer(wchar_t key_code) { 451 bool EventSendingController::NeedsShiftModifer(wchar_t key_code) {
404 // If code is an uppercase letter, assign a SHIFT key to 452 // If code is an uppercase letter, assign a SHIFT key to
405 // event_down.modifier, this logic comes from 453 // event_down.modifier, this logic comes from
406 // WebKit/WebKitTools/DumpRenderTree/Win/EventSender.cpp 454 // WebKit/WebKitTools/DumpRenderTree/Win/EventSender.cpp
407 if ((LOBYTE(key_code)) >= 'A' && (LOBYTE(key_code)) <= 'Z') 455 if ((key_code & 0xFF) >= 'A' && (key_code & 0xFF) <= 'Z')
408 return true; 456 return true;
409 return false; 457 return false;
410 } 458 }
411 459
412 void EventSendingController::leapForward( 460 void EventSendingController::leapForward(
413 const CppArgumentList& args, CppVariant* result) { 461 const CppArgumentList& args, CppVariant* result) {
414 result->SetNull(); 462 result->SetNull();
415 463
416 // TODO(mpcomplete): DumpRenderTree defers this under certain conditions. 464 // TODO(mpcomplete): DumpRenderTree defers this under certain conditions.
417 465
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 void EventSendingController::fireKeyboardEventsToElement( 542 void EventSendingController::fireKeyboardEventsToElement(
495 const CppArgumentList& args, CppVariant* result) { 543 const CppArgumentList& args, CppVariant* result) {
496 result->SetNull(); 544 result->SetNull();
497 } 545 }
498 546
499 void EventSendingController::clearKillRing( 547 void EventSendingController::clearKillRing(
500 const CppArgumentList& args, CppVariant* result) { 548 const CppArgumentList& args, CppVariant* result) {
501 result->SetNull(); 549 result->SetNull();
502 } 550 }
503 551
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/event_sending_controller.h ('k') | webkit/tools/test_shell/mac/TestShell.xcodeproj/project.pbxproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698