Bug 1546577 - Make overloads of CanCut(), CanCopy(), CanDelete() and CanPaste() which return bool instead of nsresult r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 25 Apr 2019 07:14:39 +0000
changeset 530063 feb8846c6602b5fb4a2580ee1f9155d2fb509585
parent 530062 0c850ce605222bbcc4ff3ef4321fd0e7580f98f4
child 530064 14c489ed12e40841f0156966823ff72b9dca5eb7
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1546577
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1546577 - Make overloads of CanCut(), CanCopy(), CanDelete() and CanPaste() which return bool instead of nsresult r=m_kato `CanCut()`, `CanCopy()` and `CanPaste()` return error only when the editor has already been destroyed or not been initialized yet, or when failed to access clipboard when the document is not HTML/XHTML. `CanDelete()` returns error only when the editor has already been destroyed or not been initialized yet. So, these error result won't be exposed to the web in most cases and such exception shouldn't stop any content script because Chrome basically does not throw exception in such situation as far as I know. Therefore, there should be overloads of them to return `bool` result directly for making their callers simpler. Differential Revision: https://phabricator.services.mozilla.com/D28608
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorCommands.cpp
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorCommands.cpp
editor/libeditor/HTMLEditorDataTransfer.cpp
editor/libeditor/TextEditor.cpp
editor/libeditor/TextEditor.h
editor/libeditor/TextEditorDataTransfer.cpp
editor/nsIEditor.idl
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -1119,26 +1119,44 @@ EditorBase::SetDocumentCharacterSet(cons
   document->SetDocumentCharacterSet(WrapNotNull(encoding));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 EditorBase::Cut() { return NS_ERROR_NOT_IMPLEMENTED; }
 
 NS_IMETHODIMP
-EditorBase::CanCut(bool* aCanCut) { return NS_ERROR_NOT_IMPLEMENTED; }
+EditorBase::CanCut(bool* aCanCut) {
+  if (NS_WARN_IF(!aCanCut)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+  *aCanCut = AsTextEditor()->CanCut();
+  return NS_OK;
+}
 
 NS_IMETHODIMP
 EditorBase::Copy() { return NS_ERROR_NOT_IMPLEMENTED; }
 
 NS_IMETHODIMP
-EditorBase::CanCopy(bool* aCanCut) { return NS_ERROR_NOT_IMPLEMENTED; }
+EditorBase::CanCopy(bool* aCanCopy) {
+  if (NS_WARN_IF(!aCanCopy)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+  *aCanCopy = AsTextEditor()->CanCopy();
+  return NS_OK;
+}
 
 NS_IMETHODIMP
-EditorBase::CanDelete(bool* aCanDelete) { return NS_ERROR_NOT_IMPLEMENTED; }
+EditorBase::CanDelete(bool* aCanDelete) {
+  if (NS_WARN_IF(!aCanDelete)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+  *aCanDelete = AsTextEditor()->CanDelete();
+  return NS_OK;
+}
 
 NS_IMETHODIMP
 EditorBase::Paste(int32_t aClipboardType) {
   // MOZ_KnownLive because we know "this" must be alive.
   nsresult rv =
       MOZ_KnownLive(AsTextEditor())->PasteAsAction(aClipboardType, true);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -1147,18 +1165,22 @@ EditorBase::Paste(int32_t aClipboardType
 }
 
 NS_IMETHODIMP
 EditorBase::PasteTransferable(nsITransferable* aTransferable) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-EditorBase::CanPaste(int32_t aSelectionType, bool* aCanPaste) {
-  return NS_ERROR_NOT_IMPLEMENTED;
+EditorBase::CanPaste(int32_t aClipboardType, bool* aCanPaste) {
+  if (NS_WARN_IF(!aCanPaste)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+  *aCanPaste = AsTextEditor()->CanPaste(aClipboardType);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 EditorBase::SetAttribute(Element* aElement, const nsAString& aAttribute,
                          const nsAString& aValue) {
   if (NS_WARN_IF(aAttribute.IsEmpty())) {
     return NS_ERROR_INVALID_ARG;
   }
--- a/editor/libeditor/EditorCommands.cpp
+++ b/editor/libeditor/EditorCommands.cpp
@@ -170,17 +170,18 @@ CutCommand::IsCommandEnabled(const char*
   if (!editor) {
     return NS_OK;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
   if (!textEditor->IsSelectionEditable()) {
     return NS_OK;
   }
-  return editor->CanCut(aIsEnabled);
+  *aIsEnabled = textEditor->CanCut();
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 CutCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
   }
@@ -279,17 +280,18 @@ CopyCommand::IsCommandEnabled(const char
   }
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     *aIsEnabled = false;
     return NS_OK;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
-  return textEditor->CanCopy(aIsEnabled);
+  *aIsEnabled = textEditor->CanCopy();
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 CopyCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
   }
@@ -395,17 +397,18 @@ PasteCommand::IsCommandEnabled(const cha
   if (!editor) {
     return NS_OK;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
   if (!textEditor->IsSelectionEditable()) {
     return NS_OK;
   }
-  return textEditor->CanPaste(nsIClipboard::kGlobalClipboard, aIsEnabled);
+  *aIsEnabled = textEditor->CanPaste(nsIClipboard::kGlobalClipboard);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 PasteCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
@@ -604,20 +607,17 @@ DeleteCommand::IsCommandEnabled(const ch
   MOZ_ASSERT(textEditor);
 
   // We can generally delete whenever the selection is editable.  However,
   // cmd_delete doesn't make sense if the selection is collapsed because it's
   // directionless, which is the same condition under which we can't cut.
   *aIsEnabled = textEditor->IsSelectionEditable();
 
   if (!nsCRT::strcmp("cmd_delete", aCommandName) && *aIsEnabled) {
-    nsresult rv = textEditor->CanDelete(aIsEnabled);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
+    *aIsEnabled = textEditor->CanDelete();
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DeleteCommand::DoCommand(const char* aCommandName,
                          nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
@@ -1113,17 +1113,18 @@ PasteQuotationCommand::IsCommandEnabled(
   if (!editor) {
     return NS_OK;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
   if (textEditor->IsSingleLineEditor()) {
     return NS_OK;
   }
-  return textEditor->CanPaste(nsIClipboard::kGlobalClipboard, aIsEnabled);
+  *aIsEnabled = textEditor->CanPaste(nsIClipboard::kGlobalClipboard);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 PasteQuotationCommand::DoCommand(const char* aCommandName,
                                  nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
@@ -1165,15 +1166,14 @@ PasteQuotationCommand::GetCommandStatePa
                                              nsICommandParams* aParams,
                                              nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_OK;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
-  bool enabled = false;
-  textEditor->CanPaste(nsIClipboard::kGlobalClipboard, &enabled);
-  aParams->AsCommandParams()->SetBool(STATE_ENABLED, enabled);
+  aParams->AsCommandParams()->SetBool(
+      STATE_ENABLED, textEditor->CanPaste(nsIClipboard::kGlobalClipboard));
   return NS_OK;
 }
 
 }  // namespace mozilla
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -128,17 +128,18 @@ class HTMLEditor final : public TextEdit
   // TextEditor overrides
   MOZ_CAN_RUN_SCRIPT
   virtual nsresult Init(Document& aDoc, Element* aRoot,
                         nsISelectionController* aSelCon, uint32_t aFlags,
                         const nsAString& aValue) override;
   NS_IMETHOD BeginningOfDocument() override;
   NS_IMETHOD SetFlags(uint32_t aFlags) override;
 
-  NS_IMETHOD CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
+  virtual bool CanPaste(int32_t aClipboardType) const override;
+  using EditorBase::CanPaste;
 
   MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD PasteTransferable(nsITransferable* aTransferable) override;
 
   NS_IMETHOD DeleteNode(nsINode* aNode) override;
 
   NS_IMETHOD InsertLineBreak() override;
 
--- a/editor/libeditor/HTMLEditorCommands.cpp
+++ b/editor/libeditor/HTMLEditorCommands.cpp
@@ -140,17 +140,18 @@ PasteNoFormattingCommand::IsCommandEnabl
 
   // This command is only implemented by nsIHTMLEditor, since
   //  pasting in a plaintext editor automatically only supplies
   //  "unformatted" text
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
-  return htmlEditor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
+  *outCmdEnabled = htmlEditor->CanPaste(nsIClipboard::kGlobalClipboard);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 PasteNoFormattingCommand::DoCommand(const char* aCommandName,
                                     nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -1616,54 +1616,55 @@ HTMLEditor::PasteNoFormatting(int32_t aS
 // The following arrays contain the MIME types that we can paste. The arrays
 // are used by CanPaste() and CanPasteTransferable() below.
 
 static const char* textEditorFlavors[] = {kUnicodeMime};
 static const char* textHtmlEditorFlavors[] = {kUnicodeMime,   kHTMLMime,
                                               kJPEGImageMime, kJPGImageMime,
                                               kPNGImageMime,  kGIFImageMime};
 
-NS_IMETHODIMP
-HTMLEditor::CanPaste(int32_t aSelectionType, bool* aCanPaste) {
-  NS_ENSURE_ARG_POINTER(aCanPaste);
-  *aCanPaste = false;
-
+bool HTMLEditor::CanPaste(int32_t aClipboardType) const {
   // Always enable the paste command when inside of a HTML or XHTML document.
-  RefPtr<Document> doc = GetDocument();
-  if (doc && doc->IsHTMLOrXHTML()) {
-    *aCanPaste = true;
-    return NS_OK;
+  Document* document = GetDocument();
+  if (document && document->IsHTMLOrXHTML()) {
+    return true;
   }
 
   // can't paste if readonly
   if (!IsModifiable()) {
-    return NS_OK;
+    return false;
   }
 
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(
       do_GetService("@mozilla.org/widget/clipboard;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  bool haveFlavors;
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
 
   // Use the flavors depending on the current editor mask
   if (IsPlaintextEditor()) {
+    bool haveFlavors;
     rv = clipboard->HasDataMatchingFlavors(textEditorFlavors,
                                            ArrayLength(textEditorFlavors),
-                                           aSelectionType, &haveFlavors);
-  } else {
-    rv = clipboard->HasDataMatchingFlavors(textHtmlEditorFlavors,
-                                           ArrayLength(textHtmlEditorFlavors),
-                                           aSelectionType, &haveFlavors);
+                                           aClipboardType, &haveFlavors);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return false;
+    }
+    return haveFlavors;
   }
-  NS_ENSURE_SUCCESS(rv, rv);
 
-  *aCanPaste = haveFlavors;
-  return NS_OK;
+  bool haveFlavors;
+  rv = clipboard->HasDataMatchingFlavors(textHtmlEditorFlavors,
+                                         ArrayLength(textHtmlEditorFlavors),
+                                         aClipboardType, &haveFlavors);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
+  return haveFlavors;
 }
 
 bool HTMLEditor::CanPasteTransferable(nsITransferable* aTransferable) {
   // can't paste if readonly
   if (!IsModifiable()) {
     return false;
   }
 
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -1732,17 +1732,18 @@ TextEditor::Redo(uint32_t aCount) {
 
   NotifyEditorObservers(eNotifyEditorObserversOfEnd);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return EditorBase::ToGenericNSResult(rv);
   }
   return NS_OK;
 }
 
-bool TextEditor::CanCutOrCopy(PasswordFieldAllowed aPasswordFieldAllowed) {
+bool TextEditor::CanCutOrCopy(
+    PasswordFieldAllowed aPasswordFieldAllowed) const {
   MOZ_ASSERT(IsEditActionDataAvailable());
 
   if (aPasswordFieldAllowed == ePasswordFieldNotAllowed && IsPasswordEditor()) {
     return false;
   }
 
   return !SelectionRefPtr()->IsCollapsed();
 }
@@ -1785,78 +1786,66 @@ TextEditor::Cut() {
     //     so that we need to keep using it here.
     AutoPlaceholderBatch treatAsOneTransaction(*this,
                                                *nsGkAtoms::DeleteTxnName);
     DeleteSelectionAsSubAction(eNone, eStrip);
   }
   return actionTaken ? NS_OK : NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP
-TextEditor::CanCut(bool* aCanCut) {
-  if (NS_WARN_IF(!aCanCut)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
+bool TextEditor::CanCut() const {
   AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
   if (NS_WARN_IF(!editActionData.CanHandle())) {
-    return NS_ERROR_NOT_INITIALIZED;
+    return false;
   }
 
   // Cut is always enabled in HTML documents
-  RefPtr<Document> doc = GetDocument();
-  *aCanCut = (doc && doc->IsHTMLOrXHTML()) ||
-             (IsModifiable() && CanCutOrCopy(ePasswordFieldNotAllowed));
-  return NS_OK;
+  Document* document = GetDocument();
+  if (document && document->IsHTMLOrXHTML()) {
+    return true;
+  }
+
+  return IsModifiable() && CanCutOrCopy(ePasswordFieldNotAllowed);
 }
 
 NS_IMETHODIMP
 TextEditor::Copy() {
   AutoEditActionDataSetter editActionData(*this, EditAction::eCopy);
   if (NS_WARN_IF(!editActionData.CanHandle())) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   bool actionTaken = false;
   FireClipboardEvent(eCopy, nsIClipboard::kGlobalClipboard, &actionTaken);
 
   return actionTaken ? NS_OK : NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP
-TextEditor::CanCopy(bool* aCanCopy) {
-  if (NS_WARN_IF(!aCanCopy)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
+bool TextEditor::CanCopy() const {
   AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
   if (NS_WARN_IF(!editActionData.CanHandle())) {
-    return NS_ERROR_NOT_INITIALIZED;
+    return false;
   }
 
   // Copy is always enabled in HTML documents
-  RefPtr<Document> doc = GetDocument();
-  *aCanCopy =
-      (doc && doc->IsHTMLOrXHTML()) || CanCutOrCopy(ePasswordFieldNotAllowed);
-  return NS_OK;
+  Document* document = GetDocument();
+  if (document && document->IsHTMLOrXHTML()) {
+    return true;
+  }
+
+  return CanCutOrCopy(ePasswordFieldNotAllowed);
 }
 
-NS_IMETHODIMP
-TextEditor::CanDelete(bool* aCanDelete) {
-  if (NS_WARN_IF(!aCanDelete)) {
-    return NS_ERROR_INVALID_ARG;
+bool TextEditor::CanDelete() const {
+  AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
+  if (NS_WARN_IF(!editActionData.CanHandle())) {
+    return false;
   }
 
-  AutoEditActionDataSetter editActionData(*this, EditAction::eNotEditing);
-  if (NS_WARN_IF(!editActionData.CanHandle())) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-
-  *aCanDelete = IsModifiable() && CanCutOrCopy(ePasswordFieldAllowed);
-  return NS_OK;
+  return IsModifiable() && CanCutOrCopy(ePasswordFieldAllowed);
 }
 
 already_AddRefed<nsIDocumentEncoder> TextEditor::GetAndInitDocEncoder(
     const nsAString& aFormatType, uint32_t aDocumentEncoderFlags,
     const nsACString& aCharset) const {
   MOZ_ASSERT(IsEditActionDataAvailable());
 
   nsCOMPtr<nsIDocumentEncoder> docEncoder;
--- a/editor/libeditor/TextEditor.h
+++ b/editor/libeditor/TextEditor.h
@@ -63,21 +63,29 @@ class TextEditor : public EditorBase, pu
   // If there are some good name to create non-virtual Undo()/Redo() methods,
   // we should create them and those methods should just run them.
   MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD Undo(uint32_t aCount) final;
   MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD Redo(uint32_t aCount) final;
 
   NS_IMETHOD Cut() override;
-  NS_IMETHOD CanCut(bool* aCanCut) override;
+  bool CanCut() const;
   NS_IMETHOD Copy() override;
-  NS_IMETHOD CanCopy(bool* aCanCopy) override;
-  NS_IMETHOD CanDelete(bool* aCanDelete) override;
-  NS_IMETHOD CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
+  bool CanCopy() const;
+  bool CanDelete() const;
+  virtual bool CanPaste(int32_t aClipboardType) const;
+
+  // Shouldn't be used internally, but we need these using declarations for
+  // avoiding warnings of clang.
+  using EditorBase::CanCopy;
+  using EditorBase::CanCut;
+  using EditorBase::CanDelete;
+  using EditorBase::CanPaste;
+
   MOZ_CAN_RUN_SCRIPT
   NS_IMETHOD PasteTransferable(nsITransferable* aTransferable) override;
 
   NS_IMETHOD OutputToString(const nsAString& aFormatType, uint32_t aFlags,
                             nsAString& aOutputString) override;
 
   /** Can we paste |aTransferable| or, if |aTransferable| is null, will a call
    * to pasteTransferable later possibly succeed if given an instance of
@@ -499,17 +507,17 @@ class TextEditor : public EditorBase, pu
   /**
    * Shared outputstring; returns whether selection is collapsed and resulting
    * string.
    */
   nsresult SharedOutputString(uint32_t aFlags, bool* aIsCollapsed,
                               nsAString& aResult);
 
   enum PasswordFieldAllowed { ePasswordFieldAllowed, ePasswordFieldNotAllowed };
-  bool CanCutOrCopy(PasswordFieldAllowed aPasswordFieldAllowed);
+  bool CanCutOrCopy(PasswordFieldAllowed aPasswordFieldAllowed) const;
   bool FireClipboardEvent(EventMessage aEventMessage, int32_t aSelectionType,
                           bool* aActionTaken = nullptr);
 
   bool UpdateMetaCharset(Document& aDocument, const nsACString& aCharacterSet);
 
   /**
    * EnsureComposition() should be called by composition event handlers.  This
    * tries to get the composition for the event and set it to mComposition.
--- a/editor/libeditor/TextEditorDataTransfer.cpp
+++ b/editor/libeditor/TextEditorDataTransfer.cpp
@@ -434,49 +434,46 @@ TextEditor::PasteTransferable(nsITransfe
 
   nsresult rv = InsertTextFromTransferable(aTransferable);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return EditorBase::ToGenericNSResult(rv);
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP
-TextEditor::CanPaste(int32_t aSelectionType, bool* aCanPaste) {
-  NS_ENSURE_ARG_POINTER(aCanPaste);
-  *aCanPaste = false;
-
+bool TextEditor::CanPaste(int32_t aClipboardType) const {
   // Always enable the paste command when inside of a HTML or XHTML document.
   RefPtr<Document> doc = GetDocument();
   if (doc && doc->IsHTMLOrXHTML()) {
-    *aCanPaste = true;
-    return NS_OK;
+    return true;
   }
 
   // can't paste if readonly
   if (!IsModifiable()) {
-    return NS_OK;
+    return false;
   }
 
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(
       do_GetService("@mozilla.org/widget/clipboard;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
 
   // the flavors that we can deal with
   const char* textEditorFlavors[] = {kUnicodeMime};
 
   bool haveFlavors;
   rv = clipboard->HasDataMatchingFlavors(textEditorFlavors,
                                          ArrayLength(textEditorFlavors),
-                                         aSelectionType, &haveFlavors);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aCanPaste = haveFlavors;
-  return NS_OK;
+                                         aClipboardType, &haveFlavors);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
+  return haveFlavors;
 }
 
 bool TextEditor::CanPasteTransferable(nsITransferable* aTransferable) {
   // can't paste if readonly
   if (!IsModifiable()) {
     return false;
   }
 
--- a/editor/nsIEditor.idl
+++ b/editor/nsIEditor.idl
@@ -286,28 +286,28 @@ interface nsIEditor  : nsISupports
   /** Can we delete? True if we have a non-collapsed selection.
     */
   boolean canDelete();
 
   /** paste the text in the OS clipboard at the cursor position, replacing
     * the selected text (if any)
     */
   [can_run_script]
-  void paste(in long aSelectionType);
+  void paste(in long aClipboardType);
 
   /** Paste the text in |aTransferable| at the cursor position, replacing the
     * selected text (if any).
     */
   [can_run_script]
   void pasteTransferable(in nsITransferable aTransferable);
 
   /** Can we paste? True if the doc is modifiable, and we have
     * pasteable data in the clipboard.
     */
-  boolean canPaste(in long aSelectionType);
+  boolean canPaste(in long aClipboardType);
 
   /* ------------ Selection methods -------------- */
 
   /** sets the document selection to the entire contents of the document */
   [can_run_script]
   void selectAll();
 
   /**