Bug 1130096 - Convert embedding/components/commandhandler/ to Gecko style. r=mccr8
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Mon, 11 May 2015 12:35:14 -0700
changeset 243391 0f6c617635886a1644bf5bf9cf59797a3df09f0a
parent 243390 4ff686c997507c045be0a5b058ec22bac9897fcd
child 243392 aefee110162fff03d88661067c65967bee42dc31
push id28738
push usercbook@mozilla.com
push dateTue, 12 May 2015 14:11:31 +0000
treeherdermozilla-central@bedce1b405a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1130096
milestone40.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 1130096 - Convert embedding/components/commandhandler/ to Gecko style. r=mccr8
embedding/components/commandhandler/nsBaseCommandController.cpp
embedding/components/commandhandler/nsBaseCommandController.h
embedding/components/commandhandler/nsCommandGroup.cpp
embedding/components/commandhandler/nsCommandGroup.h
embedding/components/commandhandler/nsCommandManager.cpp
embedding/components/commandhandler/nsCommandManager.h
embedding/components/commandhandler/nsCommandParams.cpp
embedding/components/commandhandler/nsCommandParams.h
embedding/components/commandhandler/nsControllerCommandTable.cpp
embedding/components/commandhandler/nsControllerCommandTable.h
--- a/embedding/components/commandhandler/nsBaseCommandController.cpp
+++ b/embedding/components/commandhandler/nsBaseCommandController.cpp
@@ -26,158 +26,158 @@ nsBaseCommandController::nsBaseCommandCo
 {
 }
 
 nsBaseCommandController::~nsBaseCommandController()
 {
 }
 
 NS_IMETHODIMP
-nsBaseCommandController::Init(nsIControllerCommandTable *aCommandTable)
+nsBaseCommandController::Init(nsIControllerCommandTable* aCommandTable)
 {
   nsresult rv = NS_OK;
 
-  if (aCommandTable)
-    mCommandTable = aCommandTable;    // owning addref
-  else
-    mCommandTable = do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
-  
+  if (aCommandTable) {
+    mCommandTable = aCommandTable;
+  } else {
+    mCommandTable =
+      do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
+  }
+
   return rv;
 }
 
 NS_IMETHODIMP
-nsBaseCommandController::SetCommandContext(nsISupports *aCommandContext)
+nsBaseCommandController::SetCommandContext(nsISupports* aCommandContext)
 {
   mCommandContextWeakPtr = nullptr;
   mCommandContextRawPtr = nullptr;
 
   if (aCommandContext) {
     nsCOMPtr<nsISupportsWeakReference> weak = do_QueryInterface(aCommandContext);
     if (weak) {
       nsresult rv =
         weak->GetWeakReference(getter_AddRefs(mCommandContextWeakPtr));
       NS_ENSURE_SUCCESS(rv, rv);
-    }
-    else {
+    } else {
       mCommandContextRawPtr = aCommandContext;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsBaseCommandController::GetInterface(const nsIID & aIID, void * *result)
+nsBaseCommandController::GetInterface(const nsIID& aIID, void** aResult)
 {
-  NS_ENSURE_ARG_POINTER(result);
+  NS_ENSURE_ARG_POINTER(aResult);
 
-  if (NS_SUCCEEDED(QueryInterface(aIID, result)))
+  if (NS_SUCCEEDED(QueryInterface(aIID, aResult))) {
     return NS_OK;
+  }
 
-  if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable)))
-  {
-    if (mCommandTable)
-      return mCommandTable->QueryInterface(aIID, result);
+  if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable))) {
+    if (mCommandTable) {
+      return mCommandTable->QueryInterface(aIID, aResult);
+    }
     return NS_ERROR_NOT_INITIALIZED;
   }
-    
+
   return NS_NOINTERFACE;
 }
 
-
-
 /* =======================================================================
  * nsIController
  * ======================================================================= */
 
 NS_IMETHODIMP
-nsBaseCommandController::IsCommandEnabled(const char *aCommand,
-                                          bool *aResult)
+nsBaseCommandController::IsCommandEnabled(const char* aCommand, bool* aResult)
 {
   NS_ENSURE_ARG_POINTER(aCommand);
   NS_ENSURE_ARG_POINTER(aResult);
   NS_ENSURE_STATE(mCommandTable);
 
   nsISupports* context = mCommandContextRawPtr;
   nsCOMPtr<nsISupports> weak;
   if (!context) {
     weak = do_QueryReferent(mCommandContextWeakPtr);
     context = weak;
   }
   return mCommandTable->IsCommandEnabled(aCommand, context, aResult);
 }
 
 NS_IMETHODIMP
-nsBaseCommandController::SupportsCommand(const char *aCommand, bool *aResult)
+nsBaseCommandController::SupportsCommand(const char* aCommand, bool* aResult)
 {
   NS_ENSURE_ARG_POINTER(aCommand);
   NS_ENSURE_ARG_POINTER(aResult);
   NS_ENSURE_STATE(mCommandTable);
 
   nsISupports* context = mCommandContextRawPtr;
   nsCOMPtr<nsISupports> weak;
   if (!context) {
     weak = do_QueryReferent(mCommandContextWeakPtr);
     context = weak;
   }
   return mCommandTable->SupportsCommand(aCommand, context, aResult);
 }
 
 NS_IMETHODIMP
-nsBaseCommandController::DoCommand(const char *aCommand)
+nsBaseCommandController::DoCommand(const char* aCommand)
 {
   NS_ENSURE_ARG_POINTER(aCommand);
   NS_ENSURE_STATE(mCommandTable);
 
   nsISupports* context = mCommandContextRawPtr;
   nsCOMPtr<nsISupports> weak;
   if (!context) {
     weak = do_QueryReferent(mCommandContextWeakPtr);
     context = weak;
   }
   return mCommandTable->DoCommand(aCommand, context);
 }
 
 NS_IMETHODIMP
-nsBaseCommandController::DoCommandWithParams(const char *aCommand,
-                                             nsICommandParams *aParams)
+nsBaseCommandController::DoCommandWithParams(const char* aCommand,
+                                             nsICommandParams* aParams)
 {
   NS_ENSURE_ARG_POINTER(aCommand);
   NS_ENSURE_STATE(mCommandTable);
 
   nsISupports* context = mCommandContextRawPtr;
   nsCOMPtr<nsISupports> weak;
   if (!context) {
     weak = do_QueryReferent(mCommandContextWeakPtr);
     context = weak;
   }
   return mCommandTable->DoCommandParams(aCommand, aParams, context);
 }
 
 NS_IMETHODIMP
-nsBaseCommandController::GetCommandStateWithParams(const char *aCommand,
-                                                   nsICommandParams *aParams)
+nsBaseCommandController::GetCommandStateWithParams(const char* aCommand,
+                                                   nsICommandParams* aParams)
 {
   NS_ENSURE_ARG_POINTER(aCommand);
   NS_ENSURE_STATE(mCommandTable);
 
   nsISupports* context = mCommandContextRawPtr;
   nsCOMPtr<nsISupports> weak;
   if (!context) {
     weak = do_QueryReferent(mCommandContextWeakPtr);
     context = weak;
   }
   return mCommandTable->GetCommandState(aCommand, aParams, context);
 }
 
 NS_IMETHODIMP
-nsBaseCommandController::OnEvent(const char * aEventName)
+nsBaseCommandController::OnEvent(const char* aEventName)
 {
   NS_ENSURE_ARG_POINTER(aEventName);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsBaseCommandController::GetSupportedCommands(uint32_t* aCount, char*** aCommands)
+nsBaseCommandController::GetSupportedCommands(uint32_t* aCount,
+                                              char*** aCommands)
 {
   NS_ENSURE_STATE(mCommandTable);
   return mCommandTable->GetSupportedCommands(aCount, aCommands);
 }
--- a/embedding/components/commandhandler/nsBaseCommandController.h
+++ b/embedding/components/commandhandler/nsBaseCommandController.h
@@ -2,59 +2,47 @@
 /* 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/. */
 
 #ifndef nsBaseCommandController_h__
 #define nsBaseCommandController_h__
 
 #define NS_BASECOMMANDCONTROLLER_CID \
-{ 0xbf88b48c, 0xfd8e, 0x40b4, { 0xba, 0x36, 0xc7, 0xc3, 0xad, 0x6d, 0x8a, 0xc9 } }
+  { 0xbf88b48c, 0xfd8e, 0x40b4, { 0xba, 0x36, 0xc7, 0xc3, 0xad, 0x6d, 0x8a, 0xc9 } }
 #define NS_BASECOMMANDCONTROLLER_CONTRACTID \
- "@mozilla.org/embedcomp/base-command-controller;1"
-
+  "@mozilla.org/embedcomp/base-command-controller;1"
 
 #include "nsIController.h"
 #include "nsIControllerContext.h"
 #include "nsIControllerCommandTable.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIWeakReferenceUtils.h"
 
-// The base editor controller is used for both text widgets, 
-//   and all other text and html editing
-class nsBaseCommandController :  public nsIController,
-                            public nsIControllerContext,
-                            public nsIInterfaceRequestor,
-                            public nsICommandController
+// The base editor controller is used for both text widgets, and all other text
+// and html editing
+class nsBaseCommandController
+  : public nsIController
+  , public nsIControllerContext
+  , public nsIInterfaceRequestor
+  , public nsICommandController
 {
 public:
-
   nsBaseCommandController();
 
-  // nsISupports
   NS_DECL_ISUPPORTS
-    
-  // nsIController
   NS_DECL_NSICONTROLLER
-
-  // nsICommandController
   NS_DECL_NSICOMMANDCONTROLLER
-
-  //nsIControllerContext
   NS_DECL_NSICONTROLLERCONTEXT
-
-  // nsIInterfaceRequestor
   NS_DECL_NSIINTERFACEREQUESTOR
 
 protected:
   virtual ~nsBaseCommandController();
 
 private:
+  nsWeakPtr mCommandContextWeakPtr;
+  nsISupports* mCommandContextRawPtr;
 
-   nsWeakPtr mCommandContextWeakPtr;
-   nsISupports* mCommandContextRawPtr;
-   
-   // Our reference to the command manager
-   nsCOMPtr<nsIControllerCommandTable> mCommandTable;     
+  // Our reference to the command manager
+  nsCOMPtr<nsIControllerCommandTable> mCommandTable;
 };
 
 #endif /* nsBaseCommandController_h_ */
-
--- a/embedding/components/commandhandler/nsCommandGroup.cpp
+++ b/embedding/components/commandhandler/nsCommandGroup.cpp
@@ -9,198 +9,201 @@
 #include "nsISimpleEnumerator.h"
 #include "nsXPCOM.h"
 #include "nsSupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsCommandGroup.h"
 #include "nsIControllerCommand.h"
 #include "nsCRT.h"
 
-
 class nsGroupsEnumerator : public nsISimpleEnumerator
 {
 public:
-  explicit nsGroupsEnumerator(nsControllerCommandGroup::GroupsHashtable &inHashTable);
+  explicit nsGroupsEnumerator(
+    nsControllerCommandGroup::GroupsHashtable& aInHashTable);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
 protected:
   virtual ~nsGroupsEnumerator();
 
-  static PLDHashOperator HashEnum(const nsACString &aKey, nsTArray<nsCString> *aData, void *aClosure);
+  static PLDHashOperator HashEnum(const nsACString& aKey,
+                                  nsTArray<nsCString>* aData, void* aClosure);
   nsresult Initialize();
 
 protected:
-
-  nsControllerCommandGroup::GroupsHashtable &mHashTable;
+  nsControllerCommandGroup::GroupsHashtable& mHashTable;
   int32_t mIndex;
-  char **mGroupNames;        // array of pointers to char16_t* in the hash table
+  char** mGroupNames;  // array of pointers to char16_t* in the hash table
   bool mInitted;
-  
 };
 
 /* Implementation file */
 NS_IMPL_ISUPPORTS(nsGroupsEnumerator, nsISimpleEnumerator)
 
-nsGroupsEnumerator::nsGroupsEnumerator(nsControllerCommandGroup::GroupsHashtable &inHashTable)
-: mHashTable(inHashTable)
-, mIndex(-1)
-, mGroupNames(nullptr)
-, mInitted(false)
+nsGroupsEnumerator::nsGroupsEnumerator(
+      nsControllerCommandGroup::GroupsHashtable& aInHashTable)
+  : mHashTable(aInHashTable)
+  , mIndex(-1)
+  , mGroupNames(nullptr)
+  , mInitted(false)
 {
-  /* member initializers and constructor code */
 }
 
 nsGroupsEnumerator::~nsGroupsEnumerator()
 {
-  delete [] mGroupNames;    // ok on null pointer
+  delete[] mGroupNames;
 }
 
-/* boolean hasMoreElements (); */
 NS_IMETHODIMP
-nsGroupsEnumerator::HasMoreElements(bool *_retval)
+nsGroupsEnumerator::HasMoreElements(bool* aResult)
 {
   nsresult rv = NS_OK;
-  
-  NS_ENSURE_ARG_POINTER(_retval);
+
+  NS_ENSURE_ARG_POINTER(aResult);
 
   if (!mInitted) {
     rv = Initialize();
-    if (NS_FAILED(rv)) return rv;
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
   }
-  
-  *_retval = (mIndex < static_cast<int32_t>(mHashTable.Count()) - 1);
+
+  *aResult = (mIndex < static_cast<int32_t>(mHashTable.Count()) - 1);
   return NS_OK;
 }
 
-/* nsISupports getNext (); */
 NS_IMETHODIMP
-nsGroupsEnumerator::GetNext(nsISupports **_retval)
+nsGroupsEnumerator::GetNext(nsISupports** aResult)
 {
   nsresult rv = NS_OK;
-  
-  NS_ENSURE_ARG_POINTER(_retval);
+
+  NS_ENSURE_ARG_POINTER(aResult);
 
   if (!mInitted) {
     rv = Initialize();
-    if (NS_FAILED(rv)) return rv;
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
   }
-  
-  mIndex ++;
-  if (mIndex >= static_cast<int32_t>(mHashTable.Count()))
+
+  mIndex++;
+  if (mIndex >= static_cast<int32_t>(mHashTable.Count())) {
     return NS_ERROR_FAILURE;
+  }
 
-  char *thisGroupName = mGroupNames[mIndex];
-  
-  nsCOMPtr<nsISupportsCString> supportsString = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
-  if (NS_FAILED(rv)) return rv;
+  char* thisGroupName = mGroupNames[mIndex];
+
+  nsCOMPtr<nsISupportsCString> supportsString =
+    do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
 
   supportsString->SetData(nsDependentCString(thisGroupName));
-  return CallQueryInterface(supportsString, _retval);
+  return CallQueryInterface(supportsString, aResult);
 }
 
 /* static */
 /* return false to stop */
 PLDHashOperator
-nsGroupsEnumerator::HashEnum(const nsACString &aKey, nsTArray<nsCString> *aData, void *aClosure)
+nsGroupsEnumerator::HashEnum(const nsACString& aKey, nsTArray<nsCString>* aData,
+                             void* aClosure)
 {
-  nsGroupsEnumerator *groupsEnum = static_cast<nsGroupsEnumerator*>(aClosure);
+  nsGroupsEnumerator* groupsEnum = static_cast<nsGroupsEnumerator*>(aClosure);
   groupsEnum->mGroupNames[groupsEnum->mIndex] = (char*)aKey.Data();
   groupsEnum->mIndex++;
   return PL_DHASH_NEXT;
 }
 
 nsresult
 nsGroupsEnumerator::Initialize()
 {
-  if (mInitted) return NS_OK;
-  
+  if (mInitted) {
+    return NS_OK;
+  }
+
   mGroupNames = new char*[mHashTable.Count()];
-  if (!mGroupNames) return NS_ERROR_OUT_OF_MEMORY;
-  
-  mIndex = 0; 
+  if (!mGroupNames) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
+
+  mIndex = 0;
   mHashTable.EnumerateRead(HashEnum, this);
 
   mIndex = -1;
   mInitted = true;
   return NS_OK;
 }
 
-#if 0
-#pragma mark -
-#endif
-
 class nsNamedGroupEnumerator : public nsISimpleEnumerator
 {
 public:
-  explicit nsNamedGroupEnumerator(nsTArray<nsCString> *inArray);
+  explicit nsNamedGroupEnumerator(nsTArray<nsCString>* aInArray);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
 protected:
   virtual ~nsNamedGroupEnumerator();
 
-  nsTArray<nsCString> *mGroupArray;
+  nsTArray<nsCString>* mGroupArray;
   int32_t mIndex;
 };
 
-nsNamedGroupEnumerator::nsNamedGroupEnumerator(nsTArray<nsCString> *inArray)
-: mGroupArray(inArray)
-, mIndex(-1)
+nsNamedGroupEnumerator::nsNamedGroupEnumerator(nsTArray<nsCString>* aInArray)
+  : mGroupArray(aInArray)
+  , mIndex(-1)
 {
 }
 
 nsNamedGroupEnumerator::~nsNamedGroupEnumerator()
 {
 }
 
 NS_IMPL_ISUPPORTS(nsNamedGroupEnumerator, nsISimpleEnumerator)
 
-/* boolean hasMoreElements (); */
 NS_IMETHODIMP
-nsNamedGroupEnumerator::HasMoreElements(bool *_retval)
+nsNamedGroupEnumerator::HasMoreElements(bool* aResult)
 {
-  NS_ENSURE_ARG_POINTER(_retval);
-  
+  NS_ENSURE_ARG_POINTER(aResult);
+
   int32_t arrayLen = mGroupArray ? mGroupArray->Length() : 0;
-  *_retval = (mIndex < arrayLen - 1); 
+  *aResult = (mIndex < arrayLen - 1);
   return NS_OK;
 }
 
-/* nsISupports getNext (); */
 NS_IMETHODIMP
-nsNamedGroupEnumerator::GetNext(nsISupports **_retval)
+nsNamedGroupEnumerator::GetNext(nsISupports** aResult)
 {
-  NS_ENSURE_ARG_POINTER(_retval);
+  NS_ENSURE_ARG_POINTER(aResult);
 
-  if (!mGroupArray)
+  if (!mGroupArray) {
     return NS_ERROR_FAILURE;
+  }
 
   mIndex++;
-  if (mIndex >= int32_t(mGroupArray->Length()))
+  if (mIndex >= int32_t(mGroupArray->Length())) {
     return NS_ERROR_FAILURE;
-    
+  }
+
   const nsCString& thisGroupName = mGroupArray->ElementAt(mIndex);
-  
+
   nsresult rv;
-  nsCOMPtr<nsISupportsCString> supportsString = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
-  if (NS_FAILED(rv)) return rv;
+  nsCOMPtr<nsISupportsCString> supportsString =
+    do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
 
   supportsString->SetData(thisGroupName);
-  return CallQueryInterface(supportsString, _retval);
+  return CallQueryInterface(supportsString, aResult);
 }
 
-#if 0
-#pragma mark -
-#endif
-
-
-/* Implementation file */
 NS_IMPL_ISUPPORTS(nsControllerCommandGroup, nsIControllerCommandGroup)
 
 nsControllerCommandGroup::nsControllerCommandGroup()
 {
 }
 
 nsControllerCommandGroup::~nsControllerCommandGroup()
 {
@@ -208,105 +211,96 @@ nsControllerCommandGroup::~nsControllerC
 }
 
 void
 nsControllerCommandGroup::ClearGroupsHash()
 {
   mGroupsHash.Clear();
 }
 
-#if 0
-#pragma mark -
-#endif
-
-/* void addCommandToGroup (in DOMString aCommand, in DOMString aGroup); */
 NS_IMETHODIMP
-nsControllerCommandGroup::AddCommandToGroup(const char *aCommand, const char *aGroup)
+nsControllerCommandGroup::AddCommandToGroup(const char* aCommand,
+                                            const char* aGroup)
 {
   nsDependentCString groupKey(aGroup);
-  nsTArray<nsCString> *commandList;
-  if ((commandList = mGroupsHash.Get(groupKey)) == nullptr)
-  {
+  nsTArray<nsCString>* commandList = mGroupsHash.Get(groupKey);
+  if (!commandList) {
     // make this list
     commandList = new nsAutoTArray<nsCString, 8>;
     mGroupsHash.Put(groupKey, commandList);
   }
 
 #ifdef DEBUG
-  nsCString *appended =
+  nsCString* appended =
 #endif
   commandList->AppendElement(aCommand);
   NS_ASSERTION(appended, "Append failed");
 
   return NS_OK;
 }
 
-/* void removeCommandFromGroup (in DOMString aCommand, in DOMString aGroup); */
 NS_IMETHODIMP
-nsControllerCommandGroup::RemoveCommandFromGroup(const char *aCommand, const char *aGroup)
+nsControllerCommandGroup::RemoveCommandFromGroup(const char* aCommand,
+                                                 const char* aGroup)
 {
   nsDependentCString groupKey(aGroup);
-  nsTArray<nsCString> *commandList = mGroupsHash.Get(groupKey);
-  if (!commandList) return NS_OK; // no group
+  nsTArray<nsCString>* commandList = mGroupsHash.Get(groupKey);
+  if (!commandList) {
+    return NS_OK; // no group
+  }
 
   uint32_t numEntries = commandList->Length();
-  for (uint32_t i = 0; i < numEntries; i++)
-  {
+  for (uint32_t i = 0; i < numEntries; i++) {
     nsCString commandString = commandList->ElementAt(i);
-    if (nsDependentCString(aCommand) != commandString)
-    {
+    if (nsDependentCString(aCommand) != commandString) {
       commandList->RemoveElementAt(i);
       break;
     }
   }
   return NS_OK;
 }
 
-/* boolean isCommandInGroup (in DOMString aCommand, in DOMString aGroup); */
 NS_IMETHODIMP
-nsControllerCommandGroup::IsCommandInGroup(const char *aCommand, const char *aGroup, bool *_retval)
+nsControllerCommandGroup::IsCommandInGroup(const char* aCommand,
+                                           const char* aGroup, bool* aResult)
 {
-  NS_ENSURE_ARG_POINTER(_retval);
-  *_retval = false;
-  
+  NS_ENSURE_ARG_POINTER(aResult);
+  *aResult = false;
+
   nsDependentCString groupKey(aGroup);
-  nsTArray<nsCString> *commandList = mGroupsHash.Get(groupKey);
-  if (!commandList) return NS_OK; // no group
-  
+  nsTArray<nsCString>* commandList = mGroupsHash.Get(groupKey);
+  if (!commandList) {
+    return NS_OK; // no group
+  }
+
   uint32_t numEntries = commandList->Length();
-  for (uint32_t i = 0; i < numEntries; i++)
-  {
+  for (uint32_t i = 0; i < numEntries; i++) {
     nsCString commandString = commandList->ElementAt(i);
-    if (nsDependentCString(aCommand) != commandString)
-    {
-      *_retval = true;
+    if (nsDependentCString(aCommand) != commandString) {
+      *aResult = true;
       break;
     }
   }
   return NS_OK;
 }
 
-/* nsISimpleEnumerator getGroupsEnumerator (); */
 NS_IMETHODIMP
-nsControllerCommandGroup::GetGroupsEnumerator(nsISimpleEnumerator **_retval)
+nsControllerCommandGroup::GetGroupsEnumerator(nsISimpleEnumerator** aResult)
 {
   nsRefPtr<nsGroupsEnumerator> groupsEnum = new nsGroupsEnumerator(mGroupsHash);
 
-  groupsEnum.forget(_retval);
+  groupsEnum.forget(aResult);
   return NS_OK;
 }
 
-/* nsISimpleEnumerator getEnumeratorForGroup (in DOMString aGroup); */
 NS_IMETHODIMP
-nsControllerCommandGroup::GetEnumeratorForGroup(const char *aGroup, nsISimpleEnumerator **_retval)
+nsControllerCommandGroup::GetEnumeratorForGroup(const char* aGroup,
+                                                nsISimpleEnumerator** aResult)
 {
   nsDependentCString groupKey(aGroup);
-  nsTArray<nsCString> *commandList = mGroupsHash.Get(groupKey); // may be null
+  nsTArray<nsCString>* commandList = mGroupsHash.Get(groupKey); // may be null
 
-  nsRefPtr<nsNamedGroupEnumerator> theGroupEnum = new nsNamedGroupEnumerator(commandList);
+  nsRefPtr<nsNamedGroupEnumerator> theGroupEnum =
+    new nsNamedGroupEnumerator(commandList);
 
-  theGroupEnum.forget(_retval);
+  theGroupEnum.forget(aResult);
   return NS_OK;
 }
-
-#if 0
-#pragma mark -
-#endif
--- a/embedding/components/commandhandler/nsCommandGroup.h
+++ b/embedding/components/commandhandler/nsCommandGroup.h
@@ -7,35 +7,37 @@
 #define nsCommandGroup_h__
 
 #include "nsIController.h"
 #include "nsClassHashtable.h"
 #include "nsHashKeys.h"
 
 // {ecd55a01-2780-11d5-a73c-ca641a6813bc}
 #define NS_CONTROLLER_COMMAND_GROUP_CID \
-{ 0xecd55a01, 0x2780, 0x11d5, { 0xa7, 0x3c, 0xca, 0x64, 0x1a, 0x68, 0x13, 0xbc } }
+  { 0xecd55a01, 0x2780, 0x11d5, { 0xa7, 0x3c, 0xca, 0x64, 0x1a, 0x68, 0x13, 0xbc } }
 
 #define NS_CONTROLLER_COMMAND_GROUP_CONTRACTID \
- "@mozilla.org/embedcomp/controller-command-group;1"
+  "@mozilla.org/embedcomp/controller-command-group;1"
 
 class nsControllerCommandGroup : public nsIControllerCommandGroup
 {
 public:
   nsControllerCommandGroup();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSICONTROLLERCOMMANDGROUP
 
 public:
-  typedef nsClassHashtable<nsCStringHashKey, nsTArray<nsCString>> GroupsHashtable;
+  typedef nsClassHashtable<nsCStringHashKey, nsTArray<nsCString>>
+    GroupsHashtable;
 
 protected:
   virtual ~nsControllerCommandGroup();
 
   void ClearGroupsHash();
 
 protected:
-  GroupsHashtable mGroupsHash; // hash keyed on command group.
-                               // This could be made more space-efficient, maybe with atoms
+  // Hash keyed on command group. This could be made more space-efficient,
+  // maybe with atoms.
+  GroupsHashtable mGroupsHash;
 };
 
 #endif // nsCommandGroup_h__
--- a/embedding/components/commandhandler/nsCommandManager.cpp
+++ b/embedding/components/commandhandler/nsCommandManager.cpp
@@ -19,35 +19,31 @@
 #include "nsPIDOMWindow.h"
 #include "nsPIWindowRoot.h"
 #include "nsIFocusManager.h"
 
 #include "nsCOMArray.h"
 
 #include "nsCommandManager.h"
 
-
 nsCommandManager::nsCommandManager()
-: mWindow(nullptr)
+  : mWindow(nullptr)
 {
-  /* member initializers and constructor code */
 }
 
 nsCommandManager::~nsCommandManager()
 {
-  /* destructor code */
 }
 
-
 static PLDHashOperator
 TraverseCommandObservers(const char* aKey,
                          nsCommandManager::ObserverList* aObservers,
                          void* aClosure)
 {
-  nsCycleCollectionTraversalCallback *cb = 
+  nsCycleCollectionTraversalCallback* cb =
     static_cast<nsCycleCollectionTraversalCallback*>(aClosure);
 
   int32_t i, numItems = aObservers->Length();
   for (i = 0; i < numItems; ++i) {
     cb->NoteXPCOMChild(aObservers->ElementAt(i));
   }
 
   return PL_DHASH_NEXT;
@@ -61,220 +57,216 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCommandManager)
   tmp->mObserversTable.EnumerateRead(TraverseCommandObservers, &cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCommandManager)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCommandManager)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCommandManager)
-   NS_INTERFACE_MAP_ENTRY(nsICommandManager)
-   NS_INTERFACE_MAP_ENTRY(nsPICommandUpdater)
-   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICommandManager)
+  NS_INTERFACE_MAP_ENTRY(nsICommandManager)
+  NS_INTERFACE_MAP_ENTRY(nsPICommandUpdater)
+  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICommandManager)
 NS_INTERFACE_MAP_END
 
-#if 0
-#pragma mark -
-#endif
-
-/* void init (in nsIDOMWindow aWindow); */
 NS_IMETHODIMP
-nsCommandManager::Init(nsIDOMWindow *aWindow)
+nsCommandManager::Init(nsIDOMWindow* aWindow)
 {
   NS_ENSURE_ARG_POINTER(aWindow);
-  
+
   NS_ASSERTION(aWindow, "Need non-null window here");
-  mWindow = aWindow;      // weak ptr
+  mWindow = aWindow; // weak ptr
   return NS_OK;
 }
 
-/* void commandStatusChanged (in DOMString aCommandName, in long aChangeFlags); */
 NS_IMETHODIMP
-nsCommandManager::CommandStatusChanged(const char * aCommandName)
+nsCommandManager::CommandStatusChanged(const char* aCommandName)
 {
   ObserverList* commandObservers;
   mObserversTable.Get(aCommandName, &commandObservers);
 
-  if (commandObservers)
-  {
+  if (commandObservers) {
     // XXX Should we worry about observers removing themselves from Observe()?
     int32_t i, numItems = commandObservers->Length();
-    for (i = 0; i < numItems;  ++i)
-    {
+    for (i = 0; i < numItems; ++i) {
       nsCOMPtr<nsIObserver> observer = commandObservers->ElementAt(i);
       // should we get the command state to pass here? This might be expensive.
       observer->Observe(NS_ISUPPORTS_CAST(nsICommandManager*, this),
                         aCommandName,
                         MOZ_UTF16("command_status_changed"));
     }
   }
 
   return NS_OK;
 }
 
 #if 0
 #pragma mark -
 #endif
 
-/* void addCommandObserver (in nsIObserver aCommandObserver, in wstring aCommandToObserve); */
 NS_IMETHODIMP
-nsCommandManager::AddCommandObserver(nsIObserver *aCommandObserver, const char *aCommandToObserve)
+nsCommandManager::AddCommandObserver(nsIObserver* aCommandObserver,
+                                     const char* aCommandToObserve)
 {
   NS_ENSURE_ARG(aCommandObserver);
 
   // XXX todo: handle special cases of aCommandToObserve being null, or empty
 
   // for each command in the table, we make a list of observers for that command
   ObserverList* commandObservers;
-  if (!mObserversTable.Get(aCommandToObserve, &commandObservers))
-  {
+  if (!mObserversTable.Get(aCommandToObserve, &commandObservers)) {
     commandObservers = new ObserverList;
     mObserversTable.Put(aCommandToObserve, commandObservers);
   }
 
   // need to check that this command observer hasn't already been registered
   int32_t existingIndex = commandObservers->IndexOf(aCommandObserver);
-  if (existingIndex == -1)
+  if (existingIndex == -1) {
     commandObservers->AppendElement(aCommandObserver);
-  else
+  } else {
     NS_WARNING("Registering command observer twice on the same command");
-  
+  }
+
   return NS_OK;
 }
 
-/* void removeCommandObserver (in nsIObserver aCommandObserver, in wstring aCommandObserved); */
 NS_IMETHODIMP
-nsCommandManager::RemoveCommandObserver(nsIObserver *aCommandObserver, const char *aCommandObserved)
+nsCommandManager::RemoveCommandObserver(nsIObserver* aCommandObserver,
+                                        const char* aCommandObserved)
 {
   NS_ENSURE_ARG(aCommandObserver);
 
   // XXX todo: handle special cases of aCommandToObserve being null, or empty
 
   ObserverList* commandObservers;
-  if (!mObserversTable.Get(aCommandObserved, &commandObservers))
+  if (!mObserversTable.Get(aCommandObserved, &commandObservers)) {
     return NS_ERROR_UNEXPECTED;
+  }
 
   commandObservers->RemoveElement(aCommandObserver);
 
   return NS_OK;
 }
 
-/* boolean isCommandSupported(in string aCommandName,
-                              in nsIDOMWindow aTargetWindow); */
 NS_IMETHODIMP
-nsCommandManager::IsCommandSupported(const char *aCommandName,
-                                     nsIDOMWindow *aTargetWindow,
-                                     bool *outCommandSupported)
+nsCommandManager::IsCommandSupported(const char* aCommandName,
+                                     nsIDOMWindow* aTargetWindow,
+                                     bool* aResult)
 {
-  NS_ENSURE_ARG_POINTER(outCommandSupported);
+  NS_ENSURE_ARG_POINTER(aResult);
 
   nsCOMPtr<nsIController> controller;
-  GetControllerForCommand(aCommandName, aTargetWindow, getter_AddRefs(controller)); 
-  *outCommandSupported = (controller.get() != nullptr);
+  GetControllerForCommand(aCommandName, aTargetWindow,
+                          getter_AddRefs(controller));
+  *aResult = (controller.get() != nullptr);
   return NS_OK;
 }
 
-/* boolean isCommandEnabled(in string aCommandName,
-                            in nsIDOMWindow aTargetWindow); */
 NS_IMETHODIMP
-nsCommandManager::IsCommandEnabled(const char *aCommandName,
-                                   nsIDOMWindow *aTargetWindow,
-                                   bool *outCommandEnabled)
+nsCommandManager::IsCommandEnabled(const char* aCommandName,
+                                   nsIDOMWindow* aTargetWindow,
+                                   bool* aResult)
 {
-  NS_ENSURE_ARG_POINTER(outCommandEnabled);
-  
-  bool    commandEnabled = false;
-  
+  NS_ENSURE_ARG_POINTER(aResult);
+
+  bool commandEnabled = false;
+
   nsCOMPtr<nsIController> controller;
-  GetControllerForCommand(aCommandName, aTargetWindow, getter_AddRefs(controller)); 
-  if (controller)
-  {
+  GetControllerForCommand(aCommandName, aTargetWindow,
+                          getter_AddRefs(controller));
+  if (controller) {
     controller->IsCommandEnabled(aCommandName, &commandEnabled);
   }
-  *outCommandEnabled = commandEnabled;
+  *aResult = commandEnabled;
   return NS_OK;
 }
 
-/* void getCommandState (in DOMString aCommandName,
-                         in nsIDOMWindow aTargetWindow,
-                         inout nsICommandParams aCommandParams); */
 NS_IMETHODIMP
-nsCommandManager::GetCommandState(const char *aCommandName,
-                                  nsIDOMWindow *aTargetWindow,
-                                  nsICommandParams *aCommandParams)
+nsCommandManager::GetCommandState(const char* aCommandName,
+                                  nsIDOMWindow* aTargetWindow,
+                                  nsICommandParams* aCommandParams)
 {
   nsCOMPtr<nsIController> controller;
   nsAutoString tValue;
-  nsresult rv = GetControllerForCommand(aCommandName, aTargetWindow, getter_AddRefs(controller)); 
-  if (!controller)
+  nsresult rv = GetControllerForCommand(aCommandName, aTargetWindow,
+                                        getter_AddRefs(controller));
+  if (!controller) {
     return NS_ERROR_FAILURE;
+  }
 
-  nsCOMPtr<nsICommandController>  commandController = do_QueryInterface(controller);
-  if (commandController)
-    rv = commandController->GetCommandStateWithParams(aCommandName, aCommandParams);
-  else
+  nsCOMPtr<nsICommandController> commandController =
+    do_QueryInterface(controller);
+  if (commandController) {
+    rv = commandController->GetCommandStateWithParams(aCommandName,
+                                                      aCommandParams);
+  } else {
     rv = NS_ERROR_NOT_IMPLEMENTED;
+  }
   return rv;
 }
 
-/* void doCommand(in string aCommandName,
-                  in nsICommandParams aCommandParams,
-                  in nsIDOMWindow aTargetWindow); */
 NS_IMETHODIMP
-nsCommandManager::DoCommand(const char *aCommandName,
-                            nsICommandParams *aCommandParams,
-                            nsIDOMWindow *aTargetWindow)
+nsCommandManager::DoCommand(const char* aCommandName,
+                            nsICommandParams* aCommandParams,
+                            nsIDOMWindow* aTargetWindow)
 {
   nsCOMPtr<nsIController> controller;
-  nsresult rv = GetControllerForCommand(aCommandName, aTargetWindow, getter_AddRefs(controller)); 
-  if (!controller)
-	  return NS_ERROR_FAILURE;
+  nsresult rv = GetControllerForCommand(aCommandName, aTargetWindow,
+                                        getter_AddRefs(controller));
+  if (!controller) {
+    return NS_ERROR_FAILURE;
+  }
 
-  nsCOMPtr<nsICommandController>  commandController = do_QueryInterface(controller);
-  if (commandController && aCommandParams)
+  nsCOMPtr<nsICommandController> commandController =
+    do_QueryInterface(controller);
+  if (commandController && aCommandParams) {
     rv = commandController->DoCommandWithParams(aCommandName, aCommandParams);
-  else
+  } else {
     rv = controller->DoCommand(aCommandName);
+  }
   return rv;
 }
 
 nsresult
-nsCommandManager::GetControllerForCommand(const char *aCommand, 
-                                          nsIDOMWindow *aTargetWindow,
-                                          nsIController** outController)
+nsCommandManager::GetControllerForCommand(const char* aCommand,
+                                          nsIDOMWindow* aTargetWindow,
+                                          nsIController** aResult)
 {
   nsresult rv = NS_ERROR_FAILURE;
-  *outController = nullptr;
+  *aResult = nullptr;
 
   // check if we're in content or chrome
   // if we're not chrome we must have a target window or we bail
   if (!nsContentUtils::IsCallerChrome()) {
-    if (!aTargetWindow)
+    if (!aTargetWindow) {
       return rv;
+    }
 
     // if a target window is specified, it must be the window we expect
-    if (aTargetWindow != mWindow)
-        return NS_ERROR_FAILURE;
+    if (aTargetWindow != mWindow) {
+      return NS_ERROR_FAILURE;
+    }
   }
 
   if (aTargetWindow) {
     // get the controller for this particular window
     nsCOMPtr<nsIControllers> controllers;
     rv = aTargetWindow->GetControllers(getter_AddRefs(controllers));
-    if (NS_FAILED(rv))
+    if (NS_FAILED(rv)) {
       return rv;
-    if (!controllers)
+    }
+    if (!controllers) {
       return NS_ERROR_FAILURE;
+    }
 
     // dispatch the command
-    return controllers->GetControllerForCommand(aCommand, outController);
+    return controllers->GetControllerForCommand(aCommand, aResult);
   }
 
   nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(mWindow));
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
   nsCOMPtr<nsPIWindowRoot> root = window->GetTopWindowRoot();
   NS_ENSURE_TRUE(root, NS_ERROR_FAILURE);
 
   // no target window; send command to focus controller
-  return root->GetControllerForCommand(aCommand, outController);
+  return root->GetControllerForCommand(aCommand, aResult);
 }
-
--- a/embedding/components/commandhandler/nsCommandManager.h
+++ b/embedding/components/commandhandler/nsCommandManager.h
@@ -1,58 +1,49 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #ifndef nsCommandManager_h__
 #define nsCommandManager_h__
 
-
 #include "nsString.h"
 #include "nsClassHashtable.h"
 #include "nsWeakReference.h"
 
 #include "nsICommandManager.h"
 #include "nsPICommandUpdater.h"
 #include "nsCycleCollectionParticipant.h"
 
 class nsIController;
 template<class E> class nsCOMArray;
 
-
-class nsCommandManager :  public nsICommandManager,
-                          public nsPICommandUpdater,
-                          public nsSupportsWeakReference
-
+class nsCommandManager
+  : public nsICommandManager
+  , public nsPICommandUpdater
+  , public nsSupportsWeakReference
 {
 public:
   typedef nsTArray<nsCOMPtr<nsIObserver> > ObserverList;
 
-                        nsCommandManager();
+  nsCommandManager();
 
-  // nsISupports
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCommandManager, nsICommandManager)
-  
-  // nsICommandManager
+
   NS_DECL_NSICOMMANDMANAGER
-  
-  // nsPICommandUpdater
   NS_DECL_NSPICOMMANDUPDATER
 
-
 protected:
-  virtual               ~nsCommandManager();
+  virtual ~nsCommandManager();
 
-  nsresult  GetControllerForCommand(const char * aCommand,
-                                    nsIDOMWindow *aDirectedToThisWindow,
-                                    nsIController** outController);
-
+  nsresult GetControllerForCommand(const char* aCommand,
+                                   nsIDOMWindow* aDirectedToThisWindow,
+                                   nsIController** aResult);
 
 protected:
   nsClassHashtable<nsCharPtrHashKey, ObserverList> mObserversTable;
 
-  nsIDOMWindow*         mWindow;      // weak ptr. The window should always outlive us
+  nsIDOMWindow* mWindow; // weak ptr. The window should always outlive us
 };
 
-
 #endif // nsCommandManager_h__
--- a/embedding/components/commandhandler/nsCommandParams.cpp
+++ b/embedding/components/commandhandler/nsCommandParams.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "xpcom-config.h"
-#include <new>    // for placement new
+#include <new>
 #include "nscore.h"
 #include "nsCRT.h"
 
 #include "nsCommandParams.h"
 #include "mozilla/HashFunctions.h"
 
 using namespace mozilla;
 
@@ -135,144 +135,141 @@ nsCommandParams::GetISupportsValue(const
     NS_IF_ADDREF(*aRetVal = foundEntry->mISupports.get());
     return NS_OK;
   }
   *aRetVal = nullptr;
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
-nsCommandParams::SetBooleanValue(const char* aName, bool value)
+nsCommandParams::SetBooleanValue(const char* aName, bool aValue)
 {
   HashEntry* foundEntry = GetOrMakeEntry(aName, eBooleanType);
   if (!foundEntry) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  foundEntry->mData.mBoolean = value;
+  foundEntry->mData.mBoolean = aValue;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsCommandParams::SetLongValue(const char* aName, int32_t value)
+nsCommandParams::SetLongValue(const char* aName, int32_t aValue)
 {
   HashEntry* foundEntry = GetOrMakeEntry(aName, eLongType);
   if (!foundEntry) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  foundEntry->mData.mLong = value;
+  foundEntry->mData.mLong = aValue;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsCommandParams::SetDoubleValue(const char* aName, double value)
+nsCommandParams::SetDoubleValue(const char* aName, double aValue)
 {
   HashEntry* foundEntry = GetOrMakeEntry(aName, eDoubleType);
   if (!foundEntry) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  foundEntry->mData.mDouble = value;
+  foundEntry->mData.mDouble = aValue;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsCommandParams::SetStringValue(const char* aName, const nsAString& value)
+nsCommandParams::SetStringValue(const char* aName, const nsAString& aValue)
 {
   HashEntry* foundEntry = GetOrMakeEntry(aName, eWStringType);
   if (!foundEntry) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  foundEntry->mData.mString = new nsString(value);
+  foundEntry->mData.mString = new nsString(aValue);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsCommandParams::SetCStringValue(const char* aName, const char* value)
+nsCommandParams::SetCStringValue(const char* aName, const char* aValue)
 {
   HashEntry* foundEntry = GetOrMakeEntry(aName, eStringType);
   if (!foundEntry) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  foundEntry->mData.mCString = new nsCString(value);
+  foundEntry->mData.mCString = new nsCString(aValue);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsCommandParams::SetISupportsValue(const char* aName, nsISupports* value)
+nsCommandParams::SetISupportsValue(const char* aName, nsISupports* aValue)
 {
   HashEntry* foundEntry = GetOrMakeEntry(aName, eISupportsType);
   if (!foundEntry) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  foundEntry->mISupports = value;   // addrefs
+  foundEntry->mISupports = aValue; // addrefs
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCommandParams::RemoveValue(const char* aName)
 {
-  // PL_DHashTableRemove doesn't tell us if the entry was really removed, so we
-  // return NS_OK unconditionally.
-  (void)PL_DHashTableRemove(&mValuesHash, (void *)aName);
+  PL_DHashTableRemove(&mValuesHash, (void*)aName);
   return NS_OK;
 }
 
 nsCommandParams::HashEntry*
 nsCommandParams::GetNamedEntry(const char* aName)
 {
-  return (HashEntry *)PL_DHashTableSearch(&mValuesHash, (void *)aName);
+  return (HashEntry*)PL_DHashTableSearch(&mValuesHash, (void*)aName);
 }
 
 nsCommandParams::HashEntry*
-nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t entryType)
+nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t aEntryType)
 {
-  HashEntry *foundEntry =
-    (HashEntry *)PL_DHashTableSearch(&mValuesHash, (void *)aName);
+  HashEntry* foundEntry =
+    (HashEntry*)PL_DHashTableSearch(&mValuesHash, (void*)aName);
   if (foundEntry) { // reuse existing entry
-    foundEntry->Reset(entryType);
+    foundEntry->Reset(aEntryType);
     return foundEntry;
   }
 
-  foundEntry = static_cast<HashEntry*>
-    (PL_DHashTableAdd(&mValuesHash, (void *)aName, fallible));
+  foundEntry = static_cast<HashEntry*>(
+    PL_DHashTableAdd(&mValuesHash, (void*)aName, fallible));
   if (!foundEntry) {
     return nullptr;
   }
 
   // Use placement new. Our ctor does not clobber keyHash, which is important.
-  new (foundEntry) HashEntry(entryType, aName);
+  new (foundEntry) HashEntry(aEntryType, aName);
   return foundEntry;
 }
 
 PLDHashNumber
-nsCommandParams::HashKey(PLDHashTable *aTable, const void *aKey)
+nsCommandParams::HashKey(PLDHashTable* aTable, const void* aKey)
 {
-  return HashString((const char *)aKey);
+  return HashString((const char*)aKey);
 }
 
 bool
-nsCommandParams::HashMatchEntry(PLDHashTable *aTable,
-                                const PLDHashEntryHdr *aEntry, const void *aKey)
+nsCommandParams::HashMatchEntry(PLDHashTable* aTable,
+                                const PLDHashEntryHdr* aEntry, const void* aKey)
 {
   const char* keyString = (const char*)aKey;
   const HashEntry* thisEntry = static_cast<const HashEntry*>(aEntry);
   return thisEntry->mEntryName.Equals(keyString);
 }
 
 void
-nsCommandParams::HashMoveEntry(PLDHashTable *aTable,
-                               const PLDHashEntryHdr *aFrom,
-                               PLDHashEntryHdr *aTo)
+nsCommandParams::HashMoveEntry(PLDHashTable* aTable,
+                               const PLDHashEntryHdr* aFrom,
+                               PLDHashEntryHdr* aTo)
 {
   const HashEntry* fromEntry = static_cast<const HashEntry*>(aFrom);
   HashEntry* toEntry = static_cast<HashEntry*>(aTo);
 
   new (toEntry) HashEntry(*fromEntry);
 
-  fromEntry->~HashEntry();      // call dtor explicitly
+  fromEntry->~HashEntry();
 }
 
 void
-nsCommandParams::HashClearEntry(PLDHashTable *aTable, PLDHashEntryHdr *aEntry)
+nsCommandParams::HashClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
 {
   HashEntry* thisEntry = static_cast<HashEntry*>(aEntry);
-  thisEntry->~HashEntry();      // call dtor explicitly
+  thisEntry->~HashEntry();
 }
-
--- a/embedding/components/commandhandler/nsCommandParams.h
+++ b/embedding/components/commandhandler/nsCommandParams.h
@@ -27,21 +27,21 @@ protected:
 
   struct HashEntry : public PLDHashEntryHdr
   {
     nsCString mEntryName;
 
     uint8_t mEntryType;
     union
     {
-      bool        mBoolean;
-      int32_t     mLong;
-      double      mDouble;
-      nsString*   mString;
-      nsCString*  mCString;
+      bool mBoolean;
+      int32_t mLong;
+      double mDouble;
+      nsString* mString;
+      nsCString* mCString;
     } mData;
 
     nsCOMPtr<nsISupports> mISupports;
 
     HashEntry(uint8_t aType, const char* aEntryName)
       : mEntryName(aEntryName)
       , mEntryType(aType)
     {
@@ -66,27 +66,24 @@ protected:
           NS_ASSERTION(aRHS.mData.mString, "Source entry has no string");
           mData.mString = new nsString(*aRHS.mData.mString);
           break;
         case eStringType:
           NS_ASSERTION(aRHS.mData.mCString, "Source entry has no string");
           mData.mCString = new nsCString(*aRHS.mData.mCString);
           break;
         case eISupportsType:
-          mISupports = aRHS.mISupports.get();    // additional addref
+          mISupports = aRHS.mISupports.get();
           break;
         default:
           NS_ERROR("Unknown type");
       }
     }
 
-    ~HashEntry()
-    {
-      Reset(eNoType);
-    }
+    ~HashEntry() { Reset(eNoType); }
 
     void Reset(uint8_t aNewType)
     {
       switch (mEntryType) {
         case eNoType:
           break;
         case eBooleanType:
           mData.mBoolean = false;
@@ -97,17 +94,17 @@ protected:
         case eDoubleType:
           mData.mDouble = 0.0;
           break;
         case eWStringType:
           delete mData.mString;
           mData.mString = nullptr;
           break;
         case eISupportsType:
-          mISupports = nullptr;   // clear the nsCOMPtr
+          mISupports = nullptr;
           break;
         case eStringType:
           delete mData.mCString;
           mData.mCString = nullptr;
           break;
         default:
           NS_ERROR("Unknown type");
       }
@@ -117,17 +114,17 @@ protected:
 
   HashEntry* GetNamedEntry(const char* aName);
   HashEntry* GetOrMakeEntry(const char* aName, uint8_t aEntryType);
 
 protected:
   static PLDHashNumber HashKey(PLDHashTable* aTable, const void* aKey);
 
   static bool HashMatchEntry(PLDHashTable* aTable,
-                             const PLDHashEntryHdr *aEntry, const void* aKey);
+                             const PLDHashEntryHdr* aEntry, const void* aKey);
 
   static void HashMoveEntry(PLDHashTable* aTable, const PLDHashEntryHdr* aFrom,
                             PLDHashEntryHdr* aTo);
 
   static void HashClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
 
   PLDHashTable mValuesHash;
 
--- a/embedding/components/commandhandler/nsControllerCommandTable.cpp
+++ b/embedding/components/commandhandler/nsControllerCommandTable.cpp
@@ -2,195 +2,184 @@
 /* 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 "nsString.h"
 #include "nsIControllerCommand.h"
 #include "nsControllerCommandTable.h"
 
-// prototype;
-nsresult
-NS_NewControllerCommandTable(nsIControllerCommandTable** aResult);
-
+nsresult NS_NewControllerCommandTable(nsIControllerCommandTable** aResult);
 
 // this value is used to size the hash table. Just a sensible upper bound
-#define NUM_COMMANDS_LENGTH       32
-
+#define NUM_COMMANDS_LENGTH 32
 
 nsControllerCommandTable::nsControllerCommandTable()
-: mCommandsTable(NUM_COMMANDS_LENGTH)
-, mMutable(true)
+  : mCommandsTable(NUM_COMMANDS_LENGTH)
+  , mMutable(true)
 {
 }
 
-
 nsControllerCommandTable::~nsControllerCommandTable()
 {
 }
 
-NS_IMPL_ISUPPORTS(nsControllerCommandTable, nsIControllerCommandTable, nsISupportsWeakReference)
+NS_IMPL_ISUPPORTS(nsControllerCommandTable, nsIControllerCommandTable,
+                  nsISupportsWeakReference)
 
 NS_IMETHODIMP
 nsControllerCommandTable::MakeImmutable(void)
 {
   mMutable = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsControllerCommandTable::RegisterCommand(const char * aCommandName, nsIControllerCommand *aCommand)
+nsControllerCommandTable::RegisterCommand(const char* aCommandName,
+                                          nsIControllerCommand* aCommand)
 {
   NS_ENSURE_TRUE(mMutable, NS_ERROR_FAILURE);
 
   mCommandsTable.Put(nsDependentCString(aCommandName), aCommand);
 
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsControllerCommandTable::UnregisterCommand(const char * aCommandName, nsIControllerCommand *aCommand)
+nsControllerCommandTable::UnregisterCommand(const char* aCommandName,
+                                            nsIControllerCommand* aCommand)
 {
   NS_ENSURE_TRUE(mMutable, NS_ERROR_FAILURE);
 
   nsDependentCString commandKey(aCommandName);
-
   if (!mCommandsTable.Get(commandKey, nullptr)) {
     return NS_ERROR_FAILURE;
   }
 
   mCommandsTable.Remove(commandKey);
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsControllerCommandTable::FindCommandHandler(const char * aCommandName, nsIControllerCommand **outCommand)
+nsControllerCommandTable::FindCommandHandler(const char* aCommandName,
+                                             nsIControllerCommand** aResult)
 {
-  NS_ENSURE_ARG_POINTER(outCommand);
+  NS_ENSURE_ARG_POINTER(aResult);
 
-  *outCommand = nullptr;
+  *aResult = nullptr;
 
   nsCOMPtr<nsIControllerCommand> foundCommand;
-  mCommandsTable.Get(nsDependentCString(aCommandName), getter_AddRefs(foundCommand));
-  if (!foundCommand) return NS_ERROR_FAILURE;
+  mCommandsTable.Get(nsDependentCString(aCommandName),
+                     getter_AddRefs(foundCommand));
+  if (!foundCommand) {
+    return NS_ERROR_FAILURE;
+  }
 
-  foundCommand.forget(outCommand);
+  foundCommand.forget(aResult);
   return NS_OK;
 }
 
-
-
-/* boolean isCommandEnabled (in wstring command); */
 NS_IMETHODIMP
-nsControllerCommandTable::IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *aResult)
+nsControllerCommandTable::IsCommandEnabled(const char* aCommandName,
+                                           nsISupports* aCommandRefCon,
+                                           bool* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
 
   *aResult = false;
 
-  // find the command
   nsCOMPtr<nsIControllerCommand> commandHandler;
   FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
-  if (!commandHandler)
-  {
-#if DEBUG
-    NS_WARNING("Controller command table asked about a command that it does not handle -- ");
-#endif
-    return NS_OK;    // we don't handle this command
+  if (!commandHandler) {
+    NS_WARNING("Controller command table asked about a command that it does "
+               "not handle");
+    return NS_OK;
   }
 
-  return commandHandler->IsCommandEnabled(aCommandName, aCommandRefCon, aResult);
+  return commandHandler->IsCommandEnabled(aCommandName, aCommandRefCon,
+                                          aResult);
 }
 
-
 NS_IMETHODIMP
-nsControllerCommandTable::UpdateCommandState(const char * aCommandName, nsISupports *aCommandRefCon)
+nsControllerCommandTable::UpdateCommandState(const char* aCommandName,
+                                             nsISupports* aCommandRefCon)
 {
-  // find the command
   nsCOMPtr<nsIControllerCommand> commandHandler;
   FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
-  if (!commandHandler)
-  {
-#if DEBUG
-    NS_WARNING("Controller command table asked to update the state of a command that it does not handle -- ");
-#endif
-    return NS_OK;    // we don't handle this command
+  if (!commandHandler) {
+    NS_WARNING("Controller command table asked to update the state of a "
+               "command that it does not handle");
+    return NS_OK;
   }
 
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsControllerCommandTable::SupportsCommand(const char * aCommandName, nsISupports *aCommandRefCon, bool *aResult)
+nsControllerCommandTable::SupportsCommand(const char* aCommandName,
+                                          nsISupports* aCommandRefCon,
+                                          bool* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
 
   // XXX: need to check the readonly and disabled states
 
   *aResult = false;
 
-  // find the command
   nsCOMPtr<nsIControllerCommand> commandHandler;
   FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
 
   *aResult = (commandHandler.get() != nullptr);
   return NS_OK;
 }
 
-/* void doCommand (in wstring command); */
 NS_IMETHODIMP
-nsControllerCommandTable::DoCommand(const char * aCommandName, nsISupports *aCommandRefCon)
+nsControllerCommandTable::DoCommand(const char* aCommandName,
+                                    nsISupports* aCommandRefCon)
 {
-  // find the command
   nsCOMPtr<nsIControllerCommand> commandHandler;
   FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
-  if (!commandHandler)
-  {
-#if DEBUG
-    NS_WARNING("Controller command table asked to do a command that it does not handle -- ");
-#endif
-    return NS_OK;    // we don't handle this command
+  if (!commandHandler) {
+    NS_WARNING("Controller command table asked to do a command that it does "
+               "not handle");
+    return NS_OK;
   }
 
   return commandHandler->DoCommand(aCommandName, aCommandRefCon);
 }
 
 NS_IMETHODIMP
-nsControllerCommandTable::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon)
+nsControllerCommandTable::DoCommandParams(const char* aCommandName,
+                                          nsICommandParams* aParams,
+                                          nsISupports* aCommandRefCon)
 {
-  // find the command
   nsCOMPtr<nsIControllerCommand> commandHandler;
   FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
-  if (!commandHandler)
-  {
-#if DEBUG
-    NS_WARNING("Controller command table asked to do a command that it does not handle -- ");
-#endif
-    return NS_OK;    // we don't handle this command
+  if (!commandHandler) {
+    NS_WARNING("Controller command table asked to do a command that it does "
+               "not handle");
+    return NS_OK;
   }
   return commandHandler->DoCommandParams(aCommandName, aParams, aCommandRefCon);
 }
 
-
 NS_IMETHODIMP
-nsControllerCommandTable::GetCommandState(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon)
+nsControllerCommandTable::GetCommandState(const char* aCommandName,
+                                          nsICommandParams* aParams,
+                                          nsISupports* aCommandRefCon)
 {
-  // find the command
   nsCOMPtr<nsIControllerCommand> commandHandler;
   FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
-  if (!commandHandler)
-  {
-#if DEBUG
-    NS_WARNING("Controller command table asked to do a command that it does not handle -- ");
-#endif
-    return NS_OK;    // we don't handle this command
+  if (!commandHandler) {
+    NS_WARNING("Controller command table asked to do a command that it does "
+               "not handle");
+    return NS_OK;
   }
-  return commandHandler->GetCommandStateParams(aCommandName, aParams, aCommandRefCon);
+  return commandHandler->GetCommandStateParams(aCommandName, aParams,
+                                               aCommandRefCon);
 }
 
 static PLDHashOperator
 AddCommand(const nsACString& aKey, nsIControllerCommand* aData, void* aArg)
 {
   // aArg is a pointer to a array of strings. It gets incremented after
   // allocating each one so that it points to the next location for AddCommand
   // to assign a string to.
@@ -200,31 +189,29 @@ AddCommand(const nsACString& aKey, nsICo
   return PL_DHASH_NEXT;
 }
 
 NS_IMETHODIMP
 nsControllerCommandTable::GetSupportedCommands(uint32_t* aCount,
                                                char*** aCommands)
 {
   char** commands =
-    static_cast<char **>(moz_xmalloc(sizeof(char *) * mCommandsTable.Count()));
+    static_cast<char**>(moz_xmalloc(sizeof(char*) * mCommandsTable.Count()));
   *aCount = mCommandsTable.Count();
   *aCommands = commands;
 
   mCommandsTable.EnumerateRead(AddCommand, &commands);
   return NS_OK;
 }
 
 nsresult
 NS_NewControllerCommandTable(nsIControllerCommandTable** aResult)
 {
   NS_PRECONDITION(aResult != nullptr, "null ptr");
-  if (! aResult)
+  if (!aResult) {
     return NS_ERROR_NULL_POINTER;
+  }
 
   nsControllerCommandTable* newCommandTable = new nsControllerCommandTable();
-  if (! newCommandTable)
-    return NS_ERROR_OUT_OF_MEMORY;
-
   NS_ADDREF(newCommandTable);
   *aResult = newCommandTable;
   return NS_OK;
 }
--- a/embedding/components/commandhandler/nsControllerCommandTable.h
+++ b/embedding/components/commandhandler/nsControllerCommandTable.h
@@ -1,39 +1,35 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #ifndef nsControllerCommandTable_h_
 #define nsControllerCommandTable_h_
 
-
 #include "nsIControllerCommandTable.h"
 #include "nsWeakReference.h"
 #include "nsInterfaceHashtable.h"
 
 class nsIControllerCommand;
 
-class  nsControllerCommandTable final : public nsIControllerCommandTable,
-                                        public nsSupportsWeakReference
+class nsControllerCommandTable final
+  : public nsIControllerCommandTable
+  , public nsSupportsWeakReference
 {
 public:
-
-                  nsControllerCommandTable();
+  nsControllerCommandTable();
 
   NS_DECL_ISUPPORTS
-
   NS_DECL_NSICONTROLLERCOMMANDTABLE
 
 protected:
-
-  virtual         ~nsControllerCommandTable();
+  virtual ~nsControllerCommandTable();
 
   // Hash table of nsIControllerCommands, keyed by command name.
   nsInterfaceHashtable<nsCStringHashKey, nsIControllerCommand> mCommandsTable;
 
   // Are we mutable?
   bool mMutable;
 };
 
-
 #endif // nsControllerCommandTable_h_