Bug 1433345 - part 1: Expose nsComposerCommandsUpdater with renaming it to mozilla::ComposerCOmmandsUpdater r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 26 Jan 2018 14:06:29 +0900
changeset 748209 aaaa7fadd796cb5db5913783dc8aa8f276bbbbf6
parent 748205 a6c753e77345e968954e8d61e3871c5883015ede
child 748210 56edc2197f05783ae7bffdfd00ef057de2731c31
push id97089
push usermasayuki@d-toybox.com
push dateMon, 29 Jan 2018 07:02:13 +0000
reviewersm_kato
bugs1433345
milestone60.0a1
Bug 1433345 - part 1: Expose nsComposerCommandsUpdater with renaming it to mozilla::ComposerCOmmandsUpdater r?m_kato For making HTMLEditor stores it directly, we should expose nsComposerCommandsUpdater first. Then, it should be in mozilla namespace. MozReview-Commit-ID: 8Vhum4Q3WY
editor/composer/ComposerCommandsUpdater.cpp
editor/composer/ComposerCommandsUpdater.h
editor/composer/moz.build
editor/composer/nsComposerCommandsUpdater.cpp
editor/composer/nsComposerCommandsUpdater.h
editor/composer/nsEditingSession.cpp
editor/composer/nsEditingSession.h
rename from editor/composer/nsComposerCommandsUpdater.cpp
rename to editor/composer/ComposerCommandsUpdater.cpp
--- a/editor/composer/nsComposerCommandsUpdater.cpp
+++ b/editor/composer/ComposerCommandsUpdater.cpp
@@ -1,68 +1,74 @@
 /* -*- 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/. */
 
+#include "mozilla/ComposerCommandsUpdater.h"
+
 #include "mozilla/mozalloc.h"           // for operator new
 #include "mozilla/dom/Selection.h"
 #include "nsAString.h"
 #include "nsComponentManagerUtils.h"    // for do_CreateInstance
-#include "nsComposerCommandsUpdater.h"
 #include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
 #include "nsError.h"                    // for NS_OK, NS_ERROR_FAILURE, etc
 #include "nsICommandManager.h"          // for nsICommandManager
 #include "nsID.h"                       // for NS_GET_IID, etc
 #include "nsIDOMWindow.h"               // for nsIDOMWindow
 #include "nsIDocShell.h"                // for nsIDocShell
 #include "nsIInterfaceRequestorUtils.h"  // for do_GetInterface
 #include "nsISelection.h"               // for nsISelection
 #include "nsITransactionManager.h"      // for nsITransactionManager
 #include "nsLiteralString.h"            // for NS_LITERAL_STRING
 #include "nsPICommandUpdater.h"         // for nsPICommandUpdater
 #include "nsPIDOMWindow.h"              // for nsPIDOMWindow
 
 class nsIDOMDocument;
 class nsITransaction;
 
-nsComposerCommandsUpdater::nsComposerCommandsUpdater()
-:  mDirtyState(eStateUninitialized)
-,  mSelectionCollapsed(eStateUninitialized)
-,  mFirstDoOfFirstUndo(true)
+namespace mozilla {
+
+ComposerCommandsUpdater::ComposerCommandsUpdater()
+  : mDirtyState(eStateUninitialized)
+  , mSelectionCollapsed(eStateUninitialized)
+  , mFirstDoOfFirstUndo(true)
 {
 }
 
-nsComposerCommandsUpdater::~nsComposerCommandsUpdater()
+ComposerCommandsUpdater::~ComposerCommandsUpdater()
 {
   // cancel any outstanding update timer
   if (mUpdateTimer) {
     mUpdateTimer->Cancel();
   }
 }
 
-NS_IMPL_ISUPPORTS(nsComposerCommandsUpdater, nsISelectionListener,
-                  nsIDocumentStateListener, nsITransactionListener,
-                  nsITimerCallback, nsINamed)
+NS_IMPL_ISUPPORTS(ComposerCommandsUpdater,
+                  nsISelectionListener,
+                  nsIDocumentStateListener,
+                  nsITransactionListener,
+                  nsITimerCallback,
+                  nsINamed)
 
 #if 0
 #pragma mark -
 #endif
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::NotifyDocumentCreated()
+ComposerCommandsUpdater::NotifyDocumentCreated()
 {
   // Trigger an nsIObserve notification that the document has been created
   UpdateOneCommand("obs_documentCreated");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::NotifyDocumentWillBeDestroyed()
+ComposerCommandsUpdater::NotifyDocumentWillBeDestroyed()
 {
   // cancel any outstanding update timer
   if (mUpdateTimer) {
     mUpdateTimer->Cancel();
     mUpdateTimer = nullptr;
   }
 
   // We can't call this right now; it is too late in some cases and the window
@@ -71,204 +77,209 @@ nsComposerCommandsUpdater::NotifyDocumen
   // Trigger an nsIObserve notification that the document will be destroyed
   UpdateOneCommand("obs_documentWillBeDestroyed");
 #endif
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::NotifyDocumentStateChanged(bool aNowDirty)
+ComposerCommandsUpdater::NotifyDocumentStateChanged(bool aNowDirty)
 {
   // update document modified. We should have some other notifications for this too.
   return UpdateDirtyState(aNowDirty);
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::NotifySelectionChanged(nsIDOMDocument *,
-                                                  nsISelection *, int16_t)
+ComposerCommandsUpdater::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
+                                                nsISelection* aSelection,
+                                                int16_t aReason)
 {
   return PrimeUpdateTimer();
 }
 
 #if 0
 #pragma mark -
 #endif
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::WillDo(nsITransactionManager *aManager,
-                                  nsITransaction *aTransaction, bool *aInterrupt)
+ComposerCommandsUpdater::WillDo(nsITransactionManager* aManager,
+                                nsITransaction* aTransaction,
+                                bool* aInterrupt)
 {
   *aInterrupt = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::DidDo(nsITransactionManager *aManager,
-  nsITransaction *aTransaction, nsresult aDoResult)
+ComposerCommandsUpdater::DidDo(nsITransactionManager* aManager,
+                               nsITransaction* aTransaction,
+                               nsresult aDoResult)
 {
   // only need to update if the status of the Undo menu item changes.
   int32_t undoCount;
   aManager->GetNumberOfUndoItems(&undoCount);
   if (undoCount == 1) {
     if (mFirstDoOfFirstUndo) {
       UpdateCommandGroup(NS_LITERAL_STRING("undo"));
     }
     mFirstDoOfFirstUndo = false;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::WillUndo(nsITransactionManager *aManager,
-                                    nsITransaction *aTransaction,
-                                    bool *aInterrupt)
+ComposerCommandsUpdater::WillUndo(nsITransactionManager* aManager,
+                                  nsITransaction* aTransaction,
+                                  bool* aInterrupt)
 {
   *aInterrupt = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::DidUndo(nsITransactionManager *aManager,
-                                   nsITransaction *aTransaction,
-                                   nsresult aUndoResult)
+ComposerCommandsUpdater::DidUndo(nsITransactionManager* aManager,
+                                 nsITransaction* aTransaction,
+                                 nsresult aUndoResult)
 {
   int32_t undoCount;
   aManager->GetNumberOfUndoItems(&undoCount);
   if (undoCount == 0)
     mFirstDoOfFirstUndo = true;    // reset the state for the next do
 
   UpdateCommandGroup(NS_LITERAL_STRING("undo"));
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::WillRedo(nsITransactionManager *aManager,
-                                    nsITransaction *aTransaction,
-                                    bool *aInterrupt)
+ComposerCommandsUpdater::WillRedo(nsITransactionManager* aManager,
+                                  nsITransaction* aTransaction,
+                                  bool* aInterrupt)
 {
   *aInterrupt = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::DidRedo(nsITransactionManager *aManager,
-                                   nsITransaction *aTransaction,
-                                   nsresult aRedoResult)
+ComposerCommandsUpdater::DidRedo(nsITransactionManager* aManager,
+                                 nsITransaction* aTransaction,
+                                 nsresult aRedoResult)
 {
   UpdateCommandGroup(NS_LITERAL_STRING("undo"));
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::WillBeginBatch(nsITransactionManager *aManager,
-                                          bool *aInterrupt)
+ComposerCommandsUpdater::WillBeginBatch(nsITransactionManager* aManager,
+                                        bool* aInterrupt)
 {
   *aInterrupt = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::DidBeginBatch(nsITransactionManager *aManager,
-                                         nsresult aResult)
+ComposerCommandsUpdater::DidBeginBatch(nsITransactionManager* aManager,
+                                       nsresult aResult)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::WillEndBatch(nsITransactionManager *aManager,
-                                        bool *aInterrupt)
+ComposerCommandsUpdater::WillEndBatch(nsITransactionManager* aManager,
+                                      bool* aInterrupt)
 {
   *aInterrupt = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::DidEndBatch(nsITransactionManager *aManager,
-                                       nsresult aResult)
+ComposerCommandsUpdater::DidEndBatch(nsITransactionManager* aManager,
+                                     nsresult aResult)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::WillMerge(nsITransactionManager *aManager,
-                                     nsITransaction *aTopTransaction,
-                                     nsITransaction *aTransactionToMerge,
-                                     bool *aInterrupt)
+ComposerCommandsUpdater::WillMerge(nsITransactionManager* aManager,
+                                   nsITransaction* aTopTransaction,
+                                   nsITransaction* aTransactionToMerge,
+                                   bool* aInterrupt)
 {
   *aInterrupt = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::DidMerge(nsITransactionManager *aManager,
-                                    nsITransaction *aTopTransaction,
-                                    nsITransaction *aTransactionToMerge,
-                                    bool aDidMerge, nsresult aMergeResult)
+ComposerCommandsUpdater::DidMerge(nsITransactionManager* aManager,
+                                  nsITransaction* aTopTransaction,
+                                  nsITransaction* aTransactionToMerge,
+                                  bool aDidMerge,
+                                  nsresult aMergeResult)
 {
   return NS_OK;
 }
 
 #if 0
 #pragma mark -
 #endif
 
 nsresult
-nsComposerCommandsUpdater::Init(nsPIDOMWindowOuter* aDOMWindow)
+ComposerCommandsUpdater::Init(nsPIDOMWindowOuter* aDOMWindow)
 {
   NS_ENSURE_ARG(aDOMWindow);
   mDOMWindow = do_GetWeakReference(aDOMWindow);
   mDocShell = do_GetWeakReference(aDOMWindow->GetDocShell());
   return NS_OK;
 }
 
 nsresult
-nsComposerCommandsUpdater::PrimeUpdateTimer()
+ComposerCommandsUpdater::PrimeUpdateTimer()
 {
   if (!mUpdateTimer) {
     mUpdateTimer = NS_NewTimer();;
     NS_ENSURE_TRUE(mUpdateTimer, NS_ERROR_OUT_OF_MEMORY);
   }
 
   const uint32_t kUpdateTimerDelay = 150;
   return mUpdateTimer->InitWithCallback(static_cast<nsITimerCallback*>(this),
                                         kUpdateTimerDelay,
                                         nsITimer::TYPE_ONE_SHOT);
 }
 
 
-void nsComposerCommandsUpdater::TimerCallback()
+void
+ComposerCommandsUpdater::TimerCallback()
 {
   // if the selection state has changed, update stuff
   bool isCollapsed = SelectionIsCollapsed();
   if (static_cast<int8_t>(isCollapsed) != mSelectionCollapsed) {
     UpdateCommandGroup(NS_LITERAL_STRING("select"));
     mSelectionCollapsed = isCollapsed;
   }
 
   // isn't this redundant with the UpdateCommandGroup above?
   // can we just nuke the above call? or create a meta command group?
   UpdateCommandGroup(NS_LITERAL_STRING("style"));
 }
 
 nsresult
-nsComposerCommandsUpdater::UpdateDirtyState(bool aNowDirty)
+ComposerCommandsUpdater::UpdateDirtyState(bool aNowDirty)
 {
   if (mDirtyState != static_cast<int8_t>(aNowDirty)) {
     UpdateCommandGroup(NS_LITERAL_STRING("save"));
     UpdateCommandGroup(NS_LITERAL_STRING("undo"));
     mDirtyState = aNowDirty;
   }
 
   return NS_OK;
 }
 
 nsresult
-nsComposerCommandsUpdater::UpdateCommandGroup(const nsAString& aCommandGroup)
+ComposerCommandsUpdater::UpdateCommandGroup(const nsAString& aCommandGroup)
 {
   nsCOMPtr<nsPICommandUpdater> commandUpdater = GetCommandUpdater();
   NS_ENSURE_TRUE(commandUpdater, NS_ERROR_FAILURE);
 
 
   // This hardcoded list of commands is temporary.
   // This code should use nsIControllerCommandGroup.
   if (aCommandGroup.EqualsLiteral("undo")) {
@@ -315,73 +326,66 @@ nsComposerCommandsUpdater::UpdateCommand
     commandUpdater->CommandStatusChanged("cmd_save");
     return NS_OK;
   }
 
   return NS_OK;
 }
 
 nsresult
-nsComposerCommandsUpdater::UpdateOneCommand(const char *aCommand)
+ComposerCommandsUpdater::UpdateOneCommand(const char* aCommand)
 {
   nsCOMPtr<nsPICommandUpdater> commandUpdater = GetCommandUpdater();
   NS_ENSURE_TRUE(commandUpdater, NS_ERROR_FAILURE);
 
   commandUpdater->CommandStatusChanged(aCommand);
 
   return NS_OK;
 }
 
 bool
-nsComposerCommandsUpdater::SelectionIsCollapsed()
+ComposerCommandsUpdater::SelectionIsCollapsed()
 {
   nsCOMPtr<nsPIDOMWindowOuter> domWindow = do_QueryReferent(mDOMWindow);
   NS_ENSURE_TRUE(domWindow, true);
 
   nsCOMPtr<nsISelection> domSelection = domWindow->GetSelection();
   if (NS_WARN_IF(!domSelection)) {
     return false;
   }
 
   return domSelection->AsSelection()->IsCollapsed();
 }
 
 already_AddRefed<nsPICommandUpdater>
-nsComposerCommandsUpdater::GetCommandUpdater()
+ComposerCommandsUpdater::GetCommandUpdater()
 {
   nsCOMPtr<nsIDocShell> docShell = do_QueryReferent(mDocShell);
   NS_ENSURE_TRUE(docShell, nullptr);
   nsCOMPtr<nsICommandManager> manager = docShell->GetCommandManager();
   nsCOMPtr<nsPICommandUpdater> updater = do_QueryInterface(manager);
   return updater.forget();
 }
 
 NS_IMETHODIMP
-nsComposerCommandsUpdater::GetName(nsACString& aName)
+ComposerCommandsUpdater::GetName(nsACString& aName)
 {
-  aName.AssignLiteral("nsComposerCommandsUpdater");
+  aName.AssignLiteral("ComposerCommandsUpdater");
   return NS_OK;
 }
 
 #if 0
 #pragma mark -
 #endif
 
 nsresult
-nsComposerCommandsUpdater::Notify(nsITimer *timer)
+ComposerCommandsUpdater::Notify(nsITimer* aTimer)
 {
-  NS_ASSERTION(timer == mUpdateTimer.get(), "Hey, this ain't my timer!");
+  NS_ASSERTION(aTimer == mUpdateTimer.get(), "Hey, this ain't my timer!");
   TimerCallback();
   return NS_OK;
 }
 
 #if 0
 #pragma mark -
 #endif
 
-
-nsresult
-NS_NewComposerCommandsUpdater(nsISelectionListener** aInstancePtrResult)
-{
-  RefPtr<nsComposerCommandsUpdater> newThang = new nsComposerCommandsUpdater;
-  newThang.forget(aInstancePtrResult);
-  return NS_OK;
-}
+} // namespace mozilla
rename from editor/composer/nsComposerCommandsUpdater.h
rename to editor/composer/ComposerCommandsUpdater.h
--- a/editor/composer/nsComposerCommandsUpdater.h
+++ b/editor/composer/ComposerCommandsUpdater.h
@@ -1,107 +1,87 @@
 /* -*- 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 nsComposerCommandsUpdater_h__
-#define nsComposerCommandsUpdater_h__
+#ifndef mozilla_ComposerCommandsUpdater_h
+#define mozilla_ComposerCommandsUpdater_h
 
 #include "nsCOMPtr.h"                   // for already_AddRefed, nsCOMPtr
 #include "nsIDocumentStateListener.h"
 #include "nsINamed.h"
 #include "nsISelectionListener.h"
 #include "nsISupportsImpl.h"            // for NS_DECL_ISUPPORTS
 #include "nsITimer.h"                   // for NS_DECL_NSITIMERCALLBACK, etc
 #include "nsITransactionListener.h"     // for nsITransactionListener
 #include "nsIWeakReferenceUtils.h"      // for nsWeakPtr
 #include "nscore.h"                     // for NS_IMETHOD, nsresult, etc
 
 class nsPIDOMWindowOuter;
 class nsITransaction;
 class nsITransactionManager;
 class nsPICommandUpdater;
 
-class nsComposerCommandsUpdater : public nsISelectionListener,
-                                  public nsIDocumentStateListener,
-                                  public nsITransactionListener,
-                                  public nsITimerCallback,
-                                  public nsINamed
+namespace mozilla {
+
+class ComposerCommandsUpdater final : public nsISelectionListener
+                                    , public nsIDocumentStateListener
+                                    , public nsITransactionListener
+                                    , public nsITimerCallback
+                                    , public nsINamed
 {
 public:
-
-                                  nsComposerCommandsUpdater();
+  ComposerCommandsUpdater();
 
   // nsISupports
   NS_DECL_ISUPPORTS
 
   // nsISelectionListener
   NS_DECL_NSISELECTIONLISTENER
 
   // nsIDocumentStateListener
   NS_DECL_NSIDOCUMENTSTATELISTENER
 
-  // nsITimerCallback interfaces
+  // nsITimerCallback
   NS_DECL_NSITIMERCALLBACK
 
   // nsINamed
   NS_DECL_NSINAMED
 
-  /** nsITransactionListener interfaces
-    */
-  NS_IMETHOD WillDo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt) override;
-  NS_IMETHOD DidDo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aDoResult) override;
-  NS_IMETHOD WillUndo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt) override;
-  NS_IMETHOD DidUndo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aUndoResult) override;
-  NS_IMETHOD WillRedo(nsITransactionManager *aManager, nsITransaction *aTransaction, bool *aInterrupt) override;
-  NS_IMETHOD DidRedo(nsITransactionManager *aManager, nsITransaction *aTransaction, nsresult aRedoResult) override;
-  NS_IMETHOD WillBeginBatch(nsITransactionManager *aManager, bool *aInterrupt) override;
-  NS_IMETHOD DidBeginBatch(nsITransactionManager *aManager, nsresult aResult) override;
-  NS_IMETHOD WillEndBatch(nsITransactionManager *aManager, bool *aInterrupt) override;
-  NS_IMETHOD DidEndBatch(nsITransactionManager *aManager, nsresult aResult) override;
-  NS_IMETHOD WillMerge(nsITransactionManager *aManager, nsITransaction *aTopTransaction,
-                       nsITransaction *aTransactionToMerge, bool *aInterrupt) override;
-  NS_IMETHOD DidMerge(nsITransactionManager *aManager, nsITransaction *aTopTransaction,
-                      nsITransaction *aTransactionToMerge,
-                      bool aDidMerge, nsresult aMergeResult) override;
+  // nsITransactionListener
+  NS_DECL_NSITRANSACTIONLISTENER
 
-
-  nsresult   Init(nsPIDOMWindowOuter* aDOMWindow);
+  nsresult Init(nsPIDOMWindowOuter* aDOMWindow);
 
 protected:
-
-  virtual ~nsComposerCommandsUpdater();
+  virtual ~ComposerCommandsUpdater();
 
-  enum {
-    eStateUninitialized   = -1,
-    eStateOff             = false,
-    eStateOn              = true
+  enum
+  {
+    eStateUninitialized = -1,
+    eStateOff = 0,
+    eStateOn = 1,
   };
 
-  bool          SelectionIsCollapsed();
-  nsresult      UpdateDirtyState(bool aNowDirty);
-  nsresult      UpdateOneCommand(const char* aCommand);
-  nsresult      UpdateCommandGroup(const nsAString& aCommandGroup);
+  bool SelectionIsCollapsed();
+  nsresult UpdateDirtyState(bool aNowDirty);
+  nsresult UpdateOneCommand(const char* aCommand);
+  nsresult UpdateCommandGroup(const nsAString& aCommandGroup);
 
   already_AddRefed<nsPICommandUpdater> GetCommandUpdater();
 
-  nsresult      PrimeUpdateTimer();
-  void          TimerCallback();
-  nsCOMPtr<nsITimer>  mUpdateTimer;
+  nsresult PrimeUpdateTimer();
+  void TimerCallback();
+
+  nsCOMPtr<nsITimer> mUpdateTimer;
 
-  nsWeakPtr     mDOMWindow;
-  nsWeakPtr     mDocShell;
-  int8_t        mDirtyState;
-  int8_t        mSelectionCollapsed;
-  bool          mFirstDoOfFirstUndo;
-
-
+  nsWeakPtr mDOMWindow;
+  nsWeakPtr mDocShell;
+  int8_t mDirtyState;
+  int8_t mSelectionCollapsed;
+  bool mFirstDoOfFirstUndo;
 };
 
-extern "C" nsresult NS_NewComposerCommandsUpdater(nsISelectionListener** aInstancePtrResult);
+} // namespace mozilla
 
-
-#endif // nsComposerCommandsUpdater_h__
+#endif // #ifndef mozilla_ComposerCommandsUpdater_h
--- a/editor/composer/moz.build
+++ b/editor/composer/moz.build
@@ -10,27 +10,28 @@ MOCHITEST_CHROME_MANIFESTS += ['test/chr
 
 XPIDL_SOURCES += [
     'nsIEditingSession.idl',
 ]
 
 XPIDL_MODULE = 'composer'
 
 UNIFIED_SOURCES += [
+    'ComposerCommandsUpdater.cpp',
     'EditorSpellCheck.cpp',
     'nsComposerCommands.cpp',
-    'nsComposerCommandsUpdater.cpp',
     'nsComposerController.cpp',
     'nsComposerDocumentCommands.cpp',
     'nsComposerRegistration.cpp',
     'nsComposeTxtSrvFilter.cpp',
     'nsEditingSession.cpp',
 ]
 
 EXPORTS.mozilla += [
+    'ComposerCommandsUpdater.h',
     'EditorSpellCheck.h',
 ]
 
 # Needed because we include HTMLEditor.h which indirectly includes nsDocument.h
 LOCAL_INCLUDES += [
     '/dom/base',
 ]
 
--- a/editor/composer/nsEditingSession.cpp
+++ b/editor/composer/nsEditingSession.cpp
@@ -2,22 +2,22 @@
 /* vim: set ts=2 sw=2 et tw=78: */
 /* 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 <string.h>                     // for nullptr, strcmp
 
 #include "imgIContainer.h"              // for imgIContainer, etc
+#include "mozilla/ComposerCommandsUpdater.h" // for ComposerCommandsUpdater
 #include "mozilla/FlushType.h"          // for FlushType::Frames
 #include "mozilla/HTMLEditor.h"         // for HTMLEditor
 #include "mozilla/mozalloc.h"           // for operator new
 #include "nsAString.h"
 #include "nsComponentManagerUtils.h"    // for do_CreateInstance
-#include "nsComposerCommandsUpdater.h"  // for nsComposerCommandsUpdater
 #include "nsContentUtils.h"
 #include "nsDebug.h"                    // for NS_ENSURE_SUCCESS, etc
 #include "nsEditingSession.h"
 #include "nsError.h"                    // for NS_ERROR_FAILURE, NS_OK, etc
 #include "nsIChannel.h"                 // for nsIChannel
 #include "nsICommandManager.h"          // for nsICommandManager
 #include "nsIContentViewer.h"           // for nsIContentViewer
 #include "nsIController.h"              // for nsIController
@@ -373,17 +373,17 @@ nsEditingSession::SetupEditorOnWindow(mo
     needHTMLController = true;
   }
 
   if (mInteractive) {
     mEditorFlags |= nsIPlaintextEditor::eEditorAllowInteraction;
   }
 
   // make the UI state maintainer
-  mStateMaintainer = new nsComposerCommandsUpdater();
+  mStateMaintainer = new ComposerCommandsUpdater();
 
   // now init the state maintainer
   // This allows notification of error state
   //  even if we don't create an editor
   rv = mStateMaintainer->Init(window);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (mEditorStatus != eEditorCreationInProgress) {
--- a/editor/composer/nsEditingSession.h
+++ b/editor/composer/nsEditingSession.h
@@ -31,24 +31,24 @@ class mozIDOMWindowProxy;
 class nsIDOMWindow;
 class nsISupports;
 class nsITimer;
 
 #define NS_EDITINGSESSION_CID                            \
 { 0xbc26ff01, 0xf2bd, 0x11d4, { 0xa7, 0x3c, 0xe5, 0xa4, 0xb5, 0xa8, 0xbd, 0xfc } }
 
 
-class nsComposerCommandsUpdater;
 class nsIChannel;
 class nsIControllers;
 class nsIDocShell;
 class nsIEditor;
 class nsIWebProgress;
 
 namespace mozilla {
+class ComposerCommandsUpdater;
 class HTMLEditor;
 } // namespace mozilla
 
 class nsEditingSession final : public nsIEditingSession,
                                public nsIWebProgressListener,
                                public nsSupportsWeakReference
 {
 public:
@@ -125,17 +125,17 @@ protected:
 
   bool            mProgressListenerRegistered;
 
   // The image animation mode before it was turned off.
   uint16_t        mImageAnimationMode;
 
   // THE REMAINING MEMBER VARIABLES WILL BECOME A SET WHEN WE EDIT
   // MORE THAN ONE EDITOR PER EDITING SESSION
-  RefPtr<nsComposerCommandsUpdater> mStateMaintainer;
+  RefPtr<mozilla::ComposerCommandsUpdater> mStateMaintainer;
 
   // Save the editor type so we can create the editor after loading uri
   nsCString       mEditorType;
   uint32_t        mEditorFlags;
   uint32_t        mEditorStatus;
   uint32_t        mBaseCommandControllerId;
   uint32_t        mDocStateControllerId;
   uint32_t        mHTMLCommandControllerId;