Chromium Code Reviews| OLD | NEW |
|---|---|
| 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, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 } | 140 } |
| 141 | 141 |
| 142 void ApplyKeyModifier(const std::wstring& arg, WebKeyboardEvent* event) { | 142 void ApplyKeyModifier(const std::wstring& arg, WebKeyboardEvent* event) { |
| 143 const wchar_t* arg_string = arg.c_str(); | 143 const wchar_t* arg_string = arg.c_str(); |
| 144 if (!wcscmp(arg_string, L"ctrlKey")) { | 144 if (!wcscmp(arg_string, L"ctrlKey")) { |
| 145 event->modifiers |= WebInputEvent::ControlKey; | 145 event->modifiers |= WebInputEvent::ControlKey; |
| 146 } else if (!wcscmp(arg_string, L"shiftKey")) { | 146 } else if (!wcscmp(arg_string, L"shiftKey")) { |
| 147 event->modifiers |= WebInputEvent::ShiftKey; | 147 event->modifiers |= WebInputEvent::ShiftKey; |
| 148 } else if (!wcscmp(arg_string, L"altKey")) { | 148 } else if (!wcscmp(arg_string, L"altKey")) { |
| 149 event->modifiers |= WebInputEvent::AltKey; | 149 event->modifiers |= WebInputEvent::AltKey; |
| 150 #if defined(OS_WIN) | |
| 151 event->isSystemKey = true; | 150 event->isSystemKey = true; |
| 152 #endif | |
| 153 } else if (!wcscmp(arg_string, L"metaKey")) { | 151 } else if (!wcscmp(arg_string, L"metaKey")) { |
| 154 event->modifiers |= WebInputEvent::MetaKey; | 152 event->modifiers |= WebInputEvent::MetaKey; |
| 155 } | 153 } |
| 156 } | 154 } |
| 157 | 155 |
| 158 void ApplyKeyModifiers(const CppVariant* arg, WebKeyboardEvent* event) { | 156 void ApplyKeyModifiers(const CppVariant* arg, WebKeyboardEvent* event) { |
| 159 if (arg->isObject()) { | 157 if (arg->isObject()) { |
| 160 std::vector<std::wstring> args = arg->ToStringVector(); | 158 std::vector<std::wstring> args = arg->ToStringVector(); |
| 161 for (std::vector<std::wstring>::const_iterator i = args.begin(); | 159 for (std::vector<std::wstring>::const_iterator i = args.begin(); |
| 162 i != args.end(); ++i) { | 160 i != args.end(); ++i) { |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 needs_shift_key_modifier = NeedsShiftModifier(code); | 477 needs_shift_key_modifier = NeedsShiftModifier(code); |
| 480 generate_char = true; | 478 generate_char = true; |
| 481 } | 479 } |
| 482 } | 480 } |
| 483 | 481 |
| 484 // For one generated keyboard event, we need to generate a keyDown/keyUp | 482 // For one generated keyboard event, we need to generate a keyDown/keyUp |
| 485 // pair; refer to EventSender.cpp in WebKit/WebKitTools/DumpRenderTree/win. | 483 // pair; refer to EventSender.cpp in WebKit/WebKitTools/DumpRenderTree/win. |
| 486 // On Windows, we might also need to generate a char event to mimic the | 484 // On Windows, we might also need to generate a char event to mimic the |
| 487 // Windows event flow; on other platforms we create a merged event and test | 485 // Windows event flow; on other platforms we create a merged event and test |
| 488 // the event flow that that platform provides. | 486 // the event flow that that platform provides. |
| 489 WebKeyboardEvent event_down, event_up; | 487 WebKeyboardEvent event_down, event_char, event_up; |
| 490 #if defined(OS_WIN) | |
| 491 event_down.type = WebInputEvent::RawKeyDown; | 488 event_down.type = WebInputEvent::RawKeyDown; |
| 492 #else | |
| 493 event_down.type = WebInputEvent::KeyDown; | |
| 494 #endif | |
| 495 event_down.modifiers = 0; | 489 event_down.modifiers = 0; |
| 496 event_down.windowsKeyCode = code; | 490 event_down.windowsKeyCode = code; |
| 497 if (generate_char) { | 491 if (generate_char) { |
| 498 event_down.text[0] = code; | 492 event_down.text[0] = code; |
| 499 event_down.unmodifiedText[0] = code; | 493 event_down.unmodifiedText[0] = code; |
| 500 } | 494 } |
| 501 event_down.setKeyIdentifierFromWindowsKeyCode(); | 495 event_down.setKeyIdentifierFromWindowsKeyCode(); |
| 502 | 496 |
| 503 if (args.size() >= 2 && (args[1].isObject() || args[1].isString())) | 497 if (args.size() >= 2 && (args[1].isObject() || args[1].isString())) |
| 504 ApplyKeyModifiers(&(args[1]), &event_down); | 498 ApplyKeyModifiers(&(args[1]), &event_down); |
| 505 | 499 |
| 506 if (needs_shift_key_modifier) | 500 if (needs_shift_key_modifier) |
| 507 event_down.modifiers |= WebInputEvent::ShiftKey; | 501 event_down.modifiers |= WebInputEvent::ShiftKey; |
| 508 | 502 |
| 509 event_up = event_down; | 503 event_char = event_up = event_down; |
| 510 event_up.type = WebInputEvent::KeyUp; | 504 event_up.type = WebInputEvent::KeyUp; |
| 511 // EventSendingController.m forces a layout here, with at least one | 505 // EventSendingController.m forces a layout here, with at least one |
| 512 // test (fast\forms\focus-control-to-page.html) relying on this. | 506 // test (fast\forms\focus-control-to-page.html) relying on this. |
| 513 webview()->layout(); | 507 webview()->layout(); |
| 514 | 508 |
| 509 #if defined(OS_MACOSX) | |
| 510 // On Mac OS, some layout tests (such as "delete-by-word-001.html") sends | |
| 511 // an option-key (or alt-key) event to test it is mapped to an appropriate | |
| 512 // editor command (such as "DeleteWordBackward"). | |
| 513 // On the other hand, EditorClientImpl::handleEditingKeyboardEvent() | |
| 514 // ignores the key event whose isSystemKey value is true and cannot map | |
| 515 // an editor command to an option-key event. | |
| 516 // As a workaround for this problem, we set isSystemKey of RawKeyDown | |
| 517 // events to false. | |
| 518 event_down.isSystemKey = false; | |
|
Avi (use Gerrit)
2009/10/21 15:19:15
I thought the system_key param on events was alway
| |
| 519 #endif | |
| 515 webview()->handleInputEvent(event_down); | 520 webview()->handleInputEvent(event_down); |
| 516 | 521 |
| 517 #if defined(OS_WIN) | |
| 518 if (generate_char) { | 522 if (generate_char) { |
| 519 WebKeyboardEvent event_char = event_down; | |
| 520 event_char.type = WebInputEvent::Char; | 523 event_char.type = WebInputEvent::Char; |
| 521 event_char.keyIdentifier[0] = '\0'; | 524 event_char.keyIdentifier[0] = '\0'; |
| 522 webview()->handleInputEvent(event_char); | 525 webview()->handleInputEvent(event_char); |
| 523 } | 526 } |
| 524 #endif | |
| 525 | 527 |
| 526 webview()->handleInputEvent(event_up); | 528 webview()->handleInputEvent(event_up); |
| 527 } | 529 } |
| 528 } | 530 } |
| 529 | 531 |
| 530 void EventSendingController::dispatchMessage( | 532 void EventSendingController::dispatchMessage( |
| 531 const CppArgumentList& args, CppVariant* result) { | 533 const CppArgumentList& args, CppVariant* result) { |
| 532 result->SetNull(); | 534 result->SetNull(); |
| 533 | 535 |
| 534 #if defined(OS_WIN) | 536 #if defined(OS_WIN) |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 | 720 |
| 719 void EventSendingController::fireKeyboardEventsToElement( | 721 void EventSendingController::fireKeyboardEventsToElement( |
| 720 const CppArgumentList& args, CppVariant* result) { | 722 const CppArgumentList& args, CppVariant* result) { |
| 721 result->SetNull(); | 723 result->SetNull(); |
| 722 } | 724 } |
| 723 | 725 |
| 724 void EventSendingController::clearKillRing( | 726 void EventSendingController::clearKillRing( |
| 725 const CppArgumentList& args, CppVariant* result) { | 727 const CppArgumentList& args, CppVariant* result) { |
| 726 result->SetNull(); | 728 result->SetNull(); |
| 727 } | 729 } |
| OLD | NEW |