Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp

Issue 2628763003: Keyboard event should not insert a character at selection if selection doesn't have focus (Closed)
Patch Set: 2017-01-12T13:25:32 Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp b/third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp
index 761d9a136a7b0f8ce6a0b2203d0fd7ecb3f42460..c61d0e15e1d54ecf902ce70052a5b3d36550520d 100644
--- a/third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp
+++ b/third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp
@@ -60,6 +60,18 @@ bool Editor::handleEditingKeyboardEvent(KeyboardEvent* evt) {
if (!behavior().shouldInsertCharacter(*evt) || !canEdit())
return false;
+ const Element* const focusedElement = m_frame->document()->focusedElement();
+ if (!focusedElement) {
+ // We may lose focused element by |command.execute(evt)|.
+ return false;
+ }
+ if (!focusedElement->containsIncludingHostElements(
+ *m_frame->selection().start().computeContainerNode())) {
+ // We should not insert text at selection start if selection doesn't have
+ // focus. See http://crbug.com/89026
+ return false;
+ }
+
// Return true to prevent default action. e.g. Space key scroll.
if (dispatchBeforeInputInsertText(evt->target(), keyEvent->text) !=
DispatchEventResult::NotCanceled)

Powered by Google App Engine
This is Rietveld 408576698