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

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

Issue 2891493003: Introduce EnabledUnselect for 'unselect' command (Closed)
Patch Set: Tue May 16 12:43:45 PDT 2017 Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 03a3aa44e59366023459af77a6d31442871996b8..0997b9633bc2789c5d7012f2c59a019564189db5 100644
--- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
@@ -2126,6 +2126,19 @@ static bool EnabledUndo(LocalFrame& frame, Event*, EditorCommandSource) {
return frame.GetEditor().CanUndo();
}
+static bool EnabledUnselect(LocalFrame& frame,
+ Event* event,
+ EditorCommandSource) {
+ frame.GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
+
+ // The term "visible" here includes a caret in editable text or a range in any
+ // text.
+ const VisibleSelection& selection =
+ frame.GetEditor().SelectionForCommand(event);
+ return (selection.IsCaret() && selection.IsContentEditable()) ||
+ selection.IsRange();
+}
+
static bool EnabledSelectAll(LocalFrame& frame, Event*, EditorCommandSource) {
// TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
@@ -2755,7 +2768,7 @@ static const EditorInternalCommand* InternalCommand(
SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateNone,
ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled},
{WebEditingCommandType::kUnselect, ExecuteUnselect, Supported,
- EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion,
+ EnabledUnselect, StateNone, ValueStateOrNull, kNotTextInsertion,
kDoNotAllowExecutionWhenDisabled},
{WebEditingCommandType::kUseCSS, ExecuteUseCSS, Supported, Enabled,
StateNone, ValueStateOrNull, kNotTextInsertion,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698