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 <memory> |
| 8 |
7 #include "core/dom/DocumentUserGestureToken.h" | 9 #include "core/dom/DocumentUserGestureToken.h" |
8 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
9 #include "core/editing/Editor.h" | 11 #include "core/editing/Editor.h" |
10 #include "core/events/KeyboardEvent.h" | 12 #include "core/events/KeyboardEvent.h" |
11 #include "core/frame/LocalFrameClient.h" | 13 #include "core/frame/LocalFrameClient.h" |
12 #include "core/html/HTMLDialogElement.h" | 14 #include "core/html/HTMLDialogElement.h" |
13 #include "core/input/EventHandler.h" | 15 #include "core/input/EventHandler.h" |
14 #include "core/input/EventHandlingUtil.h" | 16 #include "core/input/EventHandlingUtil.h" |
15 #include "core/input/InputDeviceCapabilities.h" | 17 #include "core/input/InputDeviceCapabilities.h" |
16 #include "core/input/ScrollManager.h" | 18 #include "core/input/ScrollManager.h" |
17 #include "core/layout/LayoutObject.h" | 19 #include "core/layout/LayoutObject.h" |
18 #include "core/layout/LayoutTextControlSingleLine.h" | 20 #include "core/layout/LayoutTextControlSingleLine.h" |
19 #include "core/page/ChromeClient.h" | 21 #include "core/page/ChromeClient.h" |
20 #include "core/page/FocusController.h" | 22 #include "core/page/FocusController.h" |
21 #include "core/page/Page.h" | 23 #include "core/page/Page.h" |
22 #include "core/page/SpatialNavigation.h" | 24 #include "core/page/SpatialNavigation.h" |
23 #include "platform/KeyboardCodes.h" | 25 #include "platform/KeyboardCodes.h" |
24 #include "platform/UserGestureIndicator.h" | 26 #include "platform/UserGestureIndicator.h" |
25 #include "platform/WindowsKeyboardCodes.h" | 27 #include "platform/WindowsKeyboardCodes.h" |
| 28 #include "public/platform/Platform.h" |
26 #include "public/platform/WebInputEvent.h" | 29 #include "public/platform/WebInputEvent.h" |
27 | 30 |
28 #if OS(WIN) | 31 #if OS(WIN) |
29 #include <windows.h> | 32 #include <windows.h> |
30 #elif OS(MACOSX) | 33 #elif OS(MACOSX) |
31 #import <Carbon/Carbon.h> | 34 #import <Carbon/Carbon.h> |
32 #endif | 35 #endif |
33 | 36 |
34 namespace blink { | 37 namespace blink { |
35 | 38 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // If we were in panscroll mode, we swallow the key event | 183 // If we were in panscroll mode, we swallow the key event |
181 return WebInputEventResult::kHandledSuppressed; | 184 return WebInputEventResult::kHandledSuppressed; |
182 } | 185 } |
183 | 186 |
184 // Check for cases where we are too early for events -- possible unmatched key | 187 // Check for cases where we are too early for events -- possible unmatched key |
185 // up from pressing return in the location bar. | 188 // up from pressing return in the location bar. |
186 Node* node = EventTargetNodeForDocument(frame_->GetDocument()); | 189 Node* node = EventTargetNodeForDocument(frame_->GetDocument()); |
187 if (!node) | 190 if (!node) |
188 return WebInputEventResult::kNotHandled; | 191 return WebInputEventResult::kNotHandled; |
189 | 192 |
190 UserGestureIndicator gesture_indicator( | 193 // To be meaningful enough to indicate user intention, a keyboard event needs |
191 DocumentUserGestureToken::Create(frame_->GetDocument())); | 194 // - not to be a modifier event |
| 195 // https://crbug.com/709765 |
| 196 bool is_modifier = |
| 197 Platform::Current()->IsDomKeyForModifier(initial_key_event.dom_key); |
| 198 |
| 199 std::unique_ptr<UserGestureIndicator> gesture_indicator; |
| 200 if (!is_modifier) { |
| 201 gesture_indicator.reset(new UserGestureIndicator( |
| 202 DocumentUserGestureToken::Create(frame_->GetDocument()))); |
| 203 } |
192 | 204 |
193 // In IE, access keys are special, they are handled after default keydown | 205 // In IE, access keys are special, they are handled after default keydown |
194 // processing, but cannot be canceled - this is hard to match. On Mac OS X, | 206 // processing, but cannot be canceled - this is hard to match. On Mac OS X, |
195 // we process them before dispatching keydown, as the default keydown handler | 207 // we process them before dispatching keydown, as the default keydown handler |
196 // implements Emacs key bindings, which may conflict with access keys. Then we | 208 // implements Emacs key bindings, which may conflict with access keys. Then we |
197 // dispatch keydown, but suppress its default handling. | 209 // dispatch keydown, but suppress its default handling. |
198 // On Windows, WebKit explicitly calls handleAccessKey() instead of | 210 // On Windows, WebKit explicitly calls handleAccessKey() instead of |
199 // dispatching a keypress event for WM_SYSCHAR messages. Other platforms | 211 // dispatching a keypress event for WM_SYSCHAR messages. Other platforms |
200 // currently match either Mac or Windows behavior, depending on whether they | 212 // currently match either Mac or Windows behavior, depending on whether they |
201 // send combined KeyDown events. | 213 // send combined KeyDown events. |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 if (current_modifiers & ::cmdKey) | 486 if (current_modifiers & ::cmdKey) |
475 modifiers |= WebInputEvent::kMetaKey; | 487 modifiers |= WebInputEvent::kMetaKey; |
476 #else | 488 #else |
477 // TODO(crbug.com/538289): Implement on other platforms. | 489 // TODO(crbug.com/538289): Implement on other platforms. |
478 return static_cast<WebInputEvent::Modifiers>(0); | 490 return static_cast<WebInputEvent::Modifiers>(0); |
479 #endif | 491 #endif |
480 return static_cast<WebInputEvent::Modifiers>(modifiers); | 492 return static_cast<WebInputEvent::Modifiers>(modifiers); |
481 } | 493 } |
482 | 494 |
483 } // namespace blink | 495 } // namespace blink |
OLD | NEW |