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

Unified Diff: third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp

Issue 2616623002: Do not send redundant selectionchange-events (decouple focus) (Closed)
Patch Set: Restore tab-key (and spatial) navigation's clearing behavior Created 3 years, 10 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/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 183403d5088dc50f8ddebc4ec3271022bcd066bf..aaab8722cdc2196b3977fbbf035f2bd84b52c989 100644
--- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
@@ -1877,6 +1877,22 @@ 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().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) {
@@ -2246,7 +2262,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,
@@ -2260,7 +2276,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,
@@ -2296,7 +2312,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,
@@ -2377,7 +2393,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,

Powered by Google App Engine
This is Rietveld 408576698