| 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> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/UserGestureIndicator.h" | 10 #include "core/dom/UserGestureIndicator.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Check for cases where we are too early for events -- possible unmatched key | 186 // Check for cases where we are too early for events -- possible unmatched key |
| 187 // up from pressing return in the location bar. | 187 // up from pressing return in the location bar. |
| 188 Node* node = EventTargetNodeForDocument(frame_->GetDocument()); | 188 Node* node = EventTargetNodeForDocument(frame_->GetDocument()); |
| 189 if (!node) | 189 if (!node) |
| 190 return WebInputEventResult::kNotHandled; | 190 return WebInputEventResult::kNotHandled; |
| 191 | 191 |
| 192 // To be meaningful enough to indicate user intention, a keyboard event needs | 192 // To be meaningful enough to indicate user intention, a keyboard event needs |
| 193 // - not to be a modifier event | 193 // - not to be a modifier event |
| 194 // - not to be a browser shortcut |
| 194 // https://crbug.com/709765 | 195 // https://crbug.com/709765 |
| 195 bool is_modifier = | 196 bool is_modifier = |
| 196 Platform::Current()->IsDomKeyForModifier(initial_key_event.dom_key); | 197 Platform::Current()->IsDomKeyForModifier(initial_key_event.dom_key); |
| 198 bool is_browser_shortcut = initial_key_event.is_browser_shortcut; |
| 197 | 199 |
| 198 std::unique_ptr<UserGestureIndicator> gesture_indicator; | 200 std::unique_ptr<UserGestureIndicator> gesture_indicator; |
| 199 if (!is_modifier) { | 201 if (!is_modifier && !is_browser_shortcut) { |
| 200 gesture_indicator.reset(new UserGestureIndicator( | 202 gesture_indicator.reset(new UserGestureIndicator( |
| 201 UserGestureToken::Create(frame_->GetDocument()))); | 203 UserGestureToken::Create(frame_->GetDocument()))); |
| 202 } | 204 } |
| 203 | 205 |
| 204 // In IE, access keys are special, they are handled after default keydown | 206 // In IE, access keys are special, they are handled after default keydown |
| 205 // processing, but cannot be canceled - this is hard to match. On Mac OS X, | 207 // processing, but cannot be canceled - this is hard to match. On Mac OS X, |
| 206 // we process them before dispatching keydown, as the default keydown handler | 208 // we process them before dispatching keydown, as the default keydown handler |
| 207 // implements Emacs key bindings, which may conflict with access keys. Then we | 209 // implements Emacs key bindings, which may conflict with access keys. Then we |
| 208 // dispatch keydown, but suppress its default handling. | 210 // dispatch keydown, but suppress its default handling. |
| 209 // On Windows, WebKit explicitly calls handleAccessKey() instead of | 211 // On Windows, WebKit explicitly calls handleAccessKey() instead of |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 if (current_modifiers & ::cmdKey) | 464 if (current_modifiers & ::cmdKey) |
| 463 modifiers |= WebInputEvent::kMetaKey; | 465 modifiers |= WebInputEvent::kMetaKey; |
| 464 #else | 466 #else |
| 465 // TODO(crbug.com/538289): Implement on other platforms. | 467 // TODO(crbug.com/538289): Implement on other platforms. |
| 466 return static_cast<WebInputEvent::Modifiers>(0); | 468 return static_cast<WebInputEvent::Modifiers>(0); |
| 467 #endif | 469 #endif |
| 468 return static_cast<WebInputEvent::Modifiers>(modifiers); | 470 return static_cast<WebInputEvent::Modifiers>(modifiers); |
| 469 } | 471 } |
| 470 | 472 |
| 471 } // namespace blink | 473 } // namespace blink |
| OLD | NEW |