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

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

Issue 2891203002: Make user-triggered SelectAll act as if there is no selection for hidden selection (Closed)
Patch Set: 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
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 180ac264dabe5954cdc11d1cc588f72befd586c5..fe1b058c8240ac16052a72e2822ff952758e625d 100644
--- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
@@ -1750,9 +1750,12 @@ static bool ExecuteScrollToEndOfDocument(LocalFrame& frame,
static bool ExecuteSelectAll(LocalFrame& frame,
Event*,
- EditorCommandSource,
+ EditorCommandSource source,
const String&) {
- frame.Selection().SelectAll();
+ const EUserTriggered user_triggered = source == kCommandFromMenuOrKeyBinding
+ ? kUserTriggered
+ : kNotUserTriggered;
+ frame.Selection().SelectAll(user_triggered);
return true;
}
@@ -2159,7 +2162,9 @@ static bool EnabledUnselect(LocalFrame& frame,
selection.IsRange();
}
-static bool EnabledSelectAll(LocalFrame& frame, Event*, EditorCommandSource) {
+static bool EnabledSelectAll(LocalFrame& frame,
+ Event*,
+ EditorCommandSource source) {
// TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
frame.GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
@@ -2167,6 +2172,10 @@ static bool EnabledSelectAll(LocalFrame& frame, Event*, EditorCommandSource) {
frame.Selection().ComputeVisibleSelectionInDOMTree();
if (selection.IsNone())
return true;
+ // Hidden selection appears as no selection to users, in which case user-
+ // triggered SelectAll should be enabled and act as if there is no selection.
+ if (source == kCommandFromMenuOrKeyBinding && frame.Selection().IsHidden())
+ return true;
if (Node* root = HighestEditableRoot(selection.Start())) {
if (!root->hasChildren())
return false;

Powered by Google App Engine
This is Rietveld 408576698