Index: third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
diff --git a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
index 2f2478ea8995c980aba97a71120a36575bfe5239..1b31e01787c75136961ba864cf9dd9b85a548d18 100644 |
--- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
+++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp |
@@ -1888,6 +1888,25 @@ static bool enabledInEditableText(LocalFrame& frame, |
return frame.editor().selectionForCommand(event).rootEditableElement(); |
} |
+static bool enabledInFocusedEditableText(LocalFrame& frame, |
+ Event* event, |
+ EditorCommandSource dummy) { |
+ if (!enabledInEditableText(frame, event, dummy)) |
+ return false; |
+ |
+ const Element* const focusedElement = frame.document()->focusedElement(); |
+ if (!focusedElement->containsIncludingHostElements( |
+ *frame.selection() |
+ .computeVisibleSelectionInDOMTreeDeprecated() |
+ .start() |
+ .computeContainerNode())) { |
+ // We should not move cursor if selected text does not have focus. |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
static bool enabledDelete(LocalFrame& frame, |
Event* event, |
EditorCommandSource source) { |
@@ -2262,7 +2281,7 @@ static const EditorInternalCommand* internalCommand(const String& commandName) { |
enabledVisibleSelection, stateNone, valueNull, notTextInsertion, |
doNotAllowExecutionWhenDisabled}, |
{WebEditingCommandType::MoveDown, executeMoveDown, |
- supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
+ supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone, |
valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
{WebEditingCommandType::MoveDownAndModifySelection, |
executeMoveDownAndModifySelection, supportedFromMenuOrKeyBinding, |
@@ -2276,7 +2295,7 @@ static const EditorInternalCommand* internalCommand(const String& commandName) { |
enabledVisibleSelection, stateNone, valueNull, notTextInsertion, |
doNotAllowExecutionWhenDisabled}, |
{WebEditingCommandType::MoveLeft, executeMoveLeft, |
- supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
+ supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone, |
valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
{WebEditingCommandType::MoveLeftAndModifySelection, |
executeMoveLeftAndModifySelection, supportedFromMenuOrKeyBinding, |
@@ -2312,7 +2331,7 @@ static const EditorInternalCommand* internalCommand(const String& commandName) { |
supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone, |
valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
{WebEditingCommandType::MoveRight, executeMoveRight, |
- supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
+ supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone, |
valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
{WebEditingCommandType::MoveRightAndModifySelection, |
executeMoveRightAndModifySelection, supportedFromMenuOrKeyBinding, |
@@ -2393,7 +2412,7 @@ static const EditorInternalCommand* internalCommand(const String& commandName) { |
supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
{WebEditingCommandType::MoveUp, executeMoveUp, |
- supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, |
+ supportedFromMenuOrKeyBinding, enabledInFocusedEditableText, stateNone, |
valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled}, |
{WebEditingCommandType::MoveUpAndModifySelection, |
executeMoveUpAndModifySelection, supportedFromMenuOrKeyBinding, |