Bug 1546578 - part 5: Make EditorCommand implement nsIControllerCommand::IsCommandEnabled() and call internal IsCommandEnabled() method which return bool directly r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 26 Apr 2019 13:11:24 +0000
changeset 530498 409044e9dbbdcc622a42ea9da9d9ee88ea5d4e20
parent 530497 6f718d253d8d01518b70fd56f78941882474f3b5
child 530499 93f5bf3c98074111ce1a1246b89d636f4f48b491
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
bugs1546578
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 1546578 - part 5: Make EditorCommand implement nsIControllerCommand::IsCommandEnabled() and call internal IsCommandEnabled() method which return bool directly r=m_kato This patch makes `EditorCommand` implement `nsIControllerCommand::IsCommandEnabled()` and then, makes it call internal `IsCommandEnabled()` method which returns `bool` directly and takes `TextEditor` instead. This makes each implementation really simpler. Differential Revision: https://phabricator.services.mozilla.com/D28687
editor/libeditor/EditorCommands.cpp
editor/libeditor/EditorCommands.h
editor/libeditor/HTMLEditorCommands.cpp
editor/libeditor/HTMLEditorDocumentCommands.cpp
--- a/editor/libeditor/EditorCommands.cpp
+++ b/editor/libeditor/EditorCommands.cpp
@@ -32,42 +32,41 @@ class nsISupports;
 namespace mozilla {
 
 /******************************************************************************
  * mozilla::EditorCommand
  ******************************************************************************/
 
 NS_IMPL_ISUPPORTS(EditorCommand, nsIControllerCommand)
 
+NS_IMETHODIMP
+EditorCommand::IsCommandEnabled(const char* aCommandName,
+                                nsISupports* aCommandRefCon, bool* aIsEnabled) {
+  if (NS_WARN_IF(!aCommandName) || NS_WARN_IF(!aIsEnabled)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
+  TextEditor* textEditor = editor ? editor->AsTextEditor() : nullptr;
+  *aIsEnabled = IsCommandEnabled(aCommandName, textEditor);
+  return NS_OK;
+}
+
 /******************************************************************************
  * mozilla::UndoCommand
  ******************************************************************************/
 
 StaticRefPtr<UndoCommand> UndoCommand::sInstance;
 
-NS_IMETHODIMP
-UndoCommand::IsCommandEnabled(const char* aCommandName,
-                              nsISupports* aCommandRefCon, bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool UndoCommand::IsCommandEnabled(const char* aCommandName,
+                                   TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-
-  *aIsEnabled = false;
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  if (!textEditor->IsSelectionEditable()) {
-    return NS_OK;
-  }
-  *aIsEnabled = textEditor->CanUndo();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable() && aTextEditor->CanUndo();
 }
 
 NS_IMETHODIMP
 UndoCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
   }
@@ -94,36 +93,22 @@ UndoCommand::GetCommandStateParams(const
 }
 
 /******************************************************************************
  * mozilla::RedoCommand
  ******************************************************************************/
 
 StaticRefPtr<RedoCommand> RedoCommand::sInstance;
 
-NS_IMETHODIMP
-RedoCommand::IsCommandEnabled(const char* aCommandName,
-                              nsISupports* aCommandRefCon, bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool RedoCommand::IsCommandEnabled(const char* aCommandName,
+                                   TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-
-  *aIsEnabled = false;
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  if (!textEditor->IsSelectionEditable()) {
-    return NS_OK;
-  }
-  *aIsEnabled = textEditor->CanRedo();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable() && aTextEditor->CanRedo();
 }
 
 NS_IMETHODIMP
 RedoCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
   }
@@ -150,36 +135,22 @@ RedoCommand::GetCommandStateParams(const
 }
 
 /******************************************************************************
  * mozilla::CutCommand
  ******************************************************************************/
 
 StaticRefPtr<CutCommand> CutCommand::sInstance;
 
-NS_IMETHODIMP
-CutCommand::IsCommandEnabled(const char* aCommandName,
-                             nsISupports* aCommandRefCon, bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool CutCommand::IsCommandEnabled(const char* aCommandName,
+                                  TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-
-  *aIsEnabled = false;
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  if (!textEditor->IsSelectionEditable()) {
-    return NS_OK;
-  }
-  *aIsEnabled = textEditor->CanCut();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable() && aTextEditor->CanCut();
 }
 
 NS_IMETHODIMP
 CutCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
   }
@@ -204,32 +175,22 @@ CutCommand::GetCommandStateParams(const 
 }
 
 /******************************************************************************
  * mozilla::CutOrDeleteCommand
  ******************************************************************************/
 
 StaticRefPtr<CutOrDeleteCommand> CutOrDeleteCommand::sInstance;
 
-NS_IMETHODIMP
-CutOrDeleteCommand::IsCommandEnabled(const char* aCommandName,
-                                     nsISupports* aCommandRefCon,
-                                     bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool CutOrDeleteCommand::IsCommandEnabled(const char* aCommandName,
+                                          TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    *aIsEnabled = false;
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  *aIsEnabled = textEditor->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 CutOrDeleteCommand::DoCommand(const char* aCommandName,
                               nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
@@ -265,31 +226,22 @@ CutOrDeleteCommand::GetCommandStateParam
 }
 
 /******************************************************************************
  * mozilla::CopyCommand
  ******************************************************************************/
 
 StaticRefPtr<CopyCommand> CopyCommand::sInstance;
 
-NS_IMETHODIMP
-CopyCommand::IsCommandEnabled(const char* aCommandName,
-                              nsISupports* aCommandRefCon, bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool CopyCommand::IsCommandEnabled(const char* aCommandName,
+                                   TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    *aIsEnabled = false;
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  *aIsEnabled = textEditor->CanCopy();
-  return NS_OK;
+  return aTextEditor->CanCopy();
 }
 
 NS_IMETHODIMP
 CopyCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
   }
@@ -315,33 +267,22 @@ CopyCommand::GetCommandStateParams(const
 }
 
 /******************************************************************************
  * mozilla::CopyOrDeleteCommand
  ******************************************************************************/
 
 StaticRefPtr<CopyOrDeleteCommand> CopyOrDeleteCommand::sInstance;
 
-NS_IMETHODIMP
-CopyOrDeleteCommand::IsCommandEnabled(const char* aCommandName,
-                                      nsISupports* aCommandRefCon,
-                                      bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool CopyOrDeleteCommand::IsCommandEnabled(const char* aCommandName,
+                                           TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    *aIsEnabled = false;
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  *aIsEnabled = textEditor->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 CopyOrDeleteCommand::DoCommand(const char* aCommandName,
                                nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
@@ -377,36 +318,23 @@ CopyOrDeleteCommand::GetCommandStatePara
 }
 
 /******************************************************************************
  * mozilla::PasteCommand
  ******************************************************************************/
 
 StaticRefPtr<PasteCommand> PasteCommand::sInstance;
 
-NS_IMETHODIMP
-PasteCommand::IsCommandEnabled(const char* aCommandName,
-                               nsISupports* aCommandRefCon, bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool PasteCommand::IsCommandEnabled(const char* aCommandName,
+                                    TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-
-  *aIsEnabled = false;
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  if (!textEditor->IsSelectionEditable()) {
-    return NS_OK;
-  }
-  *aIsEnabled = textEditor->CanPaste(nsIClipboard::kGlobalClipboard);
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable() &&
+         aTextEditor->CanPaste(nsIClipboard::kGlobalClipboard);
 }
 
 NS_IMETHODIMP
 PasteCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
@@ -434,37 +362,23 @@ PasteCommand::GetCommandStateParams(cons
 }
 
 /******************************************************************************
  * mozilla::PasteTransferableCommand
  ******************************************************************************/
 
 StaticRefPtr<PasteTransferableCommand> PasteTransferableCommand::sInstance;
 
-NS_IMETHODIMP
-PasteTransferableCommand::IsCommandEnabled(const char* aCommandName,
-                                           nsISupports* aCommandRefCon,
-                                           bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool PasteTransferableCommand::IsCommandEnabled(const char* aCommandName,
+                                                TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-
-  *aIsEnabled = false;
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  if (!textEditor->IsSelectionEditable()) {
-    return NS_OK;
-  }
-  *aIsEnabled = textEditor->CanPasteTransferable(nullptr);
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable() &&
+         aTextEditor->CanPasteTransferable(nullptr);
 }
 
 NS_IMETHODIMP
 PasteTransferableCommand::DoCommand(const char* aCommandName,
                                     nsISupports* aCommandRefCon) {
   return NS_ERROR_FAILURE;
 }
 
@@ -528,32 +442,22 @@ PasteTransferableCommand::GetCommandStat
 }
 
 /******************************************************************************
  * mozilla::SwitchTextDirectionCommand
  ******************************************************************************/
 
 StaticRefPtr<SwitchTextDirectionCommand> SwitchTextDirectionCommand::sInstance;
 
-NS_IMETHODIMP
-SwitchTextDirectionCommand::IsCommandEnabled(const char* aCommandName,
-                                             nsISupports* aCommandRefCon,
-                                             bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool SwitchTextDirectionCommand::IsCommandEnabled(
+    const char* aCommandName, TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    *aIsEnabled = false;
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  *aIsEnabled = textEditor->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 SwitchTextDirectionCommand::DoCommand(const char* aCommandName,
                                       nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
@@ -582,42 +486,30 @@ SwitchTextDirectionCommand::GetCommandSt
 }
 
 /******************************************************************************
  * mozilla::DeleteCommand
  ******************************************************************************/
 
 StaticRefPtr<DeleteCommand> DeleteCommand::sInstance;
 
-NS_IMETHODIMP
-DeleteCommand::IsCommandEnabled(const char* aCommandName,
-                                nsISupports* aCommandRefCon, bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool DeleteCommand::IsCommandEnabled(const char* aCommandName,
+                                     TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-
-  *aIsEnabled = false;
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    return NS_OK;
-  }
-
-  TextEditor* textEditor = editor->AsTextEditor();
-  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();
+  bool isEnabled = aTextEditor->IsSelectionEditable();
 
-  if (!nsCRT::strcmp("cmd_delete", aCommandName) && *aIsEnabled) {
-    *aIsEnabled = textEditor->CanDelete();
+  if (!nsCRT::strcmp("cmd_delete", aCommandName) && isEnabled) {
+    return aTextEditor->CanDelete();
   }
-  return NS_OK;
+  return isEnabled;
 }
 
 NS_IMETHODIMP
 DeleteCommand::DoCommand(const char* aCommandName,
                          nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
@@ -673,42 +565,30 @@ DeleteCommand::GetCommandStateParams(con
 }
 
 /******************************************************************************
  * mozilla::SelectAllCommand
  ******************************************************************************/
 
 StaticRefPtr<SelectAllCommand> SelectAllCommand::sInstance;
 
-NS_IMETHODIMP
-SelectAllCommand::IsCommandEnabled(const char* aCommandName,
-                                   nsISupports* aCommandRefCon,
-                                   bool* aIsEnabled) {
-  NS_ENSURE_ARG_POINTER(aIsEnabled);
-
-  nsresult rv = NS_OK;
+bool SelectAllCommand::IsCommandEnabled(const char* aCommandName,
+                                        TextEditor* aTextEditor) const {
   // You can always select all, unless the selection is editable,
   // and the editable region is empty!
-  *aIsEnabled = true;
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    return NS_OK;
+  if (!aTextEditor) {
+    return true;
   }
 
   // You can select all if there is an editor which is non-empty
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
   bool isEmpty = false;
-  rv = textEditor->IsEmpty(&isEmpty);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
+  if (NS_WARN_IF(NS_FAILED(aTextEditor->IsEmpty(&isEmpty)))) {
+    return false;
   }
-  *aIsEnabled = !isEmpty;
-  return NS_OK;
+  return !isEmpty;
 }
 
 NS_IMETHODIMP
 SelectAllCommand::DoCommand(const char* aCommandName,
                             nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (!editor) {
     return NS_ERROR_FAILURE;
@@ -735,30 +615,22 @@ SelectAllCommand::GetCommandStateParams(
 }
 
 /******************************************************************************
  * mozilla::SelectionMoveCommands
  ******************************************************************************/
 
 StaticRefPtr<SelectionMoveCommands> SelectionMoveCommands::sInstance;
 
-NS_IMETHODIMP
-SelectionMoveCommands::IsCommandEnabled(const char* aCommandName,
-                                        nsISupports* aCommandRefCon,
-                                        bool* aIsEnabled) {
-  NS_ENSURE_ARG_POINTER(aIsEnabled);
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    *aIsEnabled = false;
-    return NS_OK;
+bool SelectionMoveCommands::IsCommandEnabled(const char* aCommandName,
+                                             TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  *aIsEnabled = textEditor->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 static const struct ScrollCommand {
   const char* reverseScroll;
   const char* forwardScroll;
   nsresult (NS_STDCALL nsISelectionController::*scroll)(bool);
 } scrollCommands[] = {{"cmd_scrollTop", "cmd_scrollBottom",
                        &nsISelectionController::CompleteScroll},
@@ -881,32 +753,22 @@ SelectionMoveCommands::GetCommandStatePa
 }
 
 /******************************************************************************
  * mozilla::InsertPlaintextCommand
  ******************************************************************************/
 
 StaticRefPtr<InsertPlaintextCommand> InsertPlaintextCommand::sInstance;
 
-NS_IMETHODIMP
-InsertPlaintextCommand::IsCommandEnabled(const char* aCommandName,
-                                         nsISupports* aCommandRefCon,
-                                         bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool InsertPlaintextCommand::IsCommandEnabled(const char* aCommandName,
+                                              TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (NS_WARN_IF(!editor)) {
-    *aIsEnabled = false;
-    return NS_ERROR_FAILURE;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  *aIsEnabled = textEditor->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 InsertPlaintextCommand::DoCommand(const char* aCommandName,
                                   nsISupports* aCommandRefCon) {
   // No value is equivalent to empty string
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
@@ -972,33 +834,22 @@ InsertPlaintextCommand::GetCommandStateP
 }
 
 /******************************************************************************
  * mozilla::InsertParagraphCommand
  ******************************************************************************/
 
 StaticRefPtr<InsertParagraphCommand> InsertParagraphCommand::sInstance;
 
-NS_IMETHODIMP
-InsertParagraphCommand::IsCommandEnabled(const char* aCommandName,
-                                         nsISupports* aCommandRefCon,
-                                         bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool InsertParagraphCommand::IsCommandEnabled(const char* aCommandName,
+                                              TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (NS_WARN_IF(!editor)) {
-    *aIsEnabled = false;
-    return NS_ERROR_FAILURE;
-  }
-
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  *aIsEnabled = textEditor->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 InsertParagraphCommand::DoCommand(const char* aCommandName,
                                   nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
@@ -1032,33 +883,22 @@ InsertParagraphCommand::GetCommandStateP
 }
 
 /******************************************************************************
  * mozilla::InsertLineBreakCommand
  ******************************************************************************/
 
 StaticRefPtr<InsertLineBreakCommand> InsertLineBreakCommand::sInstance;
 
-NS_IMETHODIMP
-InsertLineBreakCommand::IsCommandEnabled(const char* aCommandName,
-                                         nsISupports* aCommandRefCon,
-                                         bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool InsertLineBreakCommand::IsCommandEnabled(const char* aCommandName,
+                                              TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (NS_WARN_IF(!editor)) {
-    *aIsEnabled = false;
-    return NS_ERROR_FAILURE;
-  }
-
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  *aIsEnabled = textEditor->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 InsertLineBreakCommand::DoCommand(const char* aCommandName,
                                   nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
@@ -1092,37 +932,23 @@ InsertLineBreakCommand::GetCommandStateP
 }
 
 /******************************************************************************
  * mozilla::PasteQuotationCommand
  ******************************************************************************/
 
 StaticRefPtr<PasteQuotationCommand> PasteQuotationCommand::sInstance;
 
-NS_IMETHODIMP
-PasteQuotationCommand::IsCommandEnabled(const char* aCommandName,
-                                        nsISupports* aCommandRefCon,
-                                        bool* aIsEnabled) {
-  if (NS_WARN_IF(!aIsEnabled)) {
-    return NS_ERROR_INVALID_ARG;
+bool PasteQuotationCommand::IsCommandEnabled(const char* aCommandName,
+                                             TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-
-  *aIsEnabled = false;
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
-  if (!editor) {
-    return NS_OK;
-  }
-  TextEditor* textEditor = editor->AsTextEditor();
-  MOZ_ASSERT(textEditor);
-  if (textEditor->IsSingleLineEditor()) {
-    return NS_OK;
-  }
-  *aIsEnabled = textEditor->CanPaste(nsIClipboard::kGlobalClipboard);
-  return NS_OK;
+  return !aTextEditor->IsSingleLineEditor() &&
+         aTextEditor->CanPaste(nsIClipboard::kGlobalClipboard);
 }
 
 NS_IMETHODIMP
 PasteQuotationCommand::DoCommand(const char* aCommandName,
                                  nsISupports* aCommandRefCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
--- a/editor/libeditor/EditorCommands.h
+++ b/editor/libeditor/EditorCommands.h
@@ -13,37 +13,47 @@
 #include "nsStringFwd.h"
 
 class nsAtom;
 class nsICommandParams;
 
 namespace mozilla {
 
 class HTMLEditor;
+class TextEditor;
 
 /**
  * This is a base class for commands registered with the editor controller.
  * Note that such commands are designed as singleton classes.  So, MUST be
  * stateless. Any state must be stored via the refCon (an nsIEditor).
  */
 
 class EditorCommand : public nsIControllerCommand {
  public:
   NS_DECL_ISUPPORTS
 
+  // nsIControllerCommand methods.  Use EditorCommand specific methods instead
+  // for internal use.
+  NS_IMETHOD IsCommandEnabled(const char* aCommandName,
+                              nsISupports* aCommandRefCon,
+                              bool* aIsEnabled) final;
+
+  virtual bool IsCommandEnabled(const char* aCommandName,
+                                TextEditor* aTextEditor) const = 0;
+
  protected:
   EditorCommand() = default;
   virtual ~EditorCommand() = default;
 };
 
 #define NS_DECL_EDITOR_COMMAND_METHODS(_cmd)                                  \
  public:                                                                      \
-  NS_IMETHOD IsCommandEnabled(const char* aCommandName,                       \
-                              nsISupports* aCommandRefCon, bool* aIsEnabled)  \
-      final;                                                                  \
+  virtual bool IsCommandEnabled(const char* aCommandName,                     \
+                                TextEditor* aTextEditor) const final;         \
+  using EditorCommand::IsCommandEnabled;                                      \
   MOZ_CAN_RUN_SCRIPT                                                          \
   NS_IMETHOD DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) \
       final;                                                                  \
   MOZ_CAN_RUN_SCRIPT                                                          \
   NS_IMETHOD DoCommandParams(const char* aCommandName,                        \
                              nsICommandParams* aParams,                       \
                              nsISupports* aCommandRefCon) final;              \
   NS_IMETHOD GetCommandStateParams(const char* aCommandName,                  \
--- a/editor/libeditor/HTMLEditorCommands.cpp
+++ b/editor/libeditor/HTMLEditorCommands.cpp
@@ -49,42 +49,29 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY  // XXX Need
 
 /*****************************************************************************
  * mozilla::StateUpdatingCommandBase
  *****************************************************************************/
 
 nsRefPtrHashtable<nsCharPtrHashKey, nsAtom>
     StateUpdatingCommandBase::sTagNameTable;
 
-NS_IMETHODIMP
-StateUpdatingCommandBase::IsCommandEnabled(const char* aCommandName,
-                                           nsISupports* refCon,
-                                           bool* outCmdEnabled) {
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    *outCmdEnabled = false;
-    return NS_OK;
+bool StateUpdatingCommandBase::IsCommandEnabled(const char* aCommandName,
+                                                TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  TextEditor* textEditor = editor->AsTextEditor();
-  if (!textEditor) {
-    *outCmdEnabled = false;
-    return NS_OK;
-  }
-  if (!textEditor->IsSelectionEditable()) {
-    *outCmdEnabled = false;
-    return NS_OK;
+  if (!aTextEditor->IsSelectionEditable()) {
+    return false;
   }
-  if (!nsCRT::strcmp(aCommandName, "cmd_absPos")) {
-    HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
-    *outCmdEnabled =
-        htmlEditor && htmlEditor->IsAbsolutePositionEditorEnabled();
-    return NS_OK;
+  if (!strcmp(aCommandName, "cmd_absPos")) {
+    HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
+    return htmlEditor && htmlEditor->IsAbsolutePositionEditorEnabled();
   }
-  *outCmdEnabled = true;
-  return NS_OK;
+  return true;
 }
 
 NS_IMETHODIMP
 StateUpdatingCommandBase::DoCommand(const char* aCommandName,
                                     nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
@@ -127,37 +114,30 @@ StateUpdatingCommandBase::GetCommandStat
 }
 
 /*****************************************************************************
  * mozilla::PasteNoFormattingCommand
  *****************************************************************************/
 
 StaticRefPtr<PasteNoFormattingCommand> PasteNoFormattingCommand::sInstance;
 
-NS_IMETHODIMP
-PasteNoFormattingCommand::IsCommandEnabled(const char* aCommandName,
-                                           nsISupports* refCon,
-                                           bool* outCmdEnabled) {
-  NS_ENSURE_ARG_POINTER(outCmdEnabled);
-  *outCmdEnabled = false;
-
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (NS_WARN_IF(!editor)) {
-    return NS_ERROR_FAILURE;
+bool PasteNoFormattingCommand::IsCommandEnabled(const char* aCommandName,
+                                                TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
 
   // 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;
+  HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
+  if (!htmlEditor) {
+    return false;
   }
-  *outCmdEnabled = htmlEditor->CanPaste(nsIClipboard::kGlobalClipboard);
-  return NS_OK;
+  return htmlEditor->CanPaste(nsIClipboard::kGlobalClipboard);
 }
 
 NS_IMETHODIMP
 PasteNoFormattingCommand::DoCommand(const char* aCommandName,
                                     nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
@@ -414,45 +394,39 @@ nsresult ListItemCommand::ToggleState(ns
 }
 
 /*****************************************************************************
  * mozilla::RemoveListCommand
  *****************************************************************************/
 
 StaticRefPtr<RemoveListCommand> RemoveListCommand::sInstance;
 
-NS_IMETHODIMP
-RemoveListCommand::IsCommandEnabled(const char* aCommandName,
-                                    nsISupports* refCon, bool* outCmdEnabled) {
-  *outCmdEnabled = false;
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    return NS_OK;
+bool RemoveListCommand::IsCommandEnabled(const char* aCommandName,
+                                         TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
 
-  mozilla::EditorBase* editorBase = editor->AsEditorBase();
-  MOZ_ASSERT(editorBase);
-
-  if (!editorBase->IsSelectionEditable()) {
-    return NS_OK;
+  if (!aTextEditor->IsSelectionEditable()) {
+    return false;
   }
 
   // It is enabled if we are in any list type
-  mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
+  HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
-    return NS_ERROR_FAILURE;
+    return false;
   }
 
   bool bMixed;
   nsAutoString localName;
   nsresult rv = GetListState(MOZ_KnownLive(htmlEditor), &bMixed, localName);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *outCmdEnabled = bMixed || !localName.IsEmpty();
-  return NS_OK;
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return false;
+  }
+  return bMixed || !localName.IsEmpty();
 }
 
 NS_IMETHODIMP
 RemoveListCommand::DoCommand(const char* aCommandName, nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
   }
@@ -481,28 +455,22 @@ RemoveListCommand::GetCommandStateParams
 }
 
 /*****************************************************************************
  * mozilla::IndentCommand
  *****************************************************************************/
 
 StaticRefPtr<IndentCommand> IndentCommand::sInstance;
 
-NS_IMETHODIMP
-IndentCommand::IsCommandEnabled(const char* aCommandName, nsISupports* refCon,
-                                bool* outCmdEnabled) {
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    *outCmdEnabled = false;
-    return NS_OK;
+bool IndentCommand::IsCommandEnabled(const char* aCommandName,
+                                     TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::EditorBase* editorBase = editor->AsEditorBase();
-  MOZ_ASSERT(editorBase);
-  *outCmdEnabled = editorBase->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 IndentCommand::DoCommand(const char* aCommandName, nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
   }
@@ -533,28 +501,22 @@ IndentCommand::GetCommandStateParams(con
 }
 
 /*****************************************************************************
  * mozilla::OutdentCommand
  *****************************************************************************/
 
 StaticRefPtr<OutdentCommand> OutdentCommand::sInstance;
 
-NS_IMETHODIMP
-OutdentCommand::IsCommandEnabled(const char* aCommandName, nsISupports* refCon,
-                                 bool* outCmdEnabled) {
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    *outCmdEnabled = false;
-    return NS_OK;
+bool OutdentCommand::IsCommandEnabled(const char* aCommandName,
+                                      TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::EditorBase* editorBase = editor->AsEditorBase();
-  MOZ_ASSERT(editorBase);
-  *outCmdEnabled = editorBase->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 OutdentCommand::DoCommand(const char* aCommandName, nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
   }
@@ -584,30 +546,23 @@ OutdentCommand::GetCommandStateParams(co
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
   return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 /*****************************************************************************
  * mozilla::MultiStateCommandBase
  *****************************************************************************/
 
-NS_IMETHODIMP
-MultiStateCommandBase::IsCommandEnabled(const char* aCommandName,
-                                        nsISupports* refCon,
-                                        bool* outCmdEnabled) {
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    *outCmdEnabled = false;
-    return NS_OK;
+bool MultiStateCommandBase::IsCommandEnabled(const char* aCommandName,
+                                             TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::EditorBase* editorBase = editor->AsEditorBase();
-  MOZ_ASSERT(editorBase);
   // should be disabled sometimes, like if the current selection is an image
-  *outCmdEnabled = editorBase->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 MultiStateCommandBase::DoCommand(const char* aCommandName,
                                  nsISupports* refCon) {
   NS_WARNING(
       "who is calling MultiStateCommandBase::DoCommand (no implementation)?");
   return NS_OK;
@@ -1054,43 +1009,33 @@ nsresult AbsolutePositioningCommand::Tog
 }
 
 /*****************************************************************************
  * mozilla::DecreaseZIndexCommand
  *****************************************************************************/
 
 StaticRefPtr<DecreaseZIndexCommand> DecreaseZIndexCommand::sInstance;
 
-NS_IMETHODIMP
-DecreaseZIndexCommand::IsCommandEnabled(const char* aCommandName,
-                                        nsISupports* aRefCon,
-                                        bool* aOutCmdEnabled) {
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aRefCon);
-  if (NS_WARN_IF(!editor)) {
-    return NS_ERROR_FAILURE;
+bool DecreaseZIndexCommand::IsCommandEnabled(const char* aCommandName,
+                                             TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
-  if (NS_WARN_IF(!htmlEditor)) {
-    return NS_ERROR_FAILURE;
+  HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
+  if (!htmlEditor) {
+    return false;
   }
-
   if (!htmlEditor->IsAbsolutePositionEditorEnabled()) {
-    *aOutCmdEnabled = false;
-    return NS_OK;
+    return false;
   }
-
   RefPtr<Element> positionedElement = htmlEditor->GetPositionedElement();
   if (!positionedElement) {
-    *aOutCmdEnabled = false;
-    return NS_OK;
+    return false;
   }
-
-  int32_t z = htmlEditor->GetZIndex(*positionedElement);
-  *aOutCmdEnabled = (z > 0);
-  return NS_OK;
+  return htmlEditor->GetZIndex(*positionedElement) > 0;
 }
 
 NS_IMETHODIMP
 DecreaseZIndexCommand::DoCommand(const char* aCommandName,
                                  nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
@@ -1123,36 +1068,29 @@ DecreaseZIndexCommand::GetCommandStatePa
 }
 
 /*****************************************************************************
  * mozilla::IncreaseZIndexCommand
  *****************************************************************************/
 
 StaticRefPtr<IncreaseZIndexCommand> IncreaseZIndexCommand::sInstance;
 
-NS_IMETHODIMP
-IncreaseZIndexCommand::IsCommandEnabled(const char* aCommandName,
-                                        nsISupports* aRefCon,
-                                        bool* aOutCmdEnabled) {
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aRefCon);
-  if (NS_WARN_IF(!editor)) {
-    return NS_ERROR_FAILURE;
+bool IncreaseZIndexCommand::IsCommandEnabled(const char* aCommandName,
+                                             TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
-  if (NS_WARN_IF(!htmlEditor)) {
-    return NS_ERROR_FAILURE;
+  HTMLEditor* htmlEditor = aTextEditor->AsHTMLEditor();
+  if (!htmlEditor) {
+    return false;
   }
-
   if (!htmlEditor->IsAbsolutePositionEditorEnabled()) {
-    *aOutCmdEnabled = false;
-    return NS_OK;
+    return false;
   }
-
-  *aOutCmdEnabled = !!htmlEditor->GetPositionedElement();
-  return NS_OK;
+  return !!htmlEditor->GetPositionedElement();
 }
 
 NS_IMETHODIMP
 IncreaseZIndexCommand::DoCommand(const char* aCommandName,
                                  nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
@@ -1185,30 +1123,23 @@ IncreaseZIndexCommand::GetCommandStatePa
 }
 
 /*****************************************************************************
  * mozilla::RemoveStylesCommand
  *****************************************************************************/
 
 StaticRefPtr<RemoveStylesCommand> RemoveStylesCommand::sInstance;
 
-NS_IMETHODIMP
-RemoveStylesCommand::IsCommandEnabled(const char* aCommandName,
-                                      nsISupports* refCon,
-                                      bool* outCmdEnabled) {
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    *outCmdEnabled = false;
-    return NS_OK;
+bool RemoveStylesCommand::IsCommandEnabled(const char* aCommandName,
+                                           TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::EditorBase* editorBase = editor->AsEditorBase();
-  MOZ_ASSERT(editorBase);
   // test if we have any styles?
-  *outCmdEnabled = editorBase->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 RemoveStylesCommand::DoCommand(const char* aCommandName, nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
   }
@@ -1236,30 +1167,23 @@ RemoveStylesCommand::GetCommandStatePara
 }
 
 /*****************************************************************************
  * mozilla::IncreaseFontSizeCommand
  *****************************************************************************/
 
 StaticRefPtr<IncreaseFontSizeCommand> IncreaseFontSizeCommand::sInstance;
 
-NS_IMETHODIMP
-IncreaseFontSizeCommand::IsCommandEnabled(const char* aCommandName,
-                                          nsISupports* refCon,
-                                          bool* outCmdEnabled) {
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    *outCmdEnabled = false;
-    return NS_OK;
+bool IncreaseFontSizeCommand::IsCommandEnabled(const char* aCommandName,
+                                               TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::EditorBase* editorBase = editor->AsEditorBase();
-  MOZ_ASSERT(editorBase);
   // test if we are at max size?
-  *outCmdEnabled = editorBase->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 IncreaseFontSizeCommand::DoCommand(const char* aCommandName,
                                    nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
@@ -1288,30 +1212,23 @@ IncreaseFontSizeCommand::GetCommandState
 }
 
 /*****************************************************************************
  * mozilla::DecreaseFontSizeCommand
  *****************************************************************************/
 
 StaticRefPtr<DecreaseFontSizeCommand> DecreaseFontSizeCommand::sInstance;
 
-NS_IMETHODIMP
-DecreaseFontSizeCommand::IsCommandEnabled(const char* aCommandName,
-                                          nsISupports* refCon,
-                                          bool* outCmdEnabled) {
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    *outCmdEnabled = false;
-    return NS_OK;
+bool DecreaseFontSizeCommand::IsCommandEnabled(const char* aCommandName,
+                                               TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::EditorBase* editorBase = editor->AsEditorBase();
-  MOZ_ASSERT(editorBase);
   // test if we are at min size?
-  *outCmdEnabled = editorBase->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 DecreaseFontSizeCommand::DoCommand(const char* aCommandName,
                                    nsISupports* refCon) {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     return NS_OK;
@@ -1340,29 +1257,22 @@ DecreaseFontSizeCommand::GetCommandState
 }
 
 /*****************************************************************************
  * mozilla::InsertHTMLCommand
  *****************************************************************************/
 
 StaticRefPtr<InsertHTMLCommand> InsertHTMLCommand::sInstance;
 
-NS_IMETHODIMP
-InsertHTMLCommand::IsCommandEnabled(const char* aCommandName,
-                                    nsISupports* refCon, bool* outCmdEnabled) {
-  NS_ENSURE_ARG_POINTER(outCmdEnabled);
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    *outCmdEnabled = false;
-    return NS_OK;
+bool InsertHTMLCommand::IsCommandEnabled(const char* aCommandName,
+                                         TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::EditorBase* editorBase = editor->AsEditorBase();
-  MOZ_ASSERT(editorBase);
-  *outCmdEnabled = editorBase->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 NS_IMETHODIMP
 InsertHTMLCommand::DoCommand(const char* aCommandName, nsISupports* refCon) {
   // If nsInsertHTMLCommand is called with no parameters, it was probably called
   // with an empty string parameter ''. In this case, it should act the same as
   // the delete command
   NS_ENSURE_ARG_POINTER(refCon);
@@ -1418,29 +1328,22 @@ InsertHTMLCommand::GetCommandStateParams
 
 /*****************************************************************************
  * mozilla::InsertTagCommand
  *****************************************************************************/
 
 StaticRefPtr<InsertTagCommand> InsertTagCommand::sInstance;
 nsRefPtrHashtable<nsCharPtrHashKey, nsAtom> InsertTagCommand::sTagNameTable;
 
-NS_IMETHODIMP
-InsertTagCommand::IsCommandEnabled(const char* aCommandName,
-                                   nsISupports* refCon, bool* outCmdEnabled) {
-  NS_ENSURE_ARG_POINTER(outCmdEnabled);
-  nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
-  if (!editor) {
-    *outCmdEnabled = false;
-    return NS_OK;
+bool InsertTagCommand::IsCommandEnabled(const char* aCommandName,
+                                        TextEditor* aTextEditor) const {
+  if (!aTextEditor) {
+    return false;
   }
-  mozilla::EditorBase* editorBase = editor->AsEditorBase();
-  MOZ_ASSERT(editorBase);
-  *outCmdEnabled = editorBase->IsSelectionEditable();
-  return NS_OK;
+  return aTextEditor->IsSelectionEditable();
 }
 
 // corresponding STATE_ATTRIBUTE is: src (img) and href (a)
 NS_IMETHODIMP
 InsertTagCommand::DoCommand(const char* aCmdName, nsISupports* refCon) {
   if (NS_WARN_IF(!aCmdName) || NS_WARN_IF(!refCon)) {
     return NS_ERROR_INVALID_ARG;
   }
--- a/editor/libeditor/HTMLEditorDocumentCommands.cpp
+++ b/editor/libeditor/HTMLEditorDocumentCommands.cpp
@@ -41,27 +41,20 @@ namespace mozilla {
  *  As of 11/11/02, this is just "cmd_setDocumentModified"
  *  Note that you can use the same command class, SetDocumentStateCommand,
  *    for more than one of this type of command
  *    We check the input command param for different behavior
  *****************************************************************************/
 
 StaticRefPtr<SetDocumentStateCommand> SetDocumentStateCommand::sInstance;
 
-NS_IMETHODIMP
-SetDocumentStateCommand::IsCommandEnabled(const char* aCommandName,
-                                          nsISupports* refCon,
-                                          bool* outCmdEnabled) {
-  if (NS_WARN_IF(!outCmdEnabled)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
+bool SetDocumentStateCommand::IsCommandEnabled(const char* aCommandName,
+                                               TextEditor* aTextEditor) const {
   // These commands are always enabled
-  *outCmdEnabled = true;
-  return NS_OK;
+  return true;
 }
 
 NS_IMETHODIMP
 SetDocumentStateCommand::DoCommand(const char* aCommandName,
                                    nsISupports* refCon) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
@@ -443,27 +436,20 @@ SetDocumentStateCommand::GetCommandState
  *  5. Use GetCommandStateParams() to obtain state information
  *     e.g., any creation state codes when creating an editor are
  *     supplied for "obs_documentCreated" command in the
  *     "state_data" param's value
  *****************************************************************************/
 
 StaticRefPtr<DocumentStateCommand> DocumentStateCommand::sInstance;
 
-NS_IMETHODIMP
-DocumentStateCommand::IsCommandEnabled(const char* aCommandName,
-                                       nsISupports* refCon,
-                                       bool* outCmdEnabled) {
-  if (NS_WARN_IF(!outCmdEnabled)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
+bool DocumentStateCommand::IsCommandEnabled(const char* aCommandName,
+                                            TextEditor* aTextEditor) const {
   // Always return false to discourage callers from using DoCommand()
-  *outCmdEnabled = false;
-  return NS_OK;
+  return false;
 }
 
 NS_IMETHODIMP
 DocumentStateCommand::DoCommand(const char* aCommandName, nsISupports* refCon) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP