Bug 1476294 - Make HTMLEditorDocumentCommands.cpp use non-virtual methods of nsCommandParams instead of virtual methods of nsICommandParams r=Ehsan
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 18 Jul 2018 00:30:05 +0900
changeset 482962 cfb544de8a72831a08e5f847ffae486d1f4d2a21
parent 482961 dade23c568753842f538e544cd13ed712bec23cb
child 483048 1e5fa52a612e8985e12212d1950a732954e00e45
child 483050 798bf0d7928c137ad2cde26973be7d9b47b04075
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1476294, 1450882
milestone63.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 1476294 - Make HTMLEditorDocumentCommands.cpp use non-virtual methods of nsCommandParams instead of virtual methods of nsICommandParams r=Ehsan This is remaining part of bug 1450882. I forgot to update HTMLEditorDocumentCommands.cpp when I work on the bug. This patch makes HTMLEditorDocumentCommands.cpp use non-virtual methods of nsCommandParams instead of virtual methods of nsICommandParams. MozReview-Commit-ID: 12AjXbeYNOa
editor/libeditor/HTMLEditorDocumentCommands.cpp
--- a/editor/libeditor/HTMLEditorDocumentCommands.cpp
+++ b/editor/libeditor/HTMLEditorDocumentCommands.cpp
@@ -2,21 +2,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "mozilla/HTMLEditor.h"         // for HTMLEditor
 #include "mozilla/HTMLEditorCommands.h" // for SetDocumentOptionsCommand, etc
 #include "mozilla/TextEditor.h"         // for TextEditor
+#include "nsCommandParams.h"            // for nsCommandParams
 #include "nsCOMPtr.h"                   // for nsCOMPtr, do_QueryInterface, etc
 #include "nsCRT.h"                      // for nsCRT
 #include "nsDebug.h"                    // for NS_ENSURE_ARG_POINTER, etc
 #include "nsError.h"                    // for NS_ERROR_INVALID_ARG, etc
-#include "nsICommandParams.h"           // for nsICommandParams
 #include "nsIDocShell.h"                // for nsIDocShell
 #include "nsIDocument.h"                // for nsIDocument
 #include "nsIEditingSession.h"          // for nsIEditingSession, etc
 #include "nsIEditor.h"                  // for nsIEditor
 #include "nsIPlaintextEditor.h"         // for nsIPlaintextEditor, etc
 #include "nsIPresShell.h"               // for nsIPresShell
 #include "nsISelectionController.h"     // for nsISelectionController
 #include "nsISupportsImpl.h"            // for nsPresContext::Release
@@ -35,17 +35,20 @@ class nsISupports;
 
 namespace mozilla {
 
 NS_IMETHODIMP
 SetDocumentOptionsCommand::IsCommandEnabled(const char* aCommandName,
                                             nsISupports* refCon,
                                             bool* outCmdEnabled)
 {
-  NS_ENSURE_ARG_POINTER(outCmdEnabled);
+  if (NS_WARN_IF(!outCmdEnabled)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
     *outCmdEnabled = false;
     return NS_OK;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
   *outCmdEnabled = textEditor->IsSelectionEditable();
@@ -59,101 +62,122 @@ SetDocumentOptionsCommand::DoCommand(con
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 SetDocumentOptionsCommand::DoCommandParams(const char* aCommandName,
                                            nsICommandParams* aParams,
                                            nsISupports* refCon)
 {
-  NS_ENSURE_ARG_POINTER(aParams);
+  if (NS_WARN_IF(!aParams)) {
+    return NS_ERROR_INVALID_ARG;
+  }
 
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_INVALID_ARG;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
 
   RefPtr<nsPresContext> presContext = textEditor->GetPresContext();
   if (NS_WARN_IF(!presContext)) {
     return NS_ERROR_FAILURE;
   }
 
-  int32_t animationMode;
-  nsresult rv = aParams->GetLongValue("imageAnimation", &animationMode);
-  if (NS_SUCCEEDED(rv)) {
+  nsCommandParams* params = aParams->AsCommandParams();
+
+  IgnoredErrorResult error;
+  int32_t animationMode = params->GetInt("imageAnimation", error);
+  if (!error.Failed()) {
     // for possible values of animation mode, see:
     // http://lxr.mozilla.org/seamonkey/source/image/public/imgIContainer.idl
     presContext->SetImageAnimationMode(animationMode);
+  } else {
+    error.SuppressException();
+  }
+
+  bool allowPlugins = params->GetBool("plugins", error);
+  if (error.Failed()) {
+    return NS_OK;
   }
 
-  bool allowPlugins;
-  rv = aParams->GetBooleanValue("plugins", &allowPlugins);
-  if (NS_SUCCEEDED(rv)) {
-    nsCOMPtr<nsIDocShell> docShell(presContext->GetDocShell());
-    NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
-
-    rv = docShell->SetAllowPlugins(allowPlugins);
-    NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIDocShell> docShell(presContext->GetDocShell());
+  if (NS_WARN_IF(!docShell)) {
+    return NS_ERROR_FAILURE;
   }
 
+  nsresult rv = docShell->SetAllowPlugins(allowPlugins);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SetDocumentOptionsCommand::GetCommandStateParams(const char* aCommandName,
                                                  nsICommandParams* aParams,
                                                  nsISupports* refCon)
 {
-  NS_ENSURE_ARG_POINTER(aParams);
-  NS_ENSURE_ARG_POINTER(refCon);
+  if (NS_WARN_IF(!aParams) || NS_WARN_IF(!refCon)) {
+    return NS_ERROR_INVALID_ARG;
+  }
 
   // The base editor owns most state info
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_INVALID_ARG;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
 
+  nsCommandParams* params = aParams->AsCommandParams();
+
   // Always get the enabled state
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  nsresult rv = aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsresult rv = params->SetBool(STATE_ENABLED, outCmdEnabled);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
 
   // get pres context
   RefPtr<nsPresContext> presContext = textEditor->GetPresContext();
   if (NS_WARN_IF(!presContext)) {
     return NS_ERROR_FAILURE;
   }
 
-  int32_t animationMode;
-  rv = aParams->GetLongValue("imageAnimation", &animationMode);
-  if (NS_SUCCEEDED(rv)) {
+  IgnoredErrorResult error;
+  Unused << params->GetInt("imageAnimation", error);
+  if (!error.Failed()) {
     // for possible values of animation mode, see
     // http://lxr.mozilla.org/seamonkey/source/image/public/imgIContainer.idl
-    rv = aParams->SetLongValue("imageAnimation",
-                               presContext->ImageAnimationMode());
-    NS_ENSURE_SUCCESS(rv, rv);
+    rv = params->SetInt("imageAnimation", presContext->ImageAnimationMode());
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+  } else {
+    error.SuppressException();
   }
 
-  bool allowPlugins = false;
-  rv = aParams->GetBooleanValue("plugins", &allowPlugins);
-  if (NS_SUCCEEDED(rv)) {
-    nsCOMPtr<nsIDocShell> docShell(presContext->GetDocShell());
-    NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
-
-    allowPlugins = docShell->PluginsAllowedInCurrentDoc();
-
-    rv = aParams->SetBooleanValue("plugins", allowPlugins);
-    NS_ENSURE_SUCCESS(rv, rv);
+  bool allowPlugins = params->GetBool("plugins", error);
+  if (error.Failed()) {
+    return NS_OK;
   }
 
+  nsCOMPtr<nsIDocShell> docShell(presContext->GetDocShell());
+  if (NS_WARN_IF(!docShell)) {
+    return NS_ERROR_FAILURE;
+  }
+
+  allowPlugins = docShell->PluginsAllowedInCurrentDoc();
+  rv = params->SetBool("plugins", allowPlugins);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
   return NS_OK;
 }
 
 
 /**
  *  Commands for document state that may be changed via doCommandParams
  *  As of 11/11/02, this is just "cmd_setDocumentModified"
  *  Note that you can use the same command class, nsSetDocumentStateCommand,
@@ -161,108 +185,137 @@ SetDocumentOptionsCommand::GetCommandSta
  *    We check the input command param for different behavior
  */
 
 NS_IMETHODIMP
 SetDocumentStateCommand::IsCommandEnabled(const char* aCommandName,
                                           nsISupports* refCon,
                                           bool* outCmdEnabled)
 {
+  if (NS_WARN_IF(!outCmdEnabled)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
   // These commands are always enabled
-  NS_ENSURE_ARG_POINTER(outCmdEnabled);
   *outCmdEnabled = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SetDocumentStateCommand::DoCommand(const char* aCommandName,
                                    nsISupports* refCon)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 SetDocumentStateCommand::DoCommandParams(const char* aCommandName,
                                          nsICommandParams* aParams,
                                          nsISupports* refCon)
 {
+  if (NS_WARN_IF(!aParams)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_INVALID_ARG;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
 
-  if (!nsCRT::strcmp(aCommandName, "cmd_setDocumentModified")) {
-    NS_ENSURE_ARG_POINTER(aParams);
+  nsCommandParams* params = aParams->AsCommandParams();
 
-    bool modified;
-    nsresult rv = aParams->GetBooleanValue(STATE_ATTRIBUTE, &modified);
-
+  if (!nsCRT::strcmp(aCommandName, "cmd_setDocumentModified")) {
+    ErrorResult error;
+    bool modified = params->GetBool(STATE_ATTRIBUTE, error);
     // Should we fail if this param wasn't set?
     // I'm not sure we should be that strict
-    NS_ENSURE_SUCCESS(rv, rv);
-
+    if (NS_WARN_IF(error.Failed())) {
+      return error.StealNSResult();
+    }
     if (modified) {
-      return textEditor->IncrementModificationCount(1);
+      nsresult rv = textEditor->IncrementModificationCount(1);
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return rv;
+      }
+      return NS_OK;
     }
-
-    return textEditor->ResetModificationCount();
+    nsresult rv = textEditor->ResetModificationCount();
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_setDocumentReadOnly")) {
-    NS_ENSURE_ARG_POINTER(aParams);
-    bool isReadOnly;
-    nsresult rvRO = aParams->GetBooleanValue(STATE_ATTRIBUTE, &isReadOnly);
-    NS_ENSURE_SUCCESS(rvRO, rvRO);
-    return isReadOnly ?
-      textEditor->AddFlags(nsIPlaintextEditor::eEditorReadonlyMask) :
+    ErrorResult error;
+    bool isReadOnly = params->GetBool(STATE_ATTRIBUTE, error);
+    if (NS_WARN_IF(error.Failed())) {
+      return error.StealNSResult();
+    }
+    if (isReadOnly) {
+      nsresult rv =
+        textEditor->AddFlags(nsIPlaintextEditor::eEditorReadonlyMask);
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return rv;
+      }
+      return NS_OK;
+    }
+    nsresult rv =
       textEditor->RemoveFlags(nsIPlaintextEditor::eEditorReadonlyMask);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_setDocumentUseCSS")) {
-    NS_ENSURE_ARG_POINTER(aParams);
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
-
-    bool desireCSS;
-    nsresult rvCSS = aParams->GetBooleanValue(STATE_ATTRIBUTE, &desireCSS);
-    NS_ENSURE_SUCCESS(rvCSS, rvCSS);
-
-    return htmlEditor->SetIsCSSEnabled(desireCSS);
+    ErrorResult error;
+    bool desireCSS = params->GetBool(STATE_ATTRIBUTE, error);
+    if (NS_WARN_IF(error.Failed())) {
+      return error.StealNSResult();
+    }
+    nsresult rv = htmlEditor->SetIsCSSEnabled(desireCSS);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_insertBrOnReturn")) {
-    NS_ENSURE_ARG_POINTER(aParams);
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
-
-    bool insertBrOnReturn;
-    nsresult rvBR = aParams->GetBooleanValue(STATE_ATTRIBUTE,
-                                              &insertBrOnReturn);
-    NS_ENSURE_SUCCESS(rvBR, rvBR);
-
-    return htmlEditor->SetReturnInParagraphCreatesNewParagraph(!insertBrOnReturn);
+    ErrorResult error;
+    bool insertBrOnReturn = params->GetBool(STATE_ATTRIBUTE, error);
+    if (NS_WARN_IF(error.Failed())) {
+      return error.StealNSResult();
+    }
+    nsresult rv =
+      htmlEditor->SetReturnInParagraphCreatesNewParagraph(!insertBrOnReturn);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_defaultParagraphSeparator")) {
-    if (NS_WARN_IF(!aParams)) {
-      return NS_ERROR_NULL_POINTER;
-    }
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
 
     nsAutoCString newValue;
-    nsresult rv = aParams->GetCStringValue(STATE_ATTRIBUTE, newValue);
+    nsresult rv = params->GetCString(STATE_ATTRIBUTE, newValue);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     if (newValue.LowerCaseEqualsLiteral("div")) {
       htmlEditor->SetDefaultParagraphSeparator(ParagraphSeparator::div);
       return NS_OK;
     }
@@ -277,155 +330,188 @@ SetDocumentStateCommand::DoCommandParams
     }
 
     // This should not be reachable from nsHTMLDocument::ExecCommand
     NS_WARNING("Invalid default paragraph separator");
     return NS_ERROR_UNEXPECTED;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_enableObjectResizing")) {
-    NS_ENSURE_ARG_POINTER(aParams);
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
-
-    bool enabled;
-    nsresult rvOR = aParams->GetBooleanValue(STATE_ATTRIBUTE, &enabled);
-    NS_ENSURE_SUCCESS(rvOR, rvOR);
-
-    return htmlEditor->SetObjectResizingEnabled(enabled);
+    ErrorResult error;
+    bool enabled = params->GetBool(STATE_ATTRIBUTE, error);
+    if (NS_WARN_IF(error.Failed())) {
+      return error.StealNSResult();
+    }
+    nsresult rv = htmlEditor->SetObjectResizingEnabled(enabled);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_enableInlineTableEditing")) {
-    NS_ENSURE_ARG_POINTER(aParams);
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
-
-    bool enabled;
-    nsresult rvOR = aParams->GetBooleanValue(STATE_ATTRIBUTE, &enabled);
-    NS_ENSURE_SUCCESS(rvOR, rvOR);
-
-    return htmlEditor->SetInlineTableEditingEnabled(enabled);
+    ErrorResult error;
+    bool enabled = params->GetBool(STATE_ATTRIBUTE, error);
+    if (NS_WARN_IF(error.Failed())) {
+      return error.StealNSResult();
+    }
+    nsresult rv = htmlEditor->SetInlineTableEditingEnabled(enabled);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 SetDocumentStateCommand::GetCommandStateParams(const char* aCommandName,
                                                nsICommandParams* aParams,
                                                nsISupports* refCon)
 {
-  NS_ENSURE_ARG_POINTER(aParams);
-  NS_ENSURE_ARG_POINTER(refCon);
+  if (NS_WARN_IF(!aParams) || NS_WARN_IF(!refCon)) {
+    return NS_ERROR_INVALID_ARG;
+  }
 
   // The base editor owns most state info
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_INVALID_ARG;
   }
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
 
+  nsCommandParams* params = aParams->AsCommandParams();
+
   // Always get the enabled state
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  nsresult rv = aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsresult rv = params->SetBool(STATE_ENABLED, outCmdEnabled);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_setDocumentModified")) {
     bool modified;
     rv = textEditor->GetDocumentModified(&modified);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    return aParams->SetBooleanValue(STATE_ATTRIBUTE, modified);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    rv = params->SetBool(STATE_ATTRIBUTE, modified);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_setDocumentReadOnly")) {
-    NS_ENSURE_ARG_POINTER(aParams);
-    return aParams->SetBooleanValue(STATE_ATTRIBUTE, textEditor->IsReadonly());
+    rv = params->SetBool(STATE_ATTRIBUTE, textEditor->IsReadonly());
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_setDocumentUseCSS")) {
-    NS_ENSURE_ARG_POINTER(aParams);
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
-
     bool isCSS;
     htmlEditor->GetIsCSSEnabled(&isCSS);
-    return aParams->SetBooleanValue(STATE_ALL, isCSS);
+    rv = params->SetBool(STATE_ALL, isCSS);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_insertBrOnReturn")) {
-    NS_ENSURE_ARG_POINTER(aParams);
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
-
     bool createPOnReturn;
     htmlEditor->GetReturnInParagraphCreatesNewParagraph(&createPOnReturn);
-    return aParams->SetBooleanValue(STATE_ATTRIBUTE, !createPOnReturn);
+    rv = params->SetBool(STATE_ATTRIBUTE, !createPOnReturn);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_defaultParagraphSeparator")) {
-    if (NS_WARN_IF(!aParams)) {
-      return NS_ERROR_NULL_POINTER;
-    }
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
 
     switch (htmlEditor->GetDefaultParagraphSeparator()) {
-      case ParagraphSeparator::div:
-        aParams->SetCStringValue(STATE_ATTRIBUTE, NS_LITERAL_CSTRING("div"));
+      case ParagraphSeparator::div: {
+        DebugOnly<nsresult> rv =
+          params->SetCString(STATE_ATTRIBUTE, NS_LITERAL_CSTRING("div"));
+        NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+          "Failed to set command params to return \"div\"");
         return NS_OK;
-
-      case ParagraphSeparator::p:
-        aParams->SetCStringValue(STATE_ATTRIBUTE, NS_LITERAL_CSTRING("p"));
+      }
+      case ParagraphSeparator::p: {
+        DebugOnly<nsresult> rv =
+          params->SetCString(STATE_ATTRIBUTE, NS_LITERAL_CSTRING("p"));
+        NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+          "Failed to set command params to return \"p\"");
         return NS_OK;
-
-      case ParagraphSeparator::br:
-        aParams->SetCStringValue(STATE_ATTRIBUTE, NS_LITERAL_CSTRING("br"));
+      }
+      case ParagraphSeparator::br: {
+        DebugOnly<nsresult> rv =
+          params->SetCString(STATE_ATTRIBUTE, NS_LITERAL_CSTRING("br"));
+        NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+          "Failed to set command params to return \"br\"");
         return NS_OK;
-
+      }
       default:
         MOZ_ASSERT_UNREACHABLE("Invalid paragraph separator value");
         return NS_ERROR_UNEXPECTED;
     }
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_enableObjectResizing")) {
-    NS_ENSURE_ARG_POINTER(aParams);
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
-
     bool enabled;
     htmlEditor->GetObjectResizingEnabled(&enabled);
-    return aParams->SetBooleanValue(STATE_ATTRIBUTE, enabled);
+    rv = params->SetBool(STATE_ATTRIBUTE, enabled);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "cmd_enableInlineTableEditing")) {
-    NS_ENSURE_ARG_POINTER(aParams);
     HTMLEditor* htmlEditor = textEditor->AsHTMLEditor();
     if (NS_WARN_IF(!htmlEditor)) {
       return NS_ERROR_INVALID_ARG;
     }
-
     bool enabled;
     htmlEditor->GetInlineTableEditingEnabled(&enabled);
-    return aParams->SetBooleanValue(STATE_ATTRIBUTE, enabled);
+    rv = params->SetBool(STATE_ATTRIBUTE, enabled);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 /**
  * Commands just for state notification
  *  As of 11/21/02, possible commands are:
@@ -463,17 +549,20 @@ SetDocumentStateCommand::GetCommandState
  *
  */
 
 NS_IMETHODIMP
 DocumentStateCommand::IsCommandEnabled(const char* aCommandName,
                                        nsISupports* refCon,
                                        bool* outCmdEnabled)
 {
-  NS_ENSURE_ARG_POINTER(outCmdEnabled);
+  if (NS_WARN_IF(!outCmdEnabled)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
   // Always return false to discourage callers from using DoCommand()
   *outCmdEnabled = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentStateCommand::DoCommand(const char* aCommandName,
                                 nsISupports* refCon)
@@ -489,59 +578,70 @@ DocumentStateCommand::DoCommandParams(co
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 DocumentStateCommand::GetCommandStateParams(const char* aCommandName,
                                             nsICommandParams* aParams,
                                             nsISupports* refCon)
 {
-  NS_ENSURE_ARG_POINTER(aParams);
-  NS_ENSURE_ARG_POINTER(aCommandName);
-  nsresult rv;
+  if (NS_WARN_IF(!aParams) || NS_WARN_IF(!aCommandName)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  nsCommandParams* params = aParams->AsCommandParams();
 
   if (!nsCRT::strcmp(aCommandName, "obs_documentCreated")) {
     uint32_t editorStatus = nsIEditingSession::eEditorErrorUnknown;
 
     nsCOMPtr<nsIEditingSession> editingSession = do_QueryInterface(refCon);
     if (editingSession) {
       // refCon is initially set to nsIEditingSession until editor
       //  is successfully created and source doc is loaded
       // Embedder gets error status if this fails
       // If called before startup is finished,
       //    status = eEditorCreationInProgress
-      rv = editingSession->GetEditorStatus(&editorStatus);
-      NS_ENSURE_SUCCESS(rv, rv);
+      nsresult rv = editingSession->GetEditorStatus(&editorStatus);
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return rv;
+      }
     } else {
       // If refCon is an editor, then everything started up OK!
       nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
       if (editor) {
         editorStatus = nsIEditingSession::eEditorOK;
       }
     }
 
     // Note that if refCon is not-null, but is neither
     // an nsIEditingSession or nsIEditor, we return "eEditorErrorUnknown"
-    aParams->SetLongValue(STATE_DATA, editorStatus);
+    DebugOnly<nsresult> rv = params->SetInt(STATE_DATA, editorStatus);
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to set editor status");
     return NS_OK;
   }
 
   if (!nsCRT::strcmp(aCommandName, "obs_documentLocationChanged")) {
     nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
     if (!editor) {
       return NS_OK;
     }
     TextEditor* textEditor = editor->AsTextEditor();
     MOZ_ASSERT(textEditor);
 
     nsCOMPtr<nsIDocument> doc = textEditor->GetDocument();
-    NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
-
-    nsIURI *uri = doc->GetDocumentURI();
-    NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
-
-    return aParams->SetISupportsValue(STATE_DATA, (nsISupports*)uri);
+    if (NS_WARN_IF(!doc)) {
+      return NS_ERROR_FAILURE;
+    }
+    nsIURI* uri = doc->GetDocumentURI();
+    if (NS_WARN_IF(!uri)) {
+      return NS_ERROR_FAILURE;
+    }
+    nsresult rv = params->SetISupports(STATE_DATA, uri);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    return NS_OK;
   }
 
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 } // namespace mozilla