| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 if (event.modifiers & WebKeyboardEvent::ShiftKey) | 213 if (event.modifiers & WebKeyboardEvent::ShiftKey) |
| 214 name->append("AndModifySelection"); | 214 name->append("AndModifySelection"); |
| 215 | 215 |
| 216 return true; | 216 return true; |
| 217 #else | 217 #else |
| 218 return false; | 218 return false; |
| 219 #endif | 219 #endif |
| 220 } | 220 } |
| 221 | 221 |
| 222 // Key event location code introduced in DOM Level 3. |
| 223 // See also: http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboardevents |
| 224 enum KeyLocationCode { |
| 225 DOM_KEY_LOCATION_STANDARD = 0x00, |
| 226 DOM_KEY_LOCATION_LEFT = 0x01, |
| 227 DOM_KEY_LOCATION_RIGHT = 0x02, |
| 228 DOM_KEY_LOCATION_NUMPAD = 0x03 |
| 229 }; |
| 230 |
| 222 } // anonymous namespace | 231 } // anonymous namespace |
| 223 | 232 |
| 224 EventSendingController::EventSendingController(TestShell* shell) | 233 EventSendingController::EventSendingController(TestShell* shell) |
| 225 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 234 : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| 226 // Set static shell_ variable since we can't do it in an initializer list. | 235 // Set static shell_ variable since we can't do it in an initializer list. |
| 227 // We also need to be careful not to assign shell_ to new windows which are | 236 // We also need to be careful not to assign shell_ to new windows which are |
| 228 // temporary. | 237 // temporary. |
| 229 if (NULL == shell_) | 238 if (NULL == shell_) |
| 230 shell_ = shell; | 239 shell_ = shell; |
| 231 | 240 |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 event_down.unmodifiedText[0] = code; | 581 event_down.unmodifiedText[0] = code; |
| 573 } | 582 } |
| 574 event_down.setKeyIdentifierFromWindowsKeyCode(); | 583 event_down.setKeyIdentifierFromWindowsKeyCode(); |
| 575 | 584 |
| 576 if (args.size() >= 2 && (args[1].isObject() || args[1].isString())) | 585 if (args.size() >= 2 && (args[1].isObject() || args[1].isString())) |
| 577 ApplyKeyModifiers(&(args[1]), &event_down); | 586 ApplyKeyModifiers(&(args[1]), &event_down); |
| 578 | 587 |
| 579 if (needs_shift_key_modifier) | 588 if (needs_shift_key_modifier) |
| 580 event_down.modifiers |= WebInputEvent::ShiftKey; | 589 event_down.modifiers |= WebInputEvent::ShiftKey; |
| 581 | 590 |
| 591 // See if KeyLocation argument is given. |
| 592 if (args.size() >= 3 && args[2].isNumber()) { |
| 593 int location = args[2].ToInt32(); |
| 594 if (location == DOM_KEY_LOCATION_NUMPAD) { |
| 595 event_down.modifiers |= WebInputEvent::IsKeyPad; |
| 596 } |
| 597 } |
| 598 |
| 582 event_char = event_up = event_down; | 599 event_char = event_up = event_down; |
| 583 event_up.type = WebInputEvent::KeyUp; | 600 event_up.type = WebInputEvent::KeyUp; |
| 584 // EventSendingController.m forces a layout here, with at least one | 601 // EventSendingController.m forces a layout here, with at least one |
| 585 // test (fast\forms\focus-control-to-page.html) relying on this. | 602 // test (fast\forms\focus-control-to-page.html) relying on this. |
| 586 webview()->layout(); | 603 webview()->layout(); |
| 587 | 604 |
| 588 // In the browser, if a keyboard event corresponds to an editor command, | 605 // In the browser, if a keyboard event corresponds to an editor command, |
| 589 // the command will be dispatched to the renderer just before dispatching | 606 // the command will be dispatched to the renderer just before dispatching |
| 590 // the keyboard event, and then it will be executed in the | 607 // the keyboard event, and then it will be executed in the |
| 591 // RenderView::handleCurrentKeyboardEvent() method, which is called from | 608 // RenderView::handleCurrentKeyboardEvent() method, which is called from |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 | 817 |
| 801 void EventSendingController::fireKeyboardEventsToElement( | 818 void EventSendingController::fireKeyboardEventsToElement( |
| 802 const CppArgumentList& args, CppVariant* result) { | 819 const CppArgumentList& args, CppVariant* result) { |
| 803 result->SetNull(); | 820 result->SetNull(); |
| 804 } | 821 } |
| 805 | 822 |
| 806 void EventSendingController::clearKillRing( | 823 void EventSendingController::clearKillRing( |
| 807 const CppArgumentList& args, CppVariant* result) { | 824 const CppArgumentList& args, CppVariant* result) { |
| 808 result->SetNull(); | 825 result->SetNull(); |
| 809 } | 826 } |
| OLD | NEW |