Bug 1446522 - don't return NS_ERROR_FAILURE for cut/copy/paste even when there's no selection, r?enndeakin
MozReview-Commit-ID: AhToM4sAjJn
--- a/dom/base/nsGlobalWindowCommands.cpp
+++ b/dom/base/nsGlobalWindowCommands.cpp
@@ -561,20 +561,17 @@ nsClipboardCommand::DoCommand(const char
if (notCancelled && !strcmp(aCommandName, "cmd_copyAndCollapseToEnd")) {
dom::Selection *sel =
presShell->GetCurrentSelection(SelectionType::eNormal);
NS_ENSURE_TRUE(sel, NS_ERROR_FAILURE);
sel->CollapseToEnd();
}
- if (actionTaken) {
- return NS_OK;
- }
- return NS_ERROR_FAILURE;
+ return actionTaken ? NS_OK : NS_SUCCESS_DOM_NO_OPERATION;
}
NS_IMETHODIMP
nsClipboardCommand::GetCommandStateParams(const char *aCommandName,
nsICommandParams *aParams, nsISupports *aCommandContext)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -2882,16 +2882,19 @@ nsHTMLDocument::ExecCommand(const nsAStr
// which is to look at the focused element, and defer to a focused textbox's controller
// The code past taken by other commands in ExecCommand always uses the window directly,
// rather than deferring to the textbox, which is desireable for most editor commands,
// but not 'cut' and 'copy' (as those should allow copying out of embedded editors).
// This behaviour is invoked if we call DoCommand directly on the docShell.
nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
if (docShell) {
nsresult res = docShell->DoCommand(cmdToDispatch.get());
+ if (res == NS_SUCCESS_DOM_NO_OPERATION) {
+ return false;
+ }
return NS_SUCCEEDED(res);
}
return false;
}
if (commandID.LowerCaseEqualsLiteral("gethtml")) {
rv.Throw(NS_ERROR_FAILURE);
return false;