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

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

Issue 2894473003: Fix behavior of clipboard commands when there is unfocused selection (Closed)
Patch Set: Fix UnsafeSVGAttributeSanitizationTest 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 03772a7b444d0c8704633a5c36e56cc5c05b2ec2..da67273b100e9519ea573f8fe220e90803277a22 100644
--- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
@@ -663,7 +663,7 @@ static bool ExecuteCopy(LocalFrame& frame,
// |canExecute()|. See also "Cut", and "Paste" command.
if (!CanWriteClipboard(frame, source))
return false;
- frame.GetEditor().Copy();
+ frame.GetEditor().Copy(source);
return true;
}
@@ -2044,12 +2044,18 @@ static bool EnableCaretInEditableText(LocalFrame& frame,
static bool EnabledCopy(LocalFrame& frame, Event*, EditorCommandSource source) {
if (!CanWriteClipboard(frame, source))
return false;
+ if (source == kCommandFromMenuOrKeyBinding &&
+ !frame.Selection().SelectionHasFocus())
+ return false;
return frame.GetEditor().CanDHTMLCopy() || frame.GetEditor().CanCopy();
}
static bool EnabledCut(LocalFrame& frame, Event*, EditorCommandSource source) {
if (!CanWriteClipboard(frame, source))
return false;
+ if (source == kCommandFromMenuOrKeyBinding &&
+ !frame.Selection().SelectionHasFocus())
+ return false;
return frame.GetEditor().CanDHTMLCut() || frame.GetEditor().CanCut();
}
@@ -2101,6 +2107,9 @@ static bool EnabledPaste(LocalFrame& frame,
EditorCommandSource source) {
if (!CanReadClipboard(frame, source))
return false;
+ if (source == kCommandFromMenuOrKeyBinding &&
+ !frame.Selection().SelectionHasFocus())
+ return false;
return frame.GetEditor().CanPaste();
}

Powered by Google App Engine
This is Rietveld 408576698