Bug 1450882 - part 4: Make C++ users of nsICommandParams use nsCommandParams directly r=Ehsan
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 10 Jul 2018 20:04:21 +0900
changeset 426442 da50b3158af37d5b3dacd133fd302ea639767fd1
parent 426441 da27408845b366b1547d27539f23cd25936c4980
child 426443 254564563107faac0f16dd48fa6927ddbfac955c
push id34272
push userebalazs@mozilla.com
push dateFri, 13 Jul 2018 08:51:04 +0000
treeherdermozilla-central@254564563107 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1450882
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 1450882 - part 4: Make C++ users of nsICommandParams use nsCommandParams directly r=Ehsan nsICommandParams is implemented only by nsCommandParams. So, all C++ users can treat all instances of nsICommandParams as nsCommandParams. Therefore, this patch makes all set/get value calls use non-virtual methods and all constructors directly create nsCommandParams instance. MozReview-Commit-ID: CscgK0gKp5g
dom/base/nsGlobalWindowCommands.cpp
dom/events/EventStateManager.cpp
dom/html/nsHTMLDocument.cpp
dom/ipc/TabChild.cpp
editor/libeditor/EditorCommands.cpp
editor/libeditor/HTMLEditorCommands.cpp
--- a/dom/base/nsGlobalWindowCommands.cpp
+++ b/dom/base/nsGlobalWindowCommands.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "nsGlobalWindowCommands.h"
 
 #include "nsIComponentManager.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
+#include "nsCommandParams.h"
 #include "nsCRT.h"
 #include "nsString.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Preferences.h"
 
 #include "nsIControllerCommandTable.h"
 #include "nsICommandParams.h"
 
@@ -729,18 +730,19 @@ nsresult
 nsClipboardImageCommands::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
 {
   if (!nsCRT::strcmp(sCopyImageLocationString, aCommandName))
     return aEdit->CopyImage(nsIContentViewerEdit::COPY_IMAGE_TEXT);
   if (!nsCRT::strcmp(sCopyImageContentsString, aCommandName))
     return aEdit->CopyImage(nsIContentViewerEdit::COPY_IMAGE_DATA);
   int32_t copyFlags = nsIContentViewerEdit::COPY_IMAGE_DATA |
                       nsIContentViewerEdit::COPY_IMAGE_HTML;
-  if (aParams)
-    aParams->GetLongValue("imageCopy", &copyFlags);
+  if (aParams) {
+    copyFlags = aParams->AsCommandParams()->GetInt("imageCopy");
+  }
   return aEdit->CopyImage(copyFlags);
 }
 
 #if 0
 #pragma mark -
 #endif
 
 nsresult
@@ -770,32 +772,33 @@ nsClipboardGetContentsCommand::IsClipboa
   return aEdit->GetCanGetContents(outCmdEnabled);
 }
 
 nsresult
 nsClipboardGetContentsCommand::DoClipboardCommand(const char *aCommandName, nsIContentViewerEdit* aEdit, nsICommandParams* aParams)
 {
   NS_ENSURE_ARG(aParams);
 
+  nsCommandParams* params = aParams->AsCommandParams();
+
   nsAutoCString mimeType("text/plain");
 
   nsAutoCString format;
-  if (NS_SUCCEEDED(aParams->GetCStringValue("format", format))) {
+  if (NS_SUCCEEDED(params->GetCString("format", format))) {
     mimeType.Assign(format);
   }
 
-  bool selectionOnly = false;
-  aParams->GetBooleanValue("selection_only", &selectionOnly);
-
   nsAutoString contents;
-  nsresult rv = aEdit->GetContents(mimeType.get(), selectionOnly, contents);
-  if (NS_FAILED(rv))
+  nsresult rv =
+    aEdit->GetContents(mimeType.get(), params->GetBool("selection_only"),
+                       contents);
+  if (NS_FAILED(rv)) {
     return rv;
-
-  return aParams->SetStringValue("result", contents);
+  }
+  return params->SetString("result", contents);
 }
 
 #if 0   // Remove unless needed again, bug 204777
 class nsWebNavigationBaseCommand : public nsIControllerCommand
 {
 public:
   virtual ~nsWebNavigationBaseCommand() {}
 
@@ -955,27 +958,26 @@ NS_IMETHODIMP
 nsLookUpDictionaryCommand::DoCommandParams(const char* aCommandName,
                                            nsICommandParams* aParams,
                                            nsISupports* aCommandContext)
 {
   if (NS_WARN_IF(!nsContentUtils::IsSafeToRunScript())) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  int32_t x;
-  int32_t y;
+  nsCommandParams* params = aParams->AsCommandParams();
 
-  nsresult rv = aParams->GetLongValue("x", &x);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
+  ErrorResult error;
+  int32_t x = params->GetInt("x", error);
+  if (NS_WARN_IF(error.Failed())) {
+    return error.StealNSResult();
   }
-
-  rv = aParams->GetLongValue("y", &y);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
+  int32_t y = params->GetInt("y", error);
+  if (NS_WARN_IF(error.Failed())) {
+    return error.StealNSResult();
   }
 
   LayoutDeviceIntPoint point(x, y);
 
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryInterface(aCommandContext);
   if (NS_WARN_IF(!window)) {
     return NS_ERROR_FAILURE;
   }
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -26,16 +26,17 @@
 #include "mozilla/dom/UIEvent.h"
 #include "mozilla/dom/UIEventBinding.h"
 #include "mozilla/dom/WheelEventBinding.h"
 
 #include "ContentEventHandler.h"
 #include "IMEContentObserver.h"
 #include "WheelHandlingHelper.h"
 
+#include "nsCommandParams.h"
 #include "nsCOMPtr.h"
 #include "nsFocusManager.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIContent.h"
 #include "nsIContentInlines.h"
 #include "nsIDocument.h"
 #include "nsIFrame.h"
 #include "nsIWidget.h"
@@ -5630,46 +5631,40 @@ EventStateManager::DoContentCommandEvent
             remote->SendPasteTransferable(ipcDataTransfer, isPrivateData,
                                           IPC::Principal(requestingPrincipal),
                                           contentPolicyType);
             rv = NS_OK;
           } else {
             nsCOMPtr<nsICommandController> commandController = do_QueryInterface(controller);
             NS_ENSURE_STATE(commandController);
 
-            nsCOMPtr<nsICommandParams> params = do_CreateInstance("@mozilla.org/embedcomp/command-params;1", &rv);
-            NS_ENSURE_SUCCESS(rv, rv);
-
-            rv = params->SetISupportsValue("transferable", aEvent->mTransferable);
-            NS_ENSURE_SUCCESS(rv, rv);
-
+            RefPtr<nsCommandParams> params = new nsCommandParams();
+            rv = params->SetISupports("transferable", aEvent->mTransferable);
+            if (NS_WARN_IF(NS_FAILED(rv))) {
+              return rv;
+            }
             rv = commandController->DoCommandWithParams(cmd, params);
           }
           break;
         }
 
         case eContentCommandLookUpDictionary: {
           nsCOMPtr<nsICommandController> commandController =
             do_QueryInterface(controller);
           if (NS_WARN_IF(!commandController)) {
             return NS_ERROR_FAILURE;
           }
 
-          nsCOMPtr<nsICommandParams> params =
-            do_CreateInstance("@mozilla.org/embedcomp/command-params;1", &rv);
+          RefPtr<nsCommandParams> params = new nsCommandParams();
+          rv = params->SetInt("x", aEvent->mRefPoint.x);
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return rv;
           }
 
-          rv = params->SetLongValue("x", aEvent->mRefPoint.x);
-          if (NS_WARN_IF(NS_FAILED(rv))) {
-            return rv;
-          }
-
-          rv = params->SetLongValue("y", aEvent->mRefPoint.y);
+          rv = params->SetInt("y", aEvent->mRefPoint.y);
           if (NS_WARN_IF(NS_FAILED(rv))) {
             return rv;
           }
 
           rv = commandController->DoCommandWithParams(cmd, params);
           break;
         }
 
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -104,16 +104,17 @@
 #include "nsIStringBundle.h"
 #include "nsFocusManager.h"
 #include "nsIFrame.h"
 #include "nsIContent.h"
 #include "nsLayoutStylesheetCache.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/Unused.h"
+#include "nsCommandParams.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 #define NS_MAX_DOCUMENT_WRITE_DEPTH 20
 
 #include "prtime.h"
 
@@ -3000,37 +3001,31 @@ nsHTMLDocument::ExecCommand(const nsAStr
   if (!enabled) {
     return false;
   }
 
   if (!isBool && paramStr.IsEmpty()) {
     rv = cmdMgr->DoCommand(cmdToDispatch.get(), nullptr, window);
   } else {
     // we have a command that requires a parameter, create params
-    nsCOMPtr<nsICommandParams> cmdParams = do_CreateInstance(
-                                            NS_COMMAND_PARAMS_CONTRACTID);
-    if (!cmdParams) {
-      rv.Throw(NS_ERROR_OUT_OF_MEMORY);
-      return false;
-    }
-
+    RefPtr<nsCommandParams> params = new nsCommandParams();
     if (isBool) {
-      rv = cmdParams->SetBooleanValue("state_attribute", boolVal);
+      rv = params->SetBool("state_attribute", boolVal);
     } else if (cmdToDispatch.EqualsLiteral("cmd_fontFace")) {
-      rv = cmdParams->SetStringValue("state_attribute", value);
+      rv = params->SetString("state_attribute", value);
     } else if (cmdToDispatch.EqualsLiteral("cmd_insertHTML") ||
                cmdToDispatch.EqualsLiteral("cmd_insertText")) {
-      rv = cmdParams->SetStringValue("state_data", value);
+      rv = params->SetString("state_data", value);
     } else {
-      rv = cmdParams->SetCStringValue("state_attribute", paramStr);
+      rv = params->SetCString("state_attribute", paramStr);
     }
     if (rv.Failed()) {
       return false;
     }
-    rv = cmdMgr->DoCommand(cmdToDispatch.get(), cmdParams, window);
+    rv = cmdMgr->DoCommand(cmdToDispatch.get(), params, window);
   }
 
   return !rv.Failed();
 }
 
 bool
 nsHTMLDocument::QueryCommandEnabled(const nsAString& commandID,
                                     nsIPrincipal& aSubjectPrincipal,
@@ -3100,35 +3095,26 @@ nsHTMLDocument::QueryCommandIndeterm(con
   }
 
   nsPIDOMWindowOuter* window = GetWindow();
   if (!window) {
     rv.Throw(NS_ERROR_FAILURE);
     return false;
   }
 
-  nsresult res;
-  nsCOMPtr<nsICommandParams> cmdParams = do_CreateInstance(
-                                           NS_COMMAND_PARAMS_CONTRACTID, &res);
-  if (NS_FAILED(res)) {
-    rv.Throw(res);
-    return false;
-  }
-
-  rv = cmdMgr->GetCommandState(cmdToDispatch.get(), window, cmdParams);
+  RefPtr<nsCommandParams> params = new nsCommandParams();
+  rv = cmdMgr->GetCommandState(cmdToDispatch.get(), window, params);
   if (rv.Failed()) {
     return false;
   }
 
   // If command does not have a state_mixed value, this call fails and sets
   // retval to false.  This is fine -- we want to return false in that case
   // anyway (bug 738385), so we just don't throw regardless.
-  bool retval = false;
-  cmdParams->GetBooleanValue("state_mixed", &retval);
-  return retval;
+  return params->GetBool("state_mixed");
 }
 
 bool
 nsHTMLDocument::QueryCommandState(const nsAString& commandID, ErrorResult& rv)
 {
   nsAutoCString cmdToDispatch, paramToCheck;
   bool dummy, dummy2;
   if (!ConvertToMidasInternalCommand(commandID, commandID,
@@ -3157,47 +3143,39 @@ nsHTMLDocument::QueryCommandState(const 
   }
 
   if (commandID.LowerCaseEqualsLiteral("usecss")) {
     // Per spec, state is supported for styleWithCSS but not useCSS, so we just
     // return false always.
     return false;
   }
 
-  nsCOMPtr<nsICommandParams> cmdParams = do_CreateInstance(
-                                           NS_COMMAND_PARAMS_CONTRACTID);
-  if (!cmdParams) {
-    rv.Throw(NS_ERROR_OUT_OF_MEMORY);
-    return false;
-  }
-
-  rv = cmdMgr->GetCommandState(cmdToDispatch.get(), window, cmdParams);
+  RefPtr<nsCommandParams> params = new nsCommandParams();
+  rv = cmdMgr->GetCommandState(cmdToDispatch.get(), window, params);
   if (rv.Failed()) {
     return false;
   }
 
   // handle alignment as a special case (possibly other commands too?)
   // Alignment is special because the external api is individual
   // commands but internally we use cmd_align with different
   // parameters.  When getting the state of this command, we need to
   // return the boolean for this particular alignment rather than the
   // string of 'which alignment is this?'
   if (cmdToDispatch.EqualsLiteral("cmd_align")) {
     nsAutoCString actualAlignmentType;
-    rv = cmdParams->GetCStringValue("state_attribute", actualAlignmentType);
+    rv = params->GetCString("state_attribute", actualAlignmentType);
     return !rv.Failed() && !actualAlignmentType.IsEmpty() &&
            paramToCheck == actualAlignmentType;
   }
 
   // If command does not have a state_all value, this call fails and sets
   // retval to false.  This is fine -- we want to return false in that case
   // anyway (bug 738385), so we just succeed and return false regardless.
-  bool retval = false;
-  cmdParams->GetBooleanValue("state_all", &retval);
-  return retval;
+  return params->GetBool("state_all");
 }
 
 bool
 nsHTMLDocument::QueryCommandSupported(const nsAString& commandID,
                                       CallerType aCallerType)
 {
   // Gecko technically supports all the clipboard commands including
   // cut/copy/paste, but non-privileged content will be unable to call
@@ -3252,59 +3230,52 @@ nsHTMLDocument::QueryCommandValue(const 
   }
 
   nsPIDOMWindowOuter* window = GetWindow();
   if (!window) {
     rv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
-  // create params
-  nsCOMPtr<nsICommandParams> cmdParams = do_CreateInstance(
-                                           NS_COMMAND_PARAMS_CONTRACTID);
-  if (!cmdParams) {
-    rv.Throw(NS_ERROR_OUT_OF_MEMORY);
-    return;
-  }
-
   // this is a special command since we are calling DoCommand rather than
   // GetCommandState like the other commands
+  RefPtr<nsCommandParams> params = new nsCommandParams();
   if (cmdToDispatch.EqualsLiteral("cmd_getContents")) {
-    rv = cmdParams->SetBooleanValue("selection_only", true);
+    rv = params->SetBool("selection_only", true);
+    if (rv.Failed()) {
+      return;
+    }
+    rv = params->SetCString("format", NS_LITERAL_CSTRING("text/html"));
     if (rv.Failed()) {
       return;
     }
-    rv = cmdParams->SetCStringValue("format", NS_LITERAL_CSTRING("text/html"));
-    if (rv.Failed()) {
-      return;
-    }
-    rv = cmdMgr->DoCommand(cmdToDispatch.get(), cmdParams, window);
+    rv = cmdMgr->DoCommand(cmdToDispatch.get(), params, window);
     if (rv.Failed()) {
       return;
     }
-    rv = cmdParams->GetStringValue("result", aValue);
+    params->GetString("result", aValue);
     return;
   }
 
-  rv = cmdParams->SetCStringValue("state_attribute", paramStr);
+  rv = params->SetCString("state_attribute", paramStr);
   if (rv.Failed()) {
     return;
   }
 
-  rv = cmdMgr->GetCommandState(cmdToDispatch.get(), window, cmdParams);
+  rv = cmdMgr->GetCommandState(cmdToDispatch.get(), window, params);
   if (rv.Failed()) {
     return;
   }
 
   // If command does not have a state_attribute value, this call fails, and
   // aValue will wind up being the empty string.  This is fine -- we want to
   // return "" in that case anyway (bug 738385), so we just return NS_OK
   // regardless.
   nsAutoCString result;
-  cmdParams->GetCStringValue("state_attribute", result);
+  params->GetCString("state_attribute", result);
   CopyUTF8toUTF16(result, aValue);
 }
 
 nsresult
 nsHTMLDocument::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
                       bool aPreallocateChildren) const
 {
   NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager,
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -110,17 +110,17 @@
 #include "nsIPermissionManager.h"
 #include "nsIURILoader.h"
 #include "nsIScriptError.h"
 #include "mozilla/EventForwards.h"
 #include "nsDeviceContext.h"
 #include "nsSandboxFlags.h"
 #include "FrameLayerBuilder.h"
 #include "VRManagerChild.h"
-#include "nsICommandParams.h"
+#include "nsCommandParams.h"
 #include "nsISHistory.h"
 #include "nsQueryObject.h"
 #include "nsIHttpChannel.h"
 #include "mozilla/dom/DocGroup.h"
 #include "nsString.h"
 #include "nsISupportsPrimitives.h"
 #include "mozilla/Telemetry.h"
 #include "nsDocShellLoadInfo.h"
@@ -2201,21 +2201,18 @@ TabChild::RecvPasteTransferable(const IP
                                                      trans, nullptr, this);
   NS_ENSURE_SUCCESS(rv, IPC_OK());
 
   nsCOMPtr<nsIDocShell> ourDocShell = do_GetInterface(WebNavigation());
   if (NS_WARN_IF(!ourDocShell)) {
     return IPC_OK();
   }
 
-  nsCOMPtr<nsICommandParams> params =
-    do_CreateInstance("@mozilla.org/embedcomp/command-params;1", &rv);
-  NS_ENSURE_SUCCESS(rv, IPC_OK());
-
-  rv = params->SetISupportsValue("transferable", trans);
+  RefPtr<nsCommandParams> params = new nsCommandParams();
+  rv = params->SetISupports("transferable", trans);
   NS_ENSURE_SUCCESS(rv, IPC_OK());
 
   ourDocShell->DoCommandWithParams("cmd_pasteTransferable", params);
   return IPC_OK();
 }
 
 
 a11y::PDocAccessibleChild*
--- a/editor/libeditor/EditorCommands.cpp
+++ b/editor/libeditor/EditorCommands.cpp
@@ -5,22 +5,22 @@
 
 #include "EditorCommands.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/FlushType.h"
 #include "mozilla/TextEditor.h"
 #include "mozilla/dom/Selection.h"
+#include "nsCommandParams.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
 #include "nsDebug.h"
 #include "nsError.h"
 #include "nsIClipboard.h"
-#include "nsICommandParams.h"
 #include "nsID.h"
 #include "nsIDocument.h"
 #include "nsIEditor.h"
 #include "nsIEditorMailSupport.h"
 #include "nsIPlaintextEditor.h"
 #include "nsISelectionController.h"
 #include "nsITransferable.h"
 #include "nsString.h"
@@ -94,17 +94,17 @@ UndoCommand::DoCommandParams(const char*
 
 NS_IMETHODIMP
 UndoCommand::GetCommandStateParams(const char* aCommandName,
                                    nsICommandParams* aParams,
                                    nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::RedoCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 RedoCommand::IsCommandEnabled(const char* aCommandName,
@@ -153,17 +153,17 @@ RedoCommand::DoCommandParams(const char*
 
 NS_IMETHODIMP
 RedoCommand::GetCommandStateParams(const char* aCommandName,
                                    nsICommandParams* aParams,
                                    nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::ClearUndoCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 ClearUndoCommand::IsCommandEnabled(const char* aCommandName,
@@ -215,17 +215,17 @@ ClearUndoCommand::GetCommandStateParams(
                                         nsISupports* aCommandRefCon)
 {
   NS_ENSURE_ARG_POINTER(aParams);
 
   bool enabled;
   nsresult rv = IsCommandEnabled(aCommandName, aCommandRefCon, &enabled);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return aParams->SetBooleanValue(STATE_ENABLED, enabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, enabled);
 }
 
 /******************************************************************************
  * mozilla::CutCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 CutCommand::IsCommandEnabled(const char* aCommandName,
@@ -273,17 +273,17 @@ CutCommand::DoCommandParams(const char* 
 
 NS_IMETHODIMP
 CutCommand::GetCommandStateParams(const char* aCommandName,
                                   nsICommandParams* aParams,
                                   nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::CutOrDeleteCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 CutOrDeleteCommand::IsCommandEnabled(const char* aCommandName,
@@ -337,17 +337,17 @@ CutOrDeleteCommand::DoCommandParams(cons
 
 NS_IMETHODIMP
 CutOrDeleteCommand::GetCommandStateParams(const char* aCommandName,
                                           nsICommandParams* aParams,
                                           nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::CopyCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 CopyCommand::IsCommandEnabled(const char* aCommandName,
@@ -390,17 +390,17 @@ CopyCommand::DoCommandParams(const char*
 
 NS_IMETHODIMP
 CopyCommand::GetCommandStateParams(const char* aCommandName,
                                    nsICommandParams* aParams,
                                    nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::CopyOrDeleteCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 CopyOrDeleteCommand::IsCommandEnabled(const char* aCommandName,
@@ -455,17 +455,17 @@ CopyOrDeleteCommand::DoCommandParams(con
 
 NS_IMETHODIMP
 CopyOrDeleteCommand::GetCommandStateParams(const char* aCommandName,
                                            nsICommandParams* aParams,
                                            nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::CopyAndCollapseToEndCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 CopyAndCollapseToEndCommand::IsCommandEnabled(const char* aCommandName,
@@ -516,17 +516,17 @@ CopyAndCollapseToEndCommand::DoCommandPa
 
 NS_IMETHODIMP
 CopyAndCollapseToEndCommand::GetCommandStateParams(const char* aCommandName,
                                                    nsICommandParams* aParams,
                                                    nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::PasteCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 PasteCommand::IsCommandEnabled(const char* aCommandName,
@@ -574,17 +574,17 @@ PasteCommand::DoCommandParams(const char
 
 NS_IMETHODIMP
 PasteCommand::GetCommandStateParams(const char* aCommandName,
                                     nsICommandParams* aParams,
                                     nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::PasteTransferableCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 PasteTransferableCommand::IsCommandEnabled(const char* aCommandName,
@@ -622,18 +622,18 @@ PasteTransferableCommand::DoCommandParam
                                           nsICommandParams* aParams,
                                           nsISupports* aCommandRefCon)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
 
-  nsCOMPtr<nsISupports> supports;
-  aParams->GetISupportsValue("transferable", getter_AddRefs(supports));
+  nsCOMPtr<nsISupports> supports =
+    aParams->AsCommandParams()->GetISupports("transferable");
   if (NS_WARN_IF(!supports)) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsITransferable> trans = do_QueryInterface(supports);
   if (NS_WARN_IF(!trans)) {
     return NS_ERROR_FAILURE;
   }
@@ -648,33 +648,33 @@ PasteTransferableCommand::GetCommandStat
                                                 nsICommandParams* aParams,
                                                 nsISupports* aCommandRefCon)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
 
-  nsCOMPtr<nsISupports> supports;
-  aParams->GetISupportsValue("transferable", getter_AddRefs(supports));
+  nsCOMPtr<nsISupports> supports =
+    aParams->AsCommandParams()->GetISupports("transferable");
   if (NS_WARN_IF(!supports)) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsITransferable> trans;
   trans = do_QueryInterface(supports);
   if (NS_WARN_IF(!trans)) {
     return NS_ERROR_FAILURE;
   }
 
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
 
-  return aParams->SetBooleanValue(STATE_ENABLED,
-                                  textEditor->CanPasteTransferable(trans));
+  return aParams->AsCommandParams()->SetBool(
+           STATE_ENABLED, textEditor->CanPasteTransferable(trans));
 }
 
 /******************************************************************************
  * mozilla::SwitchTextDirectionCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 SwitchTextDirectionCommand::IsCommandEnabled(const char* aCommandName,
@@ -718,17 +718,18 @@ SwitchTextDirectionCommand::DoCommandPar
 
 NS_IMETHODIMP
 SwitchTextDirectionCommand::GetCommandStateParams(const char* aCommandName,
                                                   nsICommandParams* aParams,
                                                   nsISupports* aCommandRefCon)
 {
   bool canSwitchTextDirection = true;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canSwitchTextDirection);
-  return aParams->SetBooleanValue(STATE_ENABLED, canSwitchTextDirection);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED,
+                                             canSwitchTextDirection);
 }
 
 /******************************************************************************
  * mozilla::DeleteCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 DeleteCommand::IsCommandEnabled(const char* aCommandName,
@@ -815,17 +816,17 @@ DeleteCommand::DoCommandParams(const cha
 
 NS_IMETHODIMP
 DeleteCommand::GetCommandStateParams(const char* aCommandName,
                                      nsICommandParams* aParams,
                                      nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::SelectAllCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 SelectAllCommand::IsCommandEnabled(const char* aCommandName,
@@ -879,17 +880,17 @@ SelectAllCommand::DoCommandParams(const 
 
 NS_IMETHODIMP
 SelectAllCommand::GetCommandStateParams(const char* aCommandName,
                                         nsICommandParams* aParams,
                                         nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::SelectionMoveCommands
  ******************************************************************************/
 
 NS_IMETHODIMP
 SelectionMoveCommands::IsCommandEnabled(const char* aCommandName,
@@ -1045,17 +1046,17 @@ SelectionMoveCommands::DoCommandParams(c
 
 NS_IMETHODIMP
 SelectionMoveCommands::GetCommandStateParams(const char* aCommandName,
                                              nsICommandParams* aParams,
                                              nsISupports* aCommandRefCon)
 {
   bool canUndo;
   IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo);
-  return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, canUndo);
 }
 
 /******************************************************************************
  * mozilla::InsertPlaintextCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 InsertPlaintextCommand::IsCommandEnabled(const char* aCommandName,
@@ -1109,17 +1110,17 @@ InsertPlaintextCommand::DoCommandParams(
 
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_FAILURE;
   }
 
   // Get text to insert from command params
   nsAutoString text;
-  nsresult rv = aParams->GetStringValue(STATE_DATA, text);
+  nsresult rv = aParams->AsCommandParams()->GetString(STATE_DATA, text);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   TextEditor* textEditor = editor->AsTextEditor();
   MOZ_ASSERT(textEditor);
   // XXX InsertTextAsAction() is not same as OnInputText().  However, other
   //     commands to insert line break or paragraph separator use OnInput*().
@@ -1138,17 +1139,17 @@ InsertPlaintextCommand::GetCommandStateP
                                               nsISupports* aCommandRefCon)
 {
   if (NS_WARN_IF(!aParams)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   bool aIsEnabled = false;
   IsCommandEnabled(aCommandName, aCommandRefCon, &aIsEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED, aIsEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, aIsEnabled);
 }
 
 /******************************************************************************
  * mozilla::InsertParagraphCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 InsertParagraphCommand::IsCommandEnabled(const char* aCommandName,
@@ -1200,17 +1201,17 @@ InsertParagraphCommand::GetCommandStateP
                                               nsISupports* aCommandRefCon)
 {
   if (NS_WARN_IF(!aParams)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   bool aIsEnabled = false;
   IsCommandEnabled(aCommandName, aCommandRefCon, &aIsEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED, aIsEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, aIsEnabled);
 }
 
 /******************************************************************************
  * mozilla::InsertLineBreakCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 InsertLineBreakCommand::IsCommandEnabled(const char* aCommandName,
@@ -1264,17 +1265,17 @@ InsertLineBreakCommand::GetCommandStateP
                                               nsISupports* aCommandRefCon)
 {
   if (NS_WARN_IF(!aParams)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   bool aIsEnabled = false;
   IsCommandEnabled(aCommandName, aCommandRefCon, &aIsEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED, aIsEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, aIsEnabled);
 }
 
 /******************************************************************************
  * mozilla::PasteQuotationCommand
  ******************************************************************************/
 
 NS_IMETHODIMP
 PasteQuotationCommand::IsCommandEnabled(const char* aCommandName,
@@ -1334,13 +1335,13 @@ PasteQuotationCommand::GetCommandStatePa
   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->SetBooleanValue(STATE_ENABLED, enabled);
+  aParams->AsCommandParams()->SetBool(STATE_ENABLED, enabled);
   return NS_OK;
 }
 
 } // namespace mozilla
--- a/editor/libeditor/HTMLEditorCommands.cpp
+++ b/editor/libeditor/HTMLEditorCommands.cpp
@@ -8,24 +8,24 @@
 
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/EditorBase.h"         // for EditorBase
 #include "mozilla/ErrorResult.h"
 #include "mozilla/HTMLEditor.h"         // for HTMLEditor
 #include "mozilla/HTMLEditorCommands.h"
 #include "mozilla/dom/Element.h"
 #include "nsAString.h"
+#include "nsCommandParams.h"            // for nsCommandParams, etc
 #include "nsCOMPtr.h"                   // for nsCOMPtr, do_QueryInterface, etc
 #include "nsComponentManagerUtils.h"    // for do_CreateInstance
 #include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
 #include "nsError.h"                    // for NS_OK, NS_ERROR_FAILURE, etc
 #include "nsGkAtoms.h"                  // for nsGkAtoms, nsGkAtoms::font, etc
 #include "nsAtom.h"                    // for nsAtom, etc
 #include "nsIClipboard.h"               // for nsIClipboard, etc
-#include "nsICommandParams.h"           // for nsICommandParams, etc
 #include "nsID.h"
 #include "nsIEditor.h"                  // for nsIEditor
 #include "nsIHTMLEditor.h"              // for nsIHTMLEditor, etc
 #include "nsLiteralString.h"            // for NS_LITERAL_STRING
 #include "nsReadableUtils.h"            // for EmptyString
 #include "nsString.h"                   // for nsAutoString, nsString, etc
 #include "nsStringFwd.h"                // for nsString
 
@@ -175,17 +175,17 @@ PasteNoFormattingCommand::GetCommandStat
                                                 nsISupports* refCon)
 {
   NS_ENSURE_ARG_POINTER(aParams);
 
   bool enabled = false;
   nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return aParams->SetBooleanValue(STATE_ENABLED, enabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, enabled);
 }
 
 StyleUpdatingCommand::StyleUpdatingCommand(nsAtom* aTagName)
   : StateUpdatingCommandBase(aTagName)
 {
 }
 
 nsresult
@@ -201,82 +201,86 @@ StyleUpdatingCommand::GetCurrentState(HT
   bool allOfSelectionHasProp = false;
 
   nsresult rv = aHTMLEditor->GetInlineProperty(mTagName, nullptr,
                                                EmptyString(),
                                                &firstOfSelectionHasProp,
                                                &anyOfSelectionHasProp,
                                                &allOfSelectionHasProp);
 
-  aParams->SetBooleanValue(STATE_ENABLED, NS_SUCCEEDED(rv));
-  aParams->SetBooleanValue(STATE_ALL, allOfSelectionHasProp);
-  aParams->SetBooleanValue(STATE_ANY, anyOfSelectionHasProp);
-  aParams->SetBooleanValue(STATE_MIXED, anyOfSelectionHasProp
-           && !allOfSelectionHasProp);
-  aParams->SetBooleanValue(STATE_BEGIN, firstOfSelectionHasProp);
-  aParams->SetBooleanValue(STATE_END, allOfSelectionHasProp);//not completely accurate
+  nsCommandParams* params = aParams->AsCommandParams();
+  params->SetBool(STATE_ENABLED, NS_SUCCEEDED(rv));
+  params->SetBool(STATE_ALL, allOfSelectionHasProp);
+  params->SetBool(STATE_ANY, anyOfSelectionHasProp);
+  params->SetBool(STATE_MIXED, anyOfSelectionHasProp && !allOfSelectionHasProp);
+  params->SetBool(STATE_BEGIN, firstOfSelectionHasProp);
+  params->SetBool(STATE_END, allOfSelectionHasProp); //not completely accurate
   return NS_OK;
 }
 
 nsresult
 StyleUpdatingCommand::ToggleState(HTMLEditor* aHTMLEditor)
 {
   if (NS_WARN_IF(!aHTMLEditor)) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  //create some params now...
-  nsresult rv;
-  nsCOMPtr<nsICommandParams> params =
-      do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);
-  if (NS_FAILED(rv) || !params)
-    return rv;
+  RefPtr<nsCommandParams> params = new nsCommandParams();
 
   // tags "href" and "name" are special cases in the core editor
   // they are used to remove named anchor/link and shouldn't be used for insertion
   bool doTagRemoval;
   if (mTagName == nsGkAtoms::href || mTagName == nsGkAtoms::name) {
     doTagRemoval = true;
   } else {
     // check current selection; set doTagRemoval if formatting should be removed
-    rv = GetCurrentState(aHTMLEditor, params);
-    NS_ENSURE_SUCCESS(rv, rv);
-    rv = params->GetBooleanValue(STATE_ALL, &doTagRemoval);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsresult rv = GetCurrentState(aHTMLEditor, params);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
+    ErrorResult error;
+    doTagRemoval = params->GetBool(STATE_ALL, error);
+    if (NS_WARN_IF(error.Failed())) {
+      return error.StealNSResult();
+    }
   }
 
   if (doTagRemoval) {
     // Also remove equivalent properties (bug 317093)
     if (mTagName == nsGkAtoms::b) {
-      rv = aHTMLEditor->RemoveInlineProperty(nsGkAtoms::strong, nullptr);
+      nsresult rv =
+        aHTMLEditor->RemoveInlineProperty(nsGkAtoms::strong, nullptr);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else if (mTagName == nsGkAtoms::i) {
-      rv = aHTMLEditor->RemoveInlineProperty(nsGkAtoms::em, nullptr);
+      nsresult rv =
+        aHTMLEditor->RemoveInlineProperty(nsGkAtoms::em, nullptr);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else if (mTagName == nsGkAtoms::strike) {
-      rv = aHTMLEditor->RemoveInlineProperty(nsGkAtoms::s, nullptr);
+      nsresult rv =
+        aHTMLEditor->RemoveInlineProperty(nsGkAtoms::s, nullptr);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
-    rv = aHTMLEditor->RemoveInlineProperty(mTagName, nullptr);
+    nsresult rv = aHTMLEditor->RemoveInlineProperty(mTagName, nullptr);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
-    return rv;
+    return NS_OK;
   }
 
   // Superscript and Subscript styles are mutually exclusive
   aHTMLEditor->BeginTransaction();
 
+  nsresult rv = NS_OK;
   if (mTagName == nsGkAtoms::sub || mTagName == nsGkAtoms::sup) {
     rv = aHTMLEditor->RemoveInlineProperty(mTagName, nullptr);
   }
   if (NS_SUCCEEDED(rv)) {
     rv = aHTMLEditor->SetInlineProperty(mTagName, nullptr, EmptyString());
   }
 
   aHTMLEditor->EndTransaction();
@@ -298,41 +302,42 @@ ListCommand::GetCurrentState(HTMLEditor*
   }
 
   bool bMixed;
   nsAutoString localName;
   nsresult rv = GetListState(aHTMLEditor, &bMixed, localName);
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool inList = mTagName->Equals(localName);
-  aParams->SetBooleanValue(STATE_ALL, !bMixed && inList);
-  aParams->SetBooleanValue(STATE_MIXED, bMixed);
-  aParams->SetBooleanValue(STATE_ENABLED, true);
+  nsCommandParams* params = aParams->AsCommandParams();
+  params->SetBool(STATE_ALL, !bMixed && inList);
+  params->SetBool(STATE_MIXED, bMixed);
+  params->SetBool(STATE_ENABLED, true);
   return NS_OK;
 }
 
 nsresult
 ListCommand::ToggleState(HTMLEditor* aHTMLEditor)
 {
   if (NS_WARN_IF(!aHTMLEditor)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsresult rv;
-  nsCOMPtr<nsICommandParams> params =
-      do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);
-  if (NS_FAILED(rv) || !params)
-    return rv;
-
+  RefPtr<nsCommandParams> params = new nsCommandParams();
   rv = GetCurrentState(aHTMLEditor, params);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
 
-  bool inList;
-  rv = params->GetBooleanValue(STATE_ALL,&inList);
-  NS_ENSURE_SUCCESS(rv, rv);
+  ErrorResult error;
+  bool inList = params->GetBool(STATE_ALL, error);
+  if (NS_WARN_IF(error.Failed())) {
+    return error.StealNSResult();
+  }
 
   nsDependentAtomString listType(mTagName);
   if (inList) {
     rv = aHTMLEditor->RemoveList(listType);
   } else {
     rv = aHTMLEditor->MakeOrChangeList(listType, false, EmptyString());
   }
 
@@ -362,49 +367,49 @@ ListItemCommand::GetCurrentState(HTMLEdi
       inList = mTagName == nsGkAtoms::li;
     } else if (bDT) {
       inList = mTagName == nsGkAtoms::dt;
     } else if (bDD) {
       inList = mTagName == nsGkAtoms::dd;
     }
   }
 
-  aParams->SetBooleanValue(STATE_ALL, !bMixed && inList);
-  aParams->SetBooleanValue(STATE_MIXED, bMixed);
+  nsCommandParams* params = aParams->AsCommandParams();
+  params->SetBool(STATE_ALL, !bMixed && inList);
+  params->SetBool(STATE_MIXED, bMixed);
 
   return NS_OK;
 }
 
 nsresult
 ListItemCommand::ToggleState(HTMLEditor* aHTMLEditor)
 {
   if (NS_WARN_IF(!aHTMLEditor)) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  bool inList;
   // Need to use mTagName????
-  nsresult rv;
-  nsCOMPtr<nsICommandParams> params =
-      do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv);
-  if (NS_FAILED(rv) || !params)
-    return rv;
-  rv = GetCurrentState(aHTMLEditor, params);
-  rv = params->GetBooleanValue(STATE_ALL,&inList);
-  NS_ENSURE_SUCCESS(rv, rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  RefPtr<nsCommandParams> params = new nsCommandParams();
+  GetCurrentState(aHTMLEditor, params);
+  ErrorResult error;
+  bool inList = params->GetBool(STATE_ALL, error);
+  if (NS_WARN_IF(error.Failed())) {
+    return error.StealNSResult();
+  }
 
   if (inList) {
     // To remove a list, first get what kind of list we're in
     bool bMixed;
     nsAutoString localName;
-    rv = GetListState(aHTMLEditor, &bMixed, localName);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsresult rv = GetListState(aHTMLEditor, &bMixed, localName);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return rv;
+    }
     if (localName.IsEmpty() || bMixed) {
-      return rv;
+      return NS_OK;
     }
     return aHTMLEditor->RemoveList(localName);
   }
 
   // Set to the requested paragraph type
   //XXX Note: This actually doesn't work for "LI",
   //    but we currently don't use this for non DL lists anyway.
   // Problem: won't this replace any current block paragraph style?
@@ -470,17 +475,17 @@ RemoveListCommand::DoCommandParams(const
 
 NS_IMETHODIMP
 RemoveListCommand::GetCommandStateParams(const char* aCommandName,
                                          nsICommandParams* aParams,
                                          nsISupports* refCon)
 {
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 NS_IMETHODIMP
 IndentCommand::IsCommandEnabled(const char* aCommandName,
                                 nsISupports* refCon, bool* outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (!editor) {
@@ -517,17 +522,17 @@ IndentCommand::DoCommandParams(const cha
 
 NS_IMETHODIMP
 IndentCommand::GetCommandStateParams(const char* aCommandName,
                                      nsICommandParams* aParams,
                                      nsISupports* refCon)
 {
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 
 //OUTDENT
 
 NS_IMETHODIMP
 OutdentCommand::IsCommandEnabled(const char* aCommandName,
                                  nsISupports* refCon,
@@ -568,17 +573,17 @@ OutdentCommand::DoCommandParams(const ch
 
 NS_IMETHODIMP
 OutdentCommand::GetCommandStateParams(const char* aCommandName,
                                       nsICommandParams* aParams,
                                       nsISupports* refCon)
 {
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 MultiStateCommandBase::MultiStateCommandBase()
   : HTMLEditorCommandBase()
 {
 }
 
 MultiStateCommandBase::~MultiStateCommandBase()
@@ -624,22 +629,23 @@ MultiStateCommandBase::DoCommandParams(c
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
 
   nsAutoString attribute;
   if (aParams) {
+    nsCommandParams* params = aParams->AsCommandParams();
     nsAutoCString asciiAttribute;
-    nsresult rv = aParams->GetCStringValue(STATE_ATTRIBUTE, asciiAttribute);
+    nsresult rv = params->GetCString(STATE_ATTRIBUTE, asciiAttribute);
     if (NS_SUCCEEDED(rv)) {
       CopyASCIItoUTF16(asciiAttribute, attribute);
     } else {
-      aParams->GetStringValue(STATE_ATTRIBUTE, attribute);
+      params->GetString(STATE_ATTRIBUTE, attribute);
     }
   }
   return SetState(htmlEditor, attribute);
 }
 
 NS_IMETHODIMP
 MultiStateCommandBase::GetCommandStateParams(const char* aCommandName,
                                              nsICommandParams* aParams,
@@ -670,18 +676,19 @@ ParagraphStateCommand::GetCurrentState(H
   }
 
   bool outMixed;
   nsAutoString outStateString;
   nsresult rv = aHTMLEditor->GetParagraphState(&outMixed, outStateString);
   if (NS_SUCCEEDED(rv)) {
     nsAutoCString tOutStateString;
     LossyCopyUTF16toASCII(outStateString, tOutStateString);
-    aParams->SetBooleanValue(STATE_MIXED,outMixed);
-    aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString);
+    nsCommandParams* params = aParams->AsCommandParams();
+    params->SetBool(STATE_MIXED, outMixed);
+    params->SetCString(STATE_ATTRIBUTE, tOutStateString);
   }
   return rv;
 }
 
 nsresult
 ParagraphStateCommand::SetState(HTMLEditor* aHTMLEditor,
                                 const nsString& newState)
 {
@@ -703,19 +710,19 @@ FontFaceStateCommand::GetCurrentState(HT
   if (NS_WARN_IF(!aHTMLEditor)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsAutoString outStateString;
   bool outMixed;
   nsresult rv = aHTMLEditor->GetFontFaceState(&outMixed, outStateString);
   if (NS_SUCCEEDED(rv)) {
-    aParams->SetBooleanValue(STATE_MIXED,outMixed);
-    aParams->SetCStringValue(STATE_ATTRIBUTE,
-                             NS_ConvertUTF16toUTF8(outStateString));
+    nsCommandParams* params = aParams->AsCommandParams();
+    params->SetBool(STATE_MIXED, outMixed);
+    params->SetCString(STATE_ATTRIBUTE, NS_ConvertUTF16toUTF8(outStateString));
   }
   return rv;
 }
 
 nsresult
 FontFaceStateCommand::SetState(HTMLEditor* aHTMLEditor,
                                const nsString& newState)
 {
@@ -764,19 +771,20 @@ FontSizeStateCommand::GetCurrentState(HT
                                nsGkAtoms::size,
                                EmptyString(),
                                &firstHas, &anyHas, &allHas,
                                outStateString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString tOutStateString;
   LossyCopyUTF16toASCII(outStateString, tOutStateString);
-  aParams->SetBooleanValue(STATE_MIXED, anyHas && !allHas);
-  aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString);
-  aParams->SetBooleanValue(STATE_ENABLED, true);
+  nsCommandParams* params = aParams->AsCommandParams();
+  params->SetBool(STATE_MIXED, anyHas && !allHas);
+  params->SetCString(STATE_ATTRIBUTE, tOutStateString);
+  params->SetBool(STATE_ENABLED, true);
 
   return rv;
 }
 
 
 // acceptable values for "newState" are:
 //   -2
 //   -1
@@ -827,18 +835,19 @@ FontColorStateCommand::GetCurrentState(H
 
   bool outMixed;
   nsAutoString outStateString;
   nsresult rv = aHTMLEditor->GetFontColorState(&outMixed, outStateString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString tOutStateString;
   LossyCopyUTF16toASCII(outStateString, tOutStateString);
-  aParams->SetBooleanValue(STATE_MIXED, outMixed);
-  aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString);
+  nsCommandParams* params = aParams->AsCommandParams();
+  params->SetBool(STATE_MIXED, outMixed);
+  params->SetCString(STATE_ATTRIBUTE, tOutStateString);
   return NS_OK;
 }
 
 nsresult
 FontColorStateCommand::SetState(HTMLEditor* aHTMLEditor,
                                 const nsString& newState)
 {
   if (NS_WARN_IF(!aHTMLEditor)) {
@@ -869,18 +878,19 @@ HighlightColorStateCommand::GetCurrentSt
 
   bool outMixed;
   nsAutoString outStateString;
   nsresult rv = aHTMLEditor->GetHighlightColorState(&outMixed, outStateString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString tOutStateString;
   LossyCopyUTF16toASCII(outStateString, tOutStateString);
-  aParams->SetBooleanValue(STATE_MIXED, outMixed);
-  aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString);
+  nsCommandParams* params = aParams->AsCommandParams();
+  params->SetBool(STATE_MIXED, outMixed);
+  params->SetCString(STATE_ATTRIBUTE, tOutStateString);
   return NS_OK;
 }
 
 nsresult
 HighlightColorStateCommand::SetState(HTMLEditor* aHTMLEditor,
                                      const nsString& newState)
 {
   if (NS_WARN_IF(!aHTMLEditor)) {
@@ -928,18 +938,19 @@ BackgroundColorStateCommand::GetCurrentS
 
   bool outMixed;
   nsAutoString outStateString;
   nsresult rv = aHTMLEditor->GetBackgroundColorState(&outMixed, outStateString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString tOutStateString;
   LossyCopyUTF16toASCII(outStateString, tOutStateString);
-  aParams->SetBooleanValue(STATE_MIXED, outMixed);
-  aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString);
+  nsCommandParams* params = aParams->AsCommandParams();
+  params->SetBool(STATE_MIXED, outMixed);
+  params->SetCString(STATE_ATTRIBUTE, tOutStateString);
   return NS_OK;
 }
 
 nsresult
 BackgroundColorStateCommand::SetState(HTMLEditor* aHTMLEditor,
                                       const nsString& newState)
 {
   if (NS_WARN_IF(!aHTMLEditor)) {
@@ -983,18 +994,19 @@ AlignCommand::GetCurrentState(HTMLEditor
       break;
 
     case nsIHTMLEditor::eJustify:
       outStateString.AssignLiteral("justify");
       break;
   }
   nsAutoCString tOutStateString;
   LossyCopyUTF16toASCII(outStateString, tOutStateString);
-  aParams->SetBooleanValue(STATE_MIXED,outMixed);
-  aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString);
+  nsCommandParams* params = aParams->AsCommandParams();
+  params->SetBool(STATE_MIXED, outMixed);
+  params->SetCString(STATE_ATTRIBUTE, tOutStateString);
   return NS_OK;
 }
 
 nsresult
 AlignCommand::SetState(HTMLEditor* aHTMLEditor,
                        const nsString& newState)
 {
   if (NS_WARN_IF(!aHTMLEditor)) {
@@ -1033,29 +1045,30 @@ AbsolutePositioningCommand::IsCommandEna
 nsresult
 AbsolutePositioningCommand::GetCurrentState(HTMLEditor* aHTMLEditor,
                                             nsICommandParams* aParams)
 {
   if (NS_WARN_IF(!aHTMLEditor)) {
     return NS_ERROR_INVALID_ARG;
   }
 
+  nsCommandParams* params = aParams->AsCommandParams();
   bool isEnabled = aHTMLEditor->AbsolutePositioningEnabled();
   if (!isEnabled) {
-    aParams->SetBooleanValue(STATE_MIXED,false);
-    aParams->SetCStringValue(STATE_ATTRIBUTE, EmptyCString());
+    params->SetBool(STATE_MIXED, false);
+    params->SetCString(STATE_ATTRIBUTE, EmptyCString());
     return NS_OK;
   }
 
   RefPtr<Element> container =
     aHTMLEditor->GetAbsolutelyPositionedSelectionContainer();
-  aParams->SetBooleanValue(STATE_MIXED,  false);
-  aParams->SetCStringValue(STATE_ATTRIBUTE,
-                           container ? NS_LITERAL_CSTRING("absolute") :
-                                       EmptyCString());
+  params->SetBool(STATE_MIXED,  false);
+  params->SetCString(STATE_ATTRIBUTE,
+                     container ? NS_LITERAL_CSTRING("absolute") :
+                                 EmptyCString());
   return NS_OK;
 }
 
 nsresult
 AbsolutePositioningCommand::ToggleState(HTMLEditor* aHTMLEditor)
 {
   if (NS_WARN_IF(!aHTMLEditor)) {
     return NS_ERROR_INVALID_ARG;
@@ -1125,17 +1138,17 @@ DecreaseZIndexCommand::GetCommandStatePa
                                              nsISupports* refCon)
 {
   NS_ENSURE_ARG_POINTER(aParams);
 
   bool enabled = false;
   nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return aParams->SetBooleanValue(STATE_ENABLED, enabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, enabled);
 }
 
 NS_IMETHODIMP
 IncreaseZIndexCommand::IsCommandEnabled(const char* aCommandName,
                                         nsISupports* refCon,
                                         bool* outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
@@ -1185,17 +1198,17 @@ IncreaseZIndexCommand::GetCommandStatePa
                                              nsISupports* refCon)
 {
   NS_ENSURE_ARG_POINTER(aParams);
 
   bool enabled = false;
   nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return aParams->SetBooleanValue(STATE_ENABLED, enabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, enabled);
 }
 
 NS_IMETHODIMP
 RemoveStylesCommand::IsCommandEnabled(const char* aCommandName,
                                       nsISupports* refCon,
                                       bool* outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
@@ -1235,17 +1248,17 @@ RemoveStylesCommand::DoCommandParams(con
 
 NS_IMETHODIMP
 RemoveStylesCommand::GetCommandStateParams(const char* aCommandName,
                                            nsICommandParams* aParams,
                                            nsISupports* refCon)
 {
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 NS_IMETHODIMP
 IncreaseFontSizeCommand::IsCommandEnabled(const char* aCommandName,
                                           nsISupports* refCon,
                                           bool* outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
@@ -1286,17 +1299,17 @@ IncreaseFontSizeCommand::DoCommandParams
 
 NS_IMETHODIMP
 IncreaseFontSizeCommand::GetCommandStateParams(const char* aCommandName,
                                                nsICommandParams* aParams,
                                                nsISupports* refCon)
 {
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 NS_IMETHODIMP
 DecreaseFontSizeCommand::IsCommandEnabled(const char* aCommandName,
                                           nsISupports* refCon,
                                           bool* outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
@@ -1336,17 +1349,17 @@ DecreaseFontSizeCommand::DoCommandParams
 
 NS_IMETHODIMP
 DecreaseFontSizeCommand::GetCommandStateParams(const char* aCommandName,
                                                nsICommandParams* aParams,
                                                nsISupports* refCon)
 {
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED,outCmdEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 NS_IMETHODIMP
 InsertHTMLCommand::IsCommandEnabled(const char* aCommandName,
                                     nsISupports* refCon,
                                     bool* outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
@@ -1394,33 +1407,34 @@ InsertHTMLCommand::DoCommandParams(const
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
 
   // Get HTML source string to insert from command params
   nsAutoString html;
-  nsresult rv = aParams->GetStringValue(STATE_DATA, html);
-  NS_ENSURE_SUCCESS(rv, rv);
-
+  nsresult rv = aParams->AsCommandParams()->GetString(STATE_DATA, html);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
   return htmlEditor->InsertHTML(html);
 }
 
 NS_IMETHODIMP
 InsertHTMLCommand::GetCommandStateParams(const char *aCommandName,
                                          nsICommandParams *aParams,
                                          nsISupports *refCon)
 {
   NS_ENSURE_ARG_POINTER(aParams);
   NS_ENSURE_ARG_POINTER(refCon);
 
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 InsertTagCommand::InsertTagCommand(nsAtom* aTagName)
   : HTMLEditorCommandBase()
   , mTagName(aTagName)
 {
   MOZ_ASSERT(mTagName);
 }
@@ -1489,17 +1503,18 @@ InsertTagCommand::DoCommandParams(const 
   }
   mozilla::HTMLEditor* htmlEditor = editor->AsHTMLEditor();
   if (NS_WARN_IF(!htmlEditor)) {
     return NS_ERROR_FAILURE;
   }
 
   // do we have an href to use for creating link?
   nsAutoCString asciiAttribute;
-  nsresult rv = aParams->GetCStringValue(STATE_ATTRIBUTE, asciiAttribute);
+  nsresult rv =
+    aParams->AsCommandParams()->GetCString(STATE_ATTRIBUTE, asciiAttribute);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   nsAutoString attribute;
   CopyASCIItoUTF16(asciiAttribute, attribute);
 
   if (attribute.IsEmpty()) {
     return NS_ERROR_INVALID_ARG;
@@ -1538,17 +1553,17 @@ InsertTagCommand::GetCommandStateParams(
                                         nsICommandParams *aParams,
                                         nsISupports *refCon)
 {
   NS_ENSURE_ARG_POINTER(aParams);
   NS_ENSURE_ARG_POINTER(refCon);
 
   bool outCmdEnabled = false;
   IsCommandEnabled(aCommandName, refCon, &outCmdEnabled);
-  return aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
+  return aParams->AsCommandParams()->SetBool(STATE_ENABLED, outCmdEnabled);
 }
 
 
 /****************************/
 //HELPER METHODS
 /****************************/
 
 static nsresult