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) |