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

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

Issue 2712603007: Select All present even all selectable text has been selected (Closed)
Patch Set: yosin's nits Created 3 years, 9 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 89c11ce75f4912b74a84e407ff97494e04fd9d7a..9c793b5b08531b3b703d19441614cc4c0360dd1a 100644
--- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
@@ -59,6 +59,7 @@
#include "core/html/HTMLFontElement.h"
#include "core/html/HTMLHRElement.h"
#include "core/html/HTMLImageElement.h"
+#include "core/html/TextControlElement.h"
#include "core/input/EventHandler.h"
#include "core/layout/LayoutBox.h"
#include "core/page/ChromeClient.h"
@@ -2103,6 +2104,25 @@ static bool enabledUndo(LocalFrame& frame, Event*, EditorCommandSource) {
return frame.editor().canUndo();
}
+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.
+ frame.document()->updateStyleAndLayoutIgnorePendingStylesheets();
+ const VisibleSelection& selection =
+ frame.selection().computeVisibleSelectionInDOMTree();
+ if (selection.isNone())
+ return true;
+ if (TextControlElement* textControl =
+ enclosingTextControl(selection.start())) {
+ if (textControl->innerEditorValue().isEmpty())
+ return false;
+ // TODO(amaralp): Return false if already fully selected.
+ }
+ // TODO(amaralp): Support contentEditable.
+ // TODO(amaralp): Address user-select handling.
+ return true;
+}
+
// State functions
static TriState stateNone(LocalFrame&, Event*) {
@@ -2612,8 +2632,9 @@ static const EditorInternalCommand* internalCommand(const String& commandName) {
{WebEditingCommandType::ScrollToEndOfDocument,
executeScrollToEndOfDocument, supportedFromMenuOrKeyBinding, enabled,
stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
- {WebEditingCommandType::SelectAll, executeSelectAll, supported, enabled,
- stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},
+ {WebEditingCommandType::SelectAll, executeSelectAll, supported,
+ enabledSelectAll, stateNone, valueNull, notTextInsertion,
+ doNotAllowExecutionWhenDisabled},
{WebEditingCommandType::SelectLine, executeSelectLine,
supportedFromMenuOrKeyBinding, enabledVisibleSelection, stateNone,
valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled},

Powered by Google App Engine
This is Rietveld 408576698