OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "KeyboardEventManager.h" | 5 #include "KeyboardEventManager.h" |
6 | 6 |
7 #include "core/dom/DocumentUserGestureToken.h" | 7 #include "core/dom/DocumentUserGestureToken.h" |
8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
9 #include "core/editing/Editor.h" | 9 #include "core/editing/Editor.h" |
10 #include "core/events/KeyboardEvent.h" | 10 #include "core/events/KeyboardEvent.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 else if (event->key() == "ArrowUp") | 51 else if (event->key() == "ArrowUp") |
52 retVal = WebFocusTypeUp; | 52 retVal = WebFocusTypeUp; |
53 else if (event->key() == "ArrowLeft") | 53 else if (event->key() == "ArrowLeft") |
54 retVal = WebFocusTypeLeft; | 54 retVal = WebFocusTypeLeft; |
55 else if (event->key() == "ArrowRight") | 55 else if (event->key() == "ArrowRight") |
56 retVal = WebFocusTypeRight; | 56 retVal = WebFocusTypeRight; |
57 return retVal; | 57 return retVal; |
58 } | 58 } |
59 | 59 |
60 bool mapKeyCodeForScroll(int keyCode, | 60 bool mapKeyCodeForScroll(int keyCode, |
61 PlatformEvent::Modifiers modifiers, | 61 WebInputEvent::Modifiers modifiers, |
62 ScrollDirection* scrollDirection, | 62 ScrollDirection* scrollDirection, |
63 ScrollGranularity* scrollGranularity) { | 63 ScrollGranularity* scrollGranularity) { |
64 if (modifiers & PlatformEvent::ShiftKey || modifiers & PlatformEvent::MetaKey) | 64 if (modifiers & WebInputEvent::ShiftKey || modifiers & WebInputEvent::MetaKey) |
65 return false; | 65 return false; |
66 | 66 |
67 if (modifiers & PlatformEvent::AltKey) { | 67 if (modifiers & WebInputEvent::AltKey) { |
68 // Alt-Up/Down should behave like PageUp/Down on Mac. (Note that Alt-keys | 68 // Alt-Up/Down should behave like PageUp/Down on Mac. (Note that Alt-keys |
69 // on other platforms are suppressed due to isSystemKey being set.) | 69 // on other platforms are suppressed due to isSystemKey being set.) |
70 if (keyCode == VKEY_UP) | 70 if (keyCode == VKEY_UP) |
71 keyCode = VKEY_PRIOR; | 71 keyCode = VKEY_PRIOR; |
72 else if (keyCode == VKEY_DOWN) | 72 else if (keyCode == VKEY_DOWN) |
73 keyCode = VKEY_NEXT; | 73 keyCode = VKEY_NEXT; |
74 else | 74 else |
75 return false; | 75 return false; |
76 } | 76 } |
77 | 77 |
78 if (modifiers & PlatformEvent::CtrlKey) { | 78 if (modifiers & WebInputEvent::ControlKey) { |
79 // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl | 79 // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl |
80 // key combinations which affect scrolling. | 80 // key combinations which affect scrolling. |
81 if (keyCode != VKEY_HOME && keyCode != VKEY_END) | 81 if (keyCode != VKEY_HOME && keyCode != VKEY_END) |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 switch (keyCode) { | 85 switch (keyCode) { |
86 case VKEY_LEFT: | 86 case VKEY_LEFT: |
87 *scrollDirection = ScrollLeftIgnoringWritingMode; | 87 *scrollDirection = ScrollLeftIgnoringWritingMode; |
88 *scrollGranularity = ScrollByLine; | 88 *scrollGranularity = ScrollByLine; |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 if (currentModifiers & ::cmdKey) | 455 if (currentModifiers & ::cmdKey) |
456 modifiers |= WebInputEvent::MetaKey; | 456 modifiers |= WebInputEvent::MetaKey; |
457 #else | 457 #else |
458 // TODO(crbug.com/538289): Implement on other platforms. | 458 // TODO(crbug.com/538289): Implement on other platforms. |
459 return static_cast<WebInputEvent::Modifiers>(0); | 459 return static_cast<WebInputEvent::Modifiers>(0); |
460 #endif | 460 #endif |
461 return static_cast<WebInputEvent::Modifiers>(modifiers); | 461 return static_cast<WebInputEvent::Modifiers>(modifiers); |
462 } | 462 } |
463 | 463 |
464 } // namespace blink | 464 } // namespace blink |
OLD | NEW |