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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 visitor->trace(m_scrollManager); | 133 visitor->trace(m_scrollManager); |
134 } | 134 } |
135 | 135 |
136 bool KeyboardEventManager::handleAccessKey(const WebKeyboardEvent& evt) { | 136 bool KeyboardEventManager::handleAccessKey(const WebKeyboardEvent& evt) { |
137 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. | 137 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. |
138 // IE matches lower and upper case access keys regardless of Shift key state - | 138 // IE matches lower and upper case access keys regardless of Shift key state - |
139 // but if both upper and lower case variants are present in a document, the | 139 // but if both upper and lower case variants are present in a document, the |
140 // correct element is matched based on Shift key state. Firefox only matches | 140 // correct element is matched based on Shift key state. Firefox only matches |
141 // an access key if Shift is not pressed, and does that case-insensitively. | 141 // an access key if Shift is not pressed, and does that case-insensitively. |
142 DCHECK(!(kAccessKeyModifiers & WebInputEvent::ShiftKey)); | 142 DCHECK(!(kAccessKeyModifiers & WebInputEvent::ShiftKey)); |
143 if ((evt.modifiers() & (WebKeyboardEvent::KeyModifiers & | 143 if ((evt.modifiers() & |
144 ~WebInputEvent::ShiftKey)) != kAccessKeyModifiers) | 144 (WebKeyboardEvent::KeyModifiers & ~WebInputEvent::ShiftKey)) != |
| 145 kAccessKeyModifiers) |
145 return false; | 146 return false; |
146 String key = String(evt.unmodifiedText); | 147 String key = String(evt.unmodifiedText); |
147 Element* elem = m_frame->document()->getElementByAccessKey(key.lower()); | 148 Element* elem = m_frame->document()->getElementByAccessKey(key.lower()); |
148 if (!elem) | 149 if (!elem) |
149 return false; | 150 return false; |
150 elem->accessKeyAction(false); | 151 elem->accessKeyAction(false); |
151 return true; | 152 return true; |
152 } | 153 } |
153 | 154 |
154 WebInputEventResult KeyboardEventManager::keyEvent( | 155 WebInputEventResult KeyboardEventManager::keyEvent( |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 if (currentModifiers & ::cmdKey) | 456 if (currentModifiers & ::cmdKey) |
456 modifiers |= WebInputEvent::MetaKey; | 457 modifiers |= WebInputEvent::MetaKey; |
457 #else | 458 #else |
458 // TODO(crbug.com/538289): Implement on other platforms. | 459 // TODO(crbug.com/538289): Implement on other platforms. |
459 return static_cast<WebInputEvent::Modifiers>(0); | 460 return static_cast<WebInputEvent::Modifiers>(0); |
460 #endif | 461 #endif |
461 return static_cast<WebInputEvent::Modifiers>(modifiers); | 462 return static_cast<WebInputEvent::Modifiers>(modifiers); |
462 } | 463 } |
463 | 464 |
464 } // namespace blink | 465 } // namespace blink |
OLD | NEW |