Bug 1260651 part.56 Rename nsHTMLEditor to mozilla::HTMLEditor and related stuff r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 09 Jul 2016 11:42:33 +0900
changeset 385888 51addd3c3e4791ff30cabb2860df401f2cd51b09
parent 385887 dfee7368ac6a9a5ecf5afd56605f8da850e83291
child 385889 4b047618bddf0c4ea4f859569e69f130c220eaaa
push id22587
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 06:59:31 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.56 Rename nsHTMLEditor to mozilla::HTMLEditor and related stuff r=mccr8 This patch renames classes/structs as: nsHTMLEditor -> mozilla::HTMLEditor nsHTMLEditor::BlobReader -> mozilla::HTMLEditor::BlobReader SetSelectionAfterTableEdit -> mozilla::AutoSelectionSetterAfterTableEdit nsHTMLEditor.h -> HTMLEditor.h (exposed as mozilla/editor/HTMLEditor.h) nsHTMLAbsPosition.cpp -> HTMLAbsPositionEditor.cpp nsHTMLAnonymousUtils.cpp -> HTMLAnonymousNodeEditor.cpp nsHTMLDataTransfer.cpp -> HTMLEditorDataTransfer.cpp nsHTMLEditorStyle.cpp -> HTMLStyleEditor.cpp nsHTMLInlineTableEditor.cpp -> HTMLInlineTableEditor.cpp nsHTMLObjectResizer.cpp -> HTMLEditorObjectResizer.cpp nsTableEditor.cpp -> HTMLTableEditor.cpp These new file names are clearer names which related to HTMLEditor than old names. MozReview-Commit-ID: DTWaoFvy0DF
dom/base/nsDocument.cpp
editor/libeditor/CSSEditUtils.cpp
editor/libeditor/CSSEditUtils.h
editor/libeditor/HTMLAbsPositionEditor.cpp
editor/libeditor/HTMLAnonymousNodeEditor.cpp
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditRules.h
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorDataTransfer.cpp
editor/libeditor/HTMLEditorEventListener.cpp
editor/libeditor/HTMLEditorEventListener.h
editor/libeditor/HTMLEditorObjectResizer.cpp
editor/libeditor/HTMLInlineTableEditor.cpp
editor/libeditor/HTMLStyleEditor.cpp
editor/libeditor/HTMLTableEditor.cpp
editor/libeditor/WSRunObject.cpp
editor/libeditor/WSRunObject.h
editor/libeditor/moz.build
editor/libeditor/nsEditor.cpp
editor/libeditor/nsHTMLAbsPosition.cpp
editor/libeditor/nsHTMLAnonymousUtils.cpp
editor/libeditor/nsHTMLDataTransfer.cpp
editor/libeditor/nsHTMLEditor.cpp
editor/libeditor/nsHTMLEditor.h
editor/libeditor/nsHTMLEditorStyle.cpp
editor/libeditor/nsHTMLInlineTableEditor.cpp
editor/libeditor/nsHTMLObjectResizer.cpp
editor/libeditor/nsPlaintextDataTransfer.cpp
editor/libeditor/nsPlaintextEditor.cpp
editor/libeditor/nsTableEditor.cpp
layout/base/RestyleManager.cpp
layout/build/nsLayoutModule.cpp
layout/build/nsLayoutStatics.cpp
layout/generic/nsSelection.cpp
widget/windows/nsClipboard.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -4367,17 +4367,17 @@ nsDocument::SetStyleSheetApplicableState
       AddStyleSheetToStyleSets(aSheet);
     } else {
       RemoveStyleSheetFromStyleSets(aSheet);
     }
   }
 
   // We have to always notify, since this will be called for sheets
   // that are children of sheets in our style set, as well as some
-  // sheets for nsHTMLEditor.
+  // sheets for HTMLEditor.
 
   NS_DOCUMENT_NOTIFY_OBSERVERS(StyleSheetApplicableStateChanged, (aSheet));
 
   if (StyleSheetChangeEventsEnabled()) {
     DO_STYLESHEET_NOTIFICATION(StyleSheetApplicableStateChangeEvent,
                                "StyleSheetApplicableStateChanged",
                                mApplicable,
                                aApplicable);
--- a/editor/libeditor/CSSEditUtils.cpp
+++ b/editor/libeditor/CSSEditUtils.cpp
@@ -2,30 +2,30 @@
 /* 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 "CSSEditUtils.h"
 
 #include "ChangeStyleTransaction.h"
 #include "mozilla/Assertions.h"
+#include "mozilla/HTMLEditor.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/css/Declaration.h"
 #include "mozilla/css/StyleRule.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/mozalloc.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsColor.h"
 #include "nsComputedDOMStyle.h"
 #include "nsDebug.h"
 #include "nsDependentSubstring.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
-#include "nsHTMLEditor.h"
 #include "nsIAtom.h"
 #include "nsIContent.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMElementCSSInlineStyle.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMWindow.h"
 #include "nsIDocument.h"
@@ -296,17 +296,17 @@ const CSSEditUtils::CSSEquivTable tableA
 };
 
 const CSSEditUtils::CSSEquivTable hrAlignEquivTable[] = {
   { CSSEditUtils::eCSSEditableProperty_margin_left, ProcessMarginLeftValue, nullptr, nullptr, nullptr, true, false },
   { CSSEditUtils::eCSSEditableProperty_margin_right, ProcessMarginRightValue, nullptr, nullptr, nullptr, true, false },
   { CSSEditUtils::eCSSEditableProperty_NONE, 0 }
 };
 
-CSSEditUtils::CSSEditUtils(nsHTMLEditor* aHTMLEditor)
+CSSEditUtils::CSSEditUtils(HTMLEditor* aHTMLEditor)
   : mHTMLEditor(aHTMLEditor)
   , mIsCSSPrefChecked(true)
 {
   // let's retrieve the value of the "CSS editing" pref
   mIsCSSPrefChecked = Preferences::GetBool("editor.use_css", mIsCSSPrefChecked);
 }
 
 CSSEditUtils::~CSSEditUtils()
@@ -584,17 +584,17 @@ CSSEditUtils::RemoveCSSInlineStyle(nsIDO
   nsCOMPtr<Element> element = do_QueryInterface(aNode);
   NS_ENSURE_STATE(element);
 
   // remove the property from the style attribute
   nsresult res = RemoveCSSProperty(*element, *aProperty, aPropertyValue);
   NS_ENSURE_SUCCESS(res, res);
 
   if (!element->IsHTMLElement(nsGkAtoms::span) ||
-      nsHTMLEditor::HasAttributes(element)) {
+      HTMLEditor::HasAttributes(element)) {
     return NS_OK;
   }
 
   return mHTMLEditor->RemoveContainer(element);
 }
 
 // Answers true if the property can be removed by setting a "none" CSS value
 // on a node
--- a/editor/libeditor/CSSEditUtils.h
+++ b/editor/libeditor/CSSEditUtils.h
@@ -7,41 +7,41 @@
 #define CSSEditUtils_h
 
 #include "ChangeStyleTransaction.h" // for ChangeStyleTransaction::EChangeType
 #include "nsCOMPtr.h"               // for already_AddRefed
 #include "nsTArray.h"               // for nsTArray
 #include "nscore.h"                 // for nsAString, nsresult, nullptr
 
 class nsComputedDOMStyle;
-class nsHTMLEditor;
 class nsIAtom;
 class nsIContent;
 class nsIDOMCSSStyleDeclaration;
 class nsIDOMElement;
 class nsIDOMNode;
 class nsINode;
 class nsString;
 
 namespace mozilla {
 
+class HTMLEditor;
 namespace dom {
 class Element;
 } // namespace dom
 
 typedef void (*nsProcessValueFunc)(const nsAString* aInputString,
                                    nsAString& aOutputString,
                                    const char* aDefaultValueString,
                                    const char* aPrependString,
                                    const char* aAppendString);
 
 class CSSEditUtils final
 {
 public:
-  explicit CSSEditUtils(nsHTMLEditor* aEditor);
+  explicit CSSEditUtils(HTMLEditor* aEditor);
   ~CSSEditUtils();
 
   enum nsCSSEditableProperty
   {
     eCSSEditableProperty_NONE=0,
     eCSSEditableProperty_background_color,
     eCSSEditableProperty_background_image,
     eCSSEditableProperty_border,
@@ -449,17 +449,17 @@ private:
    * @param aProperty           [IN] A CSS property.
    * @param aValue              [OUT] The retrieved value for this property.
    * @param aStyleType          [IN] eSpecified or eComputed.
    */
   nsresult GetCSSInlinePropertyBase(nsINode* aNode, nsIAtom* aProperty,
                                     nsAString& aValue, StyleType aStyleType);
 
 private:
-  nsHTMLEditor* mHTMLEditor;
+  HTMLEditor* mHTMLEditor;
   bool mIsCSSPrefChecked;
 };
 
 #define NS_EDITOR_INDENT_INCREMENT_IN        0.4134f
 #define NS_EDITOR_INDENT_INCREMENT_CM        1.05f
 #define NS_EDITOR_INDENT_INCREMENT_MM        10.5f
 #define NS_EDITOR_INDENT_INCREMENT_PT        29.76f
 #define NS_EDITOR_INDENT_INCREMENT_PC        2.48f
rename from editor/libeditor/nsHTMLAbsPosition.cpp
rename to editor/libeditor/HTMLAbsPositionEditor.cpp
--- a/editor/libeditor/nsHTMLAbsPosition.cpp
+++ b/editor/libeditor/HTMLAbsPositionEditor.cpp
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/HTMLEditor.h"
+
 #include <math.h>
 
 #include "EditorUtils.h"
 #include "HTMLEditRules.h"
 #include "HTMLEditUtils.h"
 #include "TextEditUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/Selection.h"
@@ -15,17 +17,16 @@
 #include "nsAString.h"
 #include "nsAlgorithm.h"
 #include "nsCOMPtr.h"
 #include "nsComputedDOMStyle.h"
 #include "nsDebug.h"
 #include "nsEditor.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
-#include "nsHTMLEditor.h"
 #include "nsHTMLObjectResizer.h"
 #include "nsIContent.h"
 #include "nsROCSSPrimitiveValue.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMNode.h"
@@ -41,23 +42,24 @@
 #include "nsISupportsUtils.h"
 #include "nsLiteralString.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include "nsStringFwd.h"
 #include "nscore.h"
 #include <algorithm>
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
 #define  BLACK_BG_RGB_TRIGGER 0xd0
 
 NS_IMETHODIMP
-nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
+HTMLEditor::AbsolutePositionSelection(bool aEnabled)
 {
   AutoEditBatch beginBatching(this);
   AutoRules beginRulesSniffing(this,
                                aEnabled ? EditAction::setAbsolutePosition :
                                           EditAction::removeAbsolutePosition,
                                nsIEditor::eNext);
 
   // the line below does not match the code; should it be removed?
@@ -73,17 +75,17 @@ nsHTMLEditor::AbsolutePositionSelection(
   nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (NS_FAILED(res) || cancel)
     return res;
 
   return mRules->DidDoAction(selection, &ruleInfo, res);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetAbsolutelyPositionedSelectionContainer(nsIDOMElement **_retval)
+HTMLEditor::GetAbsolutelyPositionedSelectionContainer(nsIDOMElement** _retval)
 {
   nsAutoString positionStr;
   nsCOMPtr<nsINode> node = GetSelectionContainer();
   nsCOMPtr<nsIDOMNode> resultNode;
 
   while (!resultNode && node && !node->IsHTMLElement(nsGkAtoms::html)) {
     nsresult res =
       mCSSEditUtils->GetComputedProperty(*node, *nsGkAtoms::position,
@@ -97,40 +99,41 @@ nsHTMLEditor::GetAbsolutelyPositionedSel
   }
 
   nsCOMPtr<nsIDOMElement> element = do_QueryInterface(resultNode);
   element.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetSelectionContainerAbsolutelyPositioned(bool *aIsSelectionContainerAbsolutelyPositioned)
+HTMLEditor::GetSelectionContainerAbsolutelyPositioned(
+              bool* aIsSelectionContainerAbsolutelyPositioned)
 {
   *aIsSelectionContainerAbsolutelyPositioned = (mAbsolutelyPositionedObject != nullptr);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetAbsolutePositioningEnabled(bool * aIsEnabled)
+HTMLEditor::GetAbsolutePositioningEnabled(bool* aIsEnabled)
 {
   *aIsEnabled = mIsAbsolutelyPositioningEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetAbsolutePositioningEnabled(bool aIsEnabled)
+HTMLEditor::SetAbsolutePositioningEnabled(bool aIsEnabled)
 {
   mIsAbsolutelyPositioningEnabled = aIsEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RelativeChangeElementZIndex(nsIDOMElement * aElement,
+HTMLEditor::RelativeChangeElementZIndex(nsIDOMElement* aElement,
                                           int32_t aChange,
-                                          int32_t * aReturn)
+                                          int32_t* aReturn)
 {
   NS_ENSURE_ARG_POINTER(aElement);
   NS_ENSURE_ARG_POINTER(aReturn);
   if (!aChange) // early way out, no change
     return NS_OK;
 
   int32_t zIndex;
   nsresult res = GetElementZIndex(aElement, &zIndex);
@@ -139,30 +142,31 @@ nsHTMLEditor::RelativeChangeElementZInde
   zIndex = std::max(zIndex + aChange, 0);
   SetElementZIndex(aElement, zIndex);
   *aReturn = zIndex;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetElementZIndex(nsIDOMElement* aElement, int32_t aZindex)
+HTMLEditor::SetElementZIndex(nsIDOMElement* aElement,
+                             int32_t aZindex)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_ARG_POINTER(element);
 
   nsAutoString zIndexStr;
   zIndexStr.AppendInt(aZindex);
 
   mCSSEditUtils->SetCSSProperty(*element, *nsGkAtoms::z_index, zIndexStr);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RelativeChangeZIndex(int32_t aChange)
+HTMLEditor::RelativeChangeZIndex(int32_t aChange)
 {
   AutoEditBatch beginBatching(this);
   AutoRules beginRulesSniffing(this,
                                (aChange < 0) ? EditAction::decreaseZIndex :
                                                EditAction::increaseZIndex,
                                nsIEditor::eNext);
 
   // brade: can we get rid of this comment?
@@ -177,18 +181,18 @@ nsHTMLEditor::RelativeChangeZIndex(int32
   nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
   if (cancel || NS_FAILED(res))
     return res;
 
   return mRules->DidDoAction(selection, &ruleInfo, res);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetElementZIndex(nsIDOMElement * aElement,
-                               int32_t * aZindex)
+HTMLEditor::GetElementZIndex(nsIDOMElement* aElement,
+                             int32_t* aZindex)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_STATE(element || !aElement);
   nsAutoString zIndexStr;
   *aZindex = 0;
 
   nsresult res = mCSSEditUtils->GetSpecifiedProperty(*element,
                                                      *nsGkAtoms::z_index,
@@ -222,17 +226,17 @@ nsHTMLEditor::GetElementZIndex(nsIDOMEle
     nsresult errorCode;
     *aZindex = zIndexStr.ToInteger(&errorCode);
   }
 
   return NS_OK;
 }
 
 already_AddRefed<Element>
-nsHTMLEditor::CreateGrabber(nsINode* aParentNode)
+HTMLEditor::CreateGrabber(nsINode* aParentNode)
 {
   // let's create a grabber through the element factory
   nsCOMPtr<nsIDOMElement> retDOM;
   CreateAnonymousElement(NS_LITERAL_STRING("span"), GetAsDOMNode(aParentNode),
                          NS_LITERAL_STRING("mozGrabber"), false,
                          getter_AddRefs(retDOM));
 
   NS_ENSURE_TRUE(retDOM, nullptr);
@@ -242,17 +246,17 @@ nsHTMLEditor::CreateGrabber(nsINode* aPa
   evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"),
                               mEventListener, false);
 
   nsCOMPtr<Element> ret = do_QueryInterface(retDOM);
   return ret.forget();
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RefreshGrabber()
+HTMLEditor::RefreshGrabber()
 {
   NS_ENSURE_TRUE(mAbsolutelyPositionedObject, NS_ERROR_NULL_POINTER);
 
   nsresult res = GetPositionAndDimensions(static_cast<nsIDOMElement*>(GetAsDOMNode(mAbsolutelyPositionedObject)),
                                          mPositionedObjectX,
                                          mPositionedObjectY,
                                          mPositionedObjectWidth,
                                          mPositionedObjectHeight,
@@ -265,17 +269,17 @@ nsHTMLEditor::RefreshGrabber()
 
   SetAnonymousElementPosition(mPositionedObjectX+12,
                               mPositionedObjectY-14,
                               static_cast<nsIDOMElement*>(GetAsDOMNode(mGrabber)));
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::HideGrabber()
+HTMLEditor::HideGrabber()
 {
   nsresult res = mAbsolutelyPositionedObject->UnsetAttr(kNameSpaceID_None,
                                                         nsGkAtoms::_moz_abspos,
                                                         true);
   NS_ENSURE_SUCCESS(res, res);
 
   mAbsolutelyPositionedObject = nullptr;
   NS_ENSURE_TRUE(mGrabber, NS_ERROR_NULL_POINTER);
@@ -293,17 +297,17 @@ nsHTMLEditor::HideGrabber()
   mGrabber = nullptr;
   DeleteRefToAnonymousNode(static_cast<nsIDOMElement*>(GetAsDOMNode(mPositioningShadow)), parentContent, ps);
   mPositioningShadow = nullptr;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::ShowGrabberOnElement(nsIDOMElement * aElement)
+HTMLEditor::ShowGrabberOnElement(nsIDOMElement* aElement)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_ARG_POINTER(element);
 
   if (mGrabber) {
     NS_ERROR("call HideGrabber first");
     return NS_ERROR_UNEXPECTED;
   }
@@ -322,17 +326,17 @@ nsHTMLEditor::ShowGrabberOnElement(nsIDO
   mGrabber = CreateGrabber(element->GetParentNode());
   NS_ENSURE_TRUE(mGrabber, NS_ERROR_FAILURE);
 
   // and set its position
   return RefreshGrabber();
 }
 
 nsresult
-nsHTMLEditor::StartMoving(nsIDOMElement *aHandle)
+HTMLEditor::StartMoving(nsIDOMElement* aHandle)
 {
   nsCOMPtr<nsINode> parentNode = mGrabber->GetParentNode();
 
   // now, let's create the resizing shadow
   mPositioningShadow = CreateShadow(GetAsDOMNode(parentNode),
       static_cast<nsIDOMElement*>(GetAsDOMNode(mAbsolutelyPositionedObject)));
   NS_ENSURE_TRUE(mPositioningShadow, NS_ERROR_FAILURE);
   nsresult res = SetShadowPosition(mPositioningShadow,
@@ -349,26 +353,26 @@ nsHTMLEditor::StartMoving(nsIDOMElement 
   mCSSEditUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::height,
                                       mPositionedObjectHeight);
 
   mIsMoving = true;
   return res;
 }
 
 void
-nsHTMLEditor::SnapToGrid(int32_t & newX, int32_t & newY)
+HTMLEditor::SnapToGrid(int32_t& newX, int32_t& newY)
 {
   if (mSnapToGridEnabled && mGridSize) {
     newX = (int32_t) floor( ((float)newX / (float)mGridSize) + 0.5f ) * mGridSize;
     newY = (int32_t) floor( ((float)newY / (float)mGridSize) + 0.5f ) * mGridSize;
   }
 }
 
 nsresult
-nsHTMLEditor::GrabberClicked()
+HTMLEditor::GrabberClicked()
 {
   // add a mouse move listener to the editor
   nsresult res = NS_OK;
   if (!mMouseMotionListenerP) {
     mMouseMotionListenerP = new ResizerMouseMotionListener(this);
     if (!mMouseMotionListenerP) {return NS_ERROR_NULL_POINTER;}
 
     nsCOMPtr<nsIDOMEventTarget> piTarget = GetDOMEventTarget();
@@ -380,17 +384,17 @@ nsHTMLEditor::GrabberClicked()
     NS_ASSERTION(NS_SUCCEEDED(res),
                  "failed to register mouse motion listener");
   }
   mGrabberClicked = true;
   return res;
 }
 
 nsresult
-nsHTMLEditor::EndMoving()
+HTMLEditor::EndMoving()
 {
   if (mPositioningShadow) {
     nsCOMPtr<nsIPresShell> ps = GetPresShell();
     NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
 
     nsCOMPtr<nsIContent> parentContent = mGrabber->GetParent();
     NS_ENSURE_TRUE(parentContent, NS_ERROR_FAILURE);
 
@@ -416,17 +420,18 @@ nsHTMLEditor::EndMoving()
   mIsMoving = false;
   RefPtr<Selection> selection = GetSelection();
   if (!selection) {
     return NS_ERROR_NOT_INITIALIZED;
   }
   return CheckSelectionStateForAnonymousButtons(selection);
 }
 nsresult
-nsHTMLEditor::SetFinalPosition(int32_t aX, int32_t aY)
+HTMLEditor::SetFinalPosition(int32_t aX,
+                             int32_t aY)
 {
   nsresult res = EndMoving();
   NS_ENSURE_SUCCESS(res, res);
 
   // we have now to set the new width and height of the resized object
   // we don't set the x and y position because we don't control that in
   // a normal HTML layout
   int32_t newX = mPositionedObjectX + aX - mOriginalX - (mPositionedObjectBorderLeft+mPositionedObjectMarginLeft);
@@ -451,29 +456,30 @@ nsHTMLEditor::SetFinalPosition(int32_t a
   // keep track of that size
   mPositionedObjectX  = newX;
   mPositionedObjectY  = newY;
 
   return RefreshResizers();
 }
 
 void
-nsHTMLEditor::AddPositioningOffset(int32_t & aX, int32_t & aY)
+HTMLEditor::AddPositioningOffset(int32_t& aX,
+                                 int32_t& aY)
 {
   // Get the positioning offset
   int32_t positioningOffset =
     Preferences::GetInt("editor.positioning.offset", 0);
 
   aX += positioningOffset;
   aY += positioningOffset;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::AbsolutelyPositionElement(nsIDOMElement* aElement,
-                                        bool aEnabled)
+HTMLEditor::AbsolutelyPositionElement(nsIDOMElement* aElement,
+                                      bool aEnabled)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_ARG_POINTER(element);
 
   nsAutoString positionStr;
   mCSSEditUtils->GetComputedProperty(*element, *nsGkAtoms::position,
                                      positionStr);
   bool isPositioned = (positionStr.EqualsLiteral("absolute"));
@@ -535,75 +541,79 @@ nsHTMLEditor::AbsolutelyPositionElement(
       res = RemoveContainer(element);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetSnapToGridEnabled(bool aEnabled)
+HTMLEditor::SetSnapToGridEnabled(bool aEnabled)
 {
   mSnapToGridEnabled = aEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetSnapToGridEnabled(bool * aIsEnabled)
+HTMLEditor::GetSnapToGridEnabled(bool* aIsEnabled)
 {
   *aIsEnabled = mSnapToGridEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetGridSize(uint32_t aSize)
+HTMLEditor::SetGridSize(uint32_t aSize)
 {
   mGridSize = aSize;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetGridSize(uint32_t * aSize)
+HTMLEditor::GetGridSize(uint32_t* aSize)
 {
   *aSize = mGridSize;
   return NS_OK;
 }
 
 // self-explanatory
 NS_IMETHODIMP
-nsHTMLEditor::SetElementPosition(nsIDOMElement *aElement, int32_t aX, int32_t aY)
+HTMLEditor::SetElementPosition(nsIDOMElement* aElement,
+                               int32_t aX,
+                               int32_t aY)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_STATE(element);
 
   SetElementPosition(*element, aX, aY);
   return NS_OK;
 }
 
 void
-nsHTMLEditor::SetElementPosition(dom::Element& aElement, int32_t aX, int32_t aY)
+HTMLEditor::SetElementPosition(Element& aElement,
+                               int32_t aX,
+                               int32_t aY)
 {
   AutoEditBatch batchIt(this);
   mCSSEditUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::left, aX);
   mCSSEditUtils->SetCSSPropertyPixels(aElement, *nsGkAtoms::top, aY);
 }
 
 // self-explanatory
 NS_IMETHODIMP
-nsHTMLEditor::GetPositionedElement(nsIDOMElement ** aReturn)
+HTMLEditor::GetPositionedElement(nsIDOMElement** aReturn)
 {
   nsCOMPtr<nsIDOMElement> ret =
     static_cast<nsIDOMElement*>(GetAsDOMNode(mAbsolutelyPositionedObject));
   ret.forget(aReturn);
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement * aElement,
-                                            nsAString & aReturn)
+HTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement* aElement,
+                                          nsAString& aReturn)
 {
   // we are going to outline the positioned element and bring it to the
   // front to overlap any other element intersecting with it. But
   // first, let's see what's the background and foreground colors of the
   // positioned element.
   // if background-image computed value is 'none,
   //   If the background color is 'auto' and R G B values of the foreground are
   //       each above #d0, use a black background
@@ -659,8 +669,10 @@ nsHTMLEditor::CheckPositionedElementBGan
           aReturn.AssignLiteral("white");
         return NS_OK;
       }
     }
   }
 
   return NS_OK;
 }
+
+} // namespace mozilla
rename from editor/libeditor/nsHTMLAnonymousUtils.cpp
rename to editor/libeditor/HTMLAnonymousNodeEditor.cpp
--- a/editor/libeditor/nsHTMLAnonymousUtils.cpp
+++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp
@@ -1,37 +1,37 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/HTMLEditor.h"
+
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/mozalloc.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsComputedDOMStyle.h"
 #include "nsDebug.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
-#include "nsHTMLEditor.h"
 #include "nsIAtom.h"
 #include "nsIContent.h"
 #include "nsID.h"
 #include "nsIDOMCSSPrimitiveValue.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIDOMCSSValue.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMWindow.h"
 #include "nsIDocument.h"
 #include "nsIDocumentObserver.h"
 #include "nsIHTMLAbsPosEditor.h"
-#include "nsIHTMLEditor.h"
 #include "nsIHTMLInlineTableEditor.h"
 #include "nsIHTMLObjectResizer.h"
 #include "nsIMutationObserver.h"
 #include "nsINode.h"
 #include "nsIPresShell.h"
 #include "nsISupportsImpl.h"
 #include "nsISupportsUtils.h"
 #include "nsLiteralString.h"
@@ -41,18 +41,19 @@
 #include "nsStringFwd.h"
 #include "nsUnicharUtils.h"
 #include "nscore.h"
 #include "nsContentUtils.h" // for nsAutoScriptBlocker
 
 class nsIDOMEventListener;
 class nsISelection;
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
 // retrieve an integer stored into a CSS computed float value
 static int32_t GetCSSFloatValue(nsIDOMCSSStyleDeclaration * aDecl,
                                 const nsAString & aProperty)
 {
   MOZ_ASSERT(aDecl);
 
   nsCOMPtr<nsIDOMCSSValue> value;
@@ -86,34 +87,38 @@ static int32_t GetCSSFloatValue(nsIDOMCS
         f = 5;
       break;
     }
   }
 
   return (int32_t) f;
 }
 
-class nsElementDeletionObserver final : public nsIMutationObserver
+class ElementDeletionObserver final : public nsIMutationObserver
 {
 public:
-  nsElementDeletionObserver(nsINode* aNativeAnonNode, nsINode* aObservedNode)
-  : mNativeAnonNode(aNativeAnonNode), mObservedNode(aObservedNode) {}
+  ElementDeletionObserver(nsINode* aNativeAnonNode, nsINode* aObservedNode)
+    : mNativeAnonNode(aNativeAnonNode)
+    , mObservedNode(aObservedNode)
+  {}
+
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMUTATIONOBSERVER
+
 protected:
-  ~nsElementDeletionObserver() {}
+  ~ElementDeletionObserver() {}
   nsINode* mNativeAnonNode;
   nsINode* mObservedNode;
 };
 
-NS_IMPL_ISUPPORTS(nsElementDeletionObserver, nsIMutationObserver)
-NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(nsElementDeletionObserver)
+NS_IMPL_ISUPPORTS(ElementDeletionObserver, nsIMutationObserver)
+NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(ElementDeletionObserver)
 
 void
-nsElementDeletionObserver::NodeWillBeDestroyed(const nsINode* aNode)
+ElementDeletionObserver::NodeWillBeDestroyed(const nsINode* aNode)
 {
   NS_ASSERTION(aNode == mNativeAnonNode || aNode == mObservedNode,
                "Wrong aNode!");
   if (aNode == mNativeAnonNode) {
     mObservedNode->RemoveMutationObserver(this);
   } else {
     mNativeAnonNode->RemoveMutationObserver(this);
     static_cast<nsIContent*>(mNativeAnonNode)->UnbindFromTree();
@@ -122,19 +127,21 @@ nsElementDeletionObserver::NodeWillBeDes
   NS_RELEASE_THIS();
 }
 
 // Returns in *aReturn an anonymous nsDOMElement of type aTag,
 // child of aParentNode. If aIsCreatedHidden is true, the class
 // "hidden" is added to the created element. If aAnonClass is not
 // the empty string, it becomes the value of the attribute "_moz_anonclass"
 nsresult
-nsHTMLEditor::CreateAnonymousElement(const nsAString & aTag, nsIDOMNode *  aParentNode,
-                                     const nsAString & aAnonClass, bool aIsCreatedHidden,
-                                     nsIDOMElement ** aReturn)
+HTMLEditor::CreateAnonymousElement(const nsAString& aTag,
+                                   nsIDOMNode* aParentNode,
+                                   const nsAString& aAnonClass,
+                                   bool aIsCreatedHidden,
+                                   nsIDOMElement** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aParentNode);
   NS_ENSURE_ARG_POINTER(aReturn);
   *aReturn = nullptr;
 
   nsCOMPtr<nsIContent> parentContent( do_QueryInterface(aParentNode) );
   NS_ENSURE_TRUE(parentContent, NS_OK);
 
@@ -175,18 +182,18 @@ nsHTMLEditor::CreateAnonymousElement(con
     newContent->SetIsNativeAnonymousRoot();
     res = newContent->BindToTree(doc, parentContent, parentContent, true);
     if (NS_FAILED(res)) {
       newContent->UnbindFromTree();
       return res;
     }
   }
 
-  nsElementDeletionObserver* observer =
-    new nsElementDeletionObserver(newContent, parentContent);
+  ElementDeletionObserver* observer =
+    new ElementDeletionObserver(newContent, parentContent);
   NS_ADDREF(observer); // NodeWillBeDestroyed releases.
   parentContent->AddMutationObserver(observer);
   newContent->AddMutationObserver(observer);
 
 #ifdef DEBUG
   // Editor anonymous content gets passed to RecreateFramesFor... which can't
   // _really_ deal with anonymous content (because it can't get the frame tree
   // ordering right).  But for us the ordering doesn't matter so this is sort of
@@ -199,35 +206,35 @@ nsHTMLEditor::CreateAnonymousElement(con
   ps->RecreateFramesFor(newContent);
 
   newElement.forget(aReturn);
   return NS_OK;
 }
 
 // Removes event listener and calls DeleteRefToAnonymousNode.
 void
-nsHTMLEditor::RemoveListenerAndDeleteRef(const nsAString& aEvent,
-                                         nsIDOMEventListener* aListener,
-                                         bool aUseCapture,
-                                         Element* aElement,
-                                         nsIContent * aParentContent,
-                                         nsIPresShell* aShell)
+HTMLEditor::RemoveListenerAndDeleteRef(const nsAString& aEvent,
+                                       nsIDOMEventListener* aListener,
+                                       bool aUseCapture,
+                                       Element* aElement,
+                                       nsIContent* aParentContent,
+                                       nsIPresShell* aShell)
 {
   nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
   if (evtTarget) {
     evtTarget->RemoveEventListener(aEvent, aListener, aUseCapture);
   }
   DeleteRefToAnonymousNode(static_cast<nsIDOMElement*>(GetAsDOMNode(aElement)), aParentContent, aShell);
 }
 
 // Deletes all references to an anonymous element
 void
-nsHTMLEditor::DeleteRefToAnonymousNode(nsIDOMElement* aElement,
-                                       nsIContent* aParentContent,
-                                       nsIPresShell* aShell)
+HTMLEditor::DeleteRefToAnonymousNode(nsIDOMElement* aElement,
+                                     nsIContent* aParentContent,
+                                     nsIPresShell* aShell)
 {
   // call ContentRemoved() for the anonymous content
   // node so its references get removed from the frame manager's
   // undisplay map, and its layout frames get destroyed!
 
   if (aElement) {
     nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
     if (content) {
@@ -260,17 +267,17 @@ nsHTMLEditor::DeleteRefToAnonymousNode(n
   }
 }
 
 // The following method is mostly called by a selection listener. When a
 // selection change is notified, the method is called to check if resizing
 // handles, a grabber and/or inline table editing UI need to be displayed
 // or refreshed
 NS_IMETHODIMP
-nsHTMLEditor::CheckSelectionStateForAnonymousButtons(nsISelection * aSelection)
+HTMLEditor::CheckSelectionStateForAnonymousButtons(nsISelection* aSelection)
 {
   NS_ENSURE_ARG_POINTER(aSelection);
 
   // early way out if all contextual UI extensions are disabled
   NS_ENSURE_TRUE(mIsObjectResizingEnabled ||
       mIsAbsolutelyPositioningEnabled ||
       mIsInlineTableEditingEnabled, NS_OK);
 
@@ -400,23 +407,25 @@ nsHTMLEditor::CheckSelectionStateForAnon
   }
 
   return res;
 }
 
 // Resizing and Absolute Positioning need to know everything about the
 // containing box of the element: position, size, margins, borders
 nsresult
-nsHTMLEditor::GetPositionAndDimensions(nsIDOMElement * aElement,
-                                       int32_t & aX, int32_t & aY,
-                                       int32_t & aW, int32_t & aH,
-                                       int32_t & aBorderLeft,
-                                       int32_t & aBorderTop,
-                                       int32_t & aMarginLeft,
-                                       int32_t & aMarginTop)
+HTMLEditor::GetPositionAndDimensions(nsIDOMElement* aElement,
+                                     int32_t& aX,
+                                     int32_t& aY,
+                                     int32_t& aW,
+                                     int32_t& aH,
+                                     int32_t& aBorderLeft,
+                                     int32_t& aBorderTop,
+                                     int32_t& aMarginLeft,
+                                     int32_t& aMarginTop)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_ARG_POINTER(element);
 
   // Is the element positioned ? let's check the cheap way first...
   bool isPositioned = false;
   nsresult res = aElement->HasAttribute(NS_LITERAL_STRING("_moz_abspos"), &isPositioned);
   NS_ENSURE_SUCCESS(res, res);
@@ -466,13 +475,17 @@ nsHTMLEditor::GetPositionAndDimensions(n
     aMarginLeft = 0;
     aMarginTop = 0;
   }
   return res;
 }
 
 // self-explanatory
 void
-nsHTMLEditor::SetAnonymousElementPosition(int32_t aX, int32_t aY, nsIDOMElement *aElement)
+HTMLEditor::SetAnonymousElementPosition(int32_t aX,
+                                        int32_t aY,
+                                        nsIDOMElement* aElement)
 {
   mCSSEditUtils->SetCSSPropertyPixels(aElement, NS_LITERAL_STRING("left"), aX);
   mCSSEditUtils->SetCSSPropertyPixels(aElement, NS_LITERAL_STRING("top"), aY);
 }
+
+} // namespace mozilla
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -9,16 +9,17 @@
 #include <stdlib.h>
 
 #include "CSSEditUtils.h"
 #include "EditorUtils.h"
 #include "HTMLEditUtils.h"
 #include "TextEditUtils.h"
 #include "WSRunObject.h"
 #include "mozilla/Assertions.h"
+#include "mozilla/HTMLEditor.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/OwningNonNull.h"
 #include "mozilla/mozalloc.h"
 #include "nsAutoPtr.h"
 #include "nsAString.h"
@@ -26,17 +27,16 @@
 #include "nsCRT.h"
 #include "nsCRTGlue.h"
 #include "nsComponentManagerUtils.h"
 #include "nsContentUtils.h"
 #include "nsDebug.h"
 #include "nsEditor.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
-#include "nsHTMLEditor.h"
 #include "nsIAtom.h"
 #include "nsIContent.h"
 #include "nsIContentIterator.h"
 #include "nsID.h"
 #include "nsIDOMCharacterData.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNode.h"
@@ -81,17 +81,17 @@ enum
 };
 
 /********************************************************
  *  first some helpful functors we will use
  ********************************************************/
 
 static bool IsBlockNode(const nsINode& node)
 {
-  return nsHTMLEditor::NodeIsBlockStatic(&node);
+  return HTMLEditor::NodeIsBlockStatic(&node);
 }
 
 static bool IsInlineNode(const nsINode& node)
 {
   return !IsBlockNode(node);
 }
 
 static bool
@@ -128,18 +128,18 @@ public:
   {
     return aNode->IsHTMLElement(nsGkAtoms::br);
   }
 };
 
 class EmptyEditableFunctor final : public BoolDomIterFunctor
 {
 public:
-  explicit EmptyEditableFunctor(nsHTMLEditor* editor)
-    : mHTMLEditor(editor)
+  explicit EmptyEditableFunctor(HTMLEditor* aHTMLEditor)
+    : mHTMLEditor(aHTMLEditor)
   {}
 
   virtual bool operator()(nsINode* aNode) const
   {
     if (mHTMLEditor->IsEditable(aNode) &&
         (HTMLEditUtils::IsListItem(aNode) ||
          HTMLEditUtils::IsTableCellOrCaption(*aNode))) {
       bool bIsEmptyNode;
@@ -147,17 +147,17 @@ public:
       NS_ENSURE_SUCCESS(res, false);
       if (bIsEmptyNode)
         return true;
     }
     return false;
   }
 
 protected:
-  nsHTMLEditor* mHTMLEditor;
+  HTMLEditor* mHTMLEditor;
 };
 
 /********************************************************
  * mozilla::HTMLEditRules
  ********************************************************/
 
 HTMLEditRules::HTMLEditRules()
   : mHTMLEditor(nullptr)
@@ -206,17 +206,17 @@ HTMLEditRules::InitFields()
   mCachedStyles[17] = StyleCache(nsGkAtoms::sub, EmptyString(), EmptyString());
   mCachedStyles[18] = StyleCache(nsGkAtoms::sup, EmptyString(), EmptyString());
 }
 
 HTMLEditRules::~HTMLEditRules()
 {
   // remove ourselves as a listener to edit actions
   // In some cases, we have already been removed by
-  // ~nsHTMLEditor, in which case we will get a null pointer here
+  // ~HTMLEditor, in which case we will get a null pointer here
   // which we ignore.  But this allows us to add the ability to
   // switch rule sets on the fly if we want.
   if (mHTMLEditor)
     mHTMLEditor->RemoveEditActionListener(this);
 }
 
 NS_IMPL_ADDREF_INHERITED(HTMLEditRules, TextEditRules)
 NS_IMPL_RELEASE_INHERITED(HTMLEditRules, TextEditRules)
@@ -228,17 +228,17 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLE
                                    mDocChangeRange, mUtilRange, mNewBlock,
                                    mRangeItem)
 
 NS_IMETHODIMP
 HTMLEditRules::Init(nsPlaintextEditor* aTextEditor)
 {
   InitFields();
 
-  mHTMLEditor = static_cast<nsHTMLEditor*>(aTextEditor);
+  mHTMLEditor = static_cast<HTMLEditor*>(aTextEditor);
   nsresult res;
 
   // call through to base class Init
   res = TextEditRules::Init(aTextEditor);
   NS_ENSURE_SUCCESS(res, res);
 
   // cache any prefs we care about
   static const char kPrefName[] =
@@ -1607,17 +1607,17 @@ HTMLEditRules::StandardBreakImpl(nsINode
     nsCOMPtr<nsIDOMNode> linkDOMNode;
     if (mHTMLEditor->IsInLink(GetAsDOMNode(node), address_of(linkDOMNode))) {
       // Split the link
       nsCOMPtr<Element> linkNode = do_QueryInterface(linkDOMNode);
       NS_ENSURE_STATE(linkNode || !linkDOMNode);
       nsCOMPtr<nsINode> linkParent = linkNode->GetParentNode();
       aOffset = mHTMLEditor->SplitNodeDeep(*linkNode, *node->AsContent(),
                                            aOffset,
-                                           nsHTMLEditor::EmptyContainers::no);
+                                           HTMLEditor::EmptyContainers::no);
       NS_ENSURE_STATE(aOffset != -1);
       node = linkParent;
     }
     brNode = wsObj.InsertBreak(address_of(node), &aOffset, nsIEditor::eNone);
     NS_ENSURE_TRUE(brNode, NS_ERROR_FAILURE);
   }
   node = brNode->GetParentNode();
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
@@ -1715,17 +1715,17 @@ HTMLEditRules::SplitMailCites(Selection*
         selNode = mHTMLEditor->GetNodeLocation(visNode, &selOffset);
         ++selOffset;
       }
     }
 
     NS_ENSURE_STATE(mHTMLEditor);
     NS_ENSURE_STATE(selNode->IsContent());
     int32_t newOffset = mHTMLEditor->SplitNodeDeep(*citeNode,
-        *selNode->AsContent(), selOffset, nsHTMLEditor::EmptyContainers::no,
+        *selNode->AsContent(), selOffset, HTMLEditor::EmptyContainers::no,
         getter_AddRefs(leftCite), getter_AddRefs(rightCite));
     NS_ENSURE_STATE(newOffset != -1);
     selNode = citeNode->GetParentNode();
     NS_ENSURE_STATE(mHTMLEditor);
     nsCOMPtr<Element> brNode = mHTMLEditor->CreateBR(selNode, newOffset);
     NS_ENSURE_STATE(brNode);
     // want selection before the break, and on same line
     aSelection->SetInterlinePosition(true);
@@ -3382,17 +3382,17 @@ HTMLEditRules::WillMakeBasicBlock(Select
           mHTMLEditor->GetNextHTMLNode(parent, offset);
         if (brNode && brNode->IsHTMLElement(nsGkAtoms::br)) {
           res = mHTMLEditor->DeleteNode(brNode);
           NS_ENSURE_SUCCESS(res, res);
         }
         // Do the splits!
         offset = mHTMLEditor->SplitNodeDeep(curBlock, *parent->AsContent(),
                                             offset,
-                                            nsHTMLEditor::EmptyContainers::no);
+                                            HTMLEditor::EmptyContainers::no);
         NS_ENSURE_STATE(offset != -1);
         // Put a br at the split point
         brNode = mHTMLEditor->CreateBR(curBlock->GetParentNode(), offset);
         NS_ENSURE_STATE(brNode);
         // Put selection at the split point
         res = aSelection.Collapse(curBlock->GetParentNode(), offset);
         // Don't restore the selection
         selectionRestorer.Abort();
@@ -4217,28 +4217,28 @@ HTMLEditRules::SplitBlock(Element& aBloc
 
   // Get split point location
   OwningNonNull<nsIContent> startParent = *aStartChild.GetParent();
   int32_t startOffset = startParent->IndexOf(&aStartChild);
 
   // Do the splits!
   nsCOMPtr<nsIContent> newMiddleNode1;
   mHTMLEditor->SplitNodeDeep(aBlock, startParent, startOffset,
-                             nsHTMLEditor::EmptyContainers::no,
+                             HTMLEditor::EmptyContainers::no,
                              aOutLeftNode, getter_AddRefs(newMiddleNode1));
 
   // Get split point location
   OwningNonNull<nsIContent> endParent = *aEndChild.GetParent();
   // +1 because we want to be after the child
   int32_t endOffset = 1 + endParent->IndexOf(&aEndChild);
 
   // Do the splits!
   nsCOMPtr<nsIContent> newMiddleNode2;
   mHTMLEditor->SplitNodeDeep(aBlock, endParent, endOffset,
-                             nsHTMLEditor::EmptyContainers::no,
+                             HTMLEditor::EmptyContainers::no,
                              getter_AddRefs(newMiddleNode2), aOutRightNode);
 
   if (aOutMiddleNode) {
     if (newMiddleNode2) {
       newMiddleNode2.forget(aOutMiddleNode);
     } else {
       newMiddleNode1.forget(aOutMiddleNode);
     }
@@ -4406,18 +4406,18 @@ HTMLEditRules::CreateStyleForInsertText(
     res = mHTMLEditor->InsertNode(*newNode, *node, offset);
     NS_ENSURE_SUCCESS(res, res);
     node = newNode;
     offset = 0;
     weDidSomething = true;
 
     if (relFontSize) {
       // dir indicated bigger versus smaller.  1 = bigger, -1 = smaller
-      nsHTMLEditor::FontSize dir = relFontSize > 0 ?
-        nsHTMLEditor::FontSize::incr : nsHTMLEditor::FontSize::decr;
+      HTMLEditor::FontSize dir = relFontSize > 0 ?
+        HTMLEditor::FontSize::incr : HTMLEditor::FontSize::decr;
       for (int32_t j = 0; j < DeprecatedAbs(relFontSize); j++) {
         NS_ENSURE_STATE(mHTMLEditor);
         res = mHTMLEditor->RelativeFontChangeOnTextNode(dir, newNode, 0, -1);
         NS_ENSURE_SUCCESS(res, res);
       }
     }
 
     while (item) {
@@ -4956,17 +4956,17 @@ HTMLEditRules::ExpandSelectionForDeletio
 
   nsCOMPtr<nsINode> selStartNode = range->GetStartParent();
   int32_t selStartOffset = range->StartOffset();
   nsCOMPtr<nsINode> selEndNode = range->GetEndParent();
   int32_t selEndOffset = range->EndOffset();
 
   // Find current selection common block parent
   nsCOMPtr<Element> selCommon =
-    nsHTMLEditor::GetBlock(*range->GetCommonAncestor());
+    HTMLEditor::GetBlock(*range->GetCommonAncestor());
   NS_ENSURE_STATE(selCommon);
 
   // Set up for loops and cache our root element
   nsCOMPtr<nsINode> firstBRParent;
   nsCOMPtr<nsINode> unused;
   int32_t visOffset = 0, firstBROffset = 0;
   WSType wsType;
   nsCOMPtr<Element> root = mHTMLEditor->GetActiveEditingHost();
@@ -5030,17 +5030,17 @@ HTMLEditRules::ExpandSelectionForDeletio
   aSelection.Collapse(selStartNode, selStartOffset);
 
   // Expand selection endpoint only if we didn't pass a br, or if we really
   // needed to pass that br (i.e., its block is now totally selected)
   nsresult res;
   bool doEndExpansion = true;
   if (firstBRParent) {
     // Find block node containing br
-    nsCOMPtr<Element> brBlock = nsHTMLEditor::GetBlock(*firstBRParent);
+    nsCOMPtr<Element> brBlock = HTMLEditor::GetBlock(*firstBRParent);
     bool nodeBefore = false, nodeAfter = false;
 
     // Create a range that represents expanded selection
     RefPtr<nsRange> range = new nsRange(selStartNode);
     res = range->SetStart(selStartNode, selStartOffset);
     NS_ENSURE_SUCCESS(res, res);
     res = range->SetEnd(selEndNode, selEndOffset);
     NS_ENSURE_SUCCESS(res, res);
@@ -5964,17 +5964,17 @@ HTMLEditRules::BustUpInlinesAtBRs(
     OwningNonNull<Element> breakNode = *arrayOfBreaks[i]->AsElement();
     NS_ENSURE_TRUE(splitDeepNode, NS_ERROR_NULL_POINTER);
     NS_ENSURE_TRUE(breakNode->GetParent(), NS_ERROR_NULL_POINTER);
     OwningNonNull<nsIContent> splitParentNode = *breakNode->GetParent();
     int32_t splitOffset = splitParentNode->IndexOf(breakNode);
 
     int32_t resultOffset =
       mHTMLEditor->SplitNodeDeep(*splitDeepNode, splitParentNode, splitOffset,
-                                 nsHTMLEditor::EmptyContainers::yes,
+                                 HTMLEditor::EmptyContainers::yes,
                                  getter_AddRefs(leftNode),
                                  getter_AddRefs(rightNode));
     NS_ENSURE_STATE(resultOffset != -1);
 
     // Put left node in node list
     if (leftNode) {
       // Might not be a left node.  A break might have been at the very
       // beginning of inline container, in which case SplitNodeDeep would not
@@ -6333,17 +6333,17 @@ HTMLEditRules::SplitParagraph(nsIDOMNode
   res = WSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor,
                                                 address_of(selNode), aOffset);
   *aSelNode = GetAsDOMNode(selNode);
   NS_ENSURE_SUCCESS(res, res);
   // split the paragraph
   NS_ENSURE_STATE(mHTMLEditor);
   NS_ENSURE_STATE(selNode->IsContent());
   mHTMLEditor->SplitNodeDeep(*para, *selNode->AsContent(), *aOffset,
-                             nsHTMLEditor::EmptyContainers::yes,
+                             HTMLEditor::EmptyContainers::yes,
                              getter_AddRefs(leftPara),
                              getter_AddRefs(rightPara));
   // get rid of the break, if it is visible (otherwise it may be needed to prevent an empty p)
   NS_ENSURE_STATE(mHTMLEditor);
   if (mHTMLEditor->IsVisBreak(aBRNode))
   {
     NS_ENSURE_STATE(mHTMLEditor);
     res = mHTMLEditor->DeleteNode(aBRNode);
@@ -8436,17 +8436,17 @@ HTMLEditRules::ChangeIndentation(Element
 
   mHTMLEditor->mCSSEditUtils->RemoveCSSProperty(aElement, marginProperty,
                                                 value);
 
   // Remove unnecessary divs
   if (!aElement.IsHTMLElement(nsGkAtoms::div) ||
       &aElement == mHTMLEditor->GetActiveEditingHost() ||
       !mHTMLEditor->IsDescendantOfEditorRoot(&aElement) ||
-      nsHTMLEditor::HasAttributes(&aElement)) {
+      HTMLEditor::HasAttributes(&aElement)) {
     return NS_OK;
   }
 
   nsresult res = mHTMLEditor->RemoveContainer(&aElement);
   NS_ENSURE_SUCCESS(res, res);
 
   return NS_OK;
 }
--- a/editor/libeditor/HTMLEditRules.h
+++ b/editor/libeditor/HTMLEditRules.h
@@ -13,29 +13,29 @@
 #include "nsEditor.h"
 #include "nsIEditActionListener.h"
 #include "nsIEditor.h"
 #include "nsIHTMLEditor.h"
 #include "nsISupportsImpl.h"
 #include "nsTArray.h"
 #include "nscore.h"
 
-class nsHTMLEditor;
 class nsIAtom;
 class nsIDOMCharacterData;
 class nsIDOMDocument;
 class nsIDOMElement;
 class nsIDOMNode;
 class nsIEditor;
 class nsINode;
 class nsPlaintextEditor;
 class nsRange;
 
 namespace mozilla {
 
+class HTMLEditor;
 class RulesInfo;
 struct EditorDOMPoint;
 namespace dom {
 class Element;
 class Selection;
 } // namespace dom
 
 struct StyleCache final : public PropItem
@@ -352,17 +352,17 @@ protected:
   enum class ContentsOnly { no, yes };
   nsresult AlignBlock(Element& aElement,
                       const nsAString& aAlignType, ContentsOnly aContentsOnly);
   enum class Change { minus, plus };
   nsresult ChangeIndentation(Element& aElement, Change aChange);
   void DocumentModifiedWorker();
 
 protected:
-  nsHTMLEditor* mHTMLEditor;
+  HTMLEditor* mHTMLEditor;
   RefPtr<nsRange> mDocChangeRange;
   bool mListenerEnabled;
   bool mReturnInEmptyLIKillsList;
   bool mDidDeleteSelection;
   bool mDidRangedDelete;
   bool mRestoreContentEditableCount;
   RefPtr<nsRange> mUtilRange;
   // Need to remember an int across willJoin/didJoin...
rename from editor/libeditor/nsHTMLEditor.cpp
rename to editor/libeditor/HTMLEditor.cpp
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1,14 +1,14 @@
 /* -*- 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 "nsHTMLEditor.h"
+#include "mozilla/HTMLEditor.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/TextEvents.h"
 
 #include "nsCRT.h"
 
 #include "nsUnicharUtils.h"
@@ -54,92 +54,93 @@
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 
 // Misc
 #include "EditorUtils.h"
 #include "TextEditorTest.h"
 #include "WSRunObject.h"
 #include "nsGkAtoms.h"
+#include "nsHTMLObjectResizer.h"
 #include "nsIWidget.h"
 
 #include "nsIFrame.h"
 #include "nsIParserService.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/EventTarget.h"
 #include "mozilla/dom/HTMLBodyElement.h"
 #include "nsTextFragment.h"
 #include "nsContentList.h"
 #include "mozilla/StyleSheetHandle.h"
 #include "mozilla/StyleSheetHandleInlines.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
-using namespace mozilla::widget;
+namespace mozilla {
+
+using namespace dom;
+using namespace widget;
 
 // Some utilities to handle overloading of "A" tag for link and named anchor.
 static bool
 IsLinkTag(const nsString& s)
 {
   return s.EqualsIgnoreCase("href");
 }
 
 static bool
 IsNamedAnchorTag(const nsString& s)
 {
   return s.EqualsIgnoreCase("anchor") || s.EqualsIgnoreCase("namedanchor");
 }
 
-nsHTMLEditor::nsHTMLEditor()
-: nsPlaintextEditor()
-, mCRInParagraphCreatesParagraph(false)
-, mCSSAware(false)
-, mSelectedCellIndex(0)
-, mIsObjectResizingEnabled(true)
-, mIsResizing(false)
-, mPreserveRatio(false)
-, mResizedObjectIsAnImage(false)
-, mIsAbsolutelyPositioningEnabled(true)
-, mResizedObjectIsAbsolutelyPositioned(false)
-, mGrabberClicked(false)
-, mIsMoving(false)
-, mSnapToGridEnabled(false)
-, mIsInlineTableEditingEnabled(true)
-, mOriginalX(0)
-, mOriginalY(0)
-, mResizedObjectX(0)
-, mResizedObjectY(0)
-, mResizedObjectWidth(0)
-, mResizedObjectHeight(0)
-, mResizedObjectMarginLeft(0)
-, mResizedObjectMarginTop(0)
-, mResizedObjectBorderLeft(0)
-, mResizedObjectBorderTop(0)
-, mXIncrementFactor(0)
-, mYIncrementFactor(0)
-, mWidthIncrementFactor(0)
-, mHeightIncrementFactor(0)
-, mInfoXIncrement(20)
-, mInfoYIncrement(20)
-, mPositionedObjectX(0)
-, mPositionedObjectY(0)
-, mPositionedObjectWidth(0)
-, mPositionedObjectHeight(0)
-, mPositionedObjectMarginLeft(0)
-, mPositionedObjectMarginTop(0)
-, mPositionedObjectBorderLeft(0)
-, mPositionedObjectBorderTop(0)
-, mGridSize(0)
+HTMLEditor::HTMLEditor()
+  : mCRInParagraphCreatesParagraph(false)
+  , mCSSAware(false)
+  , mSelectedCellIndex(0)
+  , mIsObjectResizingEnabled(true)
+  , mIsResizing(false)
+  , mPreserveRatio(false)
+  , mResizedObjectIsAnImage(false)
+  , mIsAbsolutelyPositioningEnabled(true)
+  , mResizedObjectIsAbsolutelyPositioned(false)
+  , mGrabberClicked(false)
+  , mIsMoving(false)
+  , mSnapToGridEnabled(false)
+  , mIsInlineTableEditingEnabled(true)
+  , mOriginalX(0)
+  , mOriginalY(0)
+  , mResizedObjectX(0)
+  , mResizedObjectY(0)
+  , mResizedObjectWidth(0)
+  , mResizedObjectHeight(0)
+  , mResizedObjectMarginLeft(0)
+  , mResizedObjectMarginTop(0)
+  , mResizedObjectBorderLeft(0)
+  , mResizedObjectBorderTop(0)
+  , mXIncrementFactor(0)
+  , mYIncrementFactor(0)
+  , mWidthIncrementFactor(0)
+  , mHeightIncrementFactor(0)
+  , mInfoXIncrement(20)
+  , mInfoYIncrement(20)
+  , mPositionedObjectX(0)
+  , mPositionedObjectY(0)
+  , mPositionedObjectWidth(0)
+  , mPositionedObjectHeight(0)
+  , mPositionedObjectMarginLeft(0)
+  , mPositionedObjectMarginTop(0)
+  , mPositionedObjectBorderLeft(0)
+  , mPositionedObjectBorderTop(0)
+  , mGridSize(0)
 {
 }
 
-nsHTMLEditor::~nsHTMLEditor()
+HTMLEditor::~HTMLEditor()
 {
   // remove the rules as an action listener.  Else we get a bad
   // ownership loop later on.  it's ok if the rules aren't a listener;
   // we ignore the error.
   nsCOMPtr<nsIEditActionListener> mListener = do_QueryInterface(mRules);
   RemoveEditActionListener(mListener);
 
   //the autopointers will clear themselves up.
@@ -175,36 +176,36 @@ nsHTMLEditor::~nsHTMLEditor()
       ps->GetPresContext()->SetLinkHandler(mLinkHandler);
     }
   }
 
   RemoveEventListeners();
 }
 
 void
-nsHTMLEditor::HideAnonymousEditingUIs()
+HTMLEditor::HideAnonymousEditingUIs()
 {
   if (mAbsolutelyPositionedObject)
     HideGrabber();
   if (mInlineEditedCell)
     HideInlineTableEditingUI();
   if (mResizedObject)
     HideResizers();
 }
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLEditor)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLEditor, nsPlaintextEditor)
+NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLEditor)
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLEditor, nsPlaintextEditor)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mTypeInState)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mStyleSheets)
 
   tmp->HideAnonymousEditingUIs();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLEditor, nsPlaintextEditor)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLEditor, nsPlaintextEditor)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTypeInState)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleSheets)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTopLeftHandle)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTopHandle)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTopRightHandle)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLeftHandle)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRightHandle)
@@ -228,37 +229,36 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAddColumnBeforeButton)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRemoveColumnButton)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAddColumnAfterButton)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAddRowBeforeButton)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRemoveRowButton)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAddRowAfterButton)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_ADDREF_INHERITED(nsHTMLEditor, nsEditor)
-NS_IMPL_RELEASE_INHERITED(nsHTMLEditor, nsEditor)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsHTMLEditor)
+NS_IMPL_ADDREF_INHERITED(HTMLEditor, nsEditor)
+NS_IMPL_RELEASE_INHERITED(HTMLEditor, nsEditor)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(HTMLEditor)
   NS_INTERFACE_MAP_ENTRY(nsIHTMLEditor)
   NS_INTERFACE_MAP_ENTRY(nsIHTMLObjectResizer)
   NS_INTERFACE_MAP_ENTRY(nsIHTMLAbsPosEditor)
   NS_INTERFACE_MAP_ENTRY(nsIHTMLInlineTableEditor)
   NS_INTERFACE_MAP_ENTRY(nsITableEditor)
   NS_INTERFACE_MAP_ENTRY(nsIEditorStyleSheets)
   NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
   NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
 NS_INTERFACE_MAP_END_INHERITING(nsPlaintextEditor)
 
-
 NS_IMETHODIMP
-nsHTMLEditor::Init(nsIDOMDocument *aDoc,
-                   nsIContent *aRoot,
-                   nsISelectionController *aSelCon,
-                   uint32_t aFlags,
-                   const nsAString& aInitialValue)
+HTMLEditor::Init(nsIDOMDocument* aDoc,
+                 nsIContent* aRoot,
+                 nsISelectionController* aSelCon,
+                 uint32_t aFlags,
+                 const nsAString& aInitialValue)
 {
   NS_PRECONDITION(aDoc && !aSelCon, "bad arg");
   NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
   MOZ_ASSERT(aInitialValue.IsEmpty(), "Non-empty initial values not supported");
 
   nsresult result = NS_OK, rulesRes = NS_OK;
 
   if (1)
@@ -321,17 +321,17 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
     }
   }
 
   NS_ENSURE_SUCCESS(rulesRes, rulesRes);
   return result;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::PreDestroy(bool aDestroyingFrames)
+HTMLEditor::PreDestroy(bool aDestroyingFrames)
 {
   if (mDidPreDestroy) {
     return NS_OK;
   }
 
   nsCOMPtr<nsINode> document = do_QueryReferent(mDocWeak);
   if (document) {
     document->RemoveMutationObserver(this);
@@ -345,17 +345,17 @@ nsHTMLEditor::PreDestroy(bool aDestroyin
   // Clean up after our anonymous content -- we don't want these nodes to
   // stay around (which they would, since the frames have an owning reference).
   HideAnonymousEditingUIs();
 
   return nsPlaintextEditor::PreDestroy(aDestroyingFrames);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetRootElement(nsIDOMElement **aRootElement)
+HTMLEditor::GetRootElement(nsIDOMElement** aRootElement)
 {
   NS_ENSURE_ARG_POINTER(aRootElement);
 
   if (mRootElement) {
     return nsEditor::GetRootElement(aRootElement);
   }
 
   *aRootElement = nullptr;
@@ -386,17 +386,17 @@ nsHTMLEditor::GetRootElement(nsIDOMEleme
 
   mRootElement = do_QueryInterface(rootElement);
   rootElement.forget(aRootElement);
 
   return NS_OK;
 }
 
 already_AddRefed<nsIContent>
-nsHTMLEditor::FindSelectionRoot(nsINode *aNode)
+HTMLEditor::FindSelectionRoot(nsINode* aNode)
 {
   NS_PRECONDITION(aNode->IsNodeOfType(nsINode::eDOCUMENT) ||
                   aNode->IsNodeOfType(nsINode::eCONTENT),
                   "aNode must be content or document node");
 
   nsCOMPtr<nsIDocument> doc = aNode->GetUncomposedDoc();
   if (!doc) {
     return nullptr;
@@ -429,42 +429,41 @@ nsHTMLEditor::FindSelectionRoot(nsINode 
   }
 
   // For non-readonly editors we want to find the root of the editable subtree
   // containing aContent.
   content = content->GetEditingHost();
   return content.forget();
 }
 
-/* virtual */
 void
-nsHTMLEditor::CreateEventListeners()
+HTMLEditor::CreateEventListeners()
 {
   // Don't create the handler twice
   if (!mEventListener) {
     mEventListener = new HTMLEditorEventListener();
   }
 }
 
 nsresult
-nsHTMLEditor::InstallEventListeners()
+HTMLEditor::InstallEventListeners()
 {
   NS_ENSURE_TRUE(mDocWeak && mEventListener,
                  NS_ERROR_NOT_INITIALIZED);
 
-  // NOTE: nsHTMLEditor doesn't need to initialize mEventTarget here because
+  // NOTE: HTMLEditor doesn't need to initialize mEventTarget here because
   // the target must be document node and it must be referenced as weak pointer.
 
   HTMLEditorEventListener* listener =
     reinterpret_cast<HTMLEditorEventListener*>(mEventListener.get());
   return listener->Connect(this);
 }
 
 void
-nsHTMLEditor::RemoveEventListeners()
+HTMLEditor::RemoveEventListeners()
 {
   if (!mDocWeak)
   {
     return;
   }
 
   nsCOMPtr<nsIDOMEventTarget> target = GetDOMEventTarget();
 
@@ -496,41 +495,41 @@ nsHTMLEditor::RemoveEventListeners()
 
   mMouseMotionListenerP = nullptr;
   mResizeEventListenerP = nullptr;
 
   nsPlaintextEditor::RemoveEventListeners();
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetFlags(uint32_t aFlags)
+HTMLEditor::SetFlags(uint32_t aFlags)
 {
   nsresult rv = nsPlaintextEditor::SetFlags(aFlags);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Sets mCSSAware to correspond to aFlags. This toggles whether CSS is
   // used to style elements in the editor. Note that the editor is only CSS
   // aware by default in Composer and in the mail editor.
   mCSSAware = !NoCSS() && !IsMailEditor();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::InitRules()
+HTMLEditor::InitRules()
 {
   if (!mRules) {
     // instantiate the rules for the html editor
     mRules = new HTMLEditRules();
   }
   return mRules->Init(static_cast<nsPlaintextEditor*>(this));
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::BeginningOfDocument()
+HTMLEditor::BeginningOfDocument()
 {
   if (!mDocWeak) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // Get the selection
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
@@ -598,17 +597,17 @@ nsHTMLEditor::BeginningOfDocument()
       selOffset = curOffset;
       done = true;
     }
   }
   return selection->Collapse(selNode, selOffset);
 }
 
 nsresult
-nsHTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
+HTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
 {
   // NOTE: When you change this method, you should also change:
   //   * editor/libeditor/tests/test_htmleditor_keyevent_handling.html
 
   if (IsReadonly() || IsDisabled()) {
     // When we're not editable, the events are handled on nsEditor, so, we can
     // bypass nsPlaintextEditor.
     return nsEditor::HandleKeyPressEvent(aKeyEvent);
@@ -752,17 +751,17 @@ AssertParserServiceIsCorrect(nsIAtom* aT
 #endif // DEBUG
 }
 
 /**
  * Returns true if the id represents an element of block type.
  * Can be used to determine if a new paragraph should be started.
  */
 bool
-nsHTMLEditor::NodeIsBlockStatic(const nsINode* aElement)
+HTMLEditor::NodeIsBlockStatic(const nsINode* aElement)
 {
   MOZ_ASSERT(aElement);
 
   // Nodes we know we want to treat as block
   // even though the parser says they're not:
   if (aElement->IsAnyOfHTMLElements(nsGkAtoms::body,
                                     nsGkAtoms::head,
                                     nsGkAtoms::tbody,
@@ -790,109 +789,111 @@ nsHTMLEditor::NodeIsBlockStatic(const ns
   MOZ_ASSERT(rv == NS_OK);
 
   AssertParserServiceIsCorrect(aElement->NodeInfo()->NameAtom(), isBlock);
 
   return isBlock;
 }
 
 nsresult
-nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, bool *aIsBlock)
+HTMLEditor::NodeIsBlockStatic(nsIDOMNode* aNode,
+                              bool* aIsBlock)
 {
   if (!aNode || !aIsBlock) { return NS_ERROR_NULL_POINTER; }
 
   nsCOMPtr<dom::Element> element = do_QueryInterface(aNode);
   *aIsBlock = element && NodeIsBlockStatic(element);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::NodeIsBlock(nsIDOMNode *aNode, bool *aIsBlock)
+HTMLEditor::NodeIsBlock(nsIDOMNode* aNode,
+                        bool* aIsBlock)
 {
   return NodeIsBlockStatic(aNode, aIsBlock);
 }
 
 bool
-nsHTMLEditor::IsBlockNode(nsINode *aNode)
+HTMLEditor::IsBlockNode(nsINode* aNode)
 {
   return aNode && NodeIsBlockStatic(aNode);
 }
 
 // Non-static version for the nsIEditor interface and JavaScript
 NS_IMETHODIMP
-nsHTMLEditor::SetDocumentTitle(const nsAString &aTitle)
+HTMLEditor::SetDocumentTitle(const nsAString& aTitle)
 {
   RefPtr<SetDocumentTitleTransaction> transaction =
     new SetDocumentTitleTransaction();
   NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
 
   nsresult rv = transaction->Init(this, &aTitle);
   NS_ENSURE_SUCCESS(rv, rv);
 
   //Don't let Rules System change the selection
   AutoTransactionsConserveSelection dontChangeSelection(this);
   return nsEditor::DoTransaction(transaction);
 }
 
-/* ------------ Block methods moved from nsEditor -------------- */
-///////////////////////////////////////////////////////////////////////////
-// GetBlockNodeParent: returns enclosing block level ancestor, if any
-//
+/**
+ * GetBlockNodeParent returns enclosing block level ancestor, if any.
+ */
 Element*
-nsHTMLEditor::GetBlockNodeParent(nsINode* aNode)
+HTMLEditor::GetBlockNodeParent(nsINode* aNode)
 {
   MOZ_ASSERT(aNode);
 
   nsCOMPtr<nsINode> p = aNode->GetParentNode();
 
   while (p) {
     if (NodeIsBlockStatic(p)) {
       return p->AsElement();
     }
     p = p->GetParentNode();
   }
 
   return nullptr;
 }
 
 nsIDOMNode*
-nsHTMLEditor::GetBlockNodeParent(nsIDOMNode *aNode)
+HTMLEditor::GetBlockNodeParent(nsIDOMNode* aNode)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
 
   if (!node) {
     NS_NOTREACHED("null node passed to GetBlockNodeParent()");
     return nullptr;
   }
 
   return GetAsDOMNode(GetBlockNodeParent(node));
 }
 
 /**
  * Returns the node if it's a block, otherwise GetBlockNodeParent
  */
 Element*
-nsHTMLEditor::GetBlock(nsINode& aNode)
+HTMLEditor::GetBlock(nsINode& aNode)
 {
   if (NodeIsBlockStatic(&aNode)) {
     return aNode.AsElement();
   }
   return GetBlockNodeParent(&aNode);
 }
 
-///////////////////////////////////////////////////////////////////////////////
-// IsNextCharInNodeWhitespace: checks the adjacent content in the same node to
-//                             see if following selection is whitespace or nbsp
+/**
+ * IsNextCharInNodeWhitespace() checks the adjacent content in the same node to
+ * see if following selection is whitespace or nbsp.
+ */
 void
-nsHTMLEditor::IsNextCharInNodeWhitespace(nsIContent* aContent,
-                                         int32_t aOffset,
-                                         bool* outIsSpace,
-                                         bool* outIsNBSP,
-                                         nsIContent** outNode,
-                                         int32_t* outOffset)
+HTMLEditor::IsNextCharInNodeWhitespace(nsIContent* aContent,
+                                       int32_t aOffset,
+                                       bool* outIsSpace,
+                                       bool* outIsNBSP,
+                                       nsIContent** outNode,
+                                       int32_t* outOffset)
 {
   MOZ_ASSERT(aContent && outIsSpace && outIsNBSP);
   MOZ_ASSERT((outNode && outOffset) || (!outNode && !outOffset));
   *outIsSpace = false;
   *outIsNBSP = false;
   if (outNode && outOffset) {
     *outNode = nullptr;
     *outOffset = -1;
@@ -907,26 +908,27 @@ nsHTMLEditor::IsNextCharInNodeWhitespace
       NS_IF_ADDREF(*outNode = aContent);
       // yes, this is _past_ the character
       *outOffset = aOffset + 1;
     }
   }
 }
 
 
-///////////////////////////////////////////////////////////////////////////////
-// IsPrevCharInNodeWhitespace: checks the adjacent content in the same node to
-//                             see if following selection is whitespace
+/**
+ * IsPrevCharInNodeWhitespace() checks the adjacent content in the same node to
+ * see if following selection is whitespace.
+ */
 void
-nsHTMLEditor::IsPrevCharInNodeWhitespace(nsIContent* aContent,
-                                         int32_t aOffset,
-                                         bool* outIsSpace,
-                                         bool* outIsNBSP,
-                                         nsIContent** outNode,
-                                         int32_t* outOffset)
+HTMLEditor::IsPrevCharInNodeWhitespace(nsIContent* aContent,
+                                       int32_t aOffset,
+                                       bool* outIsSpace,
+                                       bool* outIsNBSP,
+                                       nsIContent** outNode,
+                                       int32_t* outOffset)
 {
   MOZ_ASSERT(aContent && outIsSpace && outIsNBSP);
   MOZ_ASSERT((outNode && outOffset) || (!outNode && !outOffset));
   *outIsSpace = false;
   *outIsNBSP = false;
   if (outNode && outOffset) {
     *outNode = nullptr;
     *outOffset = -1;
@@ -938,23 +940,18 @@ nsHTMLEditor::IsPrevCharInNodeWhitespace
     *outIsNBSP = (ch == kNBSP);
     if (outNode && outOffset) {
       NS_IF_ADDREF(*outNode = aContent);
       *outOffset = aOffset - 1;
     }
   }
 }
 
-
-
-/* ------------ End Block methods -------------- */
-
-
 bool
-nsHTMLEditor::IsVisBreak(nsINode* aNode)
+HTMLEditor::IsVisBreak(nsINode* aNode)
 {
   MOZ_ASSERT(aNode);
   if (!TextEditUtils::IsBreak(aNode)) {
     return false;
   }
   // Check if there is a later node in block after br
   nsCOMPtr<nsINode> priorNode = GetPriorHTMLNode(aNode, true);
   if (priorNode && TextEditUtils::IsBreak(priorNode)) {
@@ -990,71 +987,75 @@ nsHTMLEditor::IsVisBreak(nsINode* aNode)
   if (visType & WSType::block) {
     return false;
   }
 
   return true;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetIsDocumentEditable(bool *aIsDocumentEditable)
+HTMLEditor::GetIsDocumentEditable(bool* aIsDocumentEditable)
 {
   NS_ENSURE_ARG_POINTER(aIsDocumentEditable);
 
   nsCOMPtr<nsIDOMDocument> doc = GetDOMDocument();
   *aIsDocumentEditable = doc && IsModifiable();
 
   return NS_OK;
 }
 
-bool nsHTMLEditor::IsModifiable()
+bool
+HTMLEditor::IsModifiable()
 {
   return !IsReadonly();
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::UpdateBaseURL()
+HTMLEditor::UpdateBaseURL()
 {
   nsCOMPtr<nsIDocument> doc = GetDocument();
   NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
 
   // Look for an HTML <base> tag
   RefPtr<nsContentList> nodeList =
     doc->GetElementsByTagName(NS_LITERAL_STRING("base"));
 
   // If no base tag, then set baseURL to the document's URL.  This is very
   // important, else relative URLs for links and images are wrong
   if (!nodeList || !nodeList->Item(0)) {
     doc->SetBaseURI(doc->GetDocumentURI());
   }
   return NS_OK;
 }
 
-/* This routine is needed to provide a bottleneck for typing for logging
-   purposes.  Can't use HandleKeyPress() (above) for that since it takes
-   a nsIDOMKeyEvent* parameter.  So instead we pass enough info through
-   to TypedText() to determine what action to take, but without passing
-   an event.
-   */
+/**
+ * This routine is needed to provide a bottleneck for typing for logging
+ * purposes.  Can't use HandleKeyPress() (above) for that since it takes
+ * a nsIDOMKeyEvent* parameter.  So instead we pass enough info through
+ * to TypedText() to determine what action to take, but without passing
+ * an event.
+ */
 NS_IMETHODIMP
-nsHTMLEditor::TypedText(const nsAString& aString, ETypingAction aAction)
+HTMLEditor::TypedText(const nsAString& aString,
+                      ETypingAction aAction)
 {
   AutoPlaceHolderBatch batch(this, nsGkAtoms::TypingTxnName);
 
   if (aAction == eTypedBR) {
     // only inserts a br node
     nsCOMPtr<nsIDOMNode> brNode;
     return InsertBR(address_of(brNode));
   }
 
   return nsPlaintextEditor::TypedText(aString, aAction);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::TabInTable(bool inIsShift, bool* outHandled)
+HTMLEditor::TabInTable(bool inIsShift,
+                       bool* outHandled)
 {
   NS_ENSURE_TRUE(outHandled, NS_ERROR_NULL_POINTER);
   *outHandled = false;
 
   // Find enclosing table cell from selection (cell may be selected element)
   nsCOMPtr<Element> cellElement =
     GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr);
   // Do nothing -- we didn't find a table cell
@@ -1118,37 +1119,43 @@ nsHTMLEditor::TabInTable(bool inIsShift,
       selection->Collapse(cell, 0);
     }
   }
 
   return NS_OK;
 }
 
 Element*
-nsHTMLEditor::CreateBR(nsINode* aNode, int32_t aOffset, EDirection aSelect)
+HTMLEditor::CreateBR(nsINode* aNode,
+                     int32_t aOffset,
+                     EDirection aSelect)
 {
   nsCOMPtr<nsIDOMNode> parent = GetAsDOMNode(aNode);
   int32_t offset = aOffset;
   nsCOMPtr<nsIDOMNode> outBRNode;
   // We assume everything is fine if the br is not null, irrespective of retval
   CreateBRImpl(address_of(parent), &offset, address_of(outBRNode), aSelect);
   nsCOMPtr<Element> ret = do_QueryInterface(outBRNode);
   return ret;
 }
 
-NS_IMETHODIMP nsHTMLEditor::CreateBR(nsIDOMNode *aNode, int32_t aOffset, nsCOMPtr<nsIDOMNode> *outBRNode, EDirection aSelect)
+NS_IMETHODIMP
+HTMLEditor::CreateBR(nsIDOMNode* aNode,
+                     int32_t aOffset,
+                     nsCOMPtr<nsIDOMNode>* outBRNode,
+                     EDirection aSelect)
 {
   nsCOMPtr<nsIDOMNode> parent = aNode;
   int32_t offset = aOffset;
   return CreateBRImpl(address_of(parent), &offset, outBRNode, aSelect);
 }
 
 void
-nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(
-                                         Selection* aSelection, nsINode* aNode)
+HTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(Selection* aSelection,
+                                                         nsINode* aNode)
 {
   MOZ_ASSERT(aNode);
 
   RefPtr<Selection> selection = aSelection;
   if (!selection) {
     selection = GetSelection();
   }
   if (!selection) {
@@ -1173,17 +1180,17 @@ nsHTMLEditor::CollapseSelectionToDeepest
 
 
 /**
  * This is mostly like InsertHTMLWithCharsetAndContext, but we can't use that
  * because it is selection-based and the rules code won't let us edit under the
  * <head> node
  */
 NS_IMETHODIMP
-nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
+HTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
 {
   // don't do any post processing, rules get confused
   AutoRules beginRulesSniffing(this, EditAction::ignore, nsIEditor::eNone);
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   ForceCompositionEnd();
 
@@ -1248,17 +1255,17 @@ nsHTMLEditor::ReplaceHeadContentsWithHTM
     nsresult res = InsertNode(*child, *headNode, offsetOfNewNode++);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
+HTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
 {
   ForceCompositionEnd();
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<Element> bodyElement = GetRoot();
   NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);
@@ -1400,19 +1407,19 @@ nsHTMLEditor::RebuildDocumentFromSource(
   // Copy all attributes from the div child to current body element
   CloneAttributes(bodyElement, child->AsElement());
 
   // place selection at first editable content
   return BeginningOfDocument();
 }
 
 void
-nsHTMLEditor::NormalizeEOLInsertPosition(nsINode* firstNodeToInsert,
-                                     nsCOMPtr<nsIDOMNode> *insertParentNode,
-                                     int32_t *insertOffset)
+HTMLEditor::NormalizeEOLInsertPosition(nsINode* firstNodeToInsert,
+                                       nsCOMPtr<nsIDOMNode>* insertParentNode,
+                                       int32_t* insertOffset)
 {
   /*
     This function will either correct the position passed in,
     or leave the position unchanged.
 
     When the (first) item to insert is a block level element,
     and our insertion position is after the last visible item in a line,
     i.e. the insertion position is just before a visible line break <br>,
@@ -1473,17 +1480,18 @@ nsHTMLEditor::NormalizeEOLInsertPosition
   int32_t brOffset=0;
   nsCOMPtr<nsIDOMNode> brNode = GetNodeLocation(GetAsDOMNode(nextVisNode), &brOffset);
 
   *insertParentNode = brNode;
   *insertOffset = brOffset + 1;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSelection)
+HTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement,
+                                     bool aDeleteSelection)
 {
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   nsresult res = NS_ERROR_NOT_INITIALIZED;
 
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_TRUE(element, NS_ERROR_NULL_POINTER);
@@ -1572,34 +1580,37 @@ nsHTMLEditor::InsertElementAtSelection(n
       }
     }
   }
   res = mRules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
 
-/*
-  InsertNodeAtPoint: attempts to insert aNode into the document, at a point specified by
-      {*ioParent,*ioOffset}.  Checks with strict dtd to see if containment is allowed.  If not
-      allowed, will attempt to find a parent in the parent hierarchy of *ioParent that will
-      accept aNode as a child.  If such a parent is found, will split the document tree from
-      {*ioParent,*ioOffset} up to parent, and then insert aNode.  ioParent & ioOffset are then
-      adjusted to point to the actual location that aNode was inserted at.  aNoEmptyNodes
-      specifies if the splitting process is allowed to reslt in empty nodes.
-              nsIDOMNode            *aNode           node to insert
-              nsCOMPtr<nsIDOMNode>  *ioParent        insertion parent
-              int32_t               *ioOffset        insertion offset
-              bool                  aNoEmptyNodes    splitting can result in empty nodes?
-*/
+/**
+ * InsertNodeAtPoint() attempts to insert aNode into the document, at a point
+ * specified by {*ioParent,*ioOffset}.  Checks with strict dtd to see if
+ * containment is allowed.  If not allowed, will attempt to find a parent in
+ * the parent hierarchy of *ioParent that will accept aNode as a child.  If
+ * such a parent is found, will split the document tree from
+ * {*ioParent,*ioOffset} up to parent, and then insert aNode.
+ * ioParent & ioOffset are then adjusted to point to the actual location that
+ * aNode was inserted at.  aNoEmptyNodes specifies if the splitting process
+ * is allowed to reslt in empty nodes.
+ *
+ * @param aNode             Node to insert.
+ * @param ioParent          Insertion parent.
+ * @param ioOffset          Insertion offset.
+ * @param aNoEmptyNodes     Splitting can result in empty nodes?
+ */
 nsresult
-nsHTMLEditor::InsertNodeAtPoint(nsIDOMNode *aNode,
-                                nsCOMPtr<nsIDOMNode> *ioParent,
-                                int32_t *ioOffset,
-                                bool aNoEmptyNodes)
+HTMLEditor::InsertNodeAtPoint(nsIDOMNode* aNode,
+                              nsCOMPtr<nsIDOMNode>* ioParent,
+                              int32_t* ioOffset,
+                              bool aNoEmptyNodes)
 {
   nsCOMPtr<nsIContent> node = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE(ioParent, NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE(*ioParent, NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE(ioOffset, NS_ERROR_NULL_POINTER);
 
   nsresult res = NS_OK;
@@ -1639,17 +1650,17 @@ nsHTMLEditor::InsertNodeAtPoint(nsIDOMNo
     *ioOffset = offset;
   }
   // Now we can insert the new node
   res = InsertNode(*node, *parent, *ioOffset);
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SelectElement(nsIDOMElement* aElement)
+HTMLEditor::SelectElement(nsIDOMElement* aElement)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_STATE(element || !aElement);
   nsresult res = NS_ERROR_NULL_POINTER;
 
   // Must be sure that element is contained in the document body
   if (IsDescendantOfEditorRoot(element)) {
     RefPtr<Selection> selection = GetSelection();
@@ -1667,17 +1678,17 @@ nsHTMLEditor::SelectElement(nsIDOMElemen
         res = selection->Extend(parent, offsetInParent + 1);
       }
     }
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
+HTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   NS_ENSURE_STATE(element || !aElement);
   nsresult res = NS_ERROR_NULL_POINTER;
 
   // Be sure the element is contained in the document body
   if (aElement && IsDescendantOfEditorRoot(element)) {
     RefPtr<Selection> selection = GetSelection();
@@ -1689,70 +1700,75 @@ nsHTMLEditor::SetCaretAfterElement(nsIDO
     int32_t offsetInParent = GetChildOffset(aElement, parent);
     // Collapse selection to just after desired element,
     res = selection->Collapse(parent, offsetInParent + 1);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetParagraphFormat(const nsAString& aParagraphFormat)
+HTMLEditor::SetParagraphFormat(const nsAString& aParagraphFormat)
 {
   nsAutoString tag; tag.Assign(aParagraphFormat);
   ToLowerCase(tag);
   if (tag.EqualsLiteral("dd") || tag.EqualsLiteral("dt"))
     return MakeDefinitionItem(tag);
   else
     return InsertBasicBlock(tag);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetParagraphState(bool *aMixed, nsAString &outFormat)
+HTMLEditor::GetParagraphState(bool* aMixed,
+                              nsAString& outFormat)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
   NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
   RefPtr<HTMLEditRules> htmlRules =
     static_cast<HTMLEditRules*>(mRules.get());
 
   return htmlRules->GetParagraphState(aMixed, outFormat);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetBackgroundColorState(bool *aMixed, nsAString &aOutColor)
+HTMLEditor::GetBackgroundColorState(bool* aMixed,
+                                    nsAString& aOutColor)
 {
   nsresult res;
   if (IsCSSEnabled()) {
     // if we are in CSS mode, we have to check if the containing block defines
     // a background color
     res = GetCSSBackgroundColorState(aMixed, aOutColor, true);
   }
   else {
     // in HTML mode, we look only at page's background
     res = GetHTMLBackgroundColorState(aMixed, aOutColor);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetHighlightColorState(bool *aMixed, nsAString &aOutColor)
+HTMLEditor::GetHighlightColorState(bool* aMixed,
+                                   nsAString& aOutColor)
 {
   nsresult res = NS_OK;
   *aMixed = false;
   aOutColor.AssignLiteral("transparent");
   if (IsCSSEnabled()) {
     // in CSS mode, text background can be added by the Text Highlight button
     // we need to query the background of the selection without looking for
     // the block container of the ranges in the selection
     res = GetCSSBackgroundColorState(aMixed, aOutColor, false);
   }
   return res;
 }
 
 nsresult
-nsHTMLEditor::GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor, bool aBlockLevel)
+HTMLEditor::GetCSSBackgroundColorState(bool* aMixed,
+                                       nsAString& aOutColor,
+                                       bool aBlockLevel)
 {
   NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
   *aMixed = false;
   // the default background color is transparent
   aOutColor.AssignLiteral("transparent");
 
   // get selection
   RefPtr<Selection> selection = GetSelection();
@@ -1825,17 +1841,18 @@ nsHTMLEditor::GetCSSBackgroundColorState
       }
       nodeToExamine = nodeToExamine->GetParentNode();
     } while ( aOutColor.EqualsLiteral("transparent") && nodeToExamine );
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetHTMLBackgroundColorState(bool *aMixed, nsAString &aOutColor)
+HTMLEditor::GetHTMLBackgroundColorState(bool* aMixed,
+                                        nsAString& aOutColor)
 {
   //TODO: We don't handle "mixed" correctly!
   NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
   *aMixed = false;
   aOutColor.Truncate();
 
   nsCOMPtr<nsIDOMElement> domElement;
   int32_t selectedCount;
@@ -1870,64 +1887,73 @@ nsHTMLEditor::GetHTMLBackgroundColorStat
   dom::Element* bodyElement = GetRoot();
   NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);
 
   bodyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::bgcolor, aOutColor);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetListState(bool *aMixed, bool *aOL, bool *aUL, bool *aDL)
+HTMLEditor::GetListState(bool* aMixed,
+                         bool* aOL,
+                         bool* aUL,
+                         bool* aDL)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
   NS_ENSURE_TRUE(aMixed && aOL && aUL && aDL, NS_ERROR_NULL_POINTER);
   RefPtr<HTMLEditRules> htmlRules =
     static_cast<HTMLEditRules*>(mRules.get());
 
   return htmlRules->GetListState(aMixed, aOL, aUL, aDL);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetListItemState(bool *aMixed, bool *aLI, bool *aDT, bool *aDD)
+HTMLEditor::GetListItemState(bool* aMixed,
+                             bool* aLI,
+                             bool* aDT,
+                             bool* aDD)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
   NS_ENSURE_TRUE(aMixed && aLI && aDT && aDD, NS_ERROR_NULL_POINTER);
 
   RefPtr<HTMLEditRules> htmlRules =
     static_cast<HTMLEditRules*>(mRules.get());
 
   return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
+HTMLEditor::GetAlignment(bool* aMixed,
+                         nsIHTMLEditor::EAlignment* aAlign)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
   NS_ENSURE_TRUE(aMixed && aAlign, NS_ERROR_NULL_POINTER);
   RefPtr<HTMLEditRules> htmlRules =
     static_cast<HTMLEditRules*>(mRules.get());
 
   return htmlRules->GetAlignment(aMixed, aAlign);
 }
 
-
 NS_IMETHODIMP
-nsHTMLEditor::GetIndentState(bool *aCanIndent, bool *aCanOutdent)
+HTMLEditor::GetIndentState(bool* aCanIndent,
+                           bool* aCanOutdent)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
   NS_ENSURE_TRUE(aCanIndent && aCanOutdent, NS_ERROR_NULL_POINTER);
 
   RefPtr<HTMLEditRules> htmlRules =
     static_cast<HTMLEditRules*>(mRules.get());
 
   return htmlRules->GetIndentState(aCanIndent, aCanOutdent);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList, const nsAString& aBulletType)
+HTMLEditor::MakeOrChangeList(const nsAString& aListType,
+                             bool entireList,
+                             const nsAString& aBulletType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   bool cancel, handled;
@@ -1988,19 +2014,18 @@ nsHTMLEditor::MakeOrChangeList(const nsA
       NS_ENSURE_SUCCESS(res, res);
     }
   }
 
   res = mRules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
-
 NS_IMETHODIMP
-nsHTMLEditor::RemoveList(const nsAString& aListType)
+HTMLEditor::RemoveList(const nsAString& aListType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   bool cancel, handled;
@@ -2021,17 +2046,17 @@ nsHTMLEditor::RemoveList(const nsAString
 
   // no default behavior for this yet.  what would it mean?
 
   res = mRules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
 nsresult
-nsHTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
+HTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   bool cancel, handled;
@@ -2053,17 +2078,17 @@ nsHTMLEditor::MakeDefinitionItem(const n
     // todo: no default for now.  we count on rules to handle it.
   }
 
   res = mRules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
 nsresult
-nsHTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
+HTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   bool cancel, handled;
@@ -2123,17 +2148,17 @@ nsHTMLEditor::InsertBasicBlock(const nsA
     }
   }
 
   res = mRules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::Indent(const nsAString& aIndent)
+HTMLEditor::Indent(const nsAString& aIndent)
 {
   nsresult res;
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   bool cancel, handled;
@@ -2204,17 +2229,17 @@ nsHTMLEditor::Indent(const nsAString& aI
   }
   res = mRules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
 //TODO: IMPLEMENT ALIGNMENT!
 
 NS_IMETHODIMP
-nsHTMLEditor::Align(const nsAString& aAlignType)
+HTMLEditor::Align(const nsAString& aAlignType)
 {
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   AutoEditBatch beginBatching(this);
   AutoRules beginRulesSniffing(this, EditAction::align, nsIEditor::eNext);
 
   nsCOMPtr<nsIDOMNode> node;
@@ -2229,18 +2254,18 @@ nsHTMLEditor::Align(const nsAString& aAl
   if (cancel || NS_FAILED(res))
     return res;
 
   res = mRules->DidDoAction(selection, &ruleInfo, res);
   return res;
 }
 
 already_AddRefed<Element>
-nsHTMLEditor::GetElementOrParentByTagName(const nsAString& aTagName,
-                                          nsINode* aNode)
+HTMLEditor::GetElementOrParentByTagName(const nsAString& aTagName,
+                                        nsINode* aNode)
 {
   MOZ_ASSERT(!aTagName.IsEmpty());
 
   nsCOMPtr<nsINode> node = aNode;
   if (!node) {
     // If no node supplied, get it from anchor node of current selection
     RefPtr<Selection> selection = GetSelection();
     NS_ENSURE_TRUE(selection, nullptr);
@@ -2309,19 +2334,19 @@ nsHTMLEditor::GetElementOrParentByTagNam
       break;
     }
   }
 
   return nullptr;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetElementOrParentByTagName(const nsAString& aTagName,
-                                          nsIDOMNode* aNode,
-                                          nsIDOMElement** aReturn)
+HTMLEditor::GetElementOrParentByTagName(const nsAString& aTagName,
+                                        nsIDOMNode* aNode,
+                                        nsIDOMElement** aReturn)
 {
   NS_ENSURE_TRUE(!aTagName.IsEmpty(), NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE(aReturn, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   nsCOMPtr<Element> parent =
     GetElementOrParentByTagName(aTagName, node);
   nsCOMPtr<nsIDOMElement> ret = do_QueryInterface(parent);
@@ -2330,17 +2355,18 @@ nsHTMLEditor::GetElementOrParentByTagNam
     return NS_EDITOR_ELEMENT_NOT_FOUND;
   }
 
   ret.forget(aReturn);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetSelectedElement(const nsAString& aTagName, nsIDOMElement** aReturn)
+HTMLEditor::GetSelectedElement(const nsAString& aTagName,
+                               nsIDOMElement** aReturn)
 {
   NS_ENSURE_TRUE(aReturn , NS_ERROR_NULL_POINTER);
 
   // default is null - no element found
   *aReturn = nullptr;
 
   // First look for a single element in selection
   RefPtr<Selection> selection = GetSelection();
@@ -2531,17 +2557,17 @@ nsHTMLEditor::GetSelectedElement(const n
     }
   }
   else res = NS_EDITOR_ELEMENT_NOT_FOUND;
 
   return res;
 }
 
 already_AddRefed<Element>
-nsHTMLEditor::CreateElementWithDefaults(const nsAString& aTagName)
+HTMLEditor::CreateElementWithDefaults(const nsAString& aTagName)
 {
   MOZ_ASSERT(!aTagName.IsEmpty());
 
   nsAutoString tagName(aTagName);
   ToLowerCase(tagName);
   nsAutoString realTagName;
 
   if (IsLinkTag(tagName) || IsNamedAnchorTag(tagName)) {
@@ -2590,31 +2616,32 @@ nsHTMLEditor::CreateElementWithDefaults(
     NS_ENSURE_SUCCESS(res, nullptr);
   }
   // ADD OTHER TAGS HERE
 
   return newElement.forget();
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::CreateElementWithDefaults(const nsAString& aTagName, nsIDOMElement** aReturn)
+HTMLEditor::CreateElementWithDefaults(const nsAString& aTagName,
+                                      nsIDOMElement** aReturn)
 {
   NS_ENSURE_TRUE(!aTagName.IsEmpty() && aReturn, NS_ERROR_NULL_POINTER);
   *aReturn = nullptr;
 
   nsCOMPtr<Element> newElement = CreateElementWithDefaults(aTagName);
   nsCOMPtr<nsIDOMElement> ret = do_QueryInterface(newElement);
   NS_ENSURE_TRUE(ret, NS_ERROR_FAILURE);
 
   ret.forget(aReturn);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
+HTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
 {
   NS_ENSURE_TRUE(aAnchorElement, NS_ERROR_NULL_POINTER);
 
   // We must have a real selection
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   if (selection->Collapsed()) {
@@ -2666,17 +2693,17 @@ nsHTMLEditor::InsertLinkAroundSelection(
       res = SetInlineProperty(nsGkAtoms::a, name, value);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::SetHTMLBackgroundColor(const nsAString& aColor)
+HTMLEditor::SetHTMLBackgroundColor(const nsAString& aColor)
 {
   NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document");
 
   // Find a selected or enclosing table element to set background on
   nsCOMPtr<nsIDOMElement> element;
   int32_t selectedCount;
   nsAutoString tagName;
   nsresult res = GetSelectedOrParentTableElement(tagName, &selectedCount,
@@ -2718,32 +2745,34 @@ nsHTMLEditor::SetHTMLBackgroundColor(con
   if (setColor)
     res = SetAttribute(element, bgcolor, aColor);
   else
     res = RemoveAttribute(element, bgcolor);
 
   return res;
 }
 
-NS_IMETHODIMP nsHTMLEditor::SetBodyAttribute(const nsAString& aAttribute, const nsAString& aValue)
+NS_IMETHODIMP
+HTMLEditor::SetBodyAttribute(const nsAString& aAttribute,
+                             const nsAString& aValue)
 {
   // TODO: Check selection for Cell, Row, Column or table and do color on appropriate level
 
   NS_ASSERTION(mDocWeak, "Missing Editor DOM Document");
 
   // Set the background color attribute on the body tag
   nsCOMPtr<nsIDOMElement> bodyElement = do_QueryInterface(GetRoot());
   NS_ENSURE_TRUE(bodyElement, NS_ERROR_NULL_POINTER);
 
   // Use the editor method that goes through the transaction system
   return SetAttribute(bodyElement, aAttribute, aValue);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetLinkedObjects(nsISupportsArray** aNodeList)
+HTMLEditor::GetLinkedObjects(nsISupportsArray** aNodeList)
 {
   NS_ENSURE_TRUE(aNodeList, NS_ERROR_NULL_POINTER);
 
   nsresult res;
 
   res = NS_NewISupportsArray(aNodeList);
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_TRUE(*aNodeList, NS_ERROR_NULL_POINTER);
@@ -2778,32 +2807,32 @@ nsHTMLEditor::GetLinkedObjects(nsISuppor
     }
   }
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsHTMLEditor::AddStyleSheet(const nsAString &aURL)
+HTMLEditor::AddStyleSheet(const nsAString& aURL)
 {
   // Enable existing sheet if already loaded.
   if (EnableExistingStyleSheet(aURL))
     return NS_OK;
 
   // Lose the previously-loaded sheet so there's nothing to replace
   // This pattern is different from Override methods because
   //  we must wait to remove mLastStyleSheetURL and add new sheet
   //  at the same time (in StyleSheetLoaded callback) so they are undoable together
   mLastStyleSheetURL.Truncate();
   return ReplaceStyleSheet(aURL);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::ReplaceStyleSheet(const nsAString& aURL)
+HTMLEditor::ReplaceStyleSheet(const nsAString& aURL)
 {
   // Enable existing sheet if already loaded.
   if (EnableExistingStyleSheet(aURL))
   {
     // Disable last sheet if not the same as new one
     if (!mLastStyleSheetURL.IsEmpty() && !mLastStyleSheetURL.Equals(aURL))
       return EnableStyleSheet(mLastStyleSheetURL, false);
 
@@ -2819,17 +2848,17 @@ nsHTMLEditor::ReplaceStyleSheet(const ns
   nsresult rv = NS_NewURI(getter_AddRefs(uaURI), aURL);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return ps->GetDocument()->CSSLoader()->
     LoadSheet(uaURI, false, nullptr, EmptyCString(), this);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RemoveStyleSheet(const nsAString &aURL)
+HTMLEditor::RemoveStyleSheet(const nsAString& aURL)
 {
   StyleSheetHandle::RefPtr sheet = GetStyleSheetForURL(aURL);
   NS_ENSURE_TRUE(sheet, NS_ERROR_UNEXPECTED);
 
   RefPtr<RemoveStyleSheetTransaction> transaction;
   nsresult rv =
     CreateTxnForRemoveStyleSheet(sheet, getter_AddRefs(transaction));
   if (!transaction) {
@@ -2844,17 +2873,17 @@ nsHTMLEditor::RemoveStyleSheet(const nsA
     rv = RemoveStyleSheetFromList(aURL);
   }
 
   return rv;
 }
 
 
 NS_IMETHODIMP
-nsHTMLEditor::AddOverrideStyleSheet(const nsAString& aURL)
+HTMLEditor::AddOverrideStyleSheet(const nsAString& aURL)
 {
   // Enable existing sheet if already loaded.
   if (EnableExistingStyleSheet(aURL))
     return NS_OK;
 
   // Make sure the pres shell doesn't disappear during the load.
   nsCOMPtr<nsIPresShell> ps = GetPresShell();
   NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
@@ -2884,17 +2913,17 @@ nsHTMLEditor::AddOverrideStyleSheet(cons
   // Save as the last-loaded sheet
   mLastOverrideStyleSheetURL = aURL;
 
   //Add URL and style sheet to our lists
   return AddNewStyleSheetToList(aURL, sheet);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::ReplaceOverrideStyleSheet(const nsAString& aURL)
+HTMLEditor::ReplaceOverrideStyleSheet(const nsAString& aURL)
 {
   // Enable existing sheet if already loaded.
   if (EnableExistingStyleSheet(aURL))
   {
     // Disable last sheet if not the same as new one
     if (!mLastOverrideStyleSheetURL.IsEmpty() && !mLastOverrideStyleSheetURL.Equals(aURL))
       return EnableStyleSheet(mLastOverrideStyleSheetURL, false);
 
@@ -2904,17 +2933,17 @@ nsHTMLEditor::ReplaceOverrideStyleSheet(
   if (!mLastOverrideStyleSheetURL.IsEmpty())
     RemoveOverrideStyleSheet(mLastOverrideStyleSheetURL);
 
   return AddOverrideStyleSheet(aURL);
 }
 
 // Do NOT use transaction system for override style sheets
 NS_IMETHODIMP
-nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL)
+HTMLEditor::RemoveOverrideStyleSheet(const nsAString& aURL)
 {
   StyleSheetHandle::RefPtr sheet = GetStyleSheetForURL(aURL);
 
   // Make sure we remove the stylesheet from our internal list in all
   // cases.
   nsresult rv = RemoveStyleSheetFromList(aURL);
 
   NS_ENSURE_TRUE(sheet, NS_OK); /// Don't fail if sheet not found
@@ -2926,17 +2955,18 @@ nsHTMLEditor::RemoveOverrideStyleSheet(c
   ps->RemoveOverrideStyleSheet(sheet);
   ps->RestyleForCSSRuleChanges();
 
   // Remove it from our internal list
   return rv;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::EnableStyleSheet(const nsAString &aURL, bool aEnable)
+HTMLEditor::EnableStyleSheet(const nsAString& aURL,
+                             bool aEnable)
 {
   StyleSheetHandle::RefPtr sheet = GetStyleSheetForURL(aURL);
   NS_ENSURE_TRUE(sheet, NS_OK); // Don't fail if sheet not found
 
   // Ensure the style sheet is owned by our document.
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
   sheet->SetOwningDocument(doc);
 
@@ -2944,17 +2974,17 @@ nsHTMLEditor::EnableStyleSheet(const nsA
     // XXXheycam ServoStyleSheets don't support being enabled/disabled yet.
     NS_ERROR("stylo: ServoStyleSheets can't be disabled yet");
     return NS_ERROR_FAILURE;
   }
   return sheet->AsGecko()->SetDisabled(!aEnable);
 }
 
 bool
-nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL)
+HTMLEditor::EnableExistingStyleSheet(const nsAString& aURL)
 {
   StyleSheetHandle::RefPtr sheet = GetStyleSheetForURL(aURL);
 
   // Enable sheet if already loaded.
   if (sheet)
   {
     // Ensure the style sheet is owned by our document.
     nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
@@ -2967,82 +2997,78 @@ nsHTMLEditor::EnableExistingStyleSheet(c
     }
     sheet->AsGecko()->SetDisabled(false);
     return true;
   }
   return false;
 }
 
 nsresult
-nsHTMLEditor::AddNewStyleSheetToList(const nsAString &aURL,
-                                     StyleSheetHandle aStyleSheet)
+HTMLEditor::AddNewStyleSheetToList(const nsAString& aURL,
+                                   StyleSheetHandle aStyleSheet)
 {
   uint32_t countSS = mStyleSheets.Length();
   uint32_t countU = mStyleSheetURLs.Length();
 
   if (countSS != countU)
     return NS_ERROR_UNEXPECTED;
 
   if (!mStyleSheetURLs.AppendElement(aURL))
     return NS_ERROR_UNEXPECTED;
 
   return mStyleSheets.AppendElement(aStyleSheet) ? NS_OK : NS_ERROR_UNEXPECTED;
 }
 
 nsresult
-nsHTMLEditor::RemoveStyleSheetFromList(const nsAString &aURL)
+HTMLEditor::RemoveStyleSheetFromList(const nsAString& aURL)
 {
   // is it already in the list?
   size_t foundIndex;
   foundIndex = mStyleSheetURLs.IndexOf(aURL);
   if (foundIndex == mStyleSheetURLs.NoIndex)
     return NS_ERROR_FAILURE;
 
   // Attempt both removals; if one fails there's not much we can do.
   mStyleSheets.RemoveElementAt(foundIndex);
   mStyleSheetURLs.RemoveElementAt(foundIndex);
 
   return NS_OK;
 }
 
 StyleSheetHandle
-nsHTMLEditor::GetStyleSheetForURL(const nsAString& aURL)
+HTMLEditor::GetStyleSheetForURL(const nsAString& aURL)
 {
   // is it already in the list?
   size_t foundIndex;
   foundIndex = mStyleSheetURLs.IndexOf(aURL);
   if (foundIndex == mStyleSheetURLs.NoIndex) {
     return nullptr;
   }
 
   MOZ_ASSERT(mStyleSheets[foundIndex]);
   return mStyleSheets[foundIndex];
 }
 
 void
-nsHTMLEditor::GetURLForStyleSheet(StyleSheetHandle aStyleSheet,
-                                  nsAString& aURL)
+HTMLEditor::GetURLForStyleSheet(StyleSheetHandle aStyleSheet,
+                                nsAString& aURL)
 {
   // is it already in the list?
   int32_t foundIndex = mStyleSheets.IndexOf(aStyleSheet);
 
   // Don't fail if we don't find it in our list
   if (foundIndex == -1)
     return;
 
   // Found it in the list!
   aURL = mStyleSheetURLs[foundIndex];
 }
 
-/*
- * nsIEditorMailSupport methods
- */
-
 NS_IMETHODIMP
-nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
+HTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
 {
   NS_ENSURE_TRUE(aNodeList, NS_ERROR_NULL_POINTER);
 
   nsresult rv = NS_NewISupportsArray(aNodeList);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(*aNodeList, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIContentIterator> iter =
@@ -3072,20 +3098,19 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupp
       }
     }
     iter->Next();
   }
 
   return rv;
 }
 
-
 NS_IMETHODIMP
-nsHTMLEditor::DeleteSelectionImpl(EDirection aAction,
-                                  EStripWrappers aStripWrappers)
+HTMLEditor::DeleteSelectionImpl(EDirection aAction,
+                                EStripWrappers aStripWrappers)
 {
   MOZ_ASSERT(aStripWrappers == eStrip || aStripWrappers == eNoStrip);
 
   nsresult res = nsEditor::DeleteSelectionImpl(aAction, aStripWrappers);
   NS_ENSURE_SUCCESS(res, res);
 
   // If we weren't asked to strip any wrappers, we're done.
   if (aStripWrappers == eNoStrip) {
@@ -3128,93 +3153,99 @@ nsHTMLEditor::DeleteSelectionImpl(EDirec
     }
     res = DeleteNode(content);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   return NS_OK;
 }
 
-
 nsresult
-nsHTMLEditor::DeleteNode(nsINode* aNode)
+HTMLEditor::DeleteNode(nsINode* aNode)
 {
   nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode);
   return DeleteNode(node);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DeleteNode(nsIDOMNode* aNode)
+HTMLEditor::DeleteNode(nsIDOMNode* aNode)
 {
   // do nothing if the node is read-only
   nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
   if (!IsModifiableNode(aNode) && !IsMozEditorBogusNode(content)) {
     return NS_ERROR_FAILURE;
   }
 
   return nsEditor::DeleteNode(aNode);
 }
 
 nsresult
-nsHTMLEditor::DeleteText(nsGenericDOMDataNode& aCharData, uint32_t aOffset,
-                         uint32_t aLength)
+HTMLEditor::DeleteText(nsGenericDOMDataNode& aCharData,
+                       uint32_t aOffset,
+                       uint32_t aLength)
 {
   // Do nothing if the node is read-only
   if (!IsModifiableNode(&aCharData)) {
     return NS_ERROR_FAILURE;
   }
 
   return nsEditor::DeleteText(aCharData, aOffset, aLength);
 }
 
 nsresult
-nsHTMLEditor::InsertTextImpl(const nsAString& aStringToInsert,
-                             nsCOMPtr<nsINode>* aInOutNode,
-                             int32_t* aInOutOffset, nsIDocument* aDoc)
+HTMLEditor::InsertTextImpl(const nsAString& aStringToInsert,
+                           nsCOMPtr<nsINode>* aInOutNode,
+                           int32_t* aInOutOffset,
+                           nsIDocument* aDoc)
 {
   // Do nothing if the node is read-only
   if (!IsModifiableNode(*aInOutNode)) {
     return NS_ERROR_FAILURE;
   }
 
   return nsEditor::InsertTextImpl(aStringToInsert, aInOutNode, aInOutOffset,
                                   aDoc);
 }
 
 void
-nsHTMLEditor::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
-                              nsIContent* aFirstNewContent,
-                              int32_t aIndexInContainer)
+HTMLEditor::ContentAppended(nsIDocument* aDocument,
+                            nsIContent* aContainer,
+                            nsIContent* aFirstNewContent,
+                            int32_t aIndexInContainer)
 {
   DoContentInserted(aDocument, aContainer, aFirstNewContent, aIndexInContainer,
                     eAppended);
 }
 
 void
-nsHTMLEditor::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
-                              nsIContent* aChild, int32_t aIndexInContainer)
+HTMLEditor::ContentInserted(nsIDocument* aDocument,
+                            nsIContent* aContainer,
+                            nsIContent* aChild,
+                            int32_t aIndexInContainer)
 {
   DoContentInserted(aDocument, aContainer, aChild, aIndexInContainer,
                     eInserted);
 }
 
 void
-nsHTMLEditor::DoContentInserted(nsIDocument* aDocument, nsIContent* aContainer,
-                                nsIContent* aChild, int32_t aIndexInContainer,
-                                InsertedOrAppended aInsertedOrAppended)
+HTMLEditor::DoContentInserted(nsIDocument* aDocument,
+                              nsIContent* aContainer,
+                              nsIContent* aChild,
+                              int32_t aIndexInContainer,
+                              InsertedOrAppended aInsertedOrAppended)
 {
   if (!aChild) {
     return;
   }
 
   nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(this);
 
   if (ShouldReplaceRootElement()) {
     nsContentUtils::AddScriptRunner(NewRunnableMethod(
-      this, &nsHTMLEditor::ResetRootElementAndEventTarget));
+      this, &HTMLEditor::ResetRootElementAndEventTarget));
   }
   // We don't need to handle our own modifications
   else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) {
     if (IsMozEditorBogusNode(aChild)) {
       // Ignore insertion of the bogus node
       return;
     }
     // Protect the edit rules object from dying
@@ -3238,53 +3269,55 @@ nsHTMLEditor::DoContentInserted(nsIDocum
       if (NS_SUCCEEDED(res)) {
         mInlineSpellChecker->SpellCheckRange(range);
       }
     }
   }
 }
 
 void
-nsHTMLEditor::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
-                             nsIContent* aChild, int32_t aIndexInContainer,
-                             nsIContent* aPreviousSibling)
+HTMLEditor::ContentRemoved(nsIDocument* aDocument,
+                           nsIContent* aContainer,
+                           nsIContent* aChild,
+                           int32_t aIndexInContainer,
+                           nsIContent* aPreviousSibling)
 {
   nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(this);
 
   if (SameCOMIdentity(aChild, mRootElement)) {
     nsContentUtils::AddScriptRunner(NewRunnableMethod(
-      this, &nsHTMLEditor::ResetRootElementAndEventTarget));
+      this, &HTMLEditor::ResetRootElementAndEventTarget));
   }
   // We don't need to handle our own modifications
   else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) {
     if (aChild && IsMozEditorBogusNode(aChild)) {
       // Ignore removal of the bogus node
       return;
     }
     // Protect the edit rules object from dying
     nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
     mRules->DocumentModified();
   }
 }
 
 NS_IMETHODIMP_(bool)
-nsHTMLEditor::IsModifiableNode(nsIDOMNode *aNode)
+HTMLEditor::IsModifiableNode(nsIDOMNode* aNode)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   return IsModifiableNode(node);
 }
 
 bool
-nsHTMLEditor::IsModifiableNode(nsINode *aNode)
+HTMLEditor::IsModifiableNode(nsINode* aNode)
 {
   return !aNode || aNode->IsEditable();
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetIsSelectionEditable(bool* aIsSelectionEditable)
+HTMLEditor::GetIsSelectionEditable(bool* aIsSelectionEditable)
 {
   MOZ_ASSERT(aIsSelectionEditable);
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   // Per the editing spec as of June 2012: we have to have a selection whose
   // start and end nodes are editable, and which share an ancestor editing
@@ -3324,17 +3357,17 @@ SetSelectionAroundHeadChildren(Selection
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Then extend it to just after.
   uint32_t childCount = headNode->GetChildCount();
   return aSelection->ExtendNative(headNode, childCount + 1);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetHeadContentsAsHTML(nsAString& aOutputString)
+HTMLEditor::GetHeadContentsAsHTML(nsAString& aOutputString)
 {
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   // Save current selection
   AutoSelectionRestorer selectionRestorer(selection, this);
 
   nsresult res = SetSelectionAroundHeadChildren(selection, mDocWeak);
@@ -3370,36 +3403,37 @@ nsHTMLEditor::GetHeadContentsAsHTML(nsAS
         aOutputString.Truncate(offset+1);
       }
     }
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DebugUnitTests(int32_t *outNumTests, int32_t *outNumTestsFailed)
+HTMLEditor::DebugUnitTests(int32_t* outNumTests,
+                           int32_t* outNumTestsFailed)
 {
 #ifdef DEBUG
   NS_ENSURE_TRUE(outNumTests && outNumTestsFailed, NS_ERROR_NULL_POINTER);
 
   TextEditorTest *tester = new TextEditorTest();
   NS_ENSURE_TRUE(tester, NS_ERROR_OUT_OF_MEMORY);
 
   tester->Run(this, outNumTests, outNumTestsFailed);
   delete tester;
   return NS_OK;
 #else
   return NS_ERROR_NOT_IMPLEMENTED;
 #endif
 }
 
-
 NS_IMETHODIMP
-nsHTMLEditor::StyleSheetLoaded(StyleSheetHandle aSheet, bool aWasAlternate,
-                               nsresult aStatus)
+HTMLEditor::StyleSheetLoaded(StyleSheetHandle aSheet,
+                             bool aWasAlternate,
+                             nsresult aStatus)
 {
   nsresult rv = NS_OK;
   AutoEditBatch batchIt(this);
 
   if (!mLastStyleSheetURL.IsEmpty())
     RemoveStyleSheet(mLastStyleSheetURL);
 
   RefPtr<AddStyleSheetTransaction> transaction;
@@ -3422,93 +3456,97 @@ nsHTMLEditor::StyleSheetLoaded(StyleShee
         AddNewStyleSheetToList(mLastStyleSheetURL, aSheet);
       }
     }
   }
 
   return NS_OK;
 }
 
-
-/** All editor operations which alter the doc should be prefaced
- *  with a call to StartOperation, naming the action and direction */
+/**
+ * All editor operations which alter the doc should be prefaced
+ * with a call to StartOperation, naming the action and direction.
+ */
 NS_IMETHODIMP
-nsHTMLEditor::StartOperation(EditAction opID,
-                             nsIEditor::EDirection aDirection)
+HTMLEditor::StartOperation(EditAction opID,
+                           nsIEditor::EDirection aDirection)
 {
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   nsEditor::StartOperation(opID, aDirection);  // will set mAction, mDirection
   if (mRules) return mRules->BeforeEdit(mAction, mDirection);
   return NS_OK;
 }
 
-
-/** All editor operations which alter the doc should be followed
- *  with a call to EndOperation */
+/**
+ * All editor operations which alter the doc should be followed
+ * with a call to EndOperation.
+ */
 NS_IMETHODIMP
-nsHTMLEditor::EndOperation()
+HTMLEditor::EndOperation()
 {
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   // post processing
   nsresult res = NS_OK;
   if (mRules) res = mRules->AfterEdit(mAction, mDirection);
   nsEditor::EndOperation();  // will clear mAction, mDirection
   return res;
 }
 
 bool
-nsHTMLEditor::TagCanContainTag(nsIAtom& aParentTag, nsIAtom& aChildTag)
+HTMLEditor::TagCanContainTag(nsIAtom& aParentTag,
+                             nsIAtom& aChildTag)
 {
   nsIParserService* parserService = nsContentUtils::GetParserService();
 
   int32_t childTagEnum;
   // XXX Should this handle #cdata-section too?
   if (&aChildTag == nsGkAtoms::textTagName) {
     childTagEnum = eHTMLTag_text;
   } else {
     childTagEnum = parserService->HTMLAtomTagToId(&aChildTag);
   }
 
   int32_t parentTagEnum = parserService->HTMLAtomTagToId(&aParentTag);
   return HTMLEditUtils::CanContain(parentTagEnum, childTagEnum);
 }
 
 bool
-nsHTMLEditor::IsContainer(nsINode* aNode) {
+HTMLEditor::IsContainer(nsINode* aNode)
+{
   MOZ_ASSERT(aNode);
 
   int32_t tagEnum;
   // XXX Should this handle #cdata-section too?
   if (aNode->IsNodeOfType(nsINode::eTEXT)) {
     tagEnum = eHTMLTag_text;
   } else {
     tagEnum =
       nsContentUtils::GetParserService()->HTMLStringTagToId(aNode->NodeName());
   }
 
   return HTMLEditUtils::IsContainer(tagEnum);
 }
 
 bool
-nsHTMLEditor::IsContainer(nsIDOMNode *aNode)
+HTMLEditor::IsContainer(nsIDOMNode* aNode)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   if (!node) {
     return false;
   }
   return IsContainer(node);
 }
 
 
 nsresult
-nsHTMLEditor::SelectEntireDocument(Selection* aSelection)
+HTMLEditor::SelectEntireDocument(Selection* aSelection)
 {
   if (!aSelection || !mRules) { return NS_ERROR_NULL_POINTER; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   // get editor root node
   nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
@@ -3523,17 +3561,17 @@ nsHTMLEditor::SelectEntireDocument(Selec
     // if its empty dont select entire doc - that would select the bogus node
     return aSelection->Collapse(rootElement, 0);
   }
 
   return nsEditor::SelectEntireDocument(aSelection);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SelectAll()
+HTMLEditor::SelectAll()
 {
   ForceCompositionEnd();
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_STATE(selection);
 
   nsCOMPtr<nsIDOMNode> anchorNode;
   nsresult rv = selection->GetAnchorNode(getter_AddRefs(anchorNode));
@@ -3559,38 +3597,39 @@ nsHTMLEditor::SelectAll()
 
   Maybe<mozilla::dom::Selection::AutoUserInitiated> userSelection;
   if (!rootContent->IsEditable()) {
     userSelection.emplace(selection);
   }
   return selection->SelectAllChildren(rootElement);
 }
 
-
 // this will NOT find aAttribute unless aAttribute has a non-null value
 // so singleton attributes like <Table border> will not be matched!
-bool nsHTMLEditor::IsTextPropertySetByContent(nsINode*         aNode,
-                                              nsIAtom*         aProperty,
-                                              const nsAString* aAttribute,
-                                              const nsAString* aValue,
-                                              nsAString*       outValue)
+bool
+HTMLEditor::IsTextPropertySetByContent(nsINode* aNode,
+                                       nsIAtom* aProperty,
+                                       const nsAString* aAttribute,
+                                       const nsAString* aValue,
+                                       nsAString* outValue)
 {
   MOZ_ASSERT(aNode && aProperty);
   bool isSet;
   IsTextPropertySetByContent(aNode->AsDOMNode(), aProperty, aAttribute, aValue,
                              isSet, outValue);
   return isSet;
 }
 
-void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode        *aNode,
-                                              nsIAtom           *aProperty,
-                                              const nsAString   *aAttribute,
-                                              const nsAString   *aValue,
-                                              bool              &aIsSet,
-                                              nsAString *outValue)
+void
+HTMLEditor::IsTextPropertySetByContent(nsIDOMNode* aNode,
+                                       nsIAtom* aProperty,
+                                       const nsAString* aAttribute,
+                                       const nsAString* aValue,
+                                       bool& aIsSet,
+                                       nsAString* outValue)
 {
   nsresult result;
   aIsSet = false;  // must be initialized to false for code below to work
   nsAutoString propName;
   aProperty->ToString(propName);
   nsCOMPtr<nsIDOMNode>node = aNode;
 
   while (node)
@@ -3641,26 +3680,18 @@ void nsHTMLEditor::IsTextPropertySetByCo
       node = temp;
     }
     else {
       node = nullptr;
     }
   }
 }
 
-
-//================================================================
-// HTML Editor methods
-//
-// Note: Table Editing methods are implemented in nsTableEditor.cpp
-//
-
-
 bool
-nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement)
+HTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement)
 {
   nsCOMPtr<dom::Element> element = do_QueryInterface(aElement);
   if (!element || !element->IsHTMLElement() ||
       !HTMLEditUtils::IsTableElement(element) ||
       !IsDescendantOfEditorRoot(element)) {
     return false;
   }
 
@@ -3671,54 +3702,55 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOM
 
   // Set selection at beginning of the found node
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, false);
 
   return NS_SUCCEEDED(selection->CollapseNative(node, 0));
 }
 
-///////////////////////////////////////////////////////////////////////////
-// GetEnclosingTable: find ancestor who is a table, if any
-//
+/**
+ * GetEnclosingTable() finds ancestor who is a table, if any.
+ */
 Element*
-nsHTMLEditor::GetEnclosingTable(nsINode* aNode)
+HTMLEditor::GetEnclosingTable(nsINode* aNode)
 {
   MOZ_ASSERT(aNode);
 
   for (nsCOMPtr<Element> block = GetBlockNodeParent(aNode);
        block;
        block = GetBlockNodeParent(block)) {
     if (HTMLEditUtils::IsTable(block)) {
       return block;
     }
   }
   return nullptr;
 }
 
 nsIDOMNode*
-nsHTMLEditor::GetEnclosingTable(nsIDOMNode *aNode)
+HTMLEditor::GetEnclosingTable(nsIDOMNode* aNode)
 {
-  NS_PRECONDITION(aNode, "null node passed to nsHTMLEditor::GetEnclosingTable");
+  NS_PRECONDITION(aNode, "null node passed to HTMLEditor::GetEnclosingTable");
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(node, nullptr);
   nsCOMPtr<Element> table = GetEnclosingTable(node);
   nsCOMPtr<nsIDOMNode> ret = do_QueryInterface(table);
   return ret;
 }
 
 
-/* this method scans the selection for adjacent text nodes
+/**
+ * This method scans the selection for adjacent text nodes
  * and collapses them into a single text node.
  * "adjacent" means literally adjacent siblings of the same parent.
  * Uses nsEditor::JoinNodes so action is undoable.
  * Should be called within the context of a batch transaction.
  */
 nsresult
-nsHTMLEditor::CollapseAdjacentTextNodes(nsRange* aInRange)
+HTMLEditor::CollapseAdjacentTextNodes(nsRange* aInRange)
 {
   NS_ENSURE_TRUE(aInRange, NS_ERROR_NULL_POINTER);
   AutoTransactionsConserveSelection dontSpazMySelection(this);
   nsTArray<nsCOMPtr<nsIDOMNode> > textNodes;
   // we can't actually do anything during iteration, so store the text nodes in an array
   // don't bother ref counting them because we know we can hold them for the
   // lifetime of this method
 
@@ -3769,31 +3801,30 @@ nsHTMLEditor::CollapseAdjacentTextNodes(
 
     textNodes.RemoveElementAt(0); // remove the leftmost text node from the list
   }
 
   return result;
 }
 
 nsresult
-nsHTMLEditor::SetSelectionAtDocumentStart(Selection* aSelection)
+HTMLEditor::SetSelectionAtDocumentStart(Selection* aSelection)
 {
   dom::Element* rootElement = GetRoot();
   NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
 
   return aSelection->CollapseNative(rootElement, 0);
 }
 
-
 /**
  * Remove aNode, reparenting any children into the parent of aNode.  In
  * addition, insert any br's needed to preserve identity of removed block.
  */
 nsresult
-nsHTMLEditor::RemoveBlockContainer(nsIContent& aNode)
+HTMLEditor::RemoveBlockContainer(nsIContent& aNode)
 {
   // Two possibilities: the container could be empty of editable content.  If
   // that is the case, we need to compare what is before and after aNode to
   // determine if we need a br.
   //
   // Or it could be not empty, in which case we have to compare previous
   // sibling and first child to determine if we need a leading br, and compare
   // following sibling and last child to determine if we need a trailing br.
@@ -3853,374 +3884,374 @@ nsHTMLEditor::RemoveBlockContainer(nsICo
 
   // Now remove container
   nsresult res = RemoveContainer(&aNode);
   NS_ENSURE_SUCCESS(res, res);
 
   return NS_OK;
 }
 
-
-///////////////////////////////////////////////////////////////////////////
-// GetPriorHTMLSibling: returns the previous editable sibling, if there is
-//                   one within the parent
-//
+/**
+ * GetPriorHTMLSibling() returns the previous editable sibling, if there is
+ * one within the parent.
+ */
 nsIContent*
-nsHTMLEditor::GetPriorHTMLSibling(nsINode* aNode)
+HTMLEditor::GetPriorHTMLSibling(nsINode* aNode)
 {
   MOZ_ASSERT(aNode);
 
   nsIContent* node = aNode->GetPreviousSibling();
   while (node && !IsEditable(node)) {
     node = node->GetPreviousSibling();
   }
 
   return node;
 }
 
 nsresult
-nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode)
+HTMLEditor::GetPriorHTMLSibling(nsIDOMNode* inNode,
+                                nsCOMPtr<nsIDOMNode>* outNode)
 {
   NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
   *outNode = nullptr;
 
   nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
   *outNode = do_QueryInterface(GetPriorHTMLSibling(node));
   return NS_OK;
 }
 
-
-
-///////////////////////////////////////////////////////////////////////////
-// GetPriorHTMLSibling: returns the previous editable sibling, if there is
-//                   one within the parent.  just like above routine but
-//                   takes a parent/offset instead of a node.
-//
+/**
+ * GetPriorHTMLSibling() returns the previous editable sibling, if there is
+ * one within the parent.  just like above routine but takes a parent/offset
+ * instead of a node.
+ */
 nsIContent*
-nsHTMLEditor::GetPriorHTMLSibling(nsINode* aParent, int32_t aOffset)
+HTMLEditor::GetPriorHTMLSibling(nsINode* aParent,
+                                int32_t aOffset)
 {
   MOZ_ASSERT(aParent);
 
   nsIContent* node = aParent->GetChildAt(aOffset - 1);
   if (!node || IsEditable(node)) {
     return node;
   }
 
   return GetPriorHTMLSibling(node);
 }
 
 nsresult
-nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode)
+HTMLEditor::GetPriorHTMLSibling(nsIDOMNode* inParent,
+                                int32_t inOffset,
+                                nsCOMPtr<nsIDOMNode>* outNode)
 {
   NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
   *outNode = nullptr;
 
   nsCOMPtr<nsINode> parent = do_QueryInterface(inParent);
   NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
 
   *outNode = do_QueryInterface(GetPriorHTMLSibling(parent, inOffset));
   return NS_OK;
 }
 
-
-
-///////////////////////////////////////////////////////////////////////////
-// GetNextHTMLSibling: returns the next editable sibling, if there is
-//                   one within the parent
-//
+/**
+ * GetNextHTMLSibling() returns the next editable sibling, if there is
+ * one within the parent.
+ */
 nsIContent*
-nsHTMLEditor::GetNextHTMLSibling(nsINode* aNode)
+HTMLEditor::GetNextHTMLSibling(nsINode* aNode)
 {
   MOZ_ASSERT(aNode);
 
   nsIContent* node = aNode->GetNextSibling();
   while (node && !IsEditable(node)) {
     node = node->GetNextSibling();
   }
 
   return node;
 }
 
 nsresult
-nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode)
+HTMLEditor::GetNextHTMLSibling(nsIDOMNode* inNode,
+                               nsCOMPtr<nsIDOMNode>* outNode)
 {
   NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
   *outNode = nullptr;
 
   nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
   *outNode = do_QueryInterface(GetNextHTMLSibling(node));
   return NS_OK;
 }
 
-
-
-///////////////////////////////////////////////////////////////////////////
-// GetNextHTMLSibling: returns the next editable sibling, if there is
-//                   one within the parent.  just like above routine but
-//                   takes a parent/offset instead of a node.
+/**
+ * GetNextHTMLSibling() returns the next editable sibling, if there is
+ * one within the parent.  just like above routine but takes a parent/offset
+ * instead of a node.
+ */
 nsIContent*
-nsHTMLEditor::GetNextHTMLSibling(nsINode* aParent, int32_t aOffset)
+HTMLEditor::GetNextHTMLSibling(nsINode* aParent,
+                               int32_t aOffset)
 {
   MOZ_ASSERT(aParent);
 
   nsIContent* node = aParent->GetChildAt(aOffset + 1);
   if (!node || IsEditable(node)) {
     return node;
   }
 
   return GetNextHTMLSibling(node);
 }
 
 nsresult
-nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode)
+HTMLEditor::GetNextHTMLSibling(nsIDOMNode* inParent,
+                               int32_t inOffset,
+                               nsCOMPtr<nsIDOMNode>* outNode)
 {
   NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
   *outNode = nullptr;
 
   nsCOMPtr<nsINode> parent = do_QueryInterface(inParent);
   NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
 
   *outNode = do_QueryInterface(GetNextHTMLSibling(parent, inOffset));
   return NS_OK;
 }
 
-
-
-///////////////////////////////////////////////////////////////////////////
-// GetPriorHTMLNode: returns the previous editable leaf node, if there is
-//                   one within the <body>
-//
+/**
+ * GetPriorHTMLNode() returns the previous editable leaf node, if there is
+ * one within the <body>.
+ */
 nsIContent*
-nsHTMLEditor::GetPriorHTMLNode(nsINode* aNode, bool aNoBlockCrossing)
+HTMLEditor::GetPriorHTMLNode(nsINode* aNode,
+                             bool aNoBlockCrossing)
 {
   MOZ_ASSERT(aNode);
 
   if (!GetActiveEditingHost()) {
     return nullptr;
   }
 
   return GetPriorNode(aNode, true, aNoBlockCrossing);
 }
 
 nsresult
-nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode* aNode,
-                               nsCOMPtr<nsIDOMNode>* aResultNode,
-                               bool aNoBlockCrossing)
+HTMLEditor::GetPriorHTMLNode(nsIDOMNode* aNode,
+                             nsCOMPtr<nsIDOMNode>* aResultNode,
+                             bool aNoBlockCrossing)
 {
   NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
   *aResultNode = do_QueryInterface(GetPriorHTMLNode(node, aNoBlockCrossing));
   return NS_OK;
 }
 
-
-///////////////////////////////////////////////////////////////////////////
-// GetPriorHTMLNode: same as above but takes {parent,offset} instead of node
-//
+/**
+ * GetPriorHTMLNode() is same as above but takes {parent,offset} instead of
+ * node.
+ */
 nsIContent*
-nsHTMLEditor::GetPriorHTMLNode(nsINode* aParent, int32_t aOffset,
-                               bool aNoBlockCrossing)
+HTMLEditor::GetPriorHTMLNode(nsINode* aParent,
+                             int32_t aOffset,
+                             bool aNoBlockCrossing)
 {
   MOZ_ASSERT(aParent);
 
   if (!GetActiveEditingHost()) {
     return nullptr;
   }
 
   return GetPriorNode(aParent, aOffset, true, aNoBlockCrossing);
 }
 
 nsresult
-nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode* aNode, int32_t aOffset,
-                               nsCOMPtr<nsIDOMNode>* aResultNode,
-                               bool aNoBlockCrossing)
+HTMLEditor::GetPriorHTMLNode(nsIDOMNode* aNode,
+                             int32_t aOffset,
+                             nsCOMPtr<nsIDOMNode>* aResultNode,
+                             bool aNoBlockCrossing)
 {
   NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
   *aResultNode = do_QueryInterface(GetPriorHTMLNode(node, aOffset,
                                                     aNoBlockCrossing));
   return NS_OK;
 }
 
-
-///////////////////////////////////////////////////////////////////////////
-// GetNextHTMLNode: returns the next editable leaf node, if there is
-//                   one within the <body>
-//
+/**
+ * GetNextHTMLNode() returns the next editable leaf node, if there is
+ * one within the <body>.
+ */
 nsIContent*
-nsHTMLEditor::GetNextHTMLNode(nsINode* aNode, bool aNoBlockCrossing)
+HTMLEditor::GetNextHTMLNode(nsINode* aNode,
+                            bool aNoBlockCrossing)
 {
   MOZ_ASSERT(aNode);
 
   nsIContent* result = GetNextNode(aNode, true, aNoBlockCrossing);
 
   if (result && !IsDescendantOfEditorRoot(result)) {
     return nullptr;
   }
 
   return result;
 }
 
 nsresult
-nsHTMLEditor::GetNextHTMLNode(nsIDOMNode* aNode,
-                              nsCOMPtr<nsIDOMNode>* aResultNode,
-                              bool aNoBlockCrossing)
+HTMLEditor::GetNextHTMLNode(nsIDOMNode* aNode,
+                            nsCOMPtr<nsIDOMNode>* aResultNode,
+                            bool aNoBlockCrossing)
 {
   NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
   *aResultNode = do_QueryInterface(GetNextHTMLNode(node, aNoBlockCrossing));
   return NS_OK;
 }
 
-
-///////////////////////////////////////////////////////////////////////////
-// GetNextHTMLNode: same as above but takes {parent,offset} instead of node
-//
+/**
+ * GetNextHTMLNode() is same as above but takes {parent,offset} instead of node.
+ */
 nsIContent*
-nsHTMLEditor::GetNextHTMLNode(nsINode* aParent, int32_t aOffset,
-                              bool aNoBlockCrossing)
+HTMLEditor::GetNextHTMLNode(nsINode* aParent,
+                            int32_t aOffset,
+                            bool aNoBlockCrossing)
 {
   nsIContent* content = GetNextNode(aParent, aOffset, true, aNoBlockCrossing);
   if (content && !IsDescendantOfEditorRoot(content)) {
     return nullptr;
   }
   return content;
 }
 
 nsresult
-nsHTMLEditor::GetNextHTMLNode(nsIDOMNode* aNode, int32_t aOffset,
-                              nsCOMPtr<nsIDOMNode>* aResultNode,
-                              bool aNoBlockCrossing)
+HTMLEditor::GetNextHTMLNode(nsIDOMNode* aNode,
+                            int32_t aOffset,
+                            nsCOMPtr<nsIDOMNode>* aResultNode,
+                            bool aNoBlockCrossing)
 {
   NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
 
   *aResultNode = do_QueryInterface(GetNextHTMLNode(node, aOffset,
                                                    aNoBlockCrossing));
   return NS_OK;
 }
 
-
 nsresult
-nsHTMLEditor::IsFirstEditableChild( nsIDOMNode *aNode, bool *aOutIsFirst)
+HTMLEditor::IsFirstEditableChild(nsIDOMNode* aNode,
+                                 bool* aOutIsFirst)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(aOutIsFirst && node, NS_ERROR_NULL_POINTER);
 
   // init out parms
   *aOutIsFirst = false;
 
   // find first editable child and compare it to aNode
   nsCOMPtr<nsINode> parent = node->GetParentNode();
   NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE);
 
   *aOutIsFirst = (GetFirstEditableChild(*parent) == node);
   return NS_OK;
 }
 
-
 nsresult
-nsHTMLEditor::IsLastEditableChild( nsIDOMNode *aNode, bool *aOutIsLast)
+HTMLEditor::IsLastEditableChild(nsIDOMNode* aNode,
+                                bool* aOutIsLast)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(aOutIsLast && node, NS_ERROR_NULL_POINTER);
 
   // init out parms
   *aOutIsLast = false;
 
   // find last editable child and compare it to aNode
   nsCOMPtr<nsINode> parent = node->GetParentNode();
   NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE);
 
   *aOutIsLast = (GetLastEditableChild(*parent) == node);
   return NS_OK;
 }
 
-
 nsIContent*
-nsHTMLEditor::GetFirstEditableChild(nsINode& aNode)
+HTMLEditor::GetFirstEditableChild(nsINode& aNode)
 {
   nsCOMPtr<nsIContent> child = aNode.GetFirstChild();
 
   while (child && !IsEditable(child)) {
     child = child->GetNextSibling();
   }
 
   return child;
 }
 
-
 nsIContent*
-nsHTMLEditor::GetLastEditableChild(nsINode& aNode)
+HTMLEditor::GetLastEditableChild(nsINode& aNode)
 {
   nsCOMPtr<nsIContent> child = aNode.GetLastChild();
 
   while (child && !IsEditable(child)) {
     child = child->GetPreviousSibling();
   }
 
   return child;
 }
 
 nsIContent*
-nsHTMLEditor::GetFirstEditableLeaf(nsINode& aNode)
+HTMLEditor::GetFirstEditableLeaf(nsINode& aNode)
 {
   nsCOMPtr<nsIContent> child = GetLeftmostChild(&aNode);
   while (child && (!IsEditable(child) || child->HasChildren())) {
     child = GetNextHTMLNode(child);
 
     // Only accept nodes that are descendants of aNode
     if (!aNode.Contains(child)) {
       return nullptr;
     }
   }
 
   return child;
 }
 
-
 nsIContent*
-nsHTMLEditor::GetLastEditableLeaf(nsINode& aNode)
+HTMLEditor::GetLastEditableLeaf(nsINode& aNode)
 {
   nsCOMPtr<nsIContent> child = GetRightmostChild(&aNode, false);
   while (child && (!IsEditable(child) || child->HasChildren())) {
     child = GetPriorHTMLNode(child);
 
     // Only accept nodes that are descendants of aNode
     if (!aNode.Contains(child)) {
       return nullptr;
     }
   }
 
   return child;
 }
 
-
-///////////////////////////////////////////////////////////////////////////
-// IsVisTextNode: figure out if textnode aTextNode has any visible content.
-//
+/**
+ * IsVisTextNode() figures out if textnode aTextNode has any visible content.
+ */
 nsresult
-nsHTMLEditor::IsVisTextNode(nsIContent* aNode,
-                            bool* outIsEmptyNode,
-                            bool aSafeToAskFrames)
+HTMLEditor::IsVisTextNode(nsIContent* aNode,
+                          bool* outIsEmptyNode,
+                          bool aSafeToAskFrames)
 {
   MOZ_ASSERT(aNode);
   MOZ_ASSERT(aNode->NodeType() == nsIDOMNode::TEXT_NODE);
   MOZ_ASSERT(outIsEmptyNode);
 
   *outIsEmptyNode = true;
 
   uint32_t length = aNode->TextLength();
@@ -4261,58 +4292,57 @@ nsHTMLEditor::IsVisTextNode(nsIContent* 
     else
     {
       *outIsEmptyNode = false;
     }
   }
   return NS_OK;
 }
 
-
-///////////////////////////////////////////////////////////////////////////
-// IsEmptyNode: figure out if aNode is an empty node.
-//               A block can have children and still be considered empty,
-//               if the children are empty or non-editable.
-//
+/**
+ * IsEmptyNode() figures out if aNode is an empty node.  A block can have
+ * children and still be considered empty, if the children are empty or
+ * non-editable.
+ */
 nsresult
-nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
-                           bool *outIsEmptyNode,
-                           bool aSingleBRDoesntCount,
-                           bool aListOrCellNotEmpty,
-                           bool aSafeToAskFrames)
+HTMLEditor::IsEmptyNode(nsIDOMNode*aNode,
+                        bool* outIsEmptyNode,
+                        bool aSingleBRDoesntCount,
+                        bool aListOrCellNotEmpty,
+                        bool aSafeToAskFrames)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   return IsEmptyNode(node, outIsEmptyNode, aSingleBRDoesntCount,
                      aListOrCellNotEmpty, aSafeToAskFrames);
 }
 
 nsresult
-nsHTMLEditor::IsEmptyNode(nsINode* aNode,
-                          bool* outIsEmptyNode,
-                          bool aSingleBRDoesntCount,
-                          bool aListOrCellNotEmpty,
-                          bool aSafeToAskFrames)
+HTMLEditor::IsEmptyNode(nsINode* aNode,
+                        bool* outIsEmptyNode,
+                        bool aSingleBRDoesntCount,
+                        bool aListOrCellNotEmpty,
+                        bool aSafeToAskFrames)
 {
   NS_ENSURE_TRUE(aNode && outIsEmptyNode, NS_ERROR_NULL_POINTER);
   *outIsEmptyNode = true;
   bool seenBR = false;
   return IsEmptyNodeImpl(aNode, outIsEmptyNode, aSingleBRDoesntCount,
                          aListOrCellNotEmpty, aSafeToAskFrames, &seenBR);
 }
 
-///////////////////////////////////////////////////////////////////////////
-// IsEmptyNodeImpl: workhorse for IsEmptyNode.
-//
+/**
+ * IsEmptyNodeImpl() is workhorse for IsEmptyNode().
+ */
 nsresult
-nsHTMLEditor::IsEmptyNodeImpl(nsINode* aNode,
-                              bool *outIsEmptyNode,
-                              bool aSingleBRDoesntCount,
-                              bool aListOrCellNotEmpty,
-                              bool aSafeToAskFrames,
-                              bool *aSeenBR)
+HTMLEditor::IsEmptyNodeImpl(nsINode* aNode,
+                            bool* outIsEmptyNode,
+                            bool aSingleBRDoesntCount,
+                            bool aListOrCellNotEmpty,
+                            bool aSafeToAskFrames,
+                            bool* aSeenBR)
 {
   NS_ENSURE_TRUE(aNode && outIsEmptyNode && aSeenBR, NS_ERROR_NULL_POINTER);
 
   if (aNode->NodeType() == nsIDOMNode::TEXT_NODE) {
     return IsVisTextNode(static_cast<nsIContent*>(aNode), outIsEmptyNode, aSafeToAskFrames);
   }
 
   // if it's not a text node (handled above) and it's not a container,
@@ -4396,20 +4426,20 @@ nsHTMLEditor::IsEmptyNodeImpl(nsINode* a
   }
 
   return NS_OK;
 }
 
 // add to aElement the CSS inline styles corresponding to the HTML attribute
 // aAttribute with its value aValue
 nsresult
-nsHTMLEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
-                                       const nsAString & aAttribute,
-                                       const nsAString & aValue,
-                                       bool aSuppressTransaction)
+HTMLEditor::SetAttributeOrEquivalent(nsIDOMElement* aElement,
+                                     const nsAString& aAttribute,
+                                     const nsAString& aValue,
+                                     bool aSuppressTransaction)
 {
   nsAutoScriptBlocker scriptBlocker;
 
   nsresult res = NS_OK;
   if (IsCSSEnabled() && mCSSEditUtils) {
     int32_t count;
     res = mCSSEditUtils->SetCSSEquivalentToHTMLStyle(aElement, nullptr,
                                                      &aAttribute, &aValue,
@@ -4463,19 +4493,19 @@ nsHTMLEditor::SetAttributeOrEquivalent(n
       res = aElement->SetAttribute(aAttribute, aValue);
     else
       res = SetAttribute(aElement, aAttribute, aValue);
   }
   return res;
 }
 
 nsresult
-nsHTMLEditor::RemoveAttributeOrEquivalent(nsIDOMElement* aElement,
-                                          const nsAString& aAttribute,
-                                          bool aSuppressTransaction)
+HTMLEditor::RemoveAttributeOrEquivalent(nsIDOMElement* aElement,
+                                        const nsAString& aAttribute,
+                                        bool aSuppressTransaction)
 {
   nsCOMPtr<dom::Element> element = do_QueryInterface(aElement);
   NS_ENSURE_TRUE(element, NS_OK);
 
   nsCOMPtr<nsIAtom> attribute = NS_Atomize(aAttribute);
   MOZ_ASSERT(attribute);
 
   nsresult res = NS_OK;
@@ -4492,17 +4522,17 @@ nsHTMLEditor::RemoveAttributeOrEquivalen
     } else {
       res = RemoveAttribute(aElement, aAttribute);
     }
   }
   return res;
 }
 
 nsresult
-nsHTMLEditor::SetIsCSSEnabled(bool aIsCSSPrefChecked)
+HTMLEditor::SetIsCSSEnabled(bool aIsCSSPrefChecked)
 {
   if (!mCSSEditUtils) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   mCSSEditUtils->SetCSSEnabled(aIsCSSPrefChecked);
 
   // Disable the eEditorNoCSSMask flag if we're enabling StyleWithCSS.
@@ -4515,17 +4545,17 @@ nsHTMLEditor::SetIsCSSEnabled(bool aIsCS
     flags |= eEditorNoCSSMask;
   }
 
   return SetFlags(flags);
 }
 
 // Set the block background color
 nsresult
-nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
+HTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
 {
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
   ForceCompositionEnd();
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   RefPtr<Selection> selection = GetSelection();
@@ -4660,38 +4690,38 @@ nsHTMLEditor::SetCSSBackgroundColor(cons
     // Post-process
     res = mRules->DidDoAction(selection, &ruleInfo, res);
     NS_ENSURE_SUCCESS(res, res);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetBackgroundColor(const nsAString& aColor)
+HTMLEditor::SetBackgroundColor(const nsAString& aColor)
 {
   nsresult res;
   if (IsCSSEnabled()) {
     // if we are in CSS mode, we have to apply the background color to the
     // containing block (or the body if we have no block-level element in
     // the document)
     res = SetCSSBackgroundColor(aColor);
   }
   else {
     // but in HTML mode, we can only set the document's background color
     res = SetHTMLBackgroundColor(aColor);
   }
   return res;
 }
 
-///////////////////////////////////////////////////////////////////////////
-// NodesSameType: do these nodes have the same tag?
-//
-/* virtual */
+/**
+ * NodesSameType() does these nodes have the same tag?
+ */
 bool
-nsHTMLEditor::AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2)
+HTMLEditor::AreNodesSameType(nsIContent* aNode1,
+                             nsIContent* aNode2)
 {
   MOZ_ASSERT(aNode1);
   MOZ_ASSERT(aNode2);
 
   if (aNode1->NodeInfo()->NameAtom() != aNode2->NodeInfo()->NameAtom()) {
     return false;
   }
 
@@ -4700,18 +4730,19 @@ nsHTMLEditor::AreNodesSameType(nsIConten
   }
 
   // If CSS is enabled, we are stricter about span nodes.
   return mCSSEditUtils->ElementsSameStyle(aNode1->AsDOMNode(),
                                           aNode2->AsDOMNode());
 }
 
 nsresult
-nsHTMLEditor::CopyLastEditableChildStyles(nsIDOMNode * aPreviousBlock, nsIDOMNode * aNewBlock,
-                                          Element** aOutBrNode)
+HTMLEditor::CopyLastEditableChildStyles(nsIDOMNode* aPreviousBlock,
+                                        nsIDOMNode* aNewBlock,
+                                        Element** aOutBrNode)
 {
   nsCOMPtr<nsINode> newBlock = do_QueryInterface(aNewBlock);
   NS_ENSURE_STATE(newBlock || !aNewBlock);
   *aOutBrNode = nullptr;
   nsCOMPtr<nsIDOMNode> child, tmp;
   nsresult res;
   // first, clear out aNewBlock.  Contract is that we want only the styles from previousBlock.
   res = aNewBlock->GetFirstChild(getter_AddRefs(child));
@@ -4763,17 +4794,19 @@ nsHTMLEditor::CopyLastEditableChildStyle
     RefPtr<Element> retVal = CreateBR(deepestStyle, 0);
     retVal.forget(aOutBrNode);
     NS_ENSURE_STATE(*aOutBrNode);
   }
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::GetElementOrigin(nsIDOMElement * aElement, int32_t & aX, int32_t & aY)
+HTMLEditor::GetElementOrigin(nsIDOMElement* aElement,
+                             int32_t& aX,
+                             int32_t& aY)
 {
   aX = 0;
   aY = 0;
 
   NS_ENSURE_TRUE(mDocWeak, NS_ERROR_NOT_INITIALIZED);
   nsCOMPtr<nsIPresShell> ps = GetPresShell();
   NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED);
 
@@ -4786,17 +4819,17 @@ nsHTMLEditor::GetElementOrigin(nsIDOMEle
   nsPoint off = frame->GetOffsetTo(container);
   aX = nsPresContext::AppUnitsToIntCSSPixels(off.x);
   aY = nsPresContext::AppUnitsToIntCSSPixels(off.y);
 
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::EndUpdateViewBatch()
+HTMLEditor::EndUpdateViewBatch()
 {
   nsresult res = nsEditor::EndUpdateViewBatch();
   NS_ENSURE_SUCCESS(res, res);
 
   // We may need to show resizing handles or update existing ones after
   // all transactions are done. This way of doing is preferred to DOM
   // mutation events listeners because all the changes the user can apply
   // to a document may result in multiple events, some of them quite hard
@@ -4806,27 +4839,27 @@ nsHTMLEditor::EndUpdateViewBatch()
     RefPtr<Selection> selection = GetSelection();
     NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
     res = CheckSelectionStateForAnonymousButtons(selection);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetSelectionContainer(nsIDOMElement** aReturn)
+HTMLEditor::GetSelectionContainer(nsIDOMElement** aReturn)
 {
   nsCOMPtr<nsIDOMElement> container =
     static_cast<nsIDOMElement*>(GetAsDOMNode(GetSelectionContainer()));
   NS_ENSURE_TRUE(container, NS_ERROR_FAILURE);
   container.forget(aReturn);
   return NS_OK;
 }
 
 Element*
-nsHTMLEditor::GetSelectionContainer()
+HTMLEditor::GetSelectionContainer()
 {
   // If we don't get the selection, just skip this
   NS_ENSURE_TRUE(GetSelection(), nullptr);
 
   OwningNonNull<Selection> selection = *GetSelection();
 
   nsCOMPtr<nsINode> focusNode;
 
@@ -4877,46 +4910,47 @@ nsHTMLEditor::GetSelectionContainer()
   if (focusNode && focusNode->IsElement()) {
     return focusNode->AsElement();
   }
 
   return nullptr;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::IsAnonymousElement(nsIDOMElement * aElement, bool * aReturn)
+HTMLEditor::IsAnonymousElement(nsIDOMElement* aElement,
+                               bool* aReturn)
 {
   NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
   *aReturn = content->IsRootOfNativeAnonymousSubtree();
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::SetReturnInParagraphCreatesNewParagraph(bool aCreatesNewParagraph)
+HTMLEditor::SetReturnInParagraphCreatesNewParagraph(bool aCreatesNewParagraph)
 {
   mCRInParagraphCreatesParagraph = aCreatesNewParagraph;
   return NS_OK;
 }
 
 bool
-nsHTMLEditor::GetReturnInParagraphCreatesNewParagraph()
+HTMLEditor::GetReturnInParagraphCreatesNewParagraph()
 {
   return mCRInParagraphCreatesParagraph;
 }
 
 nsresult
-nsHTMLEditor::GetReturnInParagraphCreatesNewParagraph(bool *aCreatesNewParagraph)
+HTMLEditor::GetReturnInParagraphCreatesNewParagraph(bool* aCreatesNewParagraph)
 {
   *aCreatesNewParagraph = mCRInParagraphCreatesParagraph;
   return NS_OK;
 }
 
 already_AddRefed<nsIContent>
-nsHTMLEditor::GetFocusedContent()
+HTMLEditor::GetFocusedContent()
 {
   NS_ENSURE_TRUE(mDocWeak, nullptr);
 
   nsFocusManager* fm = nsFocusManager::GetFocusManager();
   NS_ENSURE_TRUE(fm, nullptr);
 
   nsCOMPtr<nsIContent> focusedContent = fm->GetFocusedContent();
 
@@ -4945,30 +4979,30 @@ nsHTMLEditor::GetFocusedContent()
       focusedContent->HasIndependentSelection()) {
     return nullptr;
   }
   // If our window is focused, we're focused.
   return OurWindowHasFocus() ? focusedContent.forget() : nullptr;
 }
 
 already_AddRefed<nsIContent>
-nsHTMLEditor::GetFocusedContentForIME()
+HTMLEditor::GetFocusedContentForIME()
 {
   nsCOMPtr<nsIContent> focusedContent = GetFocusedContent();
   if (!focusedContent) {
     return nullptr;
   }
 
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
   NS_ENSURE_TRUE(doc, nullptr);
   return doc->HasFlag(NODE_IS_EDITABLE) ? nullptr : focusedContent.forget();
 }
 
 bool
-nsHTMLEditor::IsActiveInDOMWindow()
+HTMLEditor::IsActiveInDOMWindow()
 {
   NS_ENSURE_TRUE(mDocWeak, false);
 
   nsFocusManager* fm = nsFocusManager::GetFocusManager();
   NS_ENSURE_TRUE(fm, false);
 
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
   bool inDesignMode = doc->HasFlag(NODE_IS_EDITABLE);
@@ -4993,18 +5027,18 @@ nsHTMLEditor::IsActiveInDOMWindow()
   // we're not active).
   if (!content->HasFlag(NODE_IS_EDITABLE) ||
       content->HasIndependentSelection()) {
     return false;
   }
   return true;
 }
 
-dom::Element*
-nsHTMLEditor::GetActiveEditingHost()
+Element*
+HTMLEditor::GetActiveEditingHost()
 {
   NS_ENSURE_TRUE(mDocWeak, nullptr);
 
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
   NS_ENSURE_TRUE(doc, nullptr);
   if (doc->HasFlag(NODE_IS_EDITABLE)) {
     return doc->GetBodyElement();
   }
@@ -5024,44 +5058,44 @@ nsHTMLEditor::GetActiveEditingHost()
   // we're not active.
   if (!content->HasFlag(NODE_IS_EDITABLE) ||
       content->HasIndependentSelection()) {
     return nullptr;
   }
   return content->GetEditingHost();
 }
 
-already_AddRefed<mozilla::dom::EventTarget>
-nsHTMLEditor::GetDOMEventTarget()
+already_AddRefed<EventTarget>
+HTMLEditor::GetDOMEventTarget()
 {
   // Don't use getDocument here, because we have no way of knowing
   // whether Init() was ever called.  So we need to get the document
   // ourselves, if it exists.
   NS_PRECONDITION(mDocWeak, "This editor has not been initialized yet");
   nsCOMPtr<mozilla::dom::EventTarget> target = do_QueryReferent(mDocWeak);
   return target.forget();
 }
 
 bool
-nsHTMLEditor::ShouldReplaceRootElement()
+HTMLEditor::ShouldReplaceRootElement()
 {
   if (!mRootElement) {
     // If we don't know what is our root element, we should find our root.
     return true;
   }
 
   // If we temporary set document root element to mRootElement, but there is
   // body element now, we should replace the root element by the body element.
   nsCOMPtr<nsIDOMHTMLElement> docBody;
   GetBodyElement(getter_AddRefs(docBody));
   return !SameCOMIdentity(docBody, mRootElement);
 }
 
 void
-nsHTMLEditor::ResetRootElementAndEventTarget()
+HTMLEditor::ResetRootElementAndEventTarget()
 {
   nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
 
   // Need to remove the event listeners first because BeginningOfDocument
   // could set a new root (and event target is set by InstallEventListeners())
   // and we won't be able to remove them from the old event target then.
   RemoveEventListeners();
   mRootElement = nullptr;
@@ -5089,28 +5123,28 @@ nsHTMLEditor::ResetRootElementAndEventTa
   if (target) {
     InitializeSelection(target);
   }
 
   SyncRealTimeSpell();
 }
 
 nsresult
-nsHTMLEditor::GetBodyElement(nsIDOMHTMLElement** aBody)
+HTMLEditor::GetBodyElement(nsIDOMHTMLElement** aBody)
 {
   NS_PRECONDITION(mDocWeak, "bad state, null mDocWeak");
   nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryReferent(mDocWeak);
   if (!htmlDoc) {
     return NS_ERROR_NOT_INITIALIZED;
   }
   return htmlDoc->GetBody(aBody);
 }
 
 already_AddRefed<nsINode>
-nsHTMLEditor::GetFocusedNode()
+HTMLEditor::GetFocusedNode()
 {
   nsCOMPtr<nsIContent> focusedContent = GetFocusedContent();
   if (!focusedContent) {
     return nullptr;
   }
 
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   NS_ASSERTION(fm, "Focus manager is null");
@@ -5121,33 +5155,33 @@ nsHTMLEditor::GetFocusedNode()
     return node.forget();
   }
 
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
   return doc.forget();
 }
 
 bool
-nsHTMLEditor::OurWindowHasFocus()
+HTMLEditor::OurWindowHasFocus()
 {
   NS_ENSURE_TRUE(mDocWeak, false);
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   NS_ENSURE_TRUE(fm, false);
   nsCOMPtr<mozIDOMWindowProxy> focusedWindow;
   fm->GetFocusedWindow(getter_AddRefs(focusedWindow));
   if (!focusedWindow) {
     return false;
   }
   nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
   nsPIDOMWindowOuter* ourWindow = doc->GetWindow();
   return ourWindow == focusedWindow;
 }
 
 bool
-nsHTMLEditor::IsAcceptableInputEvent(nsIDOMEvent* aEvent)
+HTMLEditor::IsAcceptableInputEvent(nsIDOMEvent* aEvent)
 {
   if (!nsEditor::IsAcceptableInputEvent(aEvent)) {
     return false;
   }
 
   // While there is composition, all composition events in its top level window
   // are always fired on the composing editor.  Therefore, if this editor has
   // composition, the composition events should be handled in this editor.
@@ -5222,47 +5256,49 @@ nsHTMLEditor::IsAcceptableInputEvent(nsI
   // Finally, check whether we're actually focused or not.  When we're not
   // focused, we should ignore the dispatched event by script (or something)
   // because content editable element needs selection in itself for editing.
   // However, when we're not focused, it's not guaranteed.
   return IsActiveInDOMWindow();
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetPreferredIMEState(IMEState *aState)
+HTMLEditor::GetPreferredIMEState(IMEState* aState)
 {
   // HTML editor don't prefer the CSS ime-mode because IE didn't do so too.
   aState->mOpen = IMEState::DONT_CHANGE_OPEN_STATE;
   if (IsReadonly() || IsDisabled()) {
     aState->mEnabled = IMEState::DISABLED;
   } else {
     aState->mEnabled = IMEState::ENABLED;
   }
   return NS_OK;
 }
 
 already_AddRefed<nsIContent>
-nsHTMLEditor::GetInputEventTargetContent()
+HTMLEditor::GetInputEventTargetContent()
 {
   nsCOMPtr<nsIContent> target = GetActiveEditingHost();
   return target.forget();
 }
 
 bool
-nsHTMLEditor::IsEditable(nsINode* aNode) {
+HTMLEditor::IsEditable(nsINode* aNode)
+{
   if (!nsPlaintextEditor::IsEditable(aNode)) {
     return false;
   }
   if (aNode->IsElement()) {
     // If we're dealing with an element, then ask it whether it's editable.
     return aNode->IsEditable();
   }
   // We might be dealing with a text node for example, which we always consider
   // to be editable.
   return true;
 }
 
-// virtual override
-dom::Element*
-nsHTMLEditor::GetEditorRoot()
+Element*
+HTMLEditor::GetEditorRoot()
 {
   return GetActiveEditingHost();
 }
+
+} // namespace mozilla
rename from editor/libeditor/nsHTMLEditor.h
rename to editor/libeditor/HTMLEditor.h
--- a/editor/libeditor/nsHTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -1,250 +1,259 @@
 /* -*- 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 nsHTMLEditor_h__
-#define nsHTMLEditor_h__
-
-#include "nsCOMPtr.h"
-#include "nsPlaintextEditor.h"
-#include "nsIEditor.h"
-#include "nsIHTMLEditor.h"
-#include "nsITableEditor.h"
-#include "nsIEditorMailSupport.h"
-#include "nsIEditRules.h"
-#include "nsIEditorStyleSheets.h"
-#include "nsIEditorUtils.h"
-
-#include "nsEditor.h"
-#include "nsIDOMElement.h"
-#include "nsIDOMEventListener.h"
-#include "nsICSSLoaderObserver.h"
+#ifndef mozilla_HTMLEditor_h
+#define mozilla_HTMLEditor_h
 
 #include "CSSEditUtils.h"
 
-#include "nsHTMLObjectResizer.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/StyleSheetHandle.h"
+#include "mozilla/dom/Element.h"
+#include "mozilla/dom/File.h"
+
+#include "nsAttrName.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsIContentFilter.h"
+#include "nsICSSLoaderObserver.h"
+#include "nsIDocumentObserver.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMEventListener.h"
+#include "nsIEditor.h"
+#include "nsIEditorMailSupport.h"
+#include "nsIEditorStyleSheets.h"
+#include "nsIEditorUtils.h"
+#include "nsIEditRules.h"
 #include "nsIHTMLAbsPosEditor.h"
+#include "nsIHTMLEditor.h"
 #include "nsIHTMLInlineTableEditor.h"
 #include "nsIHTMLObjectResizeListener.h"
 #include "nsIHTMLObjectResizer.h"
-
-#include "nsIContentFilter.h"
-#include "nsIDocumentObserver.h"
-
+#include "nsISelectionListener.h"
+#include "nsITableEditor.h"
+#include "nsPlaintextEditor.h"
 #include "nsPoint.h"
+#include "nsStubMutationObserver.h"
 #include "nsTArray.h"
-#include "nsAutoPtr.h"
-#include "nsAttrName.h"
-#include "nsStubMutationObserver.h"
-
-#include "mozilla/Attributes.h"
-#include "mozilla/dom/Element.h"
-#include "mozilla/dom/File.h"
-#include "mozilla/StyleSheetHandle.h"
 
 class nsDocumentFragment;
 class nsIDOMKeyEvent;
 class nsITransferable;
 class nsIClipboard;
 class nsILinkHandler;
 class nsTableWrapperFrame;
 class nsIDOMRange;
 class nsRange;
 
 namespace mozilla {
+
 class HTMLEditorEventListener;
 class HTMLEditRules;
 class TextEditRules;
 class TypeInState;
 class WSRunObject;
 struct PropItem;
 template<class T> class OwningNonNull;
 namespace dom {
 class DocumentFragment;
 } // namespace dom
 namespace widget {
 struct IMEState;
 } // namespace widget
-} // namespace mozilla
 
 /**
  * The HTML editor implementation.<br>
  * Use to edit HTML document represented as a DOM tree.
  */
-class nsHTMLEditor final : public nsPlaintextEditor,
-                           public nsIHTMLEditor,
-                           public nsIHTMLObjectResizer,
-                           public nsIHTMLAbsPosEditor,
-                           public nsITableEditor,
-                           public nsIHTMLInlineTableEditor,
-                           public nsIEditorStyleSheets,
-                           public nsICSSLoaderObserver,
-                           public nsStubMutationObserver
+class HTMLEditor final : public nsPlaintextEditor
+                       , public nsIHTMLEditor
+                       , public nsIHTMLObjectResizer
+                       , public nsIHTMLAbsPosEditor
+                       , public nsITableEditor
+                       , public nsIHTMLInlineTableEditor
+                       , public nsIEditorStyleSheets
+                       , public nsICSSLoaderObserver
+                       , public nsStubMutationObserver
 {
-  typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType;
+private:
+  enum BlockTransformationType
+  {
+    eNoOp,
+    eReplaceParent = 1,
+    eInsertParent = 2
+  };
 
   const char16_t kNBSP = 160;
 
 public:
-
   enum ResizingRequestID
   {
     kX      = 0,
     kY      = 1,
     kWidth  = 2,
     kHeight = 3
   };
 
-  // see nsIHTMLEditor for documentation
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLEditor, nsPlaintextEditor)
 
-//Interfaces for addref and release and queryinterface
-//NOTE macro used is for classes that inherit from
-// another class. Only the base class should use NS_DECL_ISUPPORTS
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLEditor, nsPlaintextEditor)
-
-
-  nsHTMLEditor();
+  HTMLEditor();
 
   bool GetReturnInParagraphCreatesNewParagraph();
   Element* GetSelectionContainer();
 
-  /* ------------ nsPlaintextEditor overrides -------------- */
-  NS_IMETHOD GetIsDocumentEditable(bool *aIsDocumentEditable) override;
+  // nsPlaintextEditor overrides
+  NS_IMETHOD GetIsDocumentEditable(bool* aIsDocumentEditable) override;
   NS_IMETHOD BeginningOfDocument() override;
   virtual nsresult HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) override;
   virtual already_AddRefed<nsIContent> GetFocusedContent() override;
   virtual already_AddRefed<nsIContent> GetFocusedContentForIME() override;
   virtual bool IsActiveInDOMWindow() override;
-  virtual already_AddRefed<mozilla::dom::EventTarget> GetDOMEventTarget() override;
+  virtual already_AddRefed<dom::EventTarget> GetDOMEventTarget() override;
   virtual Element* GetEditorRoot() override;
-  virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode *aNode) override;
+  virtual already_AddRefed<nsIContent> FindSelectionRoot(
+                                         nsINode *aNode) override;
   virtual bool IsAcceptableInputEvent(nsIDOMEvent* aEvent) override;
   virtual already_AddRefed<nsIContent> GetInputEventTargetContent() override;
   virtual bool IsEditable(nsINode* aNode) override;
   using nsEditor::IsEditable;
 
-  /* ------------ nsStubMutationObserver overrides --------- */
+  // nsStubMutationObserver overrides
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
-  /* ------------ nsIEditorIMESupport overrides ------------ */
-  NS_IMETHOD GetPreferredIMEState(mozilla::widget::IMEState *aState) override;
+  // nsIEditorIMESupport overrides
+  NS_IMETHOD GetPreferredIMEState(widget::IMEState* aState) override;
 
-  /* ------------ nsIHTMLEditor methods -------------- */
-
+  // nsIHTMLEditor methods
   NS_DECL_NSIHTMLEDITOR
 
-  /* ------------ nsIHTMLObjectResizer methods -------------- */
-  /* -------- Implemented in nsHTMLObjectResizer.cpp -------- */
+  // nsIHTMLObjectResizer methods (implemented in HTMLObjectResizer.cpp)
   NS_DECL_NSIHTMLOBJECTRESIZER
 
-  /* ------------ nsIHTMLAbsPosEditor methods -------------- */
-  /* -------- Implemented in nsHTMLAbsPosition.cpp --------- */
+  // nsIHTMLAbsPosEditor methods (implemented in HTMLAbsPositionEditor.cpp)
   NS_DECL_NSIHTMLABSPOSEDITOR
 
-  /* ------------ nsIHTMLInlineTableEditor methods -------------- */
-  /* ------- Implemented in nsHTMLInlineTableEditor.cpp --------- */
+  // nsIHTMLInlineTableEditor methods (implemented in HTMLInlineTableEditor.cpp)
   NS_DECL_NSIHTMLINLINETABLEEDITOR
 
-  /* ------------ nsIHTMLEditor methods -------------- */
-  nsresult CopyLastEditableChildStyles(nsIDOMNode *aPreviousBlock, nsIDOMNode *aNewBlock,
+  // XXX Following methods are not overriding but defined here...
+  nsresult CopyLastEditableChildStyles(nsIDOMNode* aPreviousBlock,
+                                       nsIDOMNode* aNewBlock,
                                        Element** aOutBrNode);
 
-  nsresult LoadHTML(const nsAString &aInputString);
+  nsresult LoadHTML(const nsAString& aInputString);
 
-  nsresult GetCSSBackgroundColorState(bool *aMixed, nsAString &aOutColor,
+  nsresult GetCSSBackgroundColorState(bool* aMixed, nsAString& aOutColor,
                                       bool aBlockLevel);
-  NS_IMETHOD GetHTMLBackgroundColorState(bool *aMixed, nsAString &outColor);
+  NS_IMETHOD GetHTMLBackgroundColorState(bool* aMixed, nsAString& outColor);
 
-  /* ------------ nsIEditorStyleSheets methods -------------- */
-
-  NS_IMETHOD AddStyleSheet(const nsAString & aURL) override;
+  // nsIEditorStyleSheets methods
+  NS_IMETHOD AddStyleSheet(const nsAString& aURL) override;
   NS_IMETHOD ReplaceStyleSheet(const nsAString& aURL) override;
   NS_IMETHOD RemoveStyleSheet(const nsAString &aURL) override;
 
-  NS_IMETHOD AddOverrideStyleSheet(const nsAString & aURL) override;
+  NS_IMETHOD AddOverrideStyleSheet(const nsAString& aURL) override;
   NS_IMETHOD ReplaceOverrideStyleSheet(const nsAString& aURL) override;
   NS_IMETHOD RemoveOverrideStyleSheet(const nsAString &aURL) override;
 
   NS_IMETHOD EnableStyleSheet(const nsAString& aURL, bool aEnable) override;
 
-  /* ------------ nsIEditorMailSupport methods -------------- */
-
+  // nsIEditorMailSupport methods
   NS_DECL_NSIEDITORMAILSUPPORT
 
-  /* ------------ nsITableEditor methods -------------- */
-
+  // nsITableEditor methods
   NS_IMETHOD InsertTableCell(int32_t aNumber, bool aAfter) override;
   NS_IMETHOD InsertTableColumn(int32_t aNumber, bool aAfter) override;
   NS_IMETHOD InsertTableRow(int32_t aNumber, bool aAfter) override;
   NS_IMETHOD DeleteTable() override;
   NS_IMETHOD DeleteTableCell(int32_t aNumber) override;
   NS_IMETHOD DeleteTableCellContents() override;
   NS_IMETHOD DeleteTableColumn(int32_t aNumber) override;
   NS_IMETHOD DeleteTableRow(int32_t aNumber) override;
   NS_IMETHOD SelectTableCell() override;
-  NS_IMETHOD SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndCell) override;
+  NS_IMETHOD SelectBlockOfCells(nsIDOMElement* aStartCell,
+                                nsIDOMElement* aEndCell) override;
   NS_IMETHOD SelectTableRow() override;
   NS_IMETHOD SelectTableColumn() override;
   NS_IMETHOD SelectTable() override;
   NS_IMETHOD SelectAllTableCells() override;
-  NS_IMETHOD SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell) override;
+  NS_IMETHOD SwitchTableCellHeaderType(nsIDOMElement* aSourceCell,
+                                       nsIDOMElement** aNewCell) override;
   NS_IMETHOD JoinTableCells(bool aMergeNonContiguousContents) override;
   NS_IMETHOD SplitTableCell() override;
-  NS_IMETHOD NormalizeTable(nsIDOMElement *aTable) override;
-  NS_IMETHOD GetCellIndexes(nsIDOMElement *aCell,
+  NS_IMETHOD NormalizeTable(nsIDOMElement* aTable) override;
+  NS_IMETHOD GetCellIndexes(nsIDOMElement* aCell,
                             int32_t* aRowIndex, int32_t* aColIndex) override;
-  NS_IMETHOD GetTableSize(nsIDOMElement *aTable,
+  NS_IMETHOD GetTableSize(nsIDOMElement* aTable,
                           int32_t* aRowCount, int32_t* aColCount) override;
-  NS_IMETHOD GetCellAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex, nsIDOMElement **aCell) override;
+  NS_IMETHOD GetCellAt(nsIDOMElement* aTable, int32_t aRowIndex,
+                       int32_t aColIndex, nsIDOMElement **aCell) override;
   NS_IMETHOD GetCellDataAt(nsIDOMElement* aTable,
                            int32_t aRowIndex, int32_t aColIndex,
-                           nsIDOMElement **aCell,
+                           nsIDOMElement** aCell,
                            int32_t* aStartRowIndex, int32_t* aStartColIndex,
                            int32_t* aRowSpan, int32_t* aColSpan,
                            int32_t* aActualRowSpan, int32_t* aActualColSpan,
                            bool* aIsSelected) override;
-  NS_IMETHOD GetFirstRow(nsIDOMElement* aTableElement, nsIDOMNode** aRowNode) override;
-  NS_IMETHOD GetNextRow(nsIDOMNode* aCurrentRowNode, nsIDOMNode** aRowNode) override;
-  nsresult GetLastCellInRow(nsIDOMNode* aRowNode, nsIDOMNode** aCellNode);
+  NS_IMETHOD GetFirstRow(nsIDOMElement* aTableElement,
+                         nsIDOMNode** aRowNode) override;
+  NS_IMETHOD GetNextRow(nsIDOMNode* aCurrentRowNode,
+                        nsIDOMNode** aRowNode) override;
+  nsresult GetLastCellInRow(nsIDOMNode* aRowNode,
+                            nsIDOMNode** aCellNode);
 
-  NS_IMETHOD SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow, int32_t aCol,
-                                        int32_t aDirection, bool aSelected) override;
-  NS_IMETHOD GetSelectedOrParentTableElement(nsAString& aTagName,
-                                             int32_t *aSelectedCount,
-                                             nsIDOMElement** aTableElement) override;
-  NS_IMETHOD GetSelectedCellsType(nsIDOMElement *aElement, uint32_t *aSelectionType) override;
+  NS_IMETHOD SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow,
+                                        int32_t aCol, int32_t aDirection,
+                                        bool aSelected) override;
+  NS_IMETHOD GetSelectedOrParentTableElement(
+               nsAString& aTagName, int32_t* aSelectedCount,
+               nsIDOMElement** aTableElement) override;
+  NS_IMETHOD GetSelectedCellsType(nsIDOMElement* aElement,
+                                  uint32_t* aSelectionType) override;
 
   nsresult GetCellFromRange(nsRange* aRange, nsIDOMElement** aCell);
 
-  // Finds the first selected cell in first range of selection
-  // This is in the *order of selection*, not order in the table
-  // (i.e., each cell added to selection is added in another range
-  //  in the selection's rangelist, independent of location in table)
-  // aRange is optional: returns the range around the cell
-  NS_IMETHOD GetFirstSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell) override;
-  // Get next cell until no more are found. Always use GetFirstSelected cell first
-  // aRange is optional: returns the range around the cell
-  NS_IMETHOD GetNextSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell) override;
+  /**
+   * Finds the first selected cell in first range of selection
+   * This is in the *order of selection*, not order in the table
+   * (i.e., each cell added to selection is added in another range
+   *  in the selection's rangelist, independent of location in table)
+   * aRange is optional: returns the range around the cell.
+   */
+  NS_IMETHOD GetFirstSelectedCell(nsIDOMRange** aRange,
+                                  nsIDOMElement** aCell) override;
+  /**
+   * Get next cell until no more are found. Always use GetFirstSelected cell
+   * first aRange is optional: returns the range around the cell.
+   */
+  NS_IMETHOD GetNextSelectedCell(nsIDOMRange** aRange,
+                                 nsIDOMElement** aCell) override;
 
-  // Upper-left-most selected cell in table
-  NS_IMETHOD GetFirstSelectedCellInTable(int32_t *aRowIndex, int32_t *aColIndex, nsIDOMElement **aCell) override;
+  /**
+   * Upper-left-most selected cell in table.
+   */
+  NS_IMETHOD GetFirstSelectedCellInTable(int32_t* aRowIndex, int32_t* aColIndex,
+                                         nsIDOMElement** aCell) override;
 
-  /* miscellaneous */
-  // This sets background on the appropriate container element (table, cell,)
-  //   or calls into nsTextEditor to set the page background
+  // Miscellaneous
+
+  /**
+   * This sets background on the appropriate container element (table, cell,)
+   * or calls into nsTextEditor to set the page background.
+   */
   nsresult SetCSSBackgroundColor(const nsAString& aColor);
   nsresult SetHTMLBackgroundColor(const nsAString& aColor);
 
-  /* ------------ Block methods moved from nsEditor -------------- */
+  // Block methods moved from nsEditor
   static Element* GetBlockNodeParent(nsINode* aNode);
   static nsIDOMNode* GetBlockNodeParent(nsIDOMNode* aNode);
   static Element* GetBlock(nsINode& aNode);
 
   void IsNextCharInNodeWhitespace(nsIContent* aContent,
                                   int32_t aOffset,
                                   bool* outIsSpace,
                                   bool* outIsNBSP,
@@ -252,453 +261,536 @@ public:
                                   int32_t* outOffset = 0);
   void IsPrevCharInNodeWhitespace(nsIContent* aContent,
                                   int32_t aOffset,
                                   bool* outIsSpace,
                                   bool* outIsNBSP,
                                   nsIContent** outNode = nullptr,
                                   int32_t* outOffset = 0);
 
-  /* ------------ Overrides of nsEditor interface methods -------------- */
-
+  // Overrides of nsEditor interface methods
   nsresult EndUpdateViewBatch() override;
 
-  /** prepare the editor for use */
-  NS_IMETHOD Init(nsIDOMDocument *aDoc, nsIContent *aRoot,
-                  nsISelectionController *aSelCon, uint32_t aFlags,
+  NS_IMETHOD Init(nsIDOMDocument* aDoc, nsIContent* aRoot,
+                  nsISelectionController* aSelCon, uint32_t aFlags,
                   const nsAString& aValue) override;
   NS_IMETHOD PreDestroy(bool aDestroyingFrames) override;
 
-  /** Internal, static version */
-  // aElement must not be null.
+  /**
+   * @param aElement        Must not be null.
+   */
   static bool NodeIsBlockStatic(const nsINode* aElement);
   static nsresult NodeIsBlockStatic(nsIDOMNode *aNode, bool *aIsBlock);
+
 protected:
-  virtual ~nsHTMLEditor();
+  virtual ~HTMLEditor();
 
   using nsEditor::IsBlockNode;
   virtual bool IsBlockNode(nsINode *aNode) override;
 
 public:
+  // XXX Why don't we move following methods above for grouping by the origins?
   NS_IMETHOD SetFlags(uint32_t aFlags) override;
 
   NS_IMETHOD Paste(int32_t aSelectionType) override;
-  NS_IMETHOD CanPaste(int32_t aSelectionType, bool *aCanPaste) override;
+  NS_IMETHOD CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
 
-  NS_IMETHOD PasteTransferable(nsITransferable *aTransferable) override;
-  NS_IMETHOD CanPasteTransferable(nsITransferable *aTransferable, bool *aCanPaste) override;
+  NS_IMETHOD PasteTransferable(nsITransferable* aTransferable) override;
+  NS_IMETHOD CanPasteTransferable(nsITransferable* aTransferable,
+                                  bool* aCanPaste) override;
 
-  NS_IMETHOD DebugUnitTests(int32_t *outNumTests, int32_t *outNumTestsFailed) override;
+  NS_IMETHOD DebugUnitTests(int32_t* outNumTests,
+                            int32_t* outNumTestsFailed) override;
 
-  /** All editor operations which alter the doc should be prefaced
-   *  with a call to StartOperation, naming the action and direction */
+  /**
+   * All editor operations which alter the doc should be prefaced
+   * with a call to StartOperation, naming the action and direction.
+   */
   NS_IMETHOD StartOperation(EditAction opID,
                             nsIEditor::EDirection aDirection) override;
 
-  /** All editor operations which alter the doc should be followed
-   *  with a call to EndOperation */
+  /**
+   * All editor operations which alter the doc should be followed
+   * with a call to EndOperation.
+   */
   NS_IMETHOD EndOperation() override;
 
-  /** returns true if aParentTag can contain a child of type aChildTag */
-  virtual bool TagCanContainTag(nsIAtom& aParentTag, nsIAtom& aChildTag)
-    override;
+  /**
+   * returns true if aParentTag can contain a child of type aChildTag.
+   */
+  virtual bool TagCanContainTag(nsIAtom& aParentTag,
+                                nsIAtom& aChildTag) override;
 
-  /** returns true if aNode is a container */
+  /**
+   * Returns true if aNode is a container.
+   */
   virtual bool IsContainer(nsINode* aNode) override;
   virtual bool IsContainer(nsIDOMNode* aNode) override;
 
-  /** make the given selection span the entire document */
+  /**
+   * Make the given selection span the entire document.
+   */
   virtual nsresult SelectEntireDocument(Selection* aSelection) override;
 
-  NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
-                                      const nsAString & aAttribute,
-                                      const nsAString & aValue,
+  NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement* aElement,
+                                      const nsAString& aAttribute,
+                                      const nsAString& aValue,
                                       bool aSuppressTransaction) override;
-  NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
-                                         const nsAString & aAttribute,
+  NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement* aElement,
+                                         const nsAString& aAttribute,
                                          bool aSuppressTransaction) override;
 
-  /** join together any adjacent editable text nodes in the range */
+  /**
+   * Join together any adjacent editable text nodes in the range.
+   */
   nsresult CollapseAdjacentTextNodes(nsRange* aRange);
 
-  virtual bool AreNodesSameType(nsIContent* aNode1, nsIContent* aNode2)
-    override;
+  virtual bool AreNodesSameType(nsIContent* aNode1,
+                                nsIContent* aNode2) override;
 
   NS_IMETHOD DeleteSelectionImpl(EDirection aAction,
                                  EStripWrappers aStripWrappers) override;
   nsresult DeleteNode(nsINode* aNode);
-  NS_IMETHOD DeleteNode(nsIDOMNode * aNode) override;
+  NS_IMETHOD DeleteNode(nsIDOMNode* aNode) override;
   nsresult DeleteText(nsGenericDOMDataNode& aTextNode, uint32_t aOffset,
                       uint32_t aLength);
   virtual nsresult InsertTextImpl(const nsAString& aStringToInsert,
                                   nsCOMPtr<nsINode>* aInOutNode,
                                   int32_t* aInOutOffset,
                                   nsIDocument* aDoc) override;
-  NS_IMETHOD_(bool) IsModifiableNode(nsIDOMNode *aNode) override;
-  virtual bool IsModifiableNode(nsINode *aNode) override;
+  NS_IMETHOD_(bool) IsModifiableNode(nsIDOMNode* aNode) override;
+  virtual bool IsModifiableNode(nsINode* aNode) override;
 
   NS_IMETHOD GetIsSelectionEditable(bool* aIsSelectionEditable) override;
 
   NS_IMETHOD SelectAll() override;
 
-  NS_IMETHOD GetRootElement(nsIDOMElement **aRootElement) override;
+  NS_IMETHOD GetRootElement(nsIDOMElement** aRootElement) override;
 
-  /* ------------ nsICSSLoaderObserver -------------- */
-  NS_IMETHOD StyleSheetLoaded(mozilla::StyleSheetHandle aSheet,
+  // nsICSSLoaderObserver
+  NS_IMETHOD StyleSheetLoaded(StyleSheetHandle aSheet,
                               bool aWasAlternate, nsresult aStatus) override;
 
-  /* ------------ Utility Routines, not part of public API -------------- */
-  NS_IMETHOD TypedText(const nsAString& aString, ETypingAction aAction) override;
-  nsresult InsertNodeAtPoint( nsIDOMNode *aNode,
-                              nsCOMPtr<nsIDOMNode> *ioParent,
-                              int32_t *ioOffset,
-                              bool aNoEmptyNodes);
+  // Utility Routines, not part of public API
+  NS_IMETHOD TypedText(const nsAString& aString,
+                       ETypingAction aAction) override;
+  nsresult InsertNodeAtPoint(nsIDOMNode* aNode,
+                             nsCOMPtr<nsIDOMNode>* ioParent,
+                             int32_t* ioOffset,
+                             bool aNoEmptyNodes);
 
-  // Use this to assure that selection is set after attribute nodes when
-  //  trying to collapse selection at begining of a block node
-  //  e.g., when setting at beginning of a table cell
-  // This will stop at a table, however, since we don't want to
-  //  "drill down" into nested tables.
-  // aSelection is optional -- if null, we get current seletion
+  /**
+   * Use this to assure that selection is set after attribute nodes when
+   * trying to collapse selection at begining of a block node
+   * e.g., when setting at beginning of a table cell
+   * This will stop at a table, however, since we don't want to
+   * "drill down" into nested tables.
+   * @param aSelection      Optional. If null, we get current selection.
+   */
   void CollapseSelectionToDeepestNonTableFirstChild(Selection* aSelection,
                                                     nsINode* aNode);
 
   /**
    * aNode must be a non-null text node.
    * outIsEmptyNode must be non-null.
    */
   nsresult IsVisTextNode(nsIContent* aNode,
                          bool* outIsEmptyNode,
                          bool aSafeToAskFrames);
-  nsresult IsEmptyNode(nsIDOMNode *aNode, bool *outIsEmptyBlock,
+  nsresult IsEmptyNode(nsIDOMNode* aNode, bool* outIsEmptyBlock,
                        bool aMozBRDoesntCount = false,
                        bool aListOrCellNotEmpty = false,
                        bool aSafeToAskFrames = false);
   nsresult IsEmptyNode(nsINode* aNode, bool* outIsEmptyBlock,
                        bool aMozBRDoesntCount = false,
                        bool aListOrCellNotEmpty = false,
                        bool aSafeToAskFrames = false);
   nsresult IsEmptyNodeImpl(nsINode* aNode,
-                           bool *outIsEmptyBlock,
+                           bool* outIsEmptyBlock,
                            bool aMozBRDoesntCount,
                            bool aListOrCellNotEmpty,
                            bool aSafeToAskFrames,
-                           bool *aSeenBR);
+                           bool* aSeenBR);
 
-  // Returns TRUE if sheet was loaded, false if it wasn't
-  bool     EnableExistingStyleSheet(const nsAString& aURL);
+  /**
+   * Returns TRUE if sheet was loaded, false if it wasn't.
+   */
+  bool EnableExistingStyleSheet(const nsAString& aURL);
 
-  // Dealing with the internal style sheet lists:
-  mozilla::StyleSheetHandle GetStyleSheetForURL(const nsAString& aURL);
-  void GetURLForStyleSheet(mozilla::StyleSheetHandle aStyleSheet,
+  /**
+   * Dealing with the internal style sheet lists.
+   */
+  StyleSheetHandle GetStyleSheetForURL(const nsAString& aURL);
+  void GetURLForStyleSheet(StyleSheetHandle aStyleSheet,
                            nsAString& aURL);
 
-  // Add a url + known style sheet to the internal lists:
+  /**
+   * Add a url + known style sheet to the internal lists.
+   */
   nsresult AddNewStyleSheetToList(const nsAString &aURL,
-                                  mozilla::StyleSheetHandle aStyleSheet);
-
+                                  StyleSheetHandle aStyleSheet);
   nsresult RemoveStyleSheetFromList(const nsAString &aURL);
 
   bool IsCSSEnabled()
   {
     // TODO: removal of mCSSAware and use only the presence of mCSSEditUtils
     return mCSSAware && mCSSEditUtils && mCSSEditUtils->IsCSSPrefChecked();
   }
 
   static bool HasAttributes(Element* aElement)
   {
     MOZ_ASSERT(aElement);
     uint32_t attrCount = aElement->GetAttrCount();
     return attrCount > 1 ||
-           (1 == attrCount && !aElement->GetAttrNameAt(0)->Equals(nsGkAtoms::mozdirty));
+           (1 == attrCount &&
+            !aElement->GetAttrNameAt(0)->Equals(nsGkAtoms::mozdirty));
   }
 
 protected:
   class BlobReader final : public nsIEditorBlobListener
   {
   public:
-    BlobReader(mozilla::dom::BlobImpl* aBlob, nsHTMLEditor* aEditor,
+    BlobReader(dom::BlobImpl* aBlob, HTMLEditor* aHTMLEditor,
                bool aIsSafe, nsIDOMDocument* aSourceDoc,
                nsIDOMNode* aDestinationNode, int32_t aDestOffset,
                bool aDoDeleteSelection);
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIEDITORBLOBLISTENER
 
   private:
     ~BlobReader()
     {
     }
 
-    RefPtr<mozilla::dom::BlobImpl> mBlob;
-    RefPtr<nsHTMLEditor> mEditor;
+    RefPtr<dom::BlobImpl> mBlob;
+    RefPtr<HTMLEditor> mHTMLEditor;
     bool mIsSafe;
     nsCOMPtr<nsIDOMDocument> mSourceDoc;
     nsCOMPtr<nsIDOMNode> mDestinationNode;
     int32_t mDestOffset;
     bool mDoDeleteSelection;
   };
 
-  NS_IMETHOD  InitRules() override;
+  NS_IMETHOD InitRules() override;
 
-  // Create the event listeners for the editor to install
   virtual void CreateEventListeners() override;
-
   virtual nsresult InstallEventListeners() override;
   virtual void RemoveEventListeners() override;
 
   bool ShouldReplaceRootElement();
   void ResetRootElementAndEventTarget();
   nsresult GetBodyElement(nsIDOMHTMLElement** aBody);
-  // Get the focused node of this editor.
-  // @return    If the editor has focus, this returns the focused node.
-  //            Otherwise, returns null.
+
+  /**
+   * Get the focused node of this editor.
+   * @return    If the editor has focus, this returns the focused node.
+   *            Otherwise, returns null.
+   */
   already_AddRefed<nsINode> GetFocusedNode();
 
-  // Return TRUE if aElement is a table-related elemet and caret was set
+  /**
+   * Return TRUE if aElement is a table-related elemet and caret was set.
+   */
   bool SetCaretInTableCell(nsIDOMElement* aElement);
 
-  // key event helpers
-  NS_IMETHOD TabInTable(bool inIsShift, bool *outHandled);
+  NS_IMETHOD TabInTable(bool inIsShift, bool* outHandled);
   Element* CreateBR(nsINode* aNode, int32_t aOffset,
                     EDirection aSelect = eNone);
-  NS_IMETHOD CreateBR(nsIDOMNode *aNode, int32_t aOffset,
-                      nsCOMPtr<nsIDOMNode> *outBRNode, nsIEditor::EDirection aSelect = nsIEditor::eNone) override;
+  NS_IMETHOD CreateBR(
+               nsIDOMNode* aNode, int32_t aOffset,
+               nsCOMPtr<nsIDOMNode>* outBRNode,
+               nsIEditor::EDirection aSelect = nsIEditor::eNone) override;
 
-// Table Editing (implemented in nsTableEditor.cpp)
-
-  // Table utilities
+  // Table Editing (implemented in nsTableEditor.cpp)
 
-  // Insert a new cell after or before supplied aCell.
-  //  Optional: If aNewCell supplied, returns the newly-created cell (addref'd, of course)
-  // This doesn't change or use the current selection
-  NS_IMETHOD InsertCell(nsIDOMElement *aCell, int32_t aRowSpan, int32_t aColSpan,
-                        bool aAfter, bool aIsHeader, nsIDOMElement **aNewCell);
+  /**
+   * Insert a new cell after or before supplied aCell.
+   * Optional: If aNewCell supplied, returns the newly-created cell (addref'd,
+   * of course)
+   * This doesn't change or use the current selection.
+   */
+  NS_IMETHOD InsertCell(nsIDOMElement* aCell, int32_t aRowSpan,
+                        int32_t aColSpan, bool aAfter, bool aIsHeader,
+                        nsIDOMElement** aNewCell);
 
-  // Helpers that don't touch the selection or do batch transactions
-  NS_IMETHOD DeleteRow(nsIDOMElement *aTable, int32_t aRowIndex);
-  NS_IMETHOD DeleteColumn(nsIDOMElement *aTable, int32_t aColIndex);
-  NS_IMETHOD DeleteCellContents(nsIDOMElement *aCell);
+  /**
+   * Helpers that don't touch the selection or do batch transactions.
+   */
+  NS_IMETHOD DeleteRow(nsIDOMElement* aTable, int32_t aRowIndex);
+  NS_IMETHOD DeleteColumn(nsIDOMElement* aTable, int32_t aColIndex);
+  NS_IMETHOD DeleteCellContents(nsIDOMElement* aCell);
 
-  // Move all contents from aCellToMerge into aTargetCell (append at end)
-  NS_IMETHOD MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell, nsCOMPtr<nsIDOMElement> aCellToMerge, bool aDeleteCellToMerge);
+  /**
+   * Move all contents from aCellToMerge into aTargetCell (append at end).
+   */
+  NS_IMETHOD MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell,
+                        nsCOMPtr<nsIDOMElement> aCellToMerge,
+                        bool aDeleteCellToMerge);
 
   nsresult DeleteTable2(nsIDOMElement* aTable, Selection* aSelection);
-  NS_IMETHOD SetColSpan(nsIDOMElement *aCell, int32_t aColSpan);
-  NS_IMETHOD SetRowSpan(nsIDOMElement *aCell, int32_t aRowSpan);
+  NS_IMETHOD SetColSpan(nsIDOMElement* aCell, int32_t aColSpan);
+  NS_IMETHOD SetRowSpan(nsIDOMElement* aCell, int32_t aRowSpan);
 
-  // Helper used to get nsTableWrapperFrame for a table.
+  /**
+   * Helper used to get nsTableWrapperFrame for a table.
+   */
   nsTableWrapperFrame* GetTableFrame(nsIDOMElement* aTable);
-  // Needed to do appropriate deleting when last cell or row is about to be deleted
-  // This doesn't count cells that don't start in the given row (are spanning from row above)
-  int32_t  GetNumberOfCellsInRow(nsIDOMElement* aTable, int32_t rowIndex);
-  // Test if all cells in row or column at given index are selected
-  bool AllCellsInRowSelected(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aNumberOfColumns);
-  bool AllCellsInColumnSelected(nsIDOMElement *aTable, int32_t aColIndex, int32_t aNumberOfRows);
+
+  /**
+   * Needed to do appropriate deleting when last cell or row is about to be
+   * deleted.  This doesn't count cells that don't start in the given row (are
+   * spanning from row above).
+   */
+  int32_t GetNumberOfCellsInRow(nsIDOMElement* aTable, int32_t rowIndex);
+
+  /**
+   * Test if all cells in row or column at given index are selected.
+   */
+  bool AllCellsInRowSelected(nsIDOMElement* aTable, int32_t aRowIndex,
+                             int32_t aNumberOfColumns);
+  bool AllCellsInColumnSelected(nsIDOMElement* aTable, int32_t aColIndex,
+                                int32_t aNumberOfRows);
 
   bool IsEmptyCell(Element* aCell);
 
-  // Most insert methods need to get the same basic context data
-  // Any of the pointers may be null if you don't need that datum (for more efficiency)
-  // Input: *aCell is a known cell,
-  //        if null, cell is obtained from the anchor node of the selection
-  // Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is null
+  /**
+   * Most insert methods need to get the same basic context data.
+   * Any of the pointers may be null if you don't need that datum (for more
+   * efficiency).
+   * Input: *aCell is a known cell,
+   *        if null, cell is obtained from the anchor node of the selection.
+   * Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is
+   * null.
+   */
   nsresult GetCellContext(Selection** aSelection, nsIDOMElement** aTable,
                           nsIDOMElement** aCell, nsIDOMNode** aCellParent,
                           int32_t* aCellOffset, int32_t* aRowIndex,
                           int32_t* aColIndex);
 
-  NS_IMETHOD GetCellSpansAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex,
-                            int32_t& aActualRowSpan, int32_t& aActualColSpan);
+  NS_IMETHOD GetCellSpansAt(nsIDOMElement* aTable, int32_t aRowIndex,
+                            int32_t aColIndex, int32_t& aActualRowSpan,
+                            int32_t& aActualColSpan);
 
-  NS_IMETHOD SplitCellIntoColumns(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aColIndex,
-                                  int32_t aColSpanLeft, int32_t aColSpanRight, nsIDOMElement **aNewCell);
+  NS_IMETHOD SplitCellIntoColumns(nsIDOMElement* aTable, int32_t aRowIndex,
+                                  int32_t aColIndex, int32_t aColSpanLeft,
+                                  int32_t aColSpanRight,
+                                  nsIDOMElement** aNewCell);
 
-  NS_IMETHOD SplitCellIntoRows(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aColIndex,
-                               int32_t aRowSpanAbove, int32_t aRowSpanBelow, nsIDOMElement **aNewCell);
+  NS_IMETHOD SplitCellIntoRows(nsIDOMElement* aTable, int32_t aRowIndex,
+                               int32_t aColIndex, int32_t aRowSpanAbove,
+                               int32_t aRowSpanBelow, nsIDOMElement** aNewCell);
 
-  nsresult CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *sourceCell);
+  nsresult CopyCellBackgroundColor(nsIDOMElement* destCell,
+                                   nsIDOMElement* sourceCell);
 
-  // Reduce rowspan/colspan when cells span into nonexistent rows/columns
-  NS_IMETHOD FixBadRowSpan(nsIDOMElement *aTable, int32_t aRowIndex, int32_t& aNewRowCount);
-  NS_IMETHOD FixBadColSpan(nsIDOMElement *aTable, int32_t aColIndex, int32_t& aNewColCount);
+  /**
+   * Reduce rowspan/colspan when cells span into nonexistent rows/columns.
+   */
+  NS_IMETHOD FixBadRowSpan(nsIDOMElement* aTable, int32_t aRowIndex,
+                           int32_t& aNewRowCount);
+  NS_IMETHOD FixBadColSpan(nsIDOMElement* aTable, int32_t aColIndex,
+                           int32_t& aNewColCount);
 
-  // Fallback method: Call this after using ClearSelection() and you
-  //  failed to set selection to some other content in the document
+  /**
+   * Fallback method: Call this after using ClearSelection() and you
+   * failed to set selection to some other content in the document.
+   */
   nsresult SetSelectionAtDocumentStart(Selection* aSelection);
 
-// End of Table Editing utilities
+  // End of Table Editing utilities
 
   static Element* GetEnclosingTable(nsINode* aNode);
-  static nsIDOMNode* GetEnclosingTable(nsIDOMNode *aNode);
+  static nsIDOMNode* GetEnclosingTable(nsIDOMNode* aNode);
 
-  /** content-based query returns true if <aProperty aAttribute=aValue> effects aNode
-    * If <aProperty aAttribute=aValue> contains aNode,
-    * but <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is
-    * more deeply nested than the first, then the first does not effect aNode.
-    *
-    * @param aNode      The target of the query
-    * @param aProperty  The property that we are querying for
-    * @param aAttribute The attribute of aProperty, example: color in <FONT color="blue">
-    *                   May be null.
-    * @param aValue     The value of aAttribute, example: blue in <FONT color="blue">
-    *                   May be null.  Ignored if aAttribute is null.
-    * @param aIsSet     [OUT] true if <aProperty aAttribute=aValue> effects aNode.
-    * @param outValue   [OUT] the value of the attribute, if aIsSet is true
-    *
-    * The nsIContent variant returns aIsSet instead of using an out parameter.
-    */
-  bool IsTextPropertySetByContent(nsINode*         aNode,
-                                  nsIAtom*         aProperty,
+  /**
+   * Content-based query returns true if <aProperty aAttribute=aValue> effects
+   * aNode.  If <aProperty aAttribute=aValue> contains aNode, but
+   * <aProperty aAttribute=SomeOtherValue> also contains aNode and the second is
+   * more deeply nested than the first, then the first does not effect aNode.
+   *
+   * @param aNode      The target of the query
+   * @param aProperty  The property that we are querying for
+   * @param aAttribute The attribute of aProperty, example: color in
+   *                   <FONT color="blue"> May be null.
+   * @param aValue     The value of aAttribute, example: blue in
+   *                   <FONT color="blue"> May be null.  Ignored if aAttribute
+   *                   is null.
+   * @param aIsSet     [OUT] true if <aProperty aAttribute=aValue> effects
+   *                         aNode.
+   * @param outValue   [OUT] the value of the attribute, if aIsSet is true
+   *
+   * The nsIContent variant returns aIsSet instead of using an out parameter.
+   */
+  bool IsTextPropertySetByContent(nsINode* aNode,
+                                  nsIAtom* aProperty,
                                   const nsAString* aAttribute,
                                   const nsAString* aValue,
-                                  nsAString*       outValue = nullptr);
+                                  nsAString* outValue = nullptr);
 
-  void IsTextPropertySetByContent(nsIDOMNode*      aNode,
-                                  nsIAtom*         aProperty,
+  void IsTextPropertySetByContent(nsIDOMNode* aNode,
+                                  nsIAtom* aProperty,
                                   const nsAString* aAttribute,
                                   const nsAString* aValue,
-                                  bool&            aIsSet,
-                                  nsAString*       outValue = nullptr);
+                                  bool& aIsSet,
+                                  nsAString* outValue = nullptr);
 
   // Methods for handling plaintext quotations
   NS_IMETHOD PasteAsPlaintextQuotation(int32_t aSelectionType);
 
-  /** Insert a string as quoted text,
-    * replacing the selected text (if any).
-    * @param aQuotedText     The string to insert.
-    * @param aAddCites       Whether to prepend extra ">" to each line
-    *                        (usually true, unless those characters
-    *                        have already been added.)
-    * @return aNodeInserted  The node spanning the insertion, if applicable.
-    *                        If aAddCites is false, this will be null.
-    */
-  NS_IMETHOD InsertAsPlaintextQuotation(const nsAString & aQuotedText,
+  /**
+   * Insert a string as quoted text, replacing the selected text (if any).
+   * @param aQuotedText     The string to insert.
+   * @param aAddCites       Whether to prepend extra ">" to each line
+   *                        (usually true, unless those characters
+   *                        have already been added.)
+   * @return aNodeInserted  The node spanning the insertion, if applicable.
+   *                        If aAddCites is false, this will be null.
+   */
+  NS_IMETHOD InsertAsPlaintextQuotation(const nsAString& aQuotedText,
                                         bool aAddCites,
-                                        nsIDOMNode **aNodeInserted);
+                                        nsIDOMNode** aNodeInserted);
 
   nsresult InsertObject(const char* aType, nsISupports* aObject, bool aIsSafe,
-                        nsIDOMDocument *aSourceDoc,
-                        nsIDOMNode *aDestinationNode,
+                        nsIDOMDocument* aSourceDoc,
+                        nsIDOMNode* aDestinationNode,
                         int32_t aDestOffset,
                         bool aDoDeleteSelection);
 
-  // factored methods for handling insertion of data from transferables (drag&drop or clipboard)
-  NS_IMETHOD PrepareTransferable(nsITransferable **transferable) override;
-  nsresult PrepareHTMLTransferable(nsITransferable **transferable);
-  nsresult InsertFromTransferable(nsITransferable *transferable,
-                                    nsIDOMDocument *aSourceDoc,
-                                    const nsAString & aContextStr,
-                                    const nsAString & aInfoStr,
+  // factored methods for handling insertion of data from transferables
+  // (drag&drop or clipboard)
+  NS_IMETHOD PrepareTransferable(nsITransferable** transferable) override;
+  nsresult PrepareHTMLTransferable(nsITransferable** transferable);
+  nsresult InsertFromTransferable(nsITransferable* transferable,
+                                    nsIDOMDocument* aSourceDoc,
+                                    const nsAString& aContextStr,
+                                    const nsAString& aInfoStr,
                                     bool havePrivateHTMLFlavor,
                                     nsIDOMNode *aDestinationNode,
                                     int32_t aDestinationOffset,
                                     bool aDoDeleteSelection);
-  nsresult InsertFromDataTransfer(mozilla::dom::DataTransfer *aDataTransfer,
+  nsresult InsertFromDataTransfer(dom::DataTransfer* aDataTransfer,
                                   int32_t aIndex,
-                                  nsIDOMDocument *aSourceDoc,
-                                  nsIDOMNode *aDestinationNode,
+                                  nsIDOMDocument* aSourceDoc,
+                                  nsIDOMNode* aDestinationNode,
                                   int32_t aDestOffset,
                                   bool aDoDeleteSelection) override;
-  bool HavePrivateHTMLFlavor( nsIClipboard *clipboard );
-  nsresult   ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_t **aCfcontext);
-  nsresult   DoContentFilterCallback(const nsAString &aFlavor,
-                                     nsIDOMDocument *aSourceDoc,
-                                     bool aWillDeleteSelection,
-                                     nsIDOMNode **aFragmentAsNode,
-                                     nsIDOMNode **aFragStartNode,
-                                     int32_t *aFragStartOffset,
-                                     nsIDOMNode **aFragEndNode,
-                                     int32_t *aFragEndOffset,
-                                     nsIDOMNode **aTargetNode,
-                                     int32_t *aTargetOffset,
-                                     bool *aDoContinue);
+  bool HavePrivateHTMLFlavor(nsIClipboard* clipboard );
+  nsresult ParseCFHTML(nsCString& aCfhtml, char16_t** aStuffToPaste,
+                       char16_t** aCfcontext);
+  nsresult DoContentFilterCallback(const nsAString& aFlavor,
+                                   nsIDOMDocument* aSourceDoc,
+                                   bool aWillDeleteSelection,
+                                   nsIDOMNode** aFragmentAsNode,
+                                   nsIDOMNode** aFragStartNode,
+                                   int32_t* aFragStartOffset,
+                                   nsIDOMNode** aFragEndNode,
+                                   int32_t* aFragEndOffset,
+                                   nsIDOMNode** aTargetNode,
+                                   int32_t* aTargetOffset,
+                                   bool* aDoContinue);
 
-  bool       IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink = nullptr);
-  nsresult   StripFormattingNodes(nsIContent& aNode, bool aOnlyList = false);
-  nsresult   CreateDOMFragmentFromPaste(const nsAString & aInputString,
-                                        const nsAString & aContextStr,
-                                        const nsAString & aInfoStr,
-                                        nsCOMPtr<nsIDOMNode> *outFragNode,
-                                        nsCOMPtr<nsIDOMNode> *outStartNode,
-                                        nsCOMPtr<nsIDOMNode> *outEndNode,
-                                        int32_t *outStartOffset,
-                                        int32_t *outEndOffset,
-                                        bool aTrustedInput);
-  nsresult   ParseFragment(const nsAString & aStr, nsIAtom* aContextLocalName,
-                           nsIDocument* aTargetDoc,
-                           mozilla::dom::DocumentFragment** aFragment,
-                           bool aTrustedInput);
-  void       CreateListOfNodesToPaste(mozilla::dom::DocumentFragment& aFragment,
-                                      nsTArray<OwningNonNull<nsINode>>& outNodeList,
-                                      nsINode* aStartNode,
-                                      int32_t aStartOffset,
-                                      nsINode* aEndNode,
-                                      int32_t aEndOffset);
-  nsresult CreateTagStack(nsTArray<nsString> &aTagStack,
-                          nsIDOMNode *aNode);
+  bool IsInLink(nsIDOMNode* aNode, nsCOMPtr<nsIDOMNode>* outLink = nullptr);
+  nsresult StripFormattingNodes(nsIContent& aNode, bool aOnlyList = false);
+  nsresult CreateDOMFragmentFromPaste(const nsAString& aInputString,
+                                      const nsAString& aContextStr,
+                                      const nsAString& aInfoStr,
+                                      nsCOMPtr<nsIDOMNode>* outFragNode,
+                                      nsCOMPtr<nsIDOMNode>* outStartNode,
+                                      nsCOMPtr<nsIDOMNode>* outEndNode,
+                                      int32_t* outStartOffset,
+                                      int32_t* outEndOffset,
+                                      bool aTrustedInput);
+  nsresult ParseFragment(const nsAString& aStr, nsIAtom* aContextLocalName,
+                         nsIDocument* aTargetDoc,
+                         dom::DocumentFragment** aFragment, bool aTrustedInput);
+  void CreateListOfNodesToPaste(dom::DocumentFragment& aFragment,
+                                nsTArray<OwningNonNull<nsINode>>& outNodeList,
+                                nsINode* aStartNode,
+                                int32_t aStartOffset,
+                                nsINode* aEndNode,
+                                int32_t aEndOffset);
+  nsresult CreateTagStack(nsTArray<nsString>& aTagStack,
+                          nsIDOMNode* aNode);
   enum class StartOrEnd { start, end };
   void GetListAndTableParents(StartOrEnd aStartOrEnd,
                               nsTArray<OwningNonNull<nsINode>>& aNodeList,
                               nsTArray<OwningNonNull<Element>>& outArray);
-  int32_t DiscoverPartialListsAndTables(nsTArray<OwningNonNull<nsINode>>& aPasteNodes,
-                                        nsTArray<OwningNonNull<Element>>& aListsAndTables);
-  nsINode* ScanForListAndTableStructure(StartOrEnd aStartOrEnd,
-                                        nsTArray<OwningNonNull<nsINode>>& aNodes,
-                                        Element& aListOrTable);
-  void ReplaceOrphanedStructure(StartOrEnd aStartOrEnd,
-                                nsTArray<OwningNonNull<nsINode>>& aNodeArray,
-                                nsTArray<OwningNonNull<Element>>& aListAndTableArray,
-                                int32_t aHighWaterMark);
+  int32_t DiscoverPartialListsAndTables(
+            nsTArray<OwningNonNull<nsINode>>& aPasteNodes,
+            nsTArray<OwningNonNull<Element>>& aListsAndTables);
+  nsINode* ScanForListAndTableStructure(
+             StartOrEnd aStartOrEnd,
+             nsTArray<OwningNonNull<nsINode>>& aNodes,
+             Element& aListOrTable);
+  void ReplaceOrphanedStructure(
+         StartOrEnd aStartOrEnd,
+         nsTArray<OwningNonNull<nsINode>>& aNodeArray,
+         nsTArray<OwningNonNull<Element>>& aListAndTableArray,
+         int32_t aHighWaterMark);
 
-  /* small utility routine to test if a break node is visible to user */
-  bool     IsVisBreak(nsINode* aNode);
+  /**
+   * Small utility routine to test if a break node is visible to user.
+   */
+  bool IsVisBreak(nsINode* aNode);
 
-  /* utility routine to possibly adjust the insertion position when
-     inserting a block level element */
+  /**
+   * Utility routine to possibly adjust the insertion position when
+   * inserting a block level element.
+   */
   void NormalizeEOLInsertPosition(nsINode* firstNodeToInsert,
-                                  nsCOMPtr<nsIDOMNode> *insertParentNode,
-                                  int32_t *insertOffset);
+                                  nsCOMPtr<nsIDOMNode>* insertParentNode,
+                                  int32_t* insertOffset);
 
-  /* small utility routine to test the eEditorReadonly bit */
+  /**
+   * Small utility routine to test the eEditorReadonly bit.
+   */
   bool IsModifiable();
 
-  /* helpers for block transformations */
-  nsresult MakeDefinitionItem(const nsAString & aItemType);
-  nsresult InsertBasicBlock(const nsAString & aBlockType);
+  /**
+   * Helpers for block transformations.
+   */
+  nsresult MakeDefinitionItem(const nsAString& aItemType);
+  nsresult InsertBasicBlock(const nsAString& aBlockType);
 
-  /* increase/decrease the font size of selection */
+  /**
+   * Increase/decrease the font size of selection.
+   */
   enum class FontSize { incr, decr };
   nsresult RelativeFontChange(FontSize aDir);
 
-  /* helper routines for font size changing */
+  /**
+   * Helper routines for font size changing.
+   */
   nsresult RelativeFontChangeOnTextNode(FontSize aDir,
                                         Text& aTextNode,
                                         int32_t aStartOffset,
                                         int32_t aEndOffset);
   nsresult RelativeFontChangeOnNode(int32_t aSizeChange, nsIContent* aNode);
   nsresult RelativeFontChangeHelper(int32_t aSizeChange, nsINode* aNode);
 
-  /* helper routines for inline style */
+  /**
+   * Helper routines for inline style.
+   */
   nsresult SetInlinePropertyOnTextNode(Text& aData,
                                        int32_t aStartOffset,
                                        int32_t aEndOffset,
                                        nsIAtom& aProperty,
                                        const nsAString* aAttribute,
                                        const nsAString& aValue);
   nsresult SetInlinePropertyOnNode(nsIContent& aNode,
                                    nsIAtom& aProperty,
                                    const nsAString* aAttribute,
                                    const nsAString& aValue);
 
   nsresult PromoteInlineRange(nsRange& aRange);
   nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange& aRange);
   nsresult SplitStyleAboveRange(nsRange* aRange,
-                                nsIAtom *aProperty,
-                                const nsAString *aAttribute);
+                                nsIAtom* aProperty,
+                                const nsAString* aAttribute);
   nsresult SplitStyleAbovePoint(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
                                 nsIAtom* aProperty,
                                 const nsAString* aAttribute,
                                 nsIContent** aOutLeftNode = nullptr,
                                 nsIContent** aOutRightNode = nullptr);
   nsresult ApplyDefaultProperties();
   nsresult RemoveStyleInside(nsIContent& aNode,
                              nsIAtom* aProperty,
@@ -710,39 +802,49 @@ protected:
   bool NodeIsProperty(nsINode& aNode);
   bool IsAtFrontOfNode(nsINode& aNode, int32_t aOffset);
   bool IsAtEndOfNode(nsINode& aNode, int32_t aOffset);
   bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute);
 
   nsresult RemoveBlockContainer(nsIContent& aNode);
 
   nsIContent* GetPriorHTMLSibling(nsINode* aNode);
-  nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
+  nsresult GetPriorHTMLSibling(nsIDOMNode*inNode,
+                               nsCOMPtr<nsIDOMNode>* outNode);
   nsIContent* GetPriorHTMLSibling(nsINode* aParent, int32_t aOffset);
-  nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode);
+  nsresult GetPriorHTMLSibling(nsIDOMNode* inParent, int32_t inOffset,
+                               nsCOMPtr<nsIDOMNode>* outNode);
 
   nsIContent* GetNextHTMLSibling(nsINode* aNode);
-  nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
+  nsresult GetNextHTMLSibling(nsIDOMNode* inNode,
+                              nsCOMPtr<nsIDOMNode>* outNode);
   nsIContent* GetNextHTMLSibling(nsINode* aParent, int32_t aOffset);
-  nsresult GetNextHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode);
+  nsresult GetNextHTMLSibling(nsIDOMNode* inParent, int32_t inOffset,
+                              nsCOMPtr<nsIDOMNode>* outNode);
 
   nsIContent* GetPriorHTMLNode(nsINode* aNode, bool aNoBlockCrossing = false);
-  nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
+  nsresult GetPriorHTMLNode(nsIDOMNode* inNode, nsCOMPtr<nsIDOMNode>* outNode,
+                            bool bNoBlockCrossing = false);
   nsIContent* GetPriorHTMLNode(nsINode* aParent, int32_t aOffset,
                                bool aNoBlockCrossing = false);
-  nsresult GetPriorHTMLNode(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
+  nsresult GetPriorHTMLNode(nsIDOMNode* inParent, int32_t inOffset,
+                            nsCOMPtr<nsIDOMNode>* outNode,
+                            bool bNoBlockCrossing = false);
 
   nsIContent* GetNextHTMLNode(nsINode* aNode, bool aNoBlockCrossing = false);
-  nsresult GetNextHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
+  nsresult GetNextHTMLNode(nsIDOMNode* inNode, nsCOMPtr<nsIDOMNode>* outNode,
+                           bool bNoBlockCrossing = false);
   nsIContent* GetNextHTMLNode(nsINode* aParent, int32_t aOffset,
                               bool aNoBlockCrossing = false);
-  nsresult GetNextHTMLNode(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
+  nsresult GetNextHTMLNode(nsIDOMNode* inParent, int32_t inOffset,
+                           nsCOMPtr<nsIDOMNode>* outNode,
+                           bool bNoBlockCrossing = false);
 
-  nsresult IsFirstEditableChild( nsIDOMNode *aNode, bool *aOutIsFirst);
-  nsresult IsLastEditableChild( nsIDOMNode *aNode, bool *aOutIsLast);
+  nsresult IsFirstEditableChild(nsIDOMNode* aNode, bool* aOutIsFirst);
+  nsresult IsLastEditableChild(nsIDOMNode* aNode, bool* aOutIsLast);
   nsIContent* GetFirstEditableChild(nsINode& aNode);
   nsIContent* GetLastEditableChild(nsINode& aNode);
 
   nsIContent* GetFirstEditableLeaf(nsINode& aNode);
   nsIContent* GetLastEditableLeaf(nsINode& aNode);
 
   nsresult GetInlinePropertyBase(nsIAtom& aProperty,
                                  const nsAString* aAttribute,
@@ -750,97 +852,98 @@ protected:
                                  bool* aFirst,
                                  bool* aAny,
                                  bool* aAll,
                                  nsAString* outValue,
                                  bool aCheckDefaults = true);
   bool HasStyleOrIdOrClass(Element* aElement);
   nsresult RemoveElementIfNoStyleOrIdOrClass(Element& aElement);
 
-  // Whether the outer window of the DOM event target has focus or not.
-  bool     OurWindowHasFocus();
+  /**
+   * Whether the outer window of the DOM event target has focus or not.
+   */
+  bool OurWindowHasFocus();
 
-  // This function is used to insert a string of HTML input optionally with some
-  // context information into the editable field.  The HTML input either comes
-  // from a transferable object created as part of a drop/paste operation, or from
-  // the InsertHTML method.  We may want the HTML input to be sanitized (for example,
-  // if it's coming from a transferable object), in which case aTrustedInput should
-  // be set to false, otherwise, the caller should set it to true, which means that
-  // the HTML will be inserted in the DOM verbatim.
-  //
-  // aClearStyle should be set to false if you want the paste to be affected by
-  // local style (e.g., for the insertHTML command).
+  /**
+   * This function is used to insert a string of HTML input optionally with some
+   * context information into the editable field.  The HTML input either comes
+   * from a transferable object created as part of a drop/paste operation, or
+   * from the InsertHTML method.  We may want the HTML input to be sanitized
+   * (for example, if it's coming from a transferable object), in which case
+   * aTrustedInput should be set to false, otherwise, the caller should set it
+   * to true, which means that the HTML will be inserted in the DOM verbatim.
+   *
+   * aClearStyle should be set to false if you want the paste to be affected by
+   * local style (e.g., for the insertHTML command).
+   */
   nsresult DoInsertHTMLWithContext(const nsAString& aInputString,
                                    const nsAString& aContextStr,
                                    const nsAString& aInfoStr,
                                    const nsAString& aFlavor,
                                    nsIDOMDocument* aSourceDoc,
                                    nsIDOMNode* aDestNode,
                                    int32_t aDestOffset,
                                    bool aDeleteSelection,
                                    bool aTrustedInput,
                                    bool aClearStyle = true);
 
   nsresult ClearStyle(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
                       nsIAtom* aProperty, const nsAString* aAttribute);
 
   void SetElementPosition(Element& aElement, int32_t aX, int32_t aY);
 
-// Data members
 protected:
-
   nsTArray<OwningNonNull<nsIContentFilter>> mContentFilters;
 
-  RefPtr<mozilla::TypeInState> mTypeInState;
+  RefPtr<TypeInState> mTypeInState;
 
   bool mCRInParagraphCreatesParagraph;
 
   bool mCSSAware;
-  nsAutoPtr<mozilla::CSSEditUtils> mCSSEditUtils;
+  nsAutoPtr<CSSEditUtils> mCSSEditUtils;
 
   // Used by GetFirstSelectedCell and GetNextSelectedCell
   int32_t  mSelectedCellIndex;
 
   nsString mLastStyleSheetURL;
   nsString mLastOverrideStyleSheetURL;
 
   // Maintain a list of associated style sheets and their urls.
   nsTArray<nsString> mStyleSheetURLs;
-  nsTArray<mozilla::StyleSheetHandle::RefPtr> mStyleSheets;
+  nsTArray<StyleSheetHandle::RefPtr> mStyleSheets;
 
   // an array for holding default style settings
-  nsTArray<mozilla::PropItem*> mDefaultStyles;
+  nsTArray<PropItem*> mDefaultStyles;
 
 protected:
-
-  /* ANONYMOUS UTILS */
-  void     RemoveListenerAndDeleteRef(const nsAString& aEvent,
-                                      nsIDOMEventListener* aListener,
-                                      bool aUseCapture,
-                                      Element* aElement,
-                                      nsIContent* aParentContent,
-                                      nsIPresShell* aShell);
-  void     DeleteRefToAnonymousNode(nsIDOMElement* aElement,
-                                    nsIContent * aParentContent,
-                                    nsIPresShell* aShell);
+  // ANONYMOUS UTILS
+  void RemoveListenerAndDeleteRef(const nsAString& aEvent,
+                                  nsIDOMEventListener* aListener,
+                                  bool aUseCapture,
+                                  Element* aElement,
+                                  nsIContent* aParentContent,
+                                  nsIPresShell* aShell);
+  void DeleteRefToAnonymousNode(nsIDOMElement* aElement,
+                                nsIContent* aParentContent,
+                                nsIPresShell* aShell);
 
   nsresult ShowResizersInner(nsIDOMElement *aResizedElement);
 
-  // Returns the offset of an element's frame to its absolute containing block.
-  nsresult GetElementOrigin(nsIDOMElement * aElement, int32_t & aX, int32_t & aY);
-  nsresult GetPositionAndDimensions(nsIDOMElement * aElement,
-                                    int32_t & aX, int32_t & aY,
-                                    int32_t & aW, int32_t & aH,
-                                    int32_t & aBorderLeft,
-                                    int32_t & aBorderTop,
-                                    int32_t & aMarginLeft,
-                                    int32_t & aMarginTop);
-
-  /* PACKED BOOLEANS FOR RESIZING, ABSOLUTE POSITIONING AND */
-  /* INLINE TABLE EDITING */
+  /**
+   * Returns the offset of an element's frame to its absolute containing block.
+   */
+  nsresult GetElementOrigin(nsIDOMElement* aElement,
+                            int32_t& aX, int32_t& aY);
+  nsresult GetPositionAndDimensions(nsIDOMElement* aElement,
+                                    int32_t& aX, int32_t& aY,
+                                    int32_t& aW, int32_t& aH,
+                                    int32_t& aBorderLeft,
+                                    int32_t& aBorderTop,
+                                    int32_t& aMarginLeft,
+                                    int32_t& aMarginTop);
 
   // resizing
   bool mIsObjectResizingEnabled;
   bool mIsResizing;
   bool mPreserveRatio;
   bool mResizedObjectIsAnImage;
 
   // absolute positioning
@@ -850,18 +953,17 @@ protected:
   bool mGrabberClicked;
   bool mIsMoving;
 
   bool mSnapToGridEnabled;
 
   // inline table editing
   bool mIsInlineTableEditingEnabled;
 
-  /* RESIZING */
-
+  // resizing
   nsCOMPtr<Element> mTopLeftHandle;
   nsCOMPtr<Element> mTopHandle;
   nsCOMPtr<Element> mTopRightHandle;
   nsCOMPtr<Element> mLeftHandle;
   nsCOMPtr<Element> mRightHandle;
   nsCOMPtr<Element> mBottomLeftHandle;
   nsCOMPtr<Element> mBottomHandle;
   nsCOMPtr<Element> mBottomRightHandle;
@@ -899,105 +1001,105 @@ protected:
 
   int8_t  mInfoXIncrement;
   int8_t  mInfoYIncrement;
 
   nsresult SetAllResizersPosition();
 
   already_AddRefed<Element> CreateResizer(int16_t aLocation,
                                           nsIDOMNode* aParentNode);
-  void     SetAnonymousElementPosition(int32_t aX, int32_t aY, nsIDOMElement *aResizer);
+  void SetAnonymousElementPosition(int32_t aX, int32_t aY,
+                                   nsIDOMElement* aResizer);
 
   already_AddRefed<Element> CreateShadow(nsIDOMNode* aParentNode,
                                          nsIDOMElement* aOriginalObject);
   nsresult SetShadowPosition(Element* aShadow, Element* aOriginalObject,
                              int32_t aOriginalObjectX,
                              int32_t aOriginalObjectY);
 
   already_AddRefed<Element> CreateResizingInfo(nsIDOMNode* aParentNode);
   nsresult SetResizingInfoPosition(int32_t aX, int32_t aY,
                                    int32_t aW, int32_t aH);
 
-  int32_t  GetNewResizingIncrement(int32_t aX, int32_t aY, int32_t aID);
-  nsresult StartResizing(nsIDOMElement * aHandle);
-  int32_t  GetNewResizingX(int32_t aX, int32_t aY);
-  int32_t  GetNewResizingY(int32_t aX, int32_t aY);
-  int32_t  GetNewResizingWidth(int32_t aX, int32_t aY);
-  int32_t  GetNewResizingHeight(int32_t aX, int32_t aY);
-  void     HideShadowAndInfo();
-  void     SetFinalSize(int32_t aX, int32_t aY);
-  void     DeleteRefToAnonymousNode(nsIDOMNode * aNode);
-  void     SetResizeIncrements(int32_t aX, int32_t aY, int32_t aW, int32_t aH, bool aPreserveRatio);
-  void     HideAnonymousEditingUIs();
+  int32_t GetNewResizingIncrement(int32_t aX, int32_t aY, int32_t aID);
+  nsresult StartResizing(nsIDOMElement* aHandle);
+  int32_t GetNewResizingX(int32_t aX, int32_t aY);
+  int32_t GetNewResizingY(int32_t aX, int32_t aY);
+  int32_t GetNewResizingWidth(int32_t aX, int32_t aY);
+  int32_t GetNewResizingHeight(int32_t aX, int32_t aY);
+  void HideShadowAndInfo();
+  void SetFinalSize(int32_t aX, int32_t aY);
+  void DeleteRefToAnonymousNode(nsIDOMNode* aNode);
+  void SetResizeIncrements(int32_t aX, int32_t aY, int32_t aW, int32_t aH,
+                           bool aPreserveRatio);
+  void HideAnonymousEditingUIs();
 
-  /* ABSOLUTE POSITIONING */
-
+  // absolute positioning
   int32_t mPositionedObjectX;
   int32_t mPositionedObjectY;
   int32_t mPositionedObjectWidth;
   int32_t mPositionedObjectHeight;
 
   int32_t mPositionedObjectMarginLeft;
   int32_t mPositionedObjectMarginTop;
   int32_t mPositionedObjectBorderLeft;
   int32_t mPositionedObjectBorderTop;
 
   nsCOMPtr<Element> mAbsolutelyPositionedObject;
   nsCOMPtr<Element> mGrabber;
   nsCOMPtr<Element> mPositioningShadow;
 
-  int32_t      mGridSize;
+  int32_t mGridSize;
 
   already_AddRefed<Element> CreateGrabber(nsINode* aParentNode);
-  nsresult StartMoving(nsIDOMElement * aHandle);
+  nsresult StartMoving(nsIDOMElement* aHandle);
   nsresult SetFinalPosition(int32_t aX, int32_t aY);
-  void     AddPositioningOffset(int32_t & aX, int32_t & aY);
-  void     SnapToGrid(int32_t & newX, int32_t & newY);
+  void AddPositioningOffset(int32_t& aX, int32_t& aY);
+  void SnapToGrid(int32_t& newX, int32_t& newY);
   nsresult GrabberClicked();
   nsresult EndMoving();
-  nsresult CheckPositionedElementBGandFG(nsIDOMElement * aElement,
-                                         nsAString & aReturn);
+  nsresult CheckPositionedElementBGandFG(nsIDOMElement* aElement,
+                                         nsAString& aReturn);
 
-  /* INLINE TABLE EDITING */
-
+  // inline table editing
   nsCOMPtr<nsIDOMElement> mInlineEditedCell;
 
   nsCOMPtr<nsIDOMElement> mAddColumnBeforeButton;
   nsCOMPtr<nsIDOMElement> mRemoveColumnButton;
   nsCOMPtr<nsIDOMElement> mAddColumnAfterButton;
 
   nsCOMPtr<nsIDOMElement> mAddRowBeforeButton;
   nsCOMPtr<nsIDOMElement> mRemoveRowButton;
   nsCOMPtr<nsIDOMElement> mAddRowAfterButton;
 
-  void     AddMouseClickListener(nsIDOMElement * aElement);
-  void     RemoveMouseClickListener(nsIDOMElement * aElement);
+  void AddMouseClickListener(nsIDOMElement* aElement);
+  void RemoveMouseClickListener(nsIDOMElement* aElement);
 
   nsCOMPtr<nsILinkHandler> mLinkHandler;
 
 public:
-  // friends
-  friend class mozilla::HTMLEditorEventListener;
-  friend class mozilla::HTMLEditRules;
-  friend class mozilla::TextEditRules;
-  friend class mozilla::WSRunObject;
+  friend class HTMLEditorEventListener;
+  friend class HTMLEditRules;
+  friend class TextEditRules;
+  friend class WSRunObject;
 
 private:
-  // Helpers
   bool IsSimpleModifiableNode(nsIContent* aContent,
                               nsIAtom* aProperty,
                               const nsAString* aAttribute,
                               const nsAString* aValue);
   nsresult SetInlinePropertyOnNodeImpl(nsIContent& aNode,
                                        nsIAtom& aProperty,
                                        const nsAString* aAttribute,
                                        const nsAString& aValue);
   typedef enum { eInserted, eAppended } InsertedOrAppended;
   void DoContentInserted(nsIDocument* aDocument, nsIContent* aContainer,
                          nsIContent* aChild, int32_t aIndexInContainer,
                          InsertedOrAppended aInsertedOrAppended);
   already_AddRefed<Element> GetElementOrParentByTagName(
-      const nsAString& aTagName, nsINode* aNode);
+                              const nsAString& aTagName, nsINode* aNode);
   already_AddRefed<Element> CreateElementWithDefaults(
-      const nsAString& aTagName);
+                              const nsAString& aTagName);
 };
-#endif //nsHTMLEditor_h__
 
+} // namespace mozilla
+
+#endif // #ifndef mozilla_HTMLEditor_h
rename from editor/libeditor/nsHTMLDataTransfer.cpp
rename to editor/libeditor/HTMLEditorDataTransfer.cpp
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -1,14 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "mozilla/HTMLEditor.h"
+
 #include <string.h>
 
 #include "EditorUtils.h"
 #include "HTMLEditUtils.h"
 #include "TextEditUtils.h"
 #include "WSRunObject.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/dom/DocumentFragment.h"
@@ -27,17 +29,16 @@
 #include "nsComponentManagerUtils.h"
 #include "nsIScriptError.h"
 #include "nsContentUtils.h"
 #include "nsDebug.h"
 #include "nsDependentSubstring.h"
 #include "nsEditor.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
-#include "nsHTMLEditor.h"
 #include "nsIClipboard.h"
 #include "nsIContent.h"
 #include "nsIContentFilter.h"
 #include "nsIDOMComment.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentFragment.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLAnchorElement.h"
@@ -84,30 +85,32 @@
 #include "nsXPCOM.h"
 #include "nscore.h"
 #include "nsContentUtils.h"
 
 class nsIAtom;
 class nsILoadContext;
 class nsISupports;
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
 #define kInsertCookie  "_moz_Insert Here_moz_"
 
 // some little helpers
-static bool FindIntegerAfterString(const char *aLeadingString,
-                                     nsCString &aCStr, int32_t &foundNumber);
-static nsresult RemoveFragComments(nsCString &theStr);
+static bool FindIntegerAfterString(const char* aLeadingString,
+                                   nsCString& aCStr, int32_t& foundNumber);
+static nsresult RemoveFragComments(nsCString& theStr);
 static void RemoveBodyAndHead(nsINode& aNode);
-static nsresult FindTargetNode(nsIDOMNode *aStart, nsCOMPtr<nsIDOMNode> &aResult);
+static nsresult FindTargetNode(nsIDOMNode* aStart,
+                               nsCOMPtr<nsIDOMNode>& aResult);
 
 nsresult
-nsHTMLEditor::LoadHTML(const nsAString & aInputString)
+HTMLEditor::LoadHTML(const nsAString& aInputString)
 {
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
 
   // force IME commit; set up rules sniffing and batching
   ForceCompositionEnd();
   AutoEditBatch beginBatching(this);
   AutoRules beginRulesSniffing(this, EditAction::loadHTML, nsIEditor::eNext);
 
@@ -160,52 +163,51 @@ nsHTMLEditor::LoadHTML(const nsAString &
       NS_ENSURE_SUCCESS(rv, rv);
       docfrag->GetFirstChild(getter_AddRefs(nodeToInsert));
     }
   }
 
   return mRules->DidDoAction(selection, &ruleInfo, rv);
 }
 
-
-NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsAString & aInString)
+NS_IMETHODIMP
+HTMLEditor::InsertHTML(const nsAString& aInString)
 {
   const nsAFlatString& empty = EmptyString();
 
   return InsertHTMLWithContext(aInString, empty, empty, empty,
                                nullptr,  nullptr, 0, true);
 }
 
-
 nsresult
-nsHTMLEditor::InsertHTMLWithContext(const nsAString & aInputString,
-                                    const nsAString & aContextStr,
-                                    const nsAString & aInfoStr,
-                                    const nsAString & aFlavor,
-                                    nsIDOMDocument *aSourceDoc,
-                                    nsIDOMNode *aDestNode,
-                                    int32_t aDestOffset,
-                                    bool aDeleteSelection)
+HTMLEditor::InsertHTMLWithContext(const nsAString& aInputString,
+                                  const nsAString& aContextStr,
+                                  const nsAString& aInfoStr,
+                                  const nsAString& aFlavor,
+                                  nsIDOMDocument* aSourceDoc,
+                                  nsIDOMNode* aDestNode,
+                                  int32_t aDestOffset,
+                                  bool aDeleteSelection)
 {
   return DoInsertHTMLWithContext(aInputString, aContextStr, aInfoStr,
       aFlavor, aSourceDoc, aDestNode, aDestOffset, aDeleteSelection,
       /* trusted input */ true, /* clear style */ false);
 }
 
 nsresult
-nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
-                                      const nsAString & aContextStr,
-                                      const nsAString & aInfoStr,
-                                      const nsAString & aFlavor,
-                                      nsIDOMDocument *aSourceDoc,
-                                      nsIDOMNode *aDestNode,
-                                      int32_t aDestOffset,
-                                      bool aDeleteSelection,
-                                      bool aTrustedInput,
-                                      bool aClearStyle)
+HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
+                                    const nsAString& aContextStr,
+                                    const nsAString& aInfoStr,
+                                    const nsAString& aFlavor,
+                                    nsIDOMDocument* aSourceDoc,
+                                    nsIDOMNode* aDestNode,
+                                    int32_t aDestOffset,
+                                    bool aDeleteSelection,
+                                    bool aTrustedInput,
+                                    bool aClearStyle)
 {
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
 
   // Prevent the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   // force IME commit; set up rules sniffing and batching
   ForceCompositionEnd();
@@ -703,50 +705,50 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
       }
     }
   }
 
   return mRules->DidDoAction(selection, &ruleInfo, rv);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::AddInsertionListener(nsIContentFilter *aListener)
+HTMLEditor::AddInsertionListener(nsIContentFilter* aListener)
 {
   NS_ENSURE_TRUE(aListener, NS_ERROR_NULL_POINTER);
 
   // don't let a listener be added more than once
   if (!mContentFilters.Contains(aListener)) {
     mContentFilters.AppendElement(*aListener);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RemoveInsertionListener(nsIContentFilter *aListener)
+HTMLEditor::RemoveInsertionListener(nsIContentFilter* aListener)
 {
   NS_ENSURE_TRUE(aListener, NS_ERROR_FAILURE);
 
   mContentFilters.RemoveElement(aListener);
 
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::DoContentFilterCallback(const nsAString &aFlavor,
-                                      nsIDOMDocument *sourceDoc,
-                                      bool aWillDeleteSelection,
-                                      nsIDOMNode **aFragmentAsNode,
-                                      nsIDOMNode **aFragStartNode,
-                                      int32_t *aFragStartOffset,
-                                      nsIDOMNode **aFragEndNode,
-                                      int32_t *aFragEndOffset,
-                                      nsIDOMNode **aTargetNode,
-                                      int32_t *aTargetOffset,
-                                      bool *aDoContinue)
+HTMLEditor::DoContentFilterCallback(const nsAString& aFlavor,
+                                    nsIDOMDocument* sourceDoc,
+                                    bool aWillDeleteSelection,
+                                    nsIDOMNode** aFragmentAsNode,
+                                    nsIDOMNode** aFragStartNode,
+                                    int32_t* aFragStartOffset,
+                                    nsIDOMNode** aFragEndNode,
+                                    int32_t* aFragEndOffset,
+                                    nsIDOMNode** aTargetNode,
+                                    int32_t* aTargetOffset,
+                                    bool* aDoContinue)
 {
   *aDoContinue = true;
 
   for (auto& listener : mContentFilters) {
     if (!*aDoContinue) {
       break;
     }
     listener->NotifyOfInsertion(aFlavor, nullptr, sourceDoc,
@@ -755,17 +757,18 @@ nsHTMLEditor::DoContentFilterCallback(co
                                 aFragEndNode, aFragEndOffset, aTargetNode,
                                 aTargetOffset, aDoContinue);
   }
 
   return NS_OK;
 }
 
 bool
-nsHTMLEditor::IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink)
+HTMLEditor::IsInLink(nsIDOMNode* aNode,
+                     nsCOMPtr<nsIDOMNode>* outLink)
 {
   NS_ENSURE_TRUE(aNode, false);
   if (outLink)
     *outLink = nullptr;
   nsCOMPtr<nsIDOMNode> tmp, node = aNode;
   while (node)
   {
     if (HTMLEditUtils::IsLink(node)) {
@@ -774,19 +777,19 @@ nsHTMLEditor::IsInLink(nsIDOMNode *aNode
       return true;
     }
     tmp = node;
     tmp->GetParentNode(getter_AddRefs(node));
   }
   return false;
 }
 
-
 nsresult
-nsHTMLEditor::StripFormattingNodes(nsIContent& aNode, bool aListOnly)
+HTMLEditor::StripFormattingNodes(nsIContent& aNode,
+                                 bool aListOnly)
 {
   if (aNode.TextIsOnlyWhitespace()) {
     nsCOMPtr<nsINode> parent = aNode.GetParentNode();
     if (parent) {
       if (!aListOnly || HTMLEditUtils::IsList(parent)) {
         ErrorResult rv;
         parent->RemoveChild(aNode, rv);
         return rv.StealNSResult();
@@ -802,23 +805,24 @@ nsHTMLEditor::StripFormattingNodes(nsICo
       nsresult rv = StripFormattingNodes(*child, aListOnly);
       NS_ENSURE_SUCCESS(rv, rv);
       child = previous.forget();
     }
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsHTMLEditor::PrepareTransferable(nsITransferable **transferable)
+NS_IMETHODIMP
+HTMLEditor::PrepareTransferable(nsITransferable** aTransferable)
 {
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransferable)
+HTMLEditor::PrepareHTMLTransferable(nsITransferable** aTransferable)
 {
   // Create generic Transferable for getting the data
   nsresult rv = CallCreateInstance("@mozilla.org/widget/transferable;1", aTransferable);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the nsITransferable interface for getting the data from the clipboard
   if (aTransferable)
   {
@@ -861,18 +865,19 @@ nsHTMLEditor::PrepareHTMLTransferable(ns
     (*aTransferable)->AddDataFlavor(kUnicodeMime);
     (*aTransferable)->AddDataFlavor(kMozTextInternal);
   }
 
   return NS_OK;
 }
 
 bool
-FindIntegerAfterString(const char *aLeadingString,
-                       nsCString &aCStr, int32_t &foundNumber)
+FindIntegerAfterString(const char* aLeadingString,
+                       nsCString& aCStr,
+                       int32_t& foundNumber)
 {
   // first obtain offsets from cfhtml str
   int32_t numFront = aCStr.Find(aLeadingString);
   if (numFront == -1)
     return false;
   numFront += strlen(aLeadingString);
 
   int32_t numBack = aCStr.FindCharInSet(CRLF, numFront);
@@ -881,17 +886,17 @@ FindIntegerAfterString(const char *aLead
 
   nsAutoCString numStr(Substring(aCStr, numFront, numBack-numFront));
   nsresult errorCode;
   foundNumber = numStr.ToInteger(&errorCode);
   return true;
 }
 
 nsresult
-RemoveFragComments(nsCString & aStr)
+RemoveFragComments(nsCString& aStr)
 {
   // remove the StartFragment/EndFragment comments from the str, if present
   int32_t startCommentIndx = aStr.Find("<!--StartFragment");
   if (startCommentIndx >= 0)
   {
     int32_t startCommentEnd = aStr.Find("-->", false, startCommentIndx);
     if (startCommentEnd > startCommentIndx)
       aStr.Cut(startCommentIndx, (startCommentEnd+3)-startCommentIndx);
@@ -902,17 +907,19 @@ RemoveFragComments(nsCString & aStr)
     int32_t endCommentEnd = aStr.Find("-->", false, endCommentIndx);
     if (endCommentEnd > endCommentIndx)
       aStr.Cut(endCommentIndx, (endCommentEnd+3)-endCommentIndx);
   }
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_t **aCfcontext)
+HTMLEditor::ParseCFHTML(nsCString& aCfhtml,
+                        char16_t** aStuffToPaste,
+                        char16_t** aCfcontext)
 {
   // First obtain offsets from cfhtml str.
   int32_t startHTML, endHTML, startFragment, endFragment;
   if (!FindIntegerAfterString("StartHTML:", aCfhtml, startHTML) ||
       startHTML < -1)
     return NS_ERROR_FAILURE;
   if (!FindIntegerAfterString("EndHTML:", aCfhtml, endHTML) ||
       endHTML < -1)
@@ -1020,77 +1027,83 @@ ImgFromData(const nsACString& aType, con
   aOutput.AssignLiteral("<IMG src=\"data:");
   AppendUTF8toUTF16(aType, aOutput);
   aOutput.AppendLiteral(";base64,");
   AppendUTF8toUTF16(data64, aOutput);
   aOutput.AppendLiteral("\" alt=\"\" >");
   return NS_OK;
 }
 
-NS_IMPL_ISUPPORTS(nsHTMLEditor::BlobReader, nsIEditorBlobListener)
+NS_IMPL_ISUPPORTS(HTMLEditor::BlobReader, nsIEditorBlobListener)
 
-nsHTMLEditor::BlobReader::BlobReader(BlobImpl* aBlob, nsHTMLEditor* aEditor,
-                                     bool aIsSafe, nsIDOMDocument* aSourceDoc,
-                                     nsIDOMNode* aDestinationNode,
-                                     int32_t aDestOffset,
-                                     bool aDoDeleteSelection)
+HTMLEditor::BlobReader::BlobReader(BlobImpl* aBlob,
+                                   HTMLEditor* aHTMLEditor,
+                                   bool aIsSafe,
+                                   nsIDOMDocument* aSourceDoc,
+                                   nsIDOMNode* aDestinationNode,
+                                   int32_t aDestOffset,
+                                   bool aDoDeleteSelection)
   : mBlob(aBlob)
-  , mEditor(aEditor)
+  , mHTMLEditor(aHTMLEditor)
   , mIsSafe(aIsSafe)
   , mSourceDoc(aSourceDoc)
   , mDestinationNode(aDestinationNode)
   , mDestOffset(aDestOffset)
   , mDoDeleteSelection(aDoDeleteSelection)
 {
   MOZ_ASSERT(mBlob);
-  MOZ_ASSERT(mEditor);
+  MOZ_ASSERT(mHTMLEditor);
   MOZ_ASSERT(mDestinationNode);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::BlobReader::OnResult(const nsACString& aResult)
+HTMLEditor::BlobReader::OnResult(const nsACString& aResult)
 {
   nsString blobType;
   mBlob->GetType(blobType);
 
   NS_ConvertUTF16toUTF8 type(blobType);
   nsAutoString stuffToPaste;
   nsresult rv = ImgFromData(type, aResult, stuffToPaste);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  AutoEditBatch beginBatching(mEditor);
-  rv = mEditor->DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
-                                        NS_LITERAL_STRING(kFileMime),
-                                        mSourceDoc,
-                                        mDestinationNode, mDestOffset,
-                                        mDoDeleteSelection,
-                                        mIsSafe, false);
+  AutoEditBatch beginBatching(mHTMLEditor);
+  rv = mHTMLEditor->DoInsertHTMLWithContext(stuffToPaste, EmptyString(),
+                                            EmptyString(),
+                                            NS_LITERAL_STRING(kFileMime),
+                                            mSourceDoc,
+                                            mDestinationNode, mDestOffset,
+                                            mDoDeleteSelection,
+                                            mIsSafe, false);
   return rv;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::BlobReader::OnError(const nsAString& aError)
+HTMLEditor::BlobReader::OnError(const nsAString& aError)
 {
   nsCOMPtr<nsINode> destNode = do_QueryInterface(mDestinationNode);
   const nsPromiseFlatString& flat = PromiseFlatString(aError);
   const char16_t* error = flat.get();
   nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                   NS_LITERAL_CSTRING("Editor"),
                                   destNode->OwnerDoc(),
                                   nsContentUtils::eDOM_PROPERTIES,
                                   "EditorFileDropFailed",
                                   &error, 1);
   return NS_OK;
 }
 
-nsresult nsHTMLEditor::InsertObject(const char* aType, nsISupports* aObject, bool aIsSafe,
-                                    nsIDOMDocument *aSourceDoc,
-                                    nsIDOMNode *aDestinationNode,
-                                    int32_t aDestOffset,
-                                    bool aDoDeleteSelection)
+nsresult
+HTMLEditor::InsertObject(const char* aType,
+                         nsISupports* aObject,
+                         bool aIsSafe,
+                         nsIDOMDocument* aSourceDoc,
+                         nsIDOMNode* aDestinationNode,
+                         int32_t aDestOffset,
+                         bool aDoDeleteSelection)
 {
   nsresult rv;
 
   if (nsCOMPtr<BlobImpl> blob = do_QueryInterface(aObject)) {
     RefPtr<BlobReader> br = new BlobReader(blob, this, aIsSafe, aSourceDoc,
                                            aDestinationNode, aDestOffset,
                                            aDoDeleteSelection);
     nsCOMPtr<nsIEditorUtils> utils =
@@ -1165,24 +1178,24 @@ nsresult nsHTMLEditor::InsertObject(cons
                                  aDoDeleteSelection,
                                  aIsSafe, false);
   }
 
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable,
-                                     nsIDOMDocument *aSourceDoc,
-                                     const nsAString & aContextStr,
-                                     const nsAString & aInfoStr,
-                                     bool havePrivateHTMLFlavor,
-                                     nsIDOMNode *aDestinationNode,
-                                     int32_t aDestOffset,
-                                     bool aDoDeleteSelection)
+HTMLEditor::InsertFromTransferable(nsITransferable* transferable,
+                                   nsIDOMDocument* aSourceDoc,
+                                   const nsAString& aContextStr,
+                                   const nsAString& aInfoStr,
+                                   bool havePrivateHTMLFlavor,
+                                   nsIDOMNode* aDestinationNode,
+                                   int32_t aDestOffset,
+                                   bool aDoDeleteSelection)
 {
   nsresult rv = NS_OK;
   nsXPIDLCString bestFlavor;
   nsCOMPtr<nsISupports> genericDataObj;
   uint32_t len = 0;
   if (NS_SUCCEEDED(transferable->GetAnyTransferData(getter_Copies(bestFlavor), getter_AddRefs(genericDataObj), &len)))
   {
     AutoTransactionsConserveSelection dontSpazMySelection(this);
@@ -1281,31 +1294,34 @@ nsHTMLEditor::InsertFromTransferable(nsI
   // Try to scroll the selection into view if the paste succeeded
   if (NS_SUCCEEDED(rv))
     ScrollSelectionIntoView(false);
 
   return rv;
 }
 
 static void
-GetStringFromDataTransfer(nsIDOMDataTransfer *aDataTransfer, const nsAString& aType,
-                          int32_t aIndex, nsAString& aOutputString)
+GetStringFromDataTransfer(nsIDOMDataTransfer* aDataTransfer,
+                          const nsAString& aType,
+                          int32_t aIndex,
+                          nsAString& aOutputString)
 {
   nsCOMPtr<nsIVariant> variant;
   DataTransfer::Cast(aDataTransfer)->GetDataAtNoSecurityCheck(aType, aIndex, getter_AddRefs(variant));
   if (variant)
     variant->GetAsAString(aOutputString);
 }
 
-nsresult nsHTMLEditor::InsertFromDataTransfer(DataTransfer *aDataTransfer,
-                                              int32_t aIndex,
-                                              nsIDOMDocument *aSourceDoc,
-                                              nsIDOMNode *aDestinationNode,
-                                              int32_t aDestOffset,
-                                              bool aDoDeleteSelection)
+nsresult
+HTMLEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
+                                   int32_t aIndex,
+                                   nsIDOMDocument* aSourceDoc,
+                                   nsIDOMNode* aDestinationNode,
+                                   int32_t aDestOffset,
+                                   bool aDoDeleteSelection)
 {
   ErrorResult rv;
   RefPtr<DOMStringList> types = aDataTransfer->MozTypesAt(aIndex, rv);
   if (rv.Failed()) {
     return rv.StealNSResult();
   }
 
   bool hasPrivateHTMLFlavor = types->Contains(NS_LITERAL_STRING(kHTMLContext));
@@ -1395,17 +1411,18 @@ nsresult nsHTMLEditor::InsertFromDataTra
       AutoEditBatch beginBatching(this);
       return InsertTextAt(text, aDestinationNode, aDestOffset, aDoDeleteSelection);
     }
   }
 
   return NS_OK;
 }
 
-bool nsHTMLEditor::HavePrivateHTMLFlavor(nsIClipboard *aClipboard)
+bool
+HTMLEditor::HavePrivateHTMLFlavor(nsIClipboard* aClipboard)
 {
   // check the clipboard for our special kHTMLContext flavor.  If that is there, we know
   // we have our own internal html format on clipboard.
 
   NS_ENSURE_TRUE(aClipboard, false);
   bool bHavePrivateHTMLFlavor = false;
 
   const char* flavArray[] = { kHTMLContext };
@@ -1414,17 +1431,18 @@ bool nsHTMLEditor::HavePrivateHTMLFlavor
     ArrayLength(flavArray), nsIClipboard::kGlobalClipboard,
     &bHavePrivateHTMLFlavor)))
     return bHavePrivateHTMLFlavor;
 
   return false;
 }
 
 
-NS_IMETHODIMP nsHTMLEditor::Paste(int32_t aSelectionType)
+NS_IMETHODIMP
+HTMLEditor::Paste(int32_t aSelectionType)
 {
   if (!FireClipboardEvent(ePaste, aSelectionType)) {
     return NS_OK;
   }
 
   // Get Clipboard Service
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
@@ -1495,17 +1513,18 @@ NS_IMETHODIMP nsHTMLEditor::Paste(int32_
   if (!EditorHookUtils::DoInsertionHook(domdoc, nullptr, trans)) {
     return NS_OK;
   }
 
   return InsertFromTransferable(trans, nullptr, contextStr, infoStr, bHavePrivateHTMLFlavor,
                                 nullptr, 0, true);
 }
 
-NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable)
+NS_IMETHODIMP
+HTMLEditor::PasteTransferable(nsITransferable* aTransferable)
 {
   // Use an invalid value for the clipboard type as data comes from aTransferable
   // and we don't currently implement a way to put that in the data transfer yet.
   if (!FireClipboardEvent(ePaste, nsIClipboard::kGlobalClipboard)) {
     return NS_OK;
   }
 
   // handle transferable hooks
@@ -1514,20 +1533,21 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransfe
     return NS_OK;
   }
 
   nsAutoString contextStr, infoStr;
   return InsertFromTransferable(aTransferable, nullptr, contextStr, infoStr, false,
                                 nullptr, 0, true);
 }
 
-//
-// HTML PasteNoFormatting. Ignore any HTML styles and formating in paste source
-//
-NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(int32_t aSelectionType)
+/**
+ * HTML PasteNoFormatting. Ignore any HTML styles and formating in paste source.
+ */
+NS_IMETHODIMP
+HTMLEditor::PasteNoFormatting(int32_t aSelectionType)
 {
   if (!FireClipboardEvent(ePaste, aSelectionType)) {
     return NS_OK;
   }
 
   ForceCompositionEnd();
 
   // Get Clipboard Service
@@ -1548,26 +1568,27 @@ NS_IMETHODIMP nsHTMLEditor::PasteNoForma
       rv = InsertFromTransferable(trans, nullptr, empty, empty, false, nullptr, 0,
                                   true);
     }
   }
 
   return rv;
 }
 
-
 // The following arrays contain the MIME types that we can paste. The arrays
 // are used by CanPaste() and CanPasteTransferable() below.
 
 static const char* textEditorFlavors[] = { kUnicodeMime };
 static const char* textHtmlEditorFlavors[] = { kUnicodeMime, kHTMLMime,
                                                kJPEGImageMime, kJPGImageMime,
                                                kPNGImageMime, kGIFImageMime };
 
-NS_IMETHODIMP nsHTMLEditor::CanPaste(int32_t aSelectionType, bool *aCanPaste)
+NS_IMETHODIMP
+HTMLEditor::CanPaste(int32_t aSelectionType,
+                     bool* aCanPaste)
 {
   NS_ENSURE_ARG_POINTER(aCanPaste);
   *aCanPaste = false;
 
   // can't paste if readonly
   if (!IsModifiable()) {
     return NS_OK;
   }
@@ -1589,17 +1610,19 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(int
                                            aSelectionType, &haveFlavors);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aCanPaste = haveFlavors;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsHTMLEditor::CanPasteTransferable(nsITransferable *aTransferable, bool *aCanPaste)
+NS_IMETHODIMP
+HTMLEditor::CanPasteTransferable(nsITransferable* aTransferable,
+                                 bool* aCanPaste)
 {
   NS_ENSURE_ARG_POINTER(aCanPaste);
 
   // can't paste if readonly
   if (!IsModifiable()) {
     *aCanPaste = false;
     return NS_OK;
   }
@@ -1634,31 +1657,32 @@ NS_IMETHODIMP nsHTMLEditor::CanPasteTran
       return NS_OK;
     }
   }
 
   *aCanPaste = false;
   return NS_OK;
 }
 
-
-//
-// HTML PasteAsQuotation: Paste in a blockquote type=cite
-//
-NS_IMETHODIMP nsHTMLEditor::PasteAsQuotation(int32_t aSelectionType)
+/**
+ * HTML PasteAsQuotation: Paste in a blockquote type=cite.
+ */
+NS_IMETHODIMP
+HTMLEditor::PasteAsQuotation(int32_t aSelectionType)
 {
   if (IsPlaintextEditor())
     return PasteAsPlaintextQuotation(aSelectionType);
 
   nsAutoString citation;
   return PasteAsCitedQuotation(citation, aSelectionType);
 }
 
-NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAString & aCitation,
-                                                  int32_t aSelectionType)
+NS_IMETHODIMP
+HTMLEditor::PasteAsCitedQuotation(const nsAString& aCitation,
+                                  int32_t aSelectionType)
 {
   AutoEditBatch beginBatching(this);
   AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
                                nsIEditor::eNext);
 
   // get selection
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
@@ -1684,20 +1708,21 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCited
 
   // Set the selection to the underneath the node we just inserted:
   rv = selection->Collapse(newNode, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return Paste(aSelectionType);
 }
 
-//
-// Paste a plaintext quotation
-//
-NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(int32_t aSelectionType)
+/**
+ * Paste a plaintext quotation.
+ */
+NS_IMETHODIMP
+HTMLEditor::PasteAsPlaintextQuotation(int32_t aSelectionType)
 {
   // Get Clipboard Service
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Create generic Transferable for getting the data
   nsCOMPtr<nsITransferable> trans =
@@ -1737,17 +1762,17 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlain
     }
   }
   free(flav);
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::InsertTextWithQuotations(const nsAString &aStringToInsert)
+HTMLEditor::InsertTextWithQuotations(const nsAString& aStringToInsert)
 {
   // The whole operation should be undoable in one transaction:
   BeginTransaction();
 
   // We're going to loop over the string, collecting up a "hunk"
   // that's all the same type (quoted or not),
   // Whenever the quotedness changes (or we reach the string's end)
   // we will insert the hunk all at once, quoted or non.
@@ -1819,35 +1844,36 @@ nsHTMLEditor::InsertTextWithQuotations(c
     hunkStart = lineStart;
   }
 
   EndTransaction();
 
   return rv;
 }
 
-NS_IMETHODIMP nsHTMLEditor::InsertAsQuotation(const nsAString & aQuotedText,
-                                              nsIDOMNode **aNodeInserted)
+NS_IMETHODIMP
+HTMLEditor::InsertAsQuotation(const nsAString& aQuotedText,
+                              nsIDOMNode** aNodeInserted)
 {
   if (IsPlaintextEditor())
     return InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
 
   nsAutoString citation;
   return InsertAsCitedQuotation(aQuotedText, citation, false,
                                 aNodeInserted);
 }
 
 // Insert plaintext as a quotation, with cite marks (e.g. "> ").
 // This differs from its corresponding method in nsPlaintextEditor
 // in that here, quoted material is enclosed in a <pre> tag
 // in order to preserve the original line wrapping.
 NS_IMETHODIMP
-nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
-                                         bool aAddCites,
-                                         nsIDOMNode **aNodeInserted)
+HTMLEditor::InsertAsPlaintextQuotation(const nsAString& aQuotedText,
+                                       bool aAddCites,
+                                       nsIDOMNode** aNodeInserted)
 {
   // get selection
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
   AutoEditBatch beginBatching(this);
   AutoRules beginRulesSniffing(this, EditAction::insertQuotation,
                                nsIEditor::eNext);
@@ -1905,32 +1931,32 @@ nsHTMLEditor::InsertAsPlaintextQuotation
     if (parent) {
       selection->Collapse(parent, offset + 1);
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::StripCites()
+HTMLEditor::StripCites()
 {
   return nsPlaintextEditor::StripCites();
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::Rewrap(bool aRespectNewlines)
+HTMLEditor::Rewrap(bool aRespectNewlines)
 {
   return nsPlaintextEditor::Rewrap(aRespectNewlines);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
-                                     const nsAString & aCitation,
-                                     bool aInsertHTML,
-                                     nsIDOMNode **aNodeInserted)
+HTMLEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
+                                   const nsAString& aCitation,
+                                   bool aInsertHTML,
+                                   nsIDOMNode** aNodeInserted)
 {
   // Don't let anyone insert html into a "plaintext" editor:
   if (IsPlaintextEditor())
   {
     NS_ASSERTION(!aInsertHTML, "InsertAsCitedQuotation: trying to insert html into plaintext editor");
     return InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
   }
 
@@ -2084,25 +2110,26 @@ nsresult FindTargetNode(nsIDOMNode *aSta
     NS_ENSURE_SUCCESS(rv, rv);
 
     child = tmp;
   } while (child);
 
   return NS_OK;
 }
 
-nsresult nsHTMLEditor::CreateDOMFragmentFromPaste(const nsAString &aInputString,
-                                                  const nsAString & aContextStr,
-                                                  const nsAString & aInfoStr,
-                                                  nsCOMPtr<nsIDOMNode> *outFragNode,
-                                                  nsCOMPtr<nsIDOMNode> *outStartNode,
-                                                  nsCOMPtr<nsIDOMNode> *outEndNode,
-                                                  int32_t *outStartOffset,
-                                                  int32_t *outEndOffset,
-                                                  bool aTrustedInput)
+nsresult
+HTMLEditor::CreateDOMFragmentFromPaste(const nsAString& aInputString,
+                                       const nsAString& aContextStr,
+                                       const nsAString& aInfoStr,
+                                       nsCOMPtr<nsIDOMNode>* outFragNode,
+                                       nsCOMPtr<nsIDOMNode>* outStartNode,
+                                       nsCOMPtr<nsIDOMNode>* outEndNode,
+                                       int32_t* outStartOffset,
+                                       int32_t* outEndOffset,
+                                       bool aTrustedInput)
 {
   NS_ENSURE_TRUE(outFragNode && outStartNode && outEndNode, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIDocument> doc = GetDocument();
   NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
 
   // if we have context info, create a fragment for that
   nsresult rv = NS_OK;
@@ -2196,21 +2223,22 @@ nsresult nsHTMLEditor::CreateDOMFragment
   }
 
   nsCOMPtr<nsINode> node = do_QueryInterface(*outEndNode);
   *outEndOffset = node->Length();
   return NS_OK;
 }
 
 
-nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr,
-                                     nsIAtom* aContextLocalName,
-                                     nsIDocument* aTargetDocument,
-                                     DocumentFragment** aFragment,
-                                     bool aTrustedInput)
+nsresult
+HTMLEditor::ParseFragment(const nsAString& aFragStr,
+                          nsIAtom* aContextLocalName,
+                          nsIDocument* aTargetDocument,
+                          DocumentFragment** aFragment,
+                          bool aTrustedInput)
 {
   nsAutoScriptBlockerSuppressNodeRemoved autoBlocker;
 
   RefPtr<DocumentFragment> fragment =
     new DocumentFragment(aTargetDocument->NodeInfoManager());
   nsresult rv = nsContentUtils::ParseFragmentHTML(aFragStr,
                                                   fragment,
                                                   aContextLocalName ?
@@ -2224,22 +2252,23 @@ nsresult nsHTMLEditor::ParseFragment(con
                               nsIParserUtils::SanitizerAllowComments);
     sanitizer.Sanitize(fragment);
   }
   fragment.forget(aFragment);
   return rv;
 }
 
 void
-nsHTMLEditor::CreateListOfNodesToPaste(DocumentFragment& aFragment,
-                                       nsTArray<OwningNonNull<nsINode>>& outNodeList,
-                                       nsINode* aStartNode,
-                                       int32_t aStartOffset,
-                                       nsINode* aEndNode,
-                                       int32_t aEndOffset)
+HTMLEditor::CreateListOfNodesToPaste(
+              DocumentFragment& aFragment,
+              nsTArray<OwningNonNull<nsINode>>& outNodeList,
+              nsINode* aStartNode,
+              int32_t aStartOffset,
+              nsINode* aEndNode,
+              int32_t aEndOffset)
 {
   // If no info was provided about the boundary between context and stream,
   // then assume all is stream.
   if (!aStartNode) {
     aStartNode = &aFragment;
     aStartOffset = 0;
     aEndNode = &aFragment;
     aEndOffset = aFragment.Length();
@@ -2256,37 +2285,38 @@ nsHTMLEditor::CreateListOfNodesToPaste(D
   TrivialFunctor functor;
   DOMSubtreeIterator iter;
   rv = iter.Init(*docFragRange);
   NS_ENSURE_SUCCESS(rv, );
   iter.AppendList(functor, outNodeList);
 }
 
 void
-nsHTMLEditor::GetListAndTableParents(StartOrEnd aStartOrEnd,
-                                     nsTArray<OwningNonNull<nsINode>>& aNodeList,
-                                     nsTArray<OwningNonNull<Element>>& outArray)
+HTMLEditor::GetListAndTableParents(StartOrEnd aStartOrEnd,
+                                   nsTArray<OwningNonNull<nsINode>>& aNodeList,
+                                   nsTArray<OwningNonNull<Element>>& outArray)
 {
   MOZ_ASSERT(aNodeList.Length());
 
   // Build up list of parents of first (or last) node in list that are either
   // lists, or tables.
   int32_t idx = aStartOrEnd == StartOrEnd::end ? aNodeList.Length() - 1 : 0;
 
   for (nsCOMPtr<nsINode> node = aNodeList[idx]; node;
        node = node->GetParentNode()) {
     if (HTMLEditUtils::IsList(node) || HTMLEditUtils::IsTable(node)) {
       outArray.AppendElement(*node->AsElement());
     }
   }
 }
 
 int32_t
-nsHTMLEditor::DiscoverPartialListsAndTables(nsTArray<OwningNonNull<nsINode>>& aPasteNodes,
-                                            nsTArray<OwningNonNull<Element>>& aListsAndTables)
+HTMLEditor::DiscoverPartialListsAndTables(
+              nsTArray<OwningNonNull<nsINode>>& aPasteNodes,
+              nsTArray<OwningNonNull<Element>>& aListsAndTables)
 {
   int32_t ret = -1;
   int32_t listAndTableParents = aListsAndTables.Length();
 
   // Scan insertion list for table elements (other than table).
   for (auto& curNode : aPasteNodes) {
     if (HTMLEditUtils::IsTableElement(curNode) &&
         !curNode->IsHTMLElement(nsGkAtoms::table)) {
@@ -2321,19 +2351,20 @@ nsHTMLEditor::DiscoverPartialListsAndTab
         }
       }
     }
   }
   return ret;
 }
 
 nsINode*
-nsHTMLEditor::ScanForListAndTableStructure(StartOrEnd aStartOrEnd,
-                                           nsTArray<OwningNonNull<nsINode>>& aNodes,
-                                           Element& aListOrTable)
+HTMLEditor::ScanForListAndTableStructure(
+              StartOrEnd aStartOrEnd,
+              nsTArray<OwningNonNull<nsINode>>& aNodes,
+              Element& aListOrTable)
 {
   // Look upward from first/last paste node for a piece of this list/table
   int32_t idx = aStartOrEnd == StartOrEnd::end ? aNodes.Length() - 1 : 0;
   bool isList = HTMLEditUtils::IsList(&aListOrTable);
 
   for (nsCOMPtr<nsINode> node = aNodes[idx]; node;
        node = node->GetParentNode()) {
     if ((isList && HTMLEditUtils::IsListItem(node)) ||
@@ -2357,20 +2388,21 @@ nsHTMLEditor::ScanForListAndTableStructu
         return node;
       }
     }
   }
   return nullptr;
 }
 
 void
-nsHTMLEditor::ReplaceOrphanedStructure(StartOrEnd aStartOrEnd,
-                                       nsTArray<OwningNonNull<nsINode>>& aNodeArray,
-                                       nsTArray<OwningNonNull<Element>>& aListAndTableArray,
-                                       int32_t aHighWaterMark)
+HTMLEditor::ReplaceOrphanedStructure(
+              StartOrEnd aStartOrEnd,
+              nsTArray<OwningNonNull<nsINode>>& aNodeArray,
+              nsTArray<OwningNonNull<Element>>& aListAndTableArray,
+              int32_t aHighWaterMark)
 {
   OwningNonNull<Element> curNode = aListAndTableArray[aHighWaterMark];
 
   // Find substructure of list or table that must be included in paste.
   nsCOMPtr<nsINode> replaceNode =
     ScanForListAndTableStructure(aStartOrEnd, aNodeArray, curNode);
 
   if (!replaceNode) {
@@ -2396,8 +2428,10 @@ nsHTMLEditor::ReplaceOrphanedStructure(S
     aNodeArray.Clear();
     if (aStartOrEnd == StartOrEnd::end) {
       aNodeArray.AppendElement(*replaceNode);
     } else {
       aNodeArray.InsertElementAt(0, *replaceNode);
     }
   }
 }
+
+} // namespace mozilla
--- a/editor/libeditor/HTMLEditorEventListener.cpp
+++ b/editor/libeditor/HTMLEditorEventListener.cpp
@@ -1,30 +1,29 @@
 /* -*- 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 "HTMLEditorEventListener.h"
 
 #include "HTMLEditUtils.h"
+#include "mozilla/HTMLEditor.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/Selection.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsEditor.h"
 #include "nsError.h"
-#include "nsHTMLEditor.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMNode.h"
 #include "nsIEditor.h"
-#include "nsIHTMLEditor.h"
 #include "nsIHTMLInlineTableEditor.h"
 #include "nsIHTMLObjectResizer.h"
 #include "nsISupportsImpl.h"
 #include "nsLiteralString.h"
 #include "nsQueryObject.h"
 #include "nsRange.h"
 
 namespace mozilla {
@@ -34,32 +33,32 @@ using namespace dom;
 #ifdef DEBUG
 nsresult
 HTMLEditorEventListener::Connect(nsEditor* aEditor)
 {
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryObject(aEditor);
   nsCOMPtr<nsIHTMLInlineTableEditor> htmlInlineTableEditor =
     do_QueryObject(aEditor);
   NS_PRECONDITION(htmlEditor && htmlInlineTableEditor,
-                  "Set nsHTMLEditor or its sub class");
+                  "Set HTMLEditor or its sub class");
   return EditorEventListener::Connect(aEditor);
 }
 #endif
 
-nsHTMLEditor*
+HTMLEditor*
 HTMLEditorEventListener::GetHTMLEditor()
 {
-  // mEditor must be nsHTMLEditor or its subclass.
-  return static_cast<nsHTMLEditor*>(mEditor);
+  // mEditor must be HTMLEditor or its subclass.
+  return static_cast<HTMLEditor*>(mEditor);
 }
 
 nsresult
 HTMLEditorEventListener::MouseUp(nsIDOMMouseEvent* aMouseEvent)
 {
-  nsHTMLEditor* htmlEditor = GetHTMLEditor();
+  HTMLEditor* htmlEditor = GetHTMLEditor();
 
   nsCOMPtr<nsIDOMEventTarget> target;
   nsresult rv = aMouseEvent->AsEvent()->GetTarget(getter_AddRefs(target));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
 
   int32_t clientX, clientY;
@@ -68,17 +67,17 @@ HTMLEditorEventListener::MouseUp(nsIDOMM
   htmlEditor->MouseUp(clientX, clientY, element);
 
   return EditorEventListener::MouseUp(aMouseEvent);
 }
 
 nsresult
 HTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
 {
-  nsHTMLEditor* htmlEditor = GetHTMLEditor();
+  HTMLEditor* htmlEditor = GetHTMLEditor();
   // Contenteditable should disregard mousedowns outside it.
   // IsAcceptableInputEvent() checks it for a mouse event.
   if (!htmlEditor->IsAcceptableInputEvent(aMouseEvent->AsEvent())) {
     // If it's not acceptable mousedown event (including when mousedown event
     // is fired outside of the active editing host), we need to commit
     // composition because it will be change the selection to the clicked
     // point.  Then, we won't be able to commit the composition.
     return EditorEventListener::MouseDown(aMouseEvent);
--- a/editor/libeditor/HTMLEditorEventListener.h
+++ b/editor/libeditor/HTMLEditorEventListener.h
@@ -5,39 +5,40 @@
 
 #ifndef HTMLEditorEventListener_h
 #define HTMLEditorEventListener_h
 
 #include "EditorEventListener.h"
 #include "nscore.h"
 
 class nsEditor;
-class nsHTMLEditor;
 
 namespace mozilla {
 
+class HTMLEditor;
+
 class HTMLEditorEventListener final : public EditorEventListener
 {
 public:
   HTMLEditorEventListener()
   {
   }
 
   virtual ~HTMLEditorEventListener()
   {
   }
 
 #ifdef DEBUG
-  // WARNING: You must be use nsHTMLEditor or its sub class for this class.
+  // WARNING: You must be use HTMLEditor or its sub class for this class.
   virtual nsresult Connect(nsEditor* aEditor) override;
 #endif
 
 protected:
   virtual nsresult MouseDown(nsIDOMMouseEvent* aMouseEvent) override;
   virtual nsresult MouseUp(nsIDOMMouseEvent* aMouseEvent) override;
   virtual nsresult MouseClick(nsIDOMMouseEvent* aMouseEvent) override;
 
-  inline nsHTMLEditor* GetHTMLEditor();
+  inline HTMLEditor* GetHTMLEditor();
 };
 
 } // namespace mozilla
 
 #endif // #ifndef HTMLEditorEventListener_h
rename from editor/libeditor/nsHTMLObjectResizer.cpp
rename to editor/libeditor/HTMLEditorObjectResizer.cpp
--- a/editor/libeditor/nsHTMLObjectResizer.cpp
+++ b/editor/libeditor/HTMLEditorObjectResizer.cpp
@@ -1,65 +1,62 @@
 /* -*- 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/HTMLEditor.h"
 #include "nsHTMLObjectResizer.h"
 
 #include "EditorUtils.h"
 #include "HTMLEditUtils.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/mozalloc.h"
 #include "nsAString.h"
 #include "nsAlgorithm.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
-#include "nsHTMLEditor.h"
 #include "nsIAtom.h"
 #include "nsIContent.h"
 #include "nsID.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMText.h"
 #include "nsIDocument.h"
 #include "nsIEditor.h"
-#include "nsIHTMLEditor.h"
 #include "nsIHTMLObjectResizeListener.h"
 #include "nsIHTMLObjectResizer.h"
 #include "nsIPresShell.h"
 #include "nsISupportsUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include "nsStringFwd.h"
 #include "nsSubstringTuple.h"
 #include "nscore.h"
 #include <algorithm>
 
 class nsISelection;
 
-using namespace mozilla;
-using namespace mozilla::dom;
+/******************************************************************************
+ * DocumentResizeEventListener
+ ******************************************************************************/
 
-// ==================================================================
-// DocumentResizeEventListener
-// ==================================================================
 NS_IMPL_ISUPPORTS(DocumentResizeEventListener, nsIDOMEventListener)
 
-DocumentResizeEventListener::DocumentResizeEventListener(nsIHTMLEditor * aEditor)
+DocumentResizeEventListener::DocumentResizeEventListener(nsIHTMLEditor* aEditor)
 {
   mEditor = do_GetWeakReference(aEditor);
 }
 
 DocumentResizeEventListener::~DocumentResizeEventListener()
 {
 }
 
@@ -67,55 +64,57 @@ NS_IMETHODIMP
 DocumentResizeEventListener::HandleEvent(nsIDOMEvent* aMouseEvent)
 {
   nsCOMPtr<nsIHTMLObjectResizer> objectResizer = do_QueryReferent(mEditor);
   if (objectResizer)
     return objectResizer->RefreshResizers();
   return NS_OK;
 }
 
-// ==================================================================
-// ResizerSelectionListener
-// ==================================================================
+/******************************************************************************
+ * ResizerSelectionListener
+ ******************************************************************************/
 
 NS_IMPL_ISUPPORTS(ResizerSelectionListener, nsISelectionListener)
 
-ResizerSelectionListener::ResizerSelectionListener(nsIHTMLEditor * aEditor)
+ResizerSelectionListener::ResizerSelectionListener(nsIHTMLEditor* aEditor)
 {
   mEditor = do_GetWeakReference(aEditor);
 }
 
 ResizerSelectionListener::~ResizerSelectionListener()
 {
 }
 
 NS_IMETHODIMP
-ResizerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsISelection *aSelection, int16_t aReason)
+ResizerSelectionListener::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
+                                                 nsISelection* aSelection,
+                                                 int16_t aReason)
 {
   if ((aReason & (nsISelectionListener::MOUSEDOWN_REASON |
                   nsISelectionListener::KEYPRESS_REASON |
                   nsISelectionListener::SELECTALL_REASON)) && aSelection)
   {
     // the selection changed and we need to check if we have to
     // hide and/or redisplay resizing handles
     nsCOMPtr<nsIHTMLEditor> editor = do_QueryReferent(mEditor);
     if (editor)
       editor->CheckSelectionStateForAnonymousButtons(aSelection);
   }
 
   return NS_OK;
 }
 
-// ==================================================================
-// ResizerMouseMotionListener
-// ==================================================================
+/******************************************************************************
+ * ResizerMouseMotionListener
+ ******************************************************************************/
 
 NS_IMPL_ISUPPORTS(ResizerMouseMotionListener, nsIDOMEventListener)
 
-ResizerMouseMotionListener::ResizerMouseMotionListener(nsIHTMLEditor * aEditor)
+ResizerMouseMotionListener::ResizerMouseMotionListener(nsIHTMLEditor* aEditor)
 {
   mEditor = do_GetWeakReference(aEditor);
 }
 
 ResizerMouseMotionListener::~ResizerMouseMotionListener()
 {
 }
 
@@ -134,22 +133,27 @@ ResizerMouseMotionListener::HandleEvent(
   {
     // check if we have to redisplay a resizing shadow
     objectResizer->MouseMove(aMouseEvent);
   }
 
   return NS_OK;
 }
 
-// ==================================================================
-// nsHTMLEditor
-// ==================================================================
+namespace mozilla {
+
+using namespace dom;
+
+/******************************************************************************
+ * mozilla::HTMLEditor
+ ******************************************************************************/
 
 already_AddRefed<Element>
-nsHTMLEditor::CreateResizer(int16_t aLocation, nsIDOMNode* aParentNode)
+HTMLEditor::CreateResizer(int16_t aLocation,
+                          nsIDOMNode* aParentNode)
 {
   nsCOMPtr<nsIDOMElement> retDOM;
   nsresult res = CreateAnonymousElement(NS_LITERAL_STRING("span"),
                                         aParentNode,
                                         NS_LITERAL_STRING("mozResizer"),
                                         false,
                                         getter_AddRefs(retDOM));
 
@@ -194,18 +198,18 @@ nsHTMLEditor::CreateResizer(int16_t aLoc
   nsCOMPtr<Element> ret = do_QueryInterface(retDOM);
   res = ret->SetAttr(kNameSpaceID_None, nsGkAtoms::anonlocation, locationStr,
                      true);
   NS_ENSURE_SUCCESS(res, nullptr);
   return ret.forget();
 }
 
 already_AddRefed<Element>
-nsHTMLEditor::CreateShadow(nsIDOMNode* aParentNode,
-                           nsIDOMElement* aOriginalObject)
+HTMLEditor::CreateShadow(nsIDOMNode* aParentNode,
+                         nsIDOMElement* aOriginalObject)
 {
   // let's create an image through the element factory
   nsAutoString name;
   if (HTMLEditUtils::IsImage(aOriginalObject)) {
     name.AssignLiteral("img");
   } else {
     name.AssignLiteral("span");
   }
@@ -216,30 +220,30 @@ nsHTMLEditor::CreateShadow(nsIDOMNode* a
 
   NS_ENSURE_TRUE(retDOM, nullptr);
 
   nsCOMPtr<Element> ret = do_QueryInterface(retDOM);
   return ret.forget();
 }
 
 already_AddRefed<Element>
-nsHTMLEditor::CreateResizingInfo(nsIDOMNode* aParentNode)
+HTMLEditor::CreateResizingInfo(nsIDOMNode* aParentNode)
 {
   // let's create an info box through the element factory
   nsCOMPtr<nsIDOMElement> retDOM;
   CreateAnonymousElement(NS_LITERAL_STRING("span"), aParentNode,
                          NS_LITERAL_STRING("mozResizingInfo"), true,
                          getter_AddRefs(retDOM));
 
   nsCOMPtr<Element> ret = do_QueryInterface(retDOM);
   return ret.forget();
 }
 
 nsresult
-nsHTMLEditor::SetAllResizersPosition()
+HTMLEditor::SetAllResizersPosition()
 {
   NS_ENSURE_TRUE(mTopLeftHandle, NS_ERROR_FAILURE);
 
   int32_t x = mResizedObjectX;
   int32_t y = mResizedObjectY;
   int32_t w = mResizedObjectWidth;
   int32_t h = mResizedObjectHeight;
 
@@ -269,17 +273,17 @@ nsHTMLEditor::SetAllResizersPosition()
   SetAnonymousElementPosition(x-rw,     y+h-rh-1, static_cast<nsIDOMElement*>(GetAsDOMNode(mBottomLeftHandle)));
   SetAnonymousElementPosition(x+w/2-rw, y+h-rh-1, static_cast<nsIDOMElement*>(GetAsDOMNode(mBottomHandle)));
   SetAnonymousElementPosition(x+w-rw-1, y+h-rh-1, static_cast<nsIDOMElement*>(GetAsDOMNode(mBottomRightHandle)));
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RefreshResizers()
+HTMLEditor::RefreshResizers()
 {
   // nothing to do if resizers are not displayed...
   NS_ENSURE_TRUE(mResizedObject, NS_OK);
 
   nsresult res = GetPositionAndDimensions(static_cast<nsIDOMElement*>(GetAsDOMNode(mResizedObject)),
                                           mResizedObjectX,
                                           mResizedObjectY,
                                           mResizedObjectWidth,
@@ -292,26 +296,26 @@ nsHTMLEditor::RefreshResizers()
   NS_ENSURE_SUCCESS(res, res);
   res = SetAllResizersPosition();
   NS_ENSURE_SUCCESS(res, res);
   return SetShadowPosition(mResizingShadow, mResizedObject,
                            mResizedObjectX, mResizedObjectY);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::ShowResizers(nsIDOMElement *aResizedElement)
+HTMLEditor::ShowResizers(nsIDOMElement* aResizedElement)
 {
   nsresult res = ShowResizersInner(aResizedElement);
   if (NS_FAILED(res))
     HideResizers();
   return res;
 }
 
 nsresult
-nsHTMLEditor::ShowResizersInner(nsIDOMElement *aResizedElement)
+HTMLEditor::ShowResizersInner(nsIDOMElement* aResizedElement)
 {
   NS_ENSURE_ARG_POINTER(aResizedElement);
   nsresult res;
 
   nsCOMPtr<nsIDOMNode> parentNode;
   res = aResizedElement->GetParentNode(getter_AddRefs(parentNode));
   NS_ENSURE_SUCCESS(res, res);
 
@@ -381,17 +385,17 @@ nsHTMLEditor::ShowResizersInner(nsIDOMEl
   if (!mResizeEventListenerP) { return NS_ERROR_OUT_OF_MEMORY; }
   res = target->AddEventListener(NS_LITERAL_STRING("resize"), mResizeEventListenerP, false);
 
   aResizedElement->SetAttribute(NS_LITERAL_STRING("_moz_resizing"), NS_LITERAL_STRING("true"));
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::HideResizers(void)
+HTMLEditor::HideResizers()
 {
   NS_ENSURE_TRUE(mResizedObject, NS_OK);
 
   // get the presshell's document observer interface.
   nsCOMPtr<nsIPresShell> ps = GetPresShell();
   // We allow the pres shell to be null; when it is, we presume there
   // are no document observers to notify, but we still want to
   // UnbindFromTree.
@@ -476,28 +480,28 @@ nsHTMLEditor::HideResizers(void)
 
   mResizedObject->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_moz_resizing, true);
   mResizedObject = nullptr;
 
   return NS_OK;
 }
 
 void
-nsHTMLEditor::HideShadowAndInfo()
+HTMLEditor::HideShadowAndInfo()
 {
   if (mResizingShadow)
     mResizingShadow->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
                              NS_LITERAL_STRING("hidden"), true);
   if (mResizingInfo)
     mResizingInfo->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
                            NS_LITERAL_STRING("hidden"), true);
 }
 
 nsresult
-nsHTMLEditor::StartResizing(nsIDOMElement *aHandle)
+HTMLEditor::StartResizing(nsIDOMElement* aHandle)
 {
   // First notify the listeners if any
   for (auto& listener : mObjectResizeEventListeners) {
     listener->OnStartResizing(static_cast<nsIDOMElement*>(GetAsDOMNode(mResizedObject)));
   }
 
   mIsResizing = true;
   mActivatedHandle = do_QueryInterface(aHandle);
@@ -561,20 +565,21 @@ nsHTMLEditor::StartResizing(nsIDOMElemen
     result = target->AddEventListener(NS_LITERAL_STRING("mousemove"),
                                       mMouseMotionListenerP, true);
     NS_ASSERTION(NS_SUCCEEDED(result),
                  "failed to register mouse motion listener");
   }
   return result;
 }
 
-
 NS_IMETHODIMP
-nsHTMLEditor::MouseDown(int32_t aClientX, int32_t aClientY,
-                        nsIDOMElement *aTarget, nsIDOMEvent* aEvent)
+HTMLEditor::MouseDown(int32_t aClientX,
+                      int32_t aClientY,
+                      nsIDOMElement* aTarget,
+                      nsIDOMEvent* aEvent)
 {
   bool anonElement = false;
   if (aTarget && NS_SUCCEEDED(aTarget->HasAttribute(NS_LITERAL_STRING("_moz_anonclass"), &anonElement)))
     // we caught a click on an anonymous element
     if (anonElement) {
       nsAutoString anonclass;
       nsresult res = aTarget->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass);
       NS_ENSURE_SUCCESS(res, res);
@@ -592,18 +597,19 @@ nsHTMLEditor::MouseDown(int32_t aClientX
         mOriginalY = aClientY;
         return GrabberClicked();
       }
     }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::MouseUp(int32_t aClientX, int32_t aClientY,
-                      nsIDOMElement *aTarget)
+HTMLEditor::MouseUp(int32_t aClientX,
+                    int32_t aClientY,
+                    nsIDOMElement* aTarget)
 {
   if (mIsResizing) {
     // we are resizing and release the mouse button, so let's
     // end the resizing process
     mIsResizing = false;
     HideShadowAndInfo();
     SetFinalSize(aClientX, aClientY);
   }
@@ -615,31 +621,35 @@ nsHTMLEditor::MouseUp(int32_t aClientX, 
     }
     if (mGrabberClicked) {
       EndMoving();
     }
   }
   return NS_OK;
 }
 
-
 void
-nsHTMLEditor::SetResizeIncrements(int32_t aX, int32_t aY,
-                                  int32_t aW, int32_t aH,
-                                  bool aPreserveRatio)
+HTMLEditor::SetResizeIncrements(int32_t aX,
+                                int32_t aY,
+                                int32_t aW,
+                                int32_t aH,
+                                bool aPreserveRatio)
 {
   mXIncrementFactor = aX;
   mYIncrementFactor = aY;
   mWidthIncrementFactor = aW;
   mHeightIncrementFactor = aH;
   mPreserveRatio = aPreserveRatio;
 }
 
 nsresult
-nsHTMLEditor::SetResizingInfoPosition(int32_t aX, int32_t aY, int32_t aW, int32_t aH)
+HTMLEditor::SetResizingInfoPosition(int32_t aX,
+                                    int32_t aY,
+                                    int32_t aW,
+                                    int32_t aH)
 {
   nsCOMPtr<nsIDOMDocument> domdoc = GetDOMDocument();
 
   // Determine the position of the resizing info box based upon the new
   // position and size of the element (aX, aY, aW, aH), and which
   // resizer is the "activated handle".  For example, place the resizing
   // info box at the bottom-right corner of the new element, if the element
   // is being resized by the bottom-right resizer.
@@ -710,35 +720,37 @@ nsHTMLEditor::SetResizingInfoPosition(in
   NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
 
   res = mResizingInfo->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class, true);
 
   return res;
 }
 
 nsresult
-nsHTMLEditor::SetShadowPosition(Element* aShadow,
-                                Element* aOriginalObject,
-                                int32_t aOriginalObjectX,
-                                int32_t aOriginalObjectY)
+HTMLEditor::SetShadowPosition(Element* aShadow,
+                              Element* aOriginalObject,
+                              int32_t aOriginalObjectX,
+                              int32_t aOriginalObjectY)
 {
   SetAnonymousElementPosition(aOriginalObjectX, aOriginalObjectY, static_cast<nsIDOMElement*>(GetAsDOMNode(aShadow)));
 
   if (HTMLEditUtils::IsImage(aOriginalObject)) {
     nsAutoString imageSource;
     aOriginalObject->GetAttr(kNameSpaceID_None, nsGkAtoms::src, imageSource);
     nsresult res = aShadow->SetAttr(kNameSpaceID_None, nsGkAtoms::src,
                                     imageSource, true);
     NS_ENSURE_SUCCESS(res, res);
   }
   return NS_OK;
 }
 
 int32_t
-nsHTMLEditor::GetNewResizingIncrement(int32_t aX, int32_t aY, int32_t aID)
+HTMLEditor::GetNewResizingIncrement(int32_t aX,
+                                    int32_t aY,
+                                    int32_t aID)
 {
   int32_t result = 0;
   if (!mPreserveRatio) {
     switch (aID) {
       case kX:
       case kWidth:
         result = aX - mOriginalX;
         break;
@@ -768,54 +780,57 @@ nsHTMLEditor::GetNewResizingIncrement(in
         result =  (int32_t) (((float) result) / objectSizeRatio);
       result = (int32_t) (((float) result) * mHeightIncrementFactor);
       break;
   }
   return result;
 }
 
 int32_t
-nsHTMLEditor::GetNewResizingX(int32_t aX, int32_t aY)
+HTMLEditor::GetNewResizingX(int32_t aX,
+                            int32_t aY)
 {
   int32_t resized = mResizedObjectX +
                     GetNewResizingIncrement(aX, aY, kX) * mXIncrementFactor;
   int32_t max =   mResizedObjectX + mResizedObjectWidth;
   return std::min(resized, max);
 }
 
 int32_t
-nsHTMLEditor::GetNewResizingY(int32_t aX, int32_t aY)
+HTMLEditor::GetNewResizingY(int32_t aX,
+                            int32_t aY)
 {
   int32_t resized = mResizedObjectY +
                     GetNewResizingIncrement(aX, aY, kY) * mYIncrementFactor;
   int32_t max =   mResizedObjectY + mResizedObjectHeight;
   return std::min(resized, max);
 }
 
 int32_t
-nsHTMLEditor::GetNewResizingWidth(int32_t aX, int32_t aY)
+HTMLEditor::GetNewResizingWidth(int32_t aX,
+                                int32_t aY)
 {
   int32_t resized = mResizedObjectWidth +
                      GetNewResizingIncrement(aX, aY, kWidth) *
                          mWidthIncrementFactor;
   return std::max(resized, 1);
 }
 
 int32_t
-nsHTMLEditor::GetNewResizingHeight(int32_t aX, int32_t aY)
+HTMLEditor::GetNewResizingHeight(int32_t aX,
+                                 int32_t aY)
 {
   int32_t resized = mResizedObjectHeight +
                      GetNewResizingIncrement(aX, aY, kHeight) *
                          mHeightIncrementFactor;
   return std::max(resized, 1);
 }
 
-
 NS_IMETHODIMP
-nsHTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent)
+HTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent)
 {
   NS_NAMED_LITERAL_STRING(leftStr, "left");
   NS_NAMED_LITERAL_STRING(topStr, "top");
 
   if (mIsResizing) {
     // we are resizing and the mouse pointer's position has changed
     // we have to resdisplay the shadow
     nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
@@ -872,17 +887,18 @@ nsHTMLEditor::MouseMove(nsIDOMEvent* aMo
                                         newX);
     mCSSEditUtils->SetCSSPropertyPixels(*mPositioningShadow, *nsGkAtoms::top,
                                         newY);
   }
   return NS_OK;
 }
 
 void
-nsHTMLEditor::SetFinalSize(int32_t aX, int32_t aY)
+HTMLEditor::SetFinalSize(int32_t aX,
+                         int32_t aY)
 {
   if (!mResizedObject) {
     // paranoia
     return;
   }
 
   if (mActivatedHandle) {
     mActivatedHandle->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_moz_activated, true);
@@ -975,57 +991,59 @@ nsHTMLEditor::SetFinalSize(int32_t aX, i
   // keep track of that size
   mResizedObjectWidth  = width;
   mResizedObjectHeight = height;
 
   RefreshResizers();
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetResizedObject(nsIDOMElement * *aResizedObject)
+HTMLEditor::GetResizedObject(nsIDOMElement** aResizedObject)
 {
   nsCOMPtr<nsIDOMElement> ret = static_cast<nsIDOMElement*>(GetAsDOMNode(mResizedObject));
   ret.forget(aResizedObject);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetObjectResizingEnabled(bool *aIsObjectResizingEnabled)
+HTMLEditor::GetObjectResizingEnabled(bool* aIsObjectResizingEnabled)
 {
   *aIsObjectResizingEnabled = mIsObjectResizingEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetObjectResizingEnabled(bool aObjectResizingEnabled)
+HTMLEditor::SetObjectResizingEnabled(bool aObjectResizingEnabled)
 {
   mIsObjectResizingEnabled = aObjectResizingEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::AddObjectResizeEventListener(nsIHTMLObjectResizeListener * aListener)
+HTMLEditor::AddObjectResizeEventListener(nsIHTMLObjectResizeListener* aListener)
 {
   NS_ENSURE_ARG_POINTER(aListener);
   if (mObjectResizeEventListeners.Contains(aListener)) {
     /* listener already registered */
     NS_ASSERTION(false,
                  "trying to register an already registered object resize event listener");
     return NS_OK;
   }
   mObjectResizeEventListeners.AppendElement(*aListener);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RemoveObjectResizeEventListener(nsIHTMLObjectResizeListener * aListener)
+HTMLEditor::RemoveObjectResizeEventListener(
+              nsIHTMLObjectResizeListener* aListener)
 {
   NS_ENSURE_ARG_POINTER(aListener);
   if (!mObjectResizeEventListeners.Contains(aListener)) {
     /* listener was not registered */
     NS_ASSERTION(false,
                  "trying to remove an object resize event listener that was not already registered");
     return NS_OK;
   }
   mObjectResizeEventListeners.RemoveElement(aListener);
   return NS_OK;
 }
 
+} // namespace mozilla
rename from editor/libeditor/nsHTMLInlineTableEditor.cpp
rename to editor/libeditor/HTMLInlineTableEditor.cpp
--- a/editor/libeditor/nsHTMLInlineTableEditor.cpp
+++ b/editor/libeditor/HTMLInlineTableEditor.cpp
@@ -1,54 +1,54 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/HTMLEditor.h"
+
 #include "HTMLEditUtils.h"
 #include "mozilla/dom/Element.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsError.h"
-#include "nsHTMLEditor.h"
 #include "nsIContent.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMNode.h"
-#include "nsIHTMLEditor.h"
 #include "nsIHTMLObjectResizer.h"
 #include "nsIPresShell.h"
 #include "nsLiteralString.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include "nscore.h"
 
-using namespace mozilla;
+namespace mozilla {
 
 // Uncomment the following line if you want to disable
 // table deletion when the only column/row is removed
 // #define DISABLE_TABLE_DELETION 1
 
 NS_IMETHODIMP
-nsHTMLEditor::SetInlineTableEditingEnabled(bool aIsEnabled)
+HTMLEditor::SetInlineTableEditingEnabled(bool aIsEnabled)
 {
   mIsInlineTableEditingEnabled = aIsEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetInlineTableEditingEnabled(bool * aIsEnabled)
+HTMLEditor::GetInlineTableEditingEnabled(bool* aIsEnabled)
 {
   *aIsEnabled = mIsInlineTableEditingEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::ShowInlineTableEditingUI(nsIDOMElement * aCell)
+HTMLEditor::ShowInlineTableEditingUI(nsIDOMElement* aCell)
 {
   NS_ENSURE_ARG_POINTER(aCell);
 
   // do nothing if aCell is not a table cell...
   if (!HTMLEditUtils::IsTableCell(aCell)) {
     return NS_OK;
   }
 
@@ -88,17 +88,17 @@ nsHTMLEditor::ShowInlineTableEditingUI(n
   AddMouseClickListener(mRemoveRowButton);
   AddMouseClickListener(mAddRowAfterButton);
 
   mInlineEditedCell = aCell;
   return RefreshInlineTableEditingUI();
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::HideInlineTableEditingUI()
+HTMLEditor::HideInlineTableEditingUI()
 {
   mInlineEditedCell = nullptr;
 
   RemoveMouseClickListener(mAddColumnBeforeButton);
   RemoveMouseClickListener(mRemoveColumnButton);
   RemoveMouseClickListener(mAddColumnAfterButton);
   RemoveMouseClickListener(mAddRowBeforeButton);
   RemoveMouseClickListener(mRemoveRowButton);
@@ -125,17 +125,17 @@ nsHTMLEditor::HideInlineTableEditingUI()
   mRemoveRowButton = nullptr;
   DeleteRefToAnonymousNode(mAddRowAfterButton, bodyContent, ps);
   mAddRowAfterButton = nullptr;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DoInlineTableEditingAction(nsIDOMElement * aElement)
+HTMLEditor::DoInlineTableEditingAction(nsIDOMElement* aElement)
 {
   NS_ENSURE_ARG_POINTER(aElement);
   bool anonElement = false;
   if (aElement &&
       NS_SUCCEEDED(aElement->HasAttribute(NS_LITERAL_STRING("_moz_anonclass"), &anonElement)) &&
       anonElement) {
     nsAutoString anonclass;
     nsresult res = aElement->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass);
@@ -182,37 +182,37 @@ nsHTMLEditor::DoInlineTableEditingAction
         HideResizers();
     }
   }
 
   return NS_OK;
 }
 
 void
-nsHTMLEditor::AddMouseClickListener(nsIDOMElement * aElement)
+HTMLEditor::AddMouseClickListener(nsIDOMElement* aElement)
 {
   nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
   if (evtTarget) {
     evtTarget->AddEventListener(NS_LITERAL_STRING("click"),
                                 mEventListener, true);
   }
 }
 
 void
-nsHTMLEditor::RemoveMouseClickListener(nsIDOMElement * aElement)
+HTMLEditor::RemoveMouseClickListener(nsIDOMElement* aElement)
 {
   nsCOMPtr<nsIDOMEventTarget> evtTarget(do_QueryInterface(aElement));
   if (evtTarget) {
     evtTarget->RemoveEventListener(NS_LITERAL_STRING("click"),
                                    mEventListener, true);
   }
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::RefreshInlineTableEditingUI()
+HTMLEditor::RefreshInlineTableEditingUI()
 {
   nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mInlineEditedCell);
   if (!htmlElement) {
     return NS_ERROR_NULL_POINTER;
   }
 
   int32_t xCell, yCell, wCell, hCell;
   GetElementOrigin(mInlineEditedCell, xCell, yCell);
@@ -267,8 +267,9 @@ nsHTMLEditor::RefreshInlineTableEditingU
 #ifdef DISABLE_TABLE_DELETION
   }
 #endif
   SetAnonymousElementPosition(xCell-7, yVert+6,  mAddRowAfterButton);
 
   return NS_OK;
 }
 
+} // namespace mozilla
rename from editor/libeditor/nsHTMLEditorStyle.cpp
rename to editor/libeditor/HTMLStyleEditor.cpp
--- a/editor/libeditor/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/HTMLStyleEditor.cpp
@@ -1,13 +1,15 @@
 /* -*- 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/HTMLEditor.h"
+
 #include "EditorUtils.h"
 #include "HTMLEditUtils.h"
 #include "TextEditUtils.h"
 #include "TypeInState.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/SelectionState.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/Element.h"
@@ -16,17 +18,16 @@
 #include "nsAttrName.h"
 #include "nsCOMPtr.h"
 #include "nsCaseTreatment.h"
 #include "nsComponentManagerUtils.h"
 #include "nsDebug.h"
 #include "nsEditor.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
-#include "nsHTMLEditor.h"
 #include "nsIAtom.h"
 #include "nsIContent.h"
 #include "nsIContentIterator.h"
 #include "nsIDOMElement.h"
 #include "nsIEditor.h"
 #include "nsIEditorIMESupport.h"
 #include "nsIEditRules.h"
 #include "nsNameSpaceManager.h"
@@ -38,31 +39,33 @@
 #include "nsString.h"
 #include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "nsUnicharUtils.h"
 #include "nscore.h"
 
 class nsISupports;
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
 static bool
-IsEmptyTextNode(nsHTMLEditor* aThis, nsINode* aNode)
+IsEmptyTextNode(HTMLEditor* aThis, nsINode* aNode)
 {
   bool isEmptyTextNode = false;
   return nsEditor::IsTextNode(aNode) &&
          NS_SUCCEEDED(aThis->IsEmptyNode(aNode, &isEmptyTextNode)) &&
          isEmptyTextNode;
 }
 
-NS_IMETHODIMP nsHTMLEditor::AddDefaultProperty(nsIAtom *aProperty,
-                                            const nsAString & aAttribute,
-                                            const nsAString & aValue)
+NS_IMETHODIMP
+HTMLEditor::AddDefaultProperty(nsIAtom* aProperty,
+                               const nsAString& aAttribute,
+                               const nsAString& aValue)
 {
   nsString outValue;
   int32_t index;
   nsString attr(aAttribute);
   if (TypeInState::FindPropInList(aProperty, attr, &outValue, mDefaultStyles, index))
   {
     PropItem *item = mDefaultStyles[index];
     item->value = aValue;
@@ -71,47 +74,49 @@ NS_IMETHODIMP nsHTMLEditor::AddDefaultPr
   {
     nsString value(aValue);
     PropItem *propItem = new PropItem(aProperty, attr, value);
     mDefaultStyles.AppendElement(propItem);
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsHTMLEditor::RemoveDefaultProperty(nsIAtom *aProperty,
-                                   const nsAString & aAttribute,
-                                   const nsAString & aValue)
+NS_IMETHODIMP
+HTMLEditor::RemoveDefaultProperty(nsIAtom* aProperty,
+                                  const nsAString& aAttribute,
+                                  const nsAString& aValue)
 {
   nsString outValue;
   int32_t index;
   nsString attr(aAttribute);
   if (TypeInState::FindPropInList(aProperty, attr, &outValue, mDefaultStyles, index))
   {
     delete mDefaultStyles[index];
     mDefaultStyles.RemoveElementAt(index);
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsHTMLEditor::RemoveAllDefaultProperties()
+NS_IMETHODIMP
+HTMLEditor::RemoveAllDefaultProperties()
 {
   uint32_t j, defcon = mDefaultStyles.Length();
   for (j=0; j<defcon; j++)
   {
     delete mDefaultStyles[j];
   }
   mDefaultStyles.Clear();
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsHTMLEditor::SetInlineProperty(nsIAtom* aProperty,
-                                const nsAString& aAttribute,
-                                const nsAString& aValue)
+HTMLEditor::SetInlineProperty(nsIAtom* aProperty,
+                              const nsAString& aAttribute,
+                              const nsAString& aValue)
 {
   NS_ENSURE_TRUE(aProperty, NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
   ForceCompositionEnd();
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
@@ -216,25 +221,23 @@ nsHTMLEditor::SetInlineProperty(nsIAtom*
   }
   if (!cancel) {
     // Post-process
     return mRules->DidDoAction(selection, &ruleInfo, res);
   }
   return NS_OK;
 }
 
-
-
 // Helper function for SetInlinePropertyOn*: is aNode a simple old <b>, <font>,
 // <span style="">, etc. that we can reuse instead of creating a new one?
 bool
-nsHTMLEditor::IsSimpleModifiableNode(nsIContent* aContent,
-                                     nsIAtom* aProperty,
-                                     const nsAString* aAttribute,
-                                     const nsAString* aValue)
+HTMLEditor::IsSimpleModifiableNode(nsIContent* aContent,
+                                   nsIAtom* aProperty,
+                                   const nsAString* aAttribute,
+                                   const nsAString* aValue)
 {
   // aContent can be null, in which case we'll return false in a few lines
   MOZ_ASSERT(aProperty);
   MOZ_ASSERT_IF(aAttribute, aValue);
 
   nsCOMPtr<dom::Element> element = do_QueryInterface(aContent);
   if (!element) {
     return false;
@@ -293,24 +296,23 @@ nsHTMLEditor::IsSimpleModifiableNode(nsI
   NS_ENSURE_TRUE(newSpan, false);
   mCSSEditUtils->SetCSSEquivalentToHTMLStyle(newSpan, aProperty,
                                              aAttribute, aValue,
                                              /*suppress transaction*/ true);
 
   return mCSSEditUtils->ElementsSameStyle(newSpan, element);
 }
 
-
 nsresult
-nsHTMLEditor::SetInlinePropertyOnTextNode(Text& aText,
-                                          int32_t aStartOffset,
-                                          int32_t aEndOffset,
-                                          nsIAtom& aProperty,
-                                          const nsAString* aAttribute,
-                                          const nsAString& aValue)
+HTMLEditor::SetInlinePropertyOnTextNode(Text& aText,
+                                        int32_t aStartOffset,
+                                        int32_t aEndOffset,
+                                        nsIAtom& aProperty,
+                                        const nsAString* aAttribute,
+                                        const nsAString& aValue)
 {
   if (!aText.GetParentNode() ||
       !CanContainTag(*aText.GetParentNode(), aProperty)) {
     return NS_OK;
   }
 
   // Don't need to do anything if no characters actually selected
   if (aStartOffset == aEndOffset) {
@@ -358,22 +360,21 @@ nsHTMLEditor::SetInlinePropertyOnTextNod
       return MoveNode(text, sibling, 0);
     }
   }
 
   // Reparent the node inside inline node with appropriate {attribute,value}
   return SetInlinePropertyOnNode(*text, aProperty, aAttribute, aValue);
 }
 
-
 nsresult
-nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent& aNode,
-                                          nsIAtom& aProperty,
-                                          const nsAString* aAttribute,
-                                          const nsAString& aValue)
+HTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent& aNode,
+                                        nsIAtom& aProperty,
+                                        const nsAString* aAttribute,
+                                        const nsAString& aValue)
 {
   nsCOMPtr<nsIAtom> attrAtom = aAttribute ? NS_Atomize(*aAttribute) : nullptr;
 
   // If this is an element that can't be contained in a span, we have to
   // recurse to its children.
   if (!TagCanContain(*nsGkAtoms::span, aNode)) {
     if (aNode.HasChildren()) {
       nsTArray<OwningNonNull<nsIContent>> arrayOfNodes;
@@ -464,22 +465,21 @@ nsHTMLEditor::SetInlinePropertyOnNodeImp
   // ok, chuck it in its very own container
   nsCOMPtr<Element> tmp = InsertContainerAbove(&aNode, &aProperty, attrAtom,
                                                &aValue);
   NS_ENSURE_STATE(tmp);
 
   return NS_OK;
 }
 
-
 nsresult
-nsHTMLEditor::SetInlinePropertyOnNode(nsIContent& aNode,
-                                      nsIAtom& aProperty,
-                                      const nsAString* aAttribute,
-                                      const nsAString& aValue)
+HTMLEditor::SetInlinePropertyOnNode(nsIContent& aNode,
+                                    nsIAtom& aProperty,
+                                    const nsAString* aAttribute,
+                                    const nsAString& aValue)
 {
   nsCOMPtr<nsIContent> previousSibling = aNode.GetPreviousSibling(),
                        nextSibling = aNode.GetNextSibling();
   NS_ENSURE_STATE(aNode.GetParentNode());
   OwningNonNull<nsINode> parent = *aNode.GetParentNode();
 
   nsresult res = RemoveStyleInside(aNode, &aProperty, aAttribute);
   NS_ENSURE_SUCCESS(res, res);
@@ -509,20 +509,20 @@ nsHTMLEditor::SetInlinePropertyOnNode(ns
   for (auto& node : nodesToSet) {
     res = SetInlinePropertyOnNodeImpl(node, aProperty, aAttribute, aValue);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   return NS_OK;
 }
 
-
 nsresult
-nsHTMLEditor::SplitStyleAboveRange(nsRange* inRange, nsIAtom* aProperty,
-                                   const nsAString* aAttribute)
+HTMLEditor::SplitStyleAboveRange(nsRange* inRange,
+                                 nsIAtom* aProperty,
+                                 const nsAString* aAttribute)
 {
   NS_ENSURE_TRUE(inRange, NS_ERROR_NULL_POINTER);
   nsresult res;
 
   nsCOMPtr<nsINode> startNode = inRange->GetStartParent();
   int32_t startOffset = inRange->StartOffset();
   nsCOMPtr<nsINode> endNode = inRange->GetEndParent();
   int32_t endOffset = inRange->EndOffset();
@@ -545,23 +545,23 @@ nsHTMLEditor::SplitStyleAboveRange(nsRan
   // reset the range
   res = inRange->SetStart(startNode, startOffset);
   NS_ENSURE_SUCCESS(res, res);
   res = inRange->SetEnd(endNode, endOffset);
   return res;
 }
 
 nsresult
-nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsINode>* aNode,
-                                   int32_t* aOffset,
-                                   // null here means we split all properties
-                                   nsIAtom* aProperty,
-                                   const nsAString* aAttribute,
-                                   nsIContent** aOutLeftNode,
-                                   nsIContent** aOutRightNode)
+HTMLEditor::SplitStyleAbovePoint(nsCOMPtr<nsINode>* aNode,
+                                 int32_t* aOffset,
+                                 // null here means we split all properties
+                                 nsIAtom* aProperty,
+                                 const nsAString* aAttribute,
+                                 nsIContent** aOutLeftNode,
+                                 nsIContent** aOutRightNode)
 {
   NS_ENSURE_TRUE(aNode && *aNode && aOffset, NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE((*aNode)->IsContent(), NS_OK);
 
   // Split any matching style nodes above the node/offset
   OwningNonNull<nsIContent> node = *(*aNode)->AsContent();
 
   bool useCSS = IsCSSEnabled();
@@ -598,18 +598,20 @@ nsHTMLEditor::SplitStyleAbovePoint(nsCOM
     }
     node = node->GetParent();
   }
 
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::ClearStyle(nsCOMPtr<nsINode>* aNode, int32_t* aOffset,
-                         nsIAtom* aProperty, const nsAString* aAttribute)
+HTMLEditor::ClearStyle(nsCOMPtr<nsINode>* aNode,
+                       int32_t* aOffset,
+                       nsIAtom* aProperty,
+                       const nsAString* aAttribute)
 {
   nsCOMPtr<nsIContent> leftNode, rightNode;
   nsresult res = SplitStyleAbovePoint(aNode, aOffset, aProperty,
                                       aAttribute, getter_AddRefs(leftNode),
                                       getter_AddRefs(rightNode));
   NS_ENSURE_SUCCESS(res, res);
 
   if (leftNode) {
@@ -678,41 +680,42 @@ nsHTMLEditor::ClearStyle(nsCOMPtr<nsINod
     *aNode = newSelParent;
     *aOffset = newSelOffset;
   }
 
   return NS_OK;
 }
 
 bool
-nsHTMLEditor::NodeIsProperty(nsINode& aNode)
+HTMLEditor::NodeIsProperty(nsINode& aNode)
 {
   return IsContainer(&aNode) && IsEditable(&aNode) && !IsBlockNode(&aNode) &&
          !aNode.IsHTMLElement(nsGkAtoms::a);
 }
 
-nsresult nsHTMLEditor::ApplyDefaultProperties()
+nsresult
+HTMLEditor::ApplyDefaultProperties()
 {
   nsresult res = NS_OK;
   uint32_t j, defcon = mDefaultStyles.Length();
   for (j=0; j<defcon; j++)
   {
     PropItem *propItem = mDefaultStyles[j];
     NS_ENSURE_TRUE(propItem, NS_ERROR_NULL_POINTER);
     res = SetInlineProperty(propItem->tag, propItem->attr, propItem->value);
     NS_ENSURE_SUCCESS(res, res);
   }
   return res;
 }
 
 nsresult
-nsHTMLEditor::RemoveStyleInside(nsIContent& aNode,
-                                nsIAtom* aProperty,
-                                const nsAString* aAttribute,
-                                const bool aChildrenOnly /* = false */)
+HTMLEditor::RemoveStyleInside(nsIContent& aNode,
+                              nsIAtom* aProperty,
+                              const nsAString* aAttribute,
+                              const bool aChildrenOnly /* = false */)
 {
   if (aNode.GetAsText()) {
     return NS_OK;
   }
 
   // first process the children
   RefPtr<nsIContent> child = aNode.GetFirstChild();
   while (child) {
@@ -810,18 +813,18 @@ nsHTMLEditor::RemoveStyleInside(nsIConte
   ) {
     // if we are setting font size, remove any nested bigs and smalls
     return RemoveContainer(&aNode);
   }
   return NS_OK;
 }
 
 bool
-nsHTMLEditor::IsOnlyAttribute(const nsIContent* aContent,
-                              const nsAString& aAttribute)
+HTMLEditor::IsOnlyAttribute(const nsIContent* aContent,
+                            const nsAString& aAttribute)
 {
   MOZ_ASSERT(aContent);
 
   uint32_t attrCount = aContent->GetAttrCount();
   for (uint32_t i = 0; i < attrCount; ++i) {
     const nsAttrName* name = aContent->GetAttrNameAt(i);
     if (!name->NamespaceEquals(kNameSpaceID_None)) {
       return false;
@@ -837,17 +840,17 @@ nsHTMLEditor::IsOnlyAttribute(const nsIC
     }
   }
   // if we made it through all of them without finding a real attribute
   // other than aAttribute, then return true
   return true;
 }
 
 nsresult
-nsHTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange& aRange)
+HTMLEditor::PromoteRangeIfStartsOrEndsInNamedAnchor(nsRange& aRange)
 {
   // We assume that <a> is not nested.
   nsCOMPtr<nsINode> startNode = aRange.GetStartParent();
   int32_t startOffset = aRange.StartOffset();
   nsCOMPtr<nsINode> endNode = aRange.GetEndParent();
   int32_t endOffset = aRange.EndOffset();
 
   nsCOMPtr<nsINode> parent = startNode;
@@ -879,17 +882,17 @@ nsHTMLEditor::PromoteRangeIfStartsOrEnds
   NS_ENSURE_SUCCESS(res, res);
   res = aRange.SetEnd(endNode, endOffset);
   NS_ENSURE_SUCCESS(res, res);
 
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::PromoteInlineRange(nsRange& aRange)
+HTMLEditor::PromoteInlineRange(nsRange& aRange)
 {
   nsCOMPtr<nsINode> startNode = aRange.GetStartParent();
   int32_t startOffset = aRange.StartOffset();
   nsCOMPtr<nsINode> endNode = aRange.GetEndParent();
   int32_t endOffset = aRange.EndOffset();
 
   while (startNode && !startNode->IsHTMLElement(nsGkAtoms::body) &&
          IsEditable(startNode) && IsAtFrontOfNode(*startNode, startOffset)) {
@@ -912,17 +915,18 @@ nsHTMLEditor::PromoteInlineRange(nsRange
   NS_ENSURE_SUCCESS(res, res);
   res = aRange.SetEnd(endNode, endOffset);
   NS_ENSURE_SUCCESS(res, res);
 
   return NS_OK;
 }
 
 bool
-nsHTMLEditor::IsAtFrontOfNode(nsINode& aNode, int32_t aOffset)
+HTMLEditor::IsAtFrontOfNode(nsINode& aNode,
+                            int32_t aOffset)
 {
   if (!aOffset) {
     return true;
   }
 
   if (IsTextNode(&aNode)) {
     return false;
   }
@@ -931,17 +935,18 @@ nsHTMLEditor::IsAtFrontOfNode(nsINode& a
   NS_ENSURE_TRUE(firstNode, true);
   if (aNode.IndexOf(firstNode) < aOffset) {
     return false;
   }
   return true;
 }
 
 bool
-nsHTMLEditor::IsAtEndOfNode(nsINode& aNode, int32_t aOffset)
+HTMLEditor::IsAtEndOfNode(nsINode& aNode,
+                          int32_t aOffset)
 {
   if (aOffset == (int32_t)aNode.Length()) {
     return true;
   }
 
   if (IsTextNode(&aNode)) {
     return false;
   }
@@ -951,24 +956,24 @@ nsHTMLEditor::IsAtEndOfNode(nsINode& aNo
   if (aNode.IndexOf(lastNode) < aOffset) {
     return true;
   }
   return false;
 }
 
 
 nsresult
-nsHTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
-                                    const nsAString* aAttribute,
-                                    const nsAString* aValue,
-                                    bool* aFirst,
-                                    bool* aAny,
-                                    bool* aAll,
-                                    nsAString* outValue,
-                                    bool aCheckDefaults)
+HTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
+                                  const nsAString* aAttribute,
+                                  const nsAString* aValue,
+                                  bool* aFirst,
+                                  bool* aAny,
+                                  bool* aAll,
+                                  nsAString* outValue,
+                                  bool aCheckDefaults)
 {
   *aAny = false;
   *aAll = true;
   *aFirst = false;
   bool first = true;
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
@@ -1124,73 +1129,75 @@ nsHTMLEditor::GetInlinePropertyBase(nsIA
   if (!*aAny) {
     // make sure that if none of the selection is set, we don't report all is
     // set
     *aAll = false;
   }
   return NS_OK;
 }
 
-
-NS_IMETHODIMP nsHTMLEditor::GetInlineProperty(nsIAtom *aProperty,
-                                              const nsAString &aAttribute,
-                                              const nsAString &aValue,
-                                              bool *aFirst,
-                                              bool *aAny,
-                                              bool *aAll)
+NS_IMETHODIMP
+HTMLEditor::GetInlineProperty(nsIAtom* aProperty,
+                              const nsAString& aAttribute,
+                              const nsAString& aValue,
+                              bool* aFirst,
+                              bool* aAny,
+                              bool* aAll)
 {
   NS_ENSURE_TRUE(aProperty && aFirst && aAny && aAll, NS_ERROR_NULL_POINTER);
   const nsAString *att = nullptr;
   if (!aAttribute.IsEmpty())
     att = &aAttribute;
   const nsAString *val = nullptr;
   if (!aValue.IsEmpty())
     val = &aValue;
   return GetInlinePropertyBase(*aProperty, att, val, aFirst, aAny, aAll, nullptr);
 }
 
-
-NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty,
-                                              const nsAString &aAttribute,
-                                              const nsAString &aValue,
-                                              bool *aFirst,
-                                              bool *aAny,
-                                              bool *aAll,
-                                              nsAString &outValue)
+NS_IMETHODIMP
+HTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom* aProperty,
+                                           const nsAString& aAttribute,
+                                           const nsAString& aValue,
+                                           bool* aFirst,
+                                           bool* aAny,
+                                           bool* aAll,
+                                           nsAString& outValue)
 {
   NS_ENSURE_TRUE(aProperty && aFirst && aAny && aAll, NS_ERROR_NULL_POINTER);
   const nsAString *att = nullptr;
   if (!aAttribute.IsEmpty())
     att = &aAttribute;
   const nsAString *val = nullptr;
   if (!aValue.IsEmpty())
     val = &aValue;
   return GetInlinePropertyBase(*aProperty, att, val, aFirst, aAny, aAll, &outValue);
 }
 
-
-NS_IMETHODIMP nsHTMLEditor::RemoveAllInlineProperties()
+NS_IMETHODIMP
+HTMLEditor::RemoveAllInlineProperties()
 {
   AutoEditBatch batchIt(this);
   AutoRules beginRulesSniffing(this, EditAction::resetTextProperties,
                                nsIEditor::eNext);
 
   nsresult res = RemoveInlinePropertyImpl(nullptr, nullptr);
   NS_ENSURE_SUCCESS(res, res);
   return ApplyDefaultProperties();
 }
 
-NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsAString &aAttribute)
+NS_IMETHODIMP
+HTMLEditor::RemoveInlineProperty(nsIAtom* aProperty,
+                                 const nsAString& aAttribute)
 {
   return RemoveInlinePropertyImpl(aProperty, &aAttribute);
 }
 
 nsresult
-nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty,
-                                       const nsAString* aAttribute)
+HTMLEditor::RemoveInlinePropertyImpl(nsIAtom* aProperty,
+                                     const nsAString* aAttribute)
 {
   MOZ_ASSERT_IF(aProperty, aAttribute);
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
   ForceCompositionEnd();
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
 
@@ -1312,28 +1319,30 @@ nsHTMLEditor::RemoveInlinePropertyImpl(n
   if (!cancel) {
     // Post-process
     res = mRules->DidDoAction(selection, &ruleInfo, res);
     NS_ENSURE_SUCCESS(res, res);
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsHTMLEditor::IncreaseFontSize()
+NS_IMETHODIMP
+HTMLEditor::IncreaseFontSize()
 {
   return RelativeFontChange(FontSize::incr);
 }
 
-NS_IMETHODIMP nsHTMLEditor::DecreaseFontSize()
+NS_IMETHODIMP
+HTMLEditor::DecreaseFontSize()
 {
   return RelativeFontChange(FontSize::decr);
 }
 
 nsresult
-nsHTMLEditor::RelativeFontChange(FontSize aDir)
+HTMLEditor::RelativeFontChange(FontSize aDir)
 {
   ForceCompositionEnd();
 
   // Get the selection
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
   // If selection is collapsed, set typing state
   if (selection->Collapsed()) {
@@ -1433,20 +1442,20 @@ nsHTMLEditor::RelativeFontChange(FontSiz
       }
     }
   }
 
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::RelativeFontChangeOnTextNode(FontSize aDir,
-                                           Text& aTextNode,
-                                           int32_t aStartOffset,
-                                           int32_t aEndOffset)
+HTMLEditor::RelativeFontChangeOnTextNode(FontSize aDir,
+                                         Text& aTextNode,
+                                         int32_t aStartOffset,
+                                         int32_t aEndOffset)
 {
   // Don't need to do anything if no characters actually selected
   if (aStartOffset == aEndOffset) {
     return NS_OK;
   }
 
   if (!aTextNode.GetParentNode() ||
       !CanContainTag(*aTextNode.GetParentNode(), *nsGkAtoms::big)) {
@@ -1494,19 +1503,19 @@ nsHTMLEditor::RelativeFontChangeOnTextNo
 
   // Else reparent the node inside font node with appropriate relative size
   nsCOMPtr<Element> newElement = InsertContainerAbove(node, nodeType);
   NS_ENSURE_STATE(newElement);
 
   return NS_OK;
 }
 
-
 nsresult
-nsHTMLEditor::RelativeFontChangeHelper(int32_t aSizeChange, nsINode* aNode)
+HTMLEditor::RelativeFontChangeHelper(int32_t aSizeChange,
+                                     nsINode* aNode)
 {
   MOZ_ASSERT(aNode);
 
   /*  This routine looks for all the font nodes in the tree rooted by aNode,
       including aNode itself, looking for font nodes that have the size attr
       set.  Any such nodes need to have big or small put inside them, since
       they override any big/small that are above them.
   */
@@ -1534,19 +1543,19 @@ nsHTMLEditor::RelativeFontChangeHelper(i
   for (uint32_t i = aNode->GetChildCount(); i--; ) {
     nsresult rv = RelativeFontChangeHelper(aSizeChange, aNode->GetChildAt(i));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
 
-
 nsresult
-nsHTMLEditor::RelativeFontChangeOnNode(int32_t aSizeChange, nsIContent* aNode)
+HTMLEditor::RelativeFontChangeOnNode(int32_t aSizeChange,
+                                     nsIContent* aNode)
 {
   MOZ_ASSERT(aNode);
   // Can only change font size by + or - 1
   if (aSizeChange != 1 && aSizeChange != -1) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
 
   nsIAtom* atom;
@@ -1602,17 +1611,18 @@ nsHTMLEditor::RelativeFontChangeOnNode(i
     nsresult rv = RelativeFontChangeOnNode(aSizeChange, aNode->GetChildAt(i));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetFontFaceState(bool *aMixed, nsAString &outFace)
+HTMLEditor::GetFontFaceState(bool* aMixed,
+                             nsAString& outFace)
 {
   NS_ENSURE_TRUE(aMixed, NS_ERROR_FAILURE);
   *aMixed = true;
   outFace.Truncate();
 
   nsresult res;
   bool first, any, all;
 
@@ -1643,17 +1653,18 @@ nsHTMLEditor::GetFontFaceState(bool *aMi
     // there was no font face attrs of any kind.  We are in normal font.
     outFace.Truncate();
     *aMixed = false;
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetFontColorState(bool *aMixed, nsAString &aOutColor)
+HTMLEditor::GetFontColorState(bool* aMixed,
+                              nsAString& aOutColor)
 {
   NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
   *aMixed = true;
   aOutColor.Truncate();
 
   nsresult res;
   NS_NAMED_LITERAL_STRING(colorStr, "color");
   bool first, any, all;
@@ -1676,47 +1687,50 @@ nsHTMLEditor::GetFontColorState(bool *aM
   }
   return res;
 }
 
 // the return value is true only if the instance of the HTML editor we created
 // can handle CSS styles (for instance, Composer can, Messenger can't) and if
 // the CSS preference is checked
 nsresult
-nsHTMLEditor::GetIsCSSEnabled(bool *aIsCSSEnabled)
+HTMLEditor::GetIsCSSEnabled(bool* aIsCSSEnabled)
 {
   *aIsCSSEnabled = IsCSSEnabled();
   return NS_OK;
 }
 
 static bool
-HasNonEmptyAttribute(dom::Element* aElement, nsIAtom* aName)
+HasNonEmptyAttribute(Element* aElement,
+                     nsIAtom* aName)
 {
   MOZ_ASSERT(aElement);
 
   nsAutoString value;
   return aElement->GetAttr(kNameSpaceID_None, aName, value) && !value.IsEmpty();
 }
 
 bool
-nsHTMLEditor::HasStyleOrIdOrClass(dom::Element* aElement)
+HTMLEditor::HasStyleOrIdOrClass(Element* aElement)
 {
   MOZ_ASSERT(aElement);
 
   // remove the node if its style attribute is empty or absent,
   // and if it does not have a class nor an id
   return HasNonEmptyAttribute(aElement, nsGkAtoms::style) ||
          HasNonEmptyAttribute(aElement, nsGkAtoms::_class) ||
          HasNonEmptyAttribute(aElement, nsGkAtoms::id);
 }
 
 nsresult
-nsHTMLEditor::RemoveElementIfNoStyleOrIdOrClass(dom::Element& aElement)
+HTMLEditor::RemoveElementIfNoStyleOrIdOrClass(Element& aElement)
 {
   // early way out if node is not the right kind of element
   if ((!aElement.IsHTMLElement(nsGkAtoms::span) &&
        !aElement.IsHTMLElement(nsGkAtoms::font)) ||
       HasStyleOrIdOrClass(&aElement)) {
     return NS_OK;
   }
 
   return RemoveContainer(&aElement);
 }
+
+} // namespace mozilla
rename from editor/libeditor/nsTableEditor.cpp
rename to editor/libeditor/HTMLTableEditor.cpp
--- a/editor/libeditor/nsTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -1,90 +1,104 @@
 /* -*- 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 <stdio.h>
 
+#include "mozilla/HTMLEditor.h"
+
 #include "EditorUtils.h"
 #include "HTMLEditUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/Element.h"
 #include "nsAString.h"
 #include "nsAlgorithm.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsEditor.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
-#include "nsHTMLEditor.h"
 #include "nsIAtom.h"
 #include "nsIContent.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNode.h"
 #include "nsIEditor.h"
 #include "nsIFrame.h"
-#include "nsIHTMLEditor.h"
 #include "nsINode.h"
 #include "nsIPresShell.h"
 #include "nsISupportsUtils.h"
 #include "nsITableCellLayout.h" // For efficient access to table cell
 #include "nsITableEditor.h"
 #include "nsLiteralString.h"
 #include "nsQueryFrame.h"
 #include "nsRange.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsTableCellFrame.h"
 #include "nsTableWrapperFrame.h"
 #include "nscore.h"
 #include <algorithm>
 
-using namespace mozilla;
-using namespace mozilla::dom;
-
-/***************************************************************************
- * stack based helper class for restoring selection after table edit
+namespace mozilla {
+
+using namespace dom;
+
+/**
+ * Stack based helper class for restoring selection after table edit.
  */
-class MOZ_STACK_CLASS nsSetSelectionAfterTableEdit
+class MOZ_STACK_CLASS AutoSelectionSetterAfterTableEdit final
 {
-  private:
-    nsCOMPtr<nsITableEditor> mEd;
-    nsCOMPtr<nsIDOMElement> mTable;
-    int32_t mCol, mRow, mDirection, mSelected;
-  public:
-    nsSetSelectionAfterTableEdit(nsITableEditor *aEd, nsIDOMElement* aTable,
-                                 int32_t aRow, int32_t aCol, int32_t aDirection,
-                                 bool aSelected) :
-        mEd(do_QueryInterface(aEd))
-    {
-      mTable = aTable;
-      mRow = aRow;
-      mCol = aCol;
-      mDirection = aDirection;
-      mSelected = aSelected;
+private:
+  nsCOMPtr<nsITableEditor> mTableEditor;
+  nsCOMPtr<nsIDOMElement> mTable;
+  int32_t mCol, mRow, mDirection, mSelected;
+
+public:
+  AutoSelectionSetterAfterTableEdit(nsITableEditor* aTableEditor,
+                                    nsIDOMElement* aTable,
+                                    int32_t aRow,
+                                    int32_t aCol,
+                                    int32_t aDirection,
+                                    bool aSelected)
+    : mTableEditor(aTableEditor)
+    , mTable(aTable)
+    , mCol(aCol)
+    , mRow(aRow)
+    , mDirection(aDirection)
+    , mSelected(aSelected)
+  {
+  }
+
+  ~AutoSelectionSetterAfterTableEdit()
+  {
+    if (mTableEditor) {
+      mTableEditor->SetSelectionAfterTableEdit(mTable, mRow, mCol, mDirection,
+                                               mSelected);
     }
-
-    ~nsSetSelectionAfterTableEdit()
-    {
-      if (mEd)
-        mEd->SetSelectionAfterTableEdit(mTable, mRow, mCol, mDirection, mSelected);
-    }
-    // This is needed to abort the caret reset in the destructor
-    //  when one method yields control to another
-    void CancelSetCaret() {mEd = nullptr; mTable = nullptr;}
+  }
+
+  // This is needed to abort the caret reset in the destructor
+  //  when one method yields control to another
+  void CancelSetCaret()
+  {
+    mTableEditor = nullptr;
+    mTable = nullptr;
+  }
 };
 
-// Table Editing helper utilities (not exposed in IDL)
-
 NS_IMETHODIMP
-nsHTMLEditor::InsertCell(nsIDOMElement *aCell, int32_t aRowSpan, int32_t aColSpan,
-                         bool aAfter, bool aIsHeader, nsIDOMElement **aNewCell)
+HTMLEditor::InsertCell(nsIDOMElement* aCell,
+                       int32_t aRowSpan,
+                       int32_t aColSpan,
+                       bool aAfter,
+                       bool aIsHeader,
+                       nsIDOMElement** aNewCell)
 {
   NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
   if (aNewCell) *aNewCell = nullptr;
 
   // And the parent and offsets needed to do an insert
   nsCOMPtr<nsIDOMNode> cellParent;
   nsresult res = aCell->GetParentNode(getter_AddRefs(cellParent));
   NS_ENSURE_SUCCESS(res, res);
@@ -124,38 +138,39 @@ nsHTMLEditor::InsertCell(nsIDOMElement *
   }
   if(aAfter) cellOffset++;
 
   //Don't let Rules System change the selection
   AutoTransactionsConserveSelection dontChangeSelection(this);
   return InsertNode(newCell, cellParent, cellOffset);
 }
 
-NS_IMETHODIMP nsHTMLEditor::SetColSpan(nsIDOMElement *aCell, int32_t aColSpan)
+NS_IMETHODIMP
+HTMLEditor::SetColSpan(nsIDOMElement* aCell,
+                       int32_t aColSpan)
 {
   NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
   nsAutoString newSpan;
   newSpan.AppendInt(aColSpan, 10);
   return SetAttribute(aCell, NS_LITERAL_STRING("colspan"), newSpan);
 }
 
-NS_IMETHODIMP nsHTMLEditor::SetRowSpan(nsIDOMElement *aCell, int32_t aRowSpan)
+NS_IMETHODIMP
+HTMLEditor::SetRowSpan(nsIDOMElement* aCell,
+                       int32_t aRowSpan)
 {
   NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
   nsAutoString newSpan;
   newSpan.AppendInt(aRowSpan, 10);
   return SetAttribute(aCell, NS_LITERAL_STRING("rowspan"), newSpan);
 }
 
-/****************************************************************/
-
-// Table Editing interface methods
-
 NS_IMETHODIMP
-nsHTMLEditor::InsertTableCell(int32_t aNumber, bool aAfter)
+HTMLEditor::InsertTableCell(int32_t aNumber,
+                            bool aAfter)
 {
   nsCOMPtr<nsIDOMElement> table;
   nsCOMPtr<nsIDOMElement> curCell;
   nsCOMPtr<nsIDOMNode> cellParent;
   int32_t cellOffset, startRowIndex, startColIndex;
   nsresult res = GetCellContext(nullptr,
                                 getter_AddRefs(table),
                                 getter_AddRefs(curCell),
@@ -171,17 +186,19 @@ nsHTMLEditor::InsertTableCell(int32_t aN
   res = GetCellDataAt(table, startRowIndex, startColIndex,
                       getter_AddRefs(curCell),
                       &curStartRowIndex, &curStartColIndex, &rowSpan, &colSpan,
                       &actualRowSpan, &actualColSpan, &isSelected);
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_TRUE(curCell, NS_ERROR_FAILURE);
   int32_t newCellIndex = aAfter ? (startColIndex+colSpan) : startColIndex;
   //We control selection resetting after the insert...
-  nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, newCellIndex, ePreviousColumn, false);
+  AutoSelectionSetterAfterTableEdit setCaret(this, table, startRowIndex,
+                                             newCellIndex, ePreviousColumn,
+                                             false);
   //...so suppress Rules System selection munging
   AutoTransactionsConserveSelection dontChangeSelection(this);
 
   int32_t i;
   for (i = 0; i < aNumber; i++)
   {
     nsCOMPtr<nsIDOMElement> newCell;
     res = CreateElementWithDefaults(NS_LITERAL_STRING("td"), getter_AddRefs(newCell));
@@ -190,19 +207,19 @@ nsHTMLEditor::InsertTableCell(int32_t aN
       if (aAfter) cellOffset++;
       res = InsertNode(newCell, cellParent, cellOffset);
       if(NS_FAILED(res)) break;
     }
   }
   return res;
 }
 
-
 NS_IMETHODIMP
-nsHTMLEditor::GetFirstRow(nsIDOMElement* aTableElement, nsIDOMNode** aRowNode)
+HTMLEditor::GetFirstRow(nsIDOMElement* aTableElement,
+                        nsIDOMNode** aRowNode)
 {
   NS_ENSURE_TRUE(aRowNode, NS_ERROR_NULL_POINTER);
 
   *aRowNode = nullptr;
 
   NS_ENSURE_TRUE(aTableElement, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIDOMElement> tableElement;
@@ -259,17 +276,18 @@ nsHTMLEditor::GetFirstRow(nsIDOMElement*
 
     tableChild = nextChild;
   }
   // If here, row was not found
   return NS_EDITOR_ELEMENT_NOT_FOUND;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetNextRow(nsIDOMNode* aCurrentRowNode, nsIDOMNode **aRowNode)
+HTMLEditor::GetNextRow(nsIDOMNode* aCurrentRowNode,
+                       nsIDOMNode** aRowNode)
 {
   NS_ENSURE_TRUE(aRowNode, NS_ERROR_NULL_POINTER);
 
   *aRowNode = nullptr;
 
   NS_ENSURE_TRUE(aCurrentRowNode, NS_ERROR_NULL_POINTER);
 
   if (!HTMLEditUtils::IsTableRow(aCurrentRowNode)) {
@@ -333,17 +351,18 @@ nsHTMLEditor::GetNextRow(nsIDOMNode* aCu
 
     parentSibling = nextNode;
   }
   // If here, row was not found
   return NS_EDITOR_ELEMENT_NOT_FOUND;
 }
 
 nsresult
-nsHTMLEditor::GetLastCellInRow(nsIDOMNode* aRowNode, nsIDOMNode** aCellNode)
+HTMLEditor::GetLastCellInRow(nsIDOMNode* aRowNode,
+                             nsIDOMNode** aCellNode)
 {
   NS_ENSURE_TRUE(aCellNode, NS_ERROR_NULL_POINTER);
 
   *aCellNode = nullptr;
 
   NS_ENSURE_TRUE(aRowNode, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIDOMNode> rowChild;
@@ -364,17 +383,18 @@ nsHTMLEditor::GetLastCellInRow(nsIDOMNod
     NS_ADDREF(*aCellNode);
     return NS_OK;
   }
   // If here, cell was not found
   return NS_EDITOR_ELEMENT_NOT_FOUND;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::InsertTableColumn(int32_t aNumber, bool aAfter)
+HTMLEditor::InsertTableColumn(int32_t aNumber,
+                              bool aAfter)
 {
   RefPtr<Selection> selection;
   nsCOMPtr<nsIDOMElement> table;
   nsCOMPtr<nsIDOMElement> curCell;
   int32_t startRowIndex, startColIndex;
   nsresult res = GetCellContext(getter_AddRefs(selection),
                                 getter_AddRefs(table),
                                 getter_AddRefs(curCell),
@@ -411,17 +431,19 @@ nsHTMLEditor::InsertTableColumn(int32_t 
       SetColSpan(curCell, actualColSpan);
   }
 
   int32_t rowCount, colCount, rowIndex;
   res = GetTableSize(table, &rowCount, &colCount);
   NS_ENSURE_SUCCESS(res, res);
 
   //We reset caret in destructor...
-  nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousRow, false);
+  AutoSelectionSetterAfterTableEdit setCaret(this, table, startRowIndex,
+                                             startColIndex, ePreviousRow,
+                                             false);
   //.. so suppress Rules System selection munging
   AutoTransactionsConserveSelection dontChangeSelection(this);
 
   // If we are inserting after all existing columns
   // Make sure table is "well formed"
   //  before appending new column
   if (startColIndex >= colCount)
     NormalizeTable(table);
@@ -491,17 +513,18 @@ nsHTMLEditor::InsertTableColumn(int32_t 
         }
       }
     }
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::InsertTableRow(int32_t aNumber, bool aAfter)
+HTMLEditor::InsertTableRow(int32_t aNumber,
+                           bool aAfter)
 {
   RefPtr<Selection> selection;
   nsCOMPtr<nsIDOMElement> table;
   nsCOMPtr<nsIDOMElement> curCell;
 
   int32_t startRowIndex, startColIndex;
   nsresult res = GetCellContext(nullptr,
                                 getter_AddRefs(table),
@@ -540,17 +563,19 @@ nsHTMLEditor::InsertTableRow(int32_t aNu
     // Assume they want to stop the "0" behavior and
     // really add a new row. Thus we set the
     // rowspan to its true value
     if (rowSpan == 0)
       SetRowSpan(curCell, actualRowSpan);
   }
 
   //We control selection resetting after the insert...
-  nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousColumn, false);
+  AutoSelectionSetterAfterTableEdit setCaret(this, table, startRowIndex,
+                                             startColIndex, ePreviousColumn,
+                                             false);
   //...so suppress Rules System selection munging
   AutoTransactionsConserveSelection dontChangeSelection(this);
 
   nsCOMPtr<nsIDOMElement> cellForRowParent;
   int32_t cellsInRow = 0;
   if (startRowIndex < rowCount)
   {
     // We are inserting above an existing row
@@ -676,46 +701,47 @@ nsHTMLEditor::InsertTableRow(int32_t aNu
   }
   return res;
 }
 
 // Editor helper only
 // XXX Code changed for bug 217717 and now we don't need aSelection param
 //     TODO: Remove aSelection param
 nsresult
-nsHTMLEditor::DeleteTable2(nsIDOMElement* aTable, Selection* aSelection)
+HTMLEditor::DeleteTable2(nsIDOMElement* aTable,
+                         Selection* aSelection)
 {
   NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
 
   // Select the table
   nsresult res = ClearSelection();
   if (NS_SUCCEEDED(res))
     res = AppendNodeToSelectionAsRange(aTable);
   NS_ENSURE_SUCCESS(res, res);
 
   return DeleteSelection(nsIEditor::eNext, nsIEditor::eStrip);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DeleteTable()
+HTMLEditor::DeleteTable()
 {
   RefPtr<Selection> selection;
   nsCOMPtr<nsIDOMElement> table;
   nsresult res = GetCellContext(getter_AddRefs(selection),
                                 getter_AddRefs(table),
                                 nullptr, nullptr, nullptr, nullptr, nullptr);
 
   NS_ENSURE_SUCCESS(res, res);
 
   AutoEditBatch beginBatching(this);
   return DeleteTable2(table, selection);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DeleteTableCell(int32_t aNumber)
+HTMLEditor::DeleteTableCell(int32_t aNumber)
 {
   RefPtr<Selection> selection;
   nsCOMPtr<nsIDOMElement> table;
   nsCOMPtr<nsIDOMElement> cell;
   int32_t startRowIndex, startColIndex;
 
 
   nsresult res = GetCellContext(getter_AddRefs(selection),
@@ -750,18 +776,21 @@ nsHTMLEditor::DeleteTableCell(int32_t aN
     int32_t rowCount, colCount;
     res = GetTableSize(table, &rowCount, &colCount);
     NS_ENSURE_SUCCESS(res, res);
 
     // Get indexes -- may be different than original cell
     res = GetCellIndexes(cell, &startRowIndex, &startColIndex);
     NS_ENSURE_SUCCESS(res, res);
 
-    // The setCaret object will call SetSelectionAfterTableEdit in its destructor
-    nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousColumn, false);
+    // The setCaret object will call AutoSelectionSetterAfterTableEdit in its
+    // destructor
+    AutoSelectionSetterAfterTableEdit setCaret(this, table, startRowIndex,
+                                               startColIndex, ePreviousColumn,
+                                               false);
     AutoTransactionsConserveSelection dontChangeSelection(this);
 
     bool    checkToDeleteRow = true;
     bool    checkToDeleteColumn = true;
     while (cell)
     {
       bool deleteRow = false;
       bool deleteCol = false;
@@ -886,30 +915,33 @@ nsHTMLEditor::DeleteTableCell(int32_t aN
       // We need to call DeleteTableRow to handle cells with rowspan
       res = DeleteTableRow(1);
       NS_ENSURE_SUCCESS(res, res);
     }
     else
     {
       // More than 1 cell in the row
 
-      // The setCaret object will call SetSelectionAfterTableEdit in its destructor
-      nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousColumn, false);
+      // The setCaret object will call AutoSelectionSetterAfterTableEdit in its
+      // destructor
+      AutoSelectionSetterAfterTableEdit setCaret(this, table, startRowIndex,
+                                                 startColIndex, ePreviousColumn,
+                                                 false);
       AutoTransactionsConserveSelection dontChangeSelection(this);
 
       res = DeleteNode(cell);
       // If we fail, don't try to delete any more cells???
       NS_ENSURE_SUCCESS(res, res);
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DeleteTableCellContents()
+HTMLEditor::DeleteTableCellContents()
 {
   RefPtr<Selection> selection;
   nsCOMPtr<nsIDOMElement> table;
   nsCOMPtr<nsIDOMElement> cell;
   int32_t startRowIndex, startColIndex;
   nsresult res;
   res = GetCellContext(getter_AddRefs(selection),
                        getter_AddRefs(table),
@@ -936,17 +968,19 @@ nsHTMLEditor::DeleteTableCellContents()
 
   if (firstCell)
   {
     cell = firstCell;
     res = GetCellIndexes(cell, &startRowIndex, &startColIndex);
     NS_ENSURE_SUCCESS(res, res);
   }
 
-  nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousColumn, false);
+  AutoSelectionSetterAfterTableEdit setCaret(this, table, startRowIndex,
+                                             startColIndex, ePreviousColumn,
+                                             false);
 
   while (cell)
   {
     DeleteCellContents(cell);
     if (firstCell)
     {
       // We doing a selected cells, so do all of them
       res = GetNextSelectedCell(nullptr, getter_AddRefs(cell));
@@ -954,17 +988,17 @@ nsHTMLEditor::DeleteTableCellContents()
     }
     else
       cell = nullptr;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DeleteCellContents(nsIDOMElement *aCell)
+HTMLEditor::DeleteCellContents(nsIDOMElement* aCell)
 {
   NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
 
   // Prevent rules testing until we're done
   AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
 
   nsCOMPtr<nsIDOMNode> child;
   bool hasChild;
@@ -976,17 +1010,17 @@ nsHTMLEditor::DeleteCellContents(nsIDOME
     nsresult res = DeleteNode(child);
     NS_ENSURE_SUCCESS(res, res);
     aCell->HasChildNodes(&hasChild);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DeleteTableColumn(int32_t aNumber)
+HTMLEditor::DeleteTableColumn(int32_t aNumber)
 {
   RefPtr<Selection> selection;
   nsCOMPtr<nsIDOMElement> table;
   nsCOMPtr<nsIDOMElement> cell;
   int32_t startRowIndex, startColIndex, rowCount, colCount;
   nsresult res = GetCellContext(getter_AddRefs(selection),
                                 getter_AddRefs(table),
                                 getter_AddRefs(cell),
@@ -1022,17 +1056,19 @@ nsHTMLEditor::DeleteTableColumn(int32_t 
 
   if (firstCell && rangeCount > 1)
   {
     // Fetch indexes again - may be different for selected cells
     res = GetCellIndexes(firstCell, &startRowIndex, &startColIndex);
     NS_ENSURE_SUCCESS(res, res);
   }
   //We control selection resetting after the insert...
-  nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousRow, false);
+  AutoSelectionSetterAfterTableEdit setCaret(this, table, startRowIndex,
+                                             startColIndex, ePreviousRow,
+                                             false);
 
   if (firstCell && rangeCount > 1)
   {
     // Use selected cells to determine what rows to delete
     cell = firstCell;
 
     while (cell)
     {
@@ -1060,17 +1096,18 @@ nsHTMLEditor::DeleteTableColumn(int32_t 
   {
     res = DeleteColumn(table, startColIndex);
     NS_ENSURE_SUCCESS(res, res);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DeleteColumn(nsIDOMElement *aTable, int32_t aColIndex)
+HTMLEditor::DeleteColumn(nsIDOMElement* aTable,
+                         int32_t aColIndex)
 {
   NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIDOMElement> cell;
   nsCOMPtr<nsIDOMElement> cellInDeleteCol;
   int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool    isSelected;
   int32_t rowIndex = 0;
@@ -1152,17 +1189,17 @@ nsHTMLEditor::DeleteColumn(nsIDOMElement
       }
     }
   } while (cell);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::DeleteTableRow(int32_t aNumber)
+HTMLEditor::DeleteTableRow(int32_t aNumber)
 {
   RefPtr<Selection> selection;
   nsCOMPtr<nsIDOMElement> table;
   nsCOMPtr<nsIDOMElement> cell;
   int32_t startRowIndex, startColIndex;
   int32_t rowCount, colCount;
   nsresult res =  GetCellContext(getter_AddRefs(selection),
                                  getter_AddRefs(table),
@@ -1196,17 +1233,19 @@ nsHTMLEditor::DeleteTableRow(int32_t aNu
   if (firstCell && rangeCount > 1)
   {
     // Fetch indexes again - may be different for selected cells
     res = GetCellIndexes(firstCell, &startRowIndex, &startColIndex);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   //We control selection resetting after the insert...
-  nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousRow, false);
+  AutoSelectionSetterAfterTableEdit setCaret(this, table, startRowIndex,
+                                             startColIndex, ePreviousRow,
+                                             false);
   // Don't change selection during deletions
   AutoTransactionsConserveSelection dontChangeSelection(this);
 
   if (firstCell && rangeCount > 1)
   {
     // Use selected cells to determine what rows to delete
     cell = firstCell;
 
@@ -1252,17 +1291,18 @@ nsHTMLEditor::DeleteTableRow(int32_t aNu
         break;
     }
   }
   return NS_OK;
 }
 
 // Helper that doesn't batch or change the selection
 NS_IMETHODIMP
-nsHTMLEditor::DeleteRow(nsIDOMElement *aTable, int32_t aRowIndex)
+HTMLEditor::DeleteRow(nsIDOMElement* aTable,
+                      int32_t aRowIndex)
 {
   NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIDOMElement> cell;
   nsCOMPtr<nsIDOMElement> cellInDeleteRow;
   int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool    isSelected;
   int32_t colIndex = 0;
@@ -1356,49 +1396,50 @@ nsHTMLEditor::DeleteRow(nsIDOMElement *a
       NS_ENSURE_SUCCESS(res, res);
     }
   }
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsHTMLEditor::SelectTable()
+HTMLEditor::SelectTable()
 {
   nsCOMPtr<nsIDOMElement> table;
   nsresult res = NS_ERROR_FAILURE;
   res = GetElementOrParentByTagName(NS_LITERAL_STRING("table"), nullptr, getter_AddRefs(table));
   NS_ENSURE_SUCCESS(res, res);
   // Don't fail if we didn't find a table
   NS_ENSURE_TRUE(table, NS_OK);
 
   res = ClearSelection();
   if (NS_SUCCEEDED(res))
     res = AppendNodeToSelectionAsRange(table);
 
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SelectTableCell()
+HTMLEditor::SelectTableCell()
 {
   nsCOMPtr<nsIDOMElement> cell;
   nsresult res = GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr, getter_AddRefs(cell));
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_TRUE(cell, NS_EDITOR_ELEMENT_NOT_FOUND);
 
   res = ClearSelection();
   if (NS_SUCCEEDED(res))
     res = AppendNodeToSelectionAsRange(cell);
 
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndCell)
+HTMLEditor::SelectBlockOfCells(nsIDOMElement* aStartCell,
+                               nsIDOMElement* aEndCell)
 {
   NS_ENSURE_TRUE(aStartCell && aEndCell, NS_ERROR_NULL_POINTER);
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
   NS_NAMED_LITERAL_STRING(tableStr, "table");
   nsCOMPtr<nsIDOMElement> table;
@@ -1477,17 +1518,17 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOME
         if (NS_FAILED(res)) break;
       }
     }
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SelectAllTableCells()
+HTMLEditor::SelectAllTableCells()
 {
   nsCOMPtr<nsIDOMElement> cell;
   nsresult res = GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr, getter_AddRefs(cell));
   NS_ENSURE_SUCCESS(res, res);
 
   // Don't fail if we didn't find a cell
   NS_ENSURE_TRUE(cell, NS_EDITOR_ELEMENT_NOT_FOUND);
 
@@ -1540,17 +1581,17 @@ nsHTMLEditor::SelectAllTableCells()
   if (!cellSelected)
   {
     return AppendNodeToSelectionAsRange(startCell);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SelectTableRow()
+HTMLEditor::SelectTableRow()
 {
   nsCOMPtr<nsIDOMElement> cell;
   nsresult res = GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr, getter_AddRefs(cell));
   NS_ENSURE_SUCCESS(res, res);
 
   // Don't fail if we didn't find a cell
   NS_ENSURE_TRUE(cell, NS_EDITOR_ELEMENT_NOT_FOUND);
   nsCOMPtr<nsIDOMElement> startCell = cell;
@@ -1606,17 +1647,17 @@ nsHTMLEditor::SelectTableRow()
   if (!cellSelected)
   {
     return AppendNodeToSelectionAsRange(startCell);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SelectTableColumn()
+HTMLEditor::SelectTableColumn()
 {
   nsCOMPtr<nsIDOMElement> cell;
   nsresult res = GetElementOrParentByTagName(NS_LITERAL_STRING("td"), nullptr, getter_AddRefs(cell));
   NS_ENSURE_SUCCESS(res, res);
 
   // Don't fail if we didn't find a cell
   NS_ENSURE_TRUE(cell, NS_EDITOR_ELEMENT_NOT_FOUND);
 
@@ -1669,17 +1710,17 @@ nsHTMLEditor::SelectTableColumn()
   if (!cellSelected)
   {
     return AppendNodeToSelectionAsRange(startCell);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SplitTableCell()
+HTMLEditor::SplitTableCell()
 {
   nsCOMPtr<nsIDOMElement> table;
   nsCOMPtr<nsIDOMElement> cell;
   int32_t startRowIndex, startColIndex, actualRowSpan, actualColSpan;
   // Get cell, table, etc. at selection anchor node
   nsresult res = GetCellContext(nullptr,
                                 getter_AddRefs(table),
                                 getter_AddRefs(cell),
@@ -1696,17 +1737,19 @@ nsHTMLEditor::SplitTableCell()
   if (actualRowSpan <= 1 && actualColSpan <= 1)
     return NS_OK;
 
   AutoEditBatch beginBatching(this);
   // Prevent auto insertion of BR in new cell until we're done
   AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
 
   // We reset selection
-  nsSetSelectionAfterTableEdit setCaret(this, table, startRowIndex, startColIndex, ePreviousColumn, false);
+  AutoSelectionSetterAfterTableEdit setCaret(this, table, startRowIndex,
+                                             startColIndex, ePreviousColumn,
+                                             false);
   //...so suppress Rules System selection munging
   AutoTransactionsConserveSelection dontChangeSelection(this);
 
   nsCOMPtr<nsIDOMElement> newCell;
   int32_t rowIndex = startRowIndex;
   int32_t rowSpanBelow, colSpanAfter;
 
   // Split up cell row-wise first into rowspan=1 above, and the rest below,
@@ -1731,36 +1774,40 @@ nsHTMLEditor::SplitTableCell()
     }
     // Point to the new cell and repeat
     rowIndex++;
   }
   return res;
 }
 
 nsresult
-nsHTMLEditor::CopyCellBackgroundColor(nsIDOMElement *destCell, nsIDOMElement *sourceCell)
+HTMLEditor::CopyCellBackgroundColor(nsIDOMElement* destCell,
+                                    nsIDOMElement* sourceCell)
 {
   NS_ENSURE_TRUE(destCell && sourceCell, NS_ERROR_NULL_POINTER);
 
   // Copy backgournd color to new cell
   NS_NAMED_LITERAL_STRING(bgcolor, "bgcolor");
   nsAutoString color;
   bool isSet;
   nsresult res = GetAttributeValue(sourceCell, bgcolor, color, &isSet);
 
   if (NS_SUCCEEDED(res) && isSet)
     res = SetAttribute(destCell, bgcolor, color);
 
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SplitCellIntoColumns(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aColIndex,
-                                   int32_t aColSpanLeft, int32_t aColSpanRight,
-                                   nsIDOMElement **aNewCell)
+HTMLEditor::SplitCellIntoColumns(nsIDOMElement* aTable,
+                                 int32_t aRowIndex,
+                                 int32_t aColIndex,
+                                 int32_t aColSpanLeft,
+                                 int32_t aColSpanRight,
+                                 nsIDOMElement** aNewCell)
 {
   NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
   if (aNewCell) *aNewCell = nullptr;
 
   nsCOMPtr<nsIDOMElement> cell;
   int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool    isSelected;
   nsresult res = GetCellDataAt(aTable, aRowIndex, aColIndex, getter_AddRefs(cell),
@@ -1791,19 +1838,22 @@ nsHTMLEditor::SplitCellIntoColumns(nsIDO
       NS_ADDREF(*aNewCell);
     }
     res = CopyCellBackgroundColor(newCell, cell);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SplitCellIntoRows(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aColIndex,
-                                int32_t aRowSpanAbove, int32_t aRowSpanBelow,
-                                nsIDOMElement **aNewCell)
+HTMLEditor::SplitCellIntoRows(nsIDOMElement* aTable,
+                              int32_t aRowIndex,
+                              int32_t aColIndex,
+                              int32_t aRowSpanAbove,
+                              int32_t aRowSpanBelow,
+                              nsIDOMElement** aNewCell)
 {
   NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
   if (aNewCell) *aNewCell = nullptr;
 
   nsCOMPtr<nsIDOMElement> cell;
   int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool    isSelected;
   nsresult res = GetCellDataAt(aTable, aRowIndex, aColIndex, getter_AddRefs(cell),
@@ -1905,17 +1955,18 @@ nsHTMLEditor::SplitCellIntoRows(nsIDOMEl
       NS_ADDREF(*aNewCell);
     }
     res = CopyCellBackgroundColor(newCell, cell2);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell)
+HTMLEditor::SwitchTableCellHeaderType(nsIDOMElement* aSourceCell,
+                                      nsIDOMElement** aNewCell)
 {
   nsCOMPtr<Element> sourceCell = do_QueryInterface(aSourceCell);
   NS_ENSURE_TRUE(sourceCell, NS_ERROR_NULL_POINTER);
 
   AutoEditBatch beginBatching(this);
   // Prevent auto insertion of BR in new cell created by ReplaceContainer
   AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext);
 
@@ -1943,17 +1994,17 @@ nsHTMLEditor::SwitchTableCellHeaderType(
     *aNewCell = newElement.get();
     NS_ADDREF(*aNewCell);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
+HTMLEditor::JoinTableCells(bool aMergeNonContiguousContents)
 {
   nsCOMPtr<nsIDOMElement> table;
   nsCOMPtr<nsIDOMElement> targetCell;
   int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool    isSelected;
   nsCOMPtr<nsIDOMElement> cell2;
   int32_t startRowIndex2, startColIndex2, rowSpan2, colSpan2, actualRowSpan2, actualColSpan2;
   bool    isSelected2;
@@ -1966,17 +2017,17 @@ nsHTMLEditor::JoinTableCells(bool aMerge
                                 &startRowIndex, &startColIndex);
   NS_ENSURE_SUCCESS(res, res);
   if(!table || !targetCell) return NS_EDITOR_ELEMENT_NOT_FOUND;
 
   AutoEditBatch beginBatching(this);
   //Don't let Rules System change the selection
   AutoTransactionsConserveSelection dontChangeSelection(this);
 
-  // Note: We dont' use nsSetSelectionAfterTableEdit here so the selection
+  // Note: We dont' use AutoSelectionSetterAfterTableEdit here so the selection
   //  is retained after joining. This leaves the target cell selected
   //  as well as the "non-contiguous" cells, so user can see what happened.
 
   nsCOMPtr<nsIDOMElement> firstCell;
   int32_t firstRowIndex, firstColIndex;
   res = GetFirstSelectedCellInTable(&firstRowIndex, &firstColIndex, getter_AddRefs(firstCell));
   NS_ENSURE_SUCCESS(res, res);
 
@@ -2283,19 +2334,19 @@ nsHTMLEditor::JoinTableCells(bool aMerge
     // Reset target cell's colspan to encompass cell to the right
     res = SetColSpan(targetCell, actualColSpan+actualColSpan2);
     NS_ENSURE_SUCCESS(res, res);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell,
-                         nsCOMPtr<nsIDOMElement> aCellToMerge,
-                         bool aDeleteCellToMerge)
+HTMLEditor::MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell,
+                       nsCOMPtr<nsIDOMElement> aCellToMerge,
+                       bool aDeleteCellToMerge)
 {
   nsCOMPtr<dom::Element> targetCell = do_QueryInterface(aTargetCell);
   nsCOMPtr<dom::Element> cellToMerge = do_QueryInterface(aCellToMerge);
   NS_ENSURE_TRUE(targetCell && cellToMerge, NS_ERROR_NULL_POINTER);
 
   // Prevent rules testing until we're done
   AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
 
@@ -2333,17 +2384,19 @@ nsHTMLEditor::MergeCells(nsCOMPtr<nsIDOM
   if (aDeleteCellToMerge)
     return DeleteNode(aCellToMerge);
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsHTMLEditor::FixBadRowSpan(nsIDOMElement *aTable, int32_t aRowIndex, int32_t& aNewRowCount)
+HTMLEditor::FixBadRowSpan(nsIDOMElement* aTable,
+                          int32_t aRowIndex,
+                          int32_t& aNewRowCount)
 {
   NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
 
   int32_t rowCount, colCount;
   nsresult res = GetTableSize(aTable, &rowCount, &colCount);
   NS_ENSURE_SUCCESS(res, res);
 
   nsCOMPtr<nsIDOMElement>cell;
@@ -2391,17 +2444,19 @@ nsHTMLEditor::FixBadRowSpan(nsIDOMElemen
       }
       NS_ASSERTION((actualColSpan > 0),"ActualColSpan = 0 in FixBadRowSpan");
     }
   }
   return GetTableSize(aTable, &aNewRowCount, &colCount);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::FixBadColSpan(nsIDOMElement *aTable, int32_t aColIndex, int32_t& aNewColCount)
+HTMLEditor::FixBadColSpan(nsIDOMElement* aTable,
+                          int32_t aColIndex,
+                          int32_t& aNewColCount)
 {
   NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
 
   int32_t rowCount, colCount;
   nsresult res = GetTableSize(aTable, &rowCount, &colCount);
   NS_ENSURE_SUCCESS(res, res);
 
   nsCOMPtr<nsIDOMElement> cell;
@@ -2449,17 +2504,17 @@ nsHTMLEditor::FixBadColSpan(nsIDOMElemen
       }
       NS_ASSERTION((actualRowSpan > 0),"ActualRowSpan = 0 in FixBadColSpan");
     }
   }
   return GetTableSize(aTable, &rowCount, &aNewColCount);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::NormalizeTable(nsIDOMElement *aTable)
+HTMLEditor::NormalizeTable(nsIDOMElement* aTable)
 {
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDOMElement> table;
   nsresult res = GetElementOrParentByTagName(NS_LITERAL_STRING("table"),
                                              aTable, getter_AddRefs(table));
   NS_ENSURE_SUCCESS(res, res);
@@ -2537,18 +2592,19 @@ nsHTMLEditor::NormalizeTable(nsIDOMEleme
         previousCellInRow = cell;
       }
     }
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetCellIndexes(nsIDOMElement *aCell,
-                             int32_t *aRowIndex, int32_t *aColIndex)
+HTMLEditor::GetCellIndexes(nsIDOMElement* aCell,
+                           int32_t* aRowIndex,
+                           int32_t* aColIndex)
 {
   NS_ENSURE_ARG_POINTER(aRowIndex);
   *aColIndex=0; // initialize out params
   NS_ENSURE_ARG_POINTER(aColIndex);
   *aRowIndex=0;
   nsresult res=NS_ERROR_NOT_INITIALIZED;
   if (!aCell)
   {
@@ -2572,27 +2628,29 @@ nsHTMLEditor::GetCellIndexes(nsIDOMEleme
   NS_ENSURE_TRUE(layoutObject, NS_ERROR_FAILURE);
 
   nsITableCellLayout *cellLayoutObject = do_QueryFrame(layoutObject);
   NS_ENSURE_TRUE(cellLayoutObject, NS_ERROR_FAILURE);
   return cellLayoutObject->GetCellIndexes(*aRowIndex, *aColIndex);
 }
 
 nsTableWrapperFrame*
-nsHTMLEditor::GetTableFrame(nsIDOMElement* aTable)
+HTMLEditor::GetTableFrame(nsIDOMElement* aTable)
 {
   NS_ENSURE_TRUE(aTable, nullptr);
 
   nsCOMPtr<nsIContent> nodeAsContent( do_QueryInterface(aTable) );
   NS_ENSURE_TRUE(nodeAsContent, nullptr);
   return do_QueryFrame(nodeAsContent->GetPrimaryFrame());
 }
 
 //Return actual number of cells (a cell with colspan > 1 counts as just 1)
-int32_t nsHTMLEditor::GetNumberOfCellsInRow(nsIDOMElement* aTable, int32_t rowIndex)
+int32_t
+HTMLEditor::GetNumberOfCellsInRow(nsIDOMElement* aTable,
+                                  int32_t rowIndex)
 {
   int32_t cellCount = 0;
   nsCOMPtr<nsIDOMElement> cell;
   int32_t colIndex = 0;
   nsresult res;
   do {
     int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
     bool    isSelected;
@@ -2612,22 +2670,20 @@ int32_t nsHTMLEditor::GetNumberOfCellsIn
     else
       colIndex++;
 
   } while (cell);
 
   return cellCount;
 }
 
-/* Not scriptable: For convenience in C++
-   Use GetTableRowCount and GetTableColumnCount from JavaScript
-*/
 NS_IMETHODIMP
-nsHTMLEditor::GetTableSize(nsIDOMElement *aTable,
-                           int32_t* aRowCount, int32_t* aColCount)
+HTMLEditor::GetTableSize(nsIDOMElement* aTable,
+                         int32_t* aRowCount,
+                         int32_t* aColCount)
 {
   NS_ENSURE_ARG_POINTER(aRowCount);
   NS_ENSURE_ARG_POINTER(aColCount);
   nsresult res;
   *aRowCount = 0;
   *aColCount = 0;
   nsCOMPtr<nsIDOMElement> table;
   // Get the selected talbe or the table enclosing the selection anchor
@@ -2640,22 +2696,27 @@ nsHTMLEditor::GetTableSize(nsIDOMElement
 
   *aRowCount = tableFrame->GetRowCount();
   *aColCount = tableFrame->GetColCount();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetCellDataAt(nsIDOMElement* aTable, int32_t aRowIndex,
-                            int32_t aColIndex, nsIDOMElement **aCell,
-                            int32_t* aStartRowIndex, int32_t* aStartColIndex,
-                            int32_t* aRowSpan, int32_t* aColSpan,
-                            int32_t* aActualRowSpan, int32_t* aActualColSpan,
-                            bool* aIsSelected)
+HTMLEditor::GetCellDataAt(nsIDOMElement* aTable,
+                          int32_t aRowIndex,
+                          int32_t aColIndex,
+                          nsIDOMElement** aCell,
+                          int32_t* aStartRowIndex,
+                          int32_t* aStartColIndex,
+                          int32_t* aRowSpan,
+                          int32_t* aColSpan,
+                          int32_t* aActualRowSpan,
+                          int32_t* aActualColSpan,
+                          bool* aIsSelected)
 {
   NS_ENSURE_ARG_POINTER(aStartRowIndex);
   NS_ENSURE_ARG_POINTER(aStartColIndex);
   NS_ENSURE_ARG_POINTER(aRowSpan);
   NS_ENSURE_ARG_POINTER(aColSpan);
   NS_ENSURE_ARG_POINTER(aActualRowSpan);
   NS_ENSURE_ARG_POINTER(aActualColSpan);
   NS_ENSURE_ARG_POINTER(aIsSelected);
@@ -2702,17 +2763,20 @@ nsHTMLEditor::GetCellDataAt(nsIDOMElemen
   nsCOMPtr<nsIDOMElement> domCell = do_QueryInterface(cellFrame->GetContent());
   domCell.forget(aCell);
 
   return NS_OK;
 }
 
 // When all you want is the cell
 NS_IMETHODIMP
-nsHTMLEditor::GetCellAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex, nsIDOMElement **aCell)
+HTMLEditor::GetCellAt(nsIDOMElement* aTable,
+                      int32_t aRowIndex,
+                      int32_t aColIndex,
+                      nsIDOMElement** aCell)
 {
   NS_ENSURE_ARG_POINTER(aCell);
   *aCell = nullptr;
 
   if (!aTable)
   {
     // Get the selected table or the table enclosing the selection anchor
     nsCOMPtr<nsIDOMElement> table;
@@ -2732,35 +2796,40 @@ nsHTMLEditor::GetCellAt(nsIDOMElement* a
     do_QueryInterface(tableFrame->GetCellAt(aRowIndex, aColIndex));
   domCell.forget(aCell);
 
   return NS_OK;
 }
 
 // When all you want are the rowspan and colspan (not exposed in nsITableEditor)
 NS_IMETHODIMP
-nsHTMLEditor::GetCellSpansAt(nsIDOMElement* aTable, int32_t aRowIndex, int32_t aColIndex,
-                             int32_t& aActualRowSpan, int32_t& aActualColSpan)
+HTMLEditor::GetCellSpansAt(nsIDOMElement* aTable,
+                           int32_t aRowIndex,
+                           int32_t aColIndex,
+                           int32_t& aActualRowSpan,
+                           int32_t& aActualColSpan)
 {
   nsTableWrapperFrame* tableFrame = GetTableFrame(aTable);
   if (!tableFrame)
     return NS_ERROR_FAILURE;
 
   aActualRowSpan = tableFrame->GetEffectiveRowSpanAt(aRowIndex, aColIndex);
   aActualColSpan = tableFrame->GetEffectiveColSpanAt(aRowIndex, aColIndex);
 
   return NS_OK;
 }
 
 nsresult
-nsHTMLEditor::GetCellContext(Selection** aSelection,
-                             nsIDOMElement   **aTable,
-                             nsIDOMElement   **aCell,
-                             nsIDOMNode      **aCellParent, int32_t *aCellOffset,
-                             int32_t *aRowIndex, int32_t *aColIndex)
+HTMLEditor::GetCellContext(Selection** aSelection,
+                           nsIDOMElement** aTable,
+                           nsIDOMElement** aCell,
+                           nsIDOMNode** aCellParent,
+                           int32_t* aCellOffset,
+                           int32_t* aRowIndex,
+                           int32_t* aColIndex)
 {
   // Initialize return pointers
   if (aSelection) *aSelection = nullptr;
   if (aTable) *aTable = nullptr;
   if (aCell) *aCell = nullptr;
   if (aCellParent) *aCellParent = nullptr;
   if (aCellOffset) *aCellOffset = 0;
   if (aRowIndex) *aRowIndex = 0;
@@ -2853,17 +2922,18 @@ nsHTMLEditor::GetCellContext(Selection**
       *aCellOffset = GetChildOffset(cell, cellParent);
     }
   }
 
   return res;
 }
 
 nsresult
-nsHTMLEditor::GetCellFromRange(nsRange* aRange, nsIDOMElement** aCell)
+HTMLEditor::GetCellFromRange(nsRange* aRange,
+                             nsIDOMElement** aCell)
 {
   // Note: this might return a node that is outside of the range.
   // Use carefully.
   NS_ENSURE_TRUE(aRange && aCell, NS_ERROR_NULL_POINTER);
 
   *aCell = nullptr;
 
   nsCOMPtr<nsIDOMNode> startParent;
@@ -2902,17 +2972,18 @@ nsHTMLEditor::GetCellFromRange(nsRange* 
     *aCell = cellElement.get();
     NS_ADDREF(*aCell);
     return NS_OK;
   }
   return NS_EDITOR_ELEMENT_NOT_FOUND;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetFirstSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell)
+HTMLEditor::GetFirstSelectedCell(nsIDOMRange** aRange,
+                                 nsIDOMElement** aCell)
 {
   NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
   *aCell = nullptr;
   if (aRange) *aRange = nullptr;
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
@@ -2940,17 +3011,18 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDO
 
   // Setup for next cell
   mSelectedCellIndex = 1;
 
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetNextSelectedCell(nsIDOMRange **aRange, nsIDOMElement **aCell)
+HTMLEditor::GetNextSelectedCell(nsIDOMRange** aRange,
+                                nsIDOMElement** aCell)
 {
   NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
   *aCell = nullptr;
   if (aRange) *aRange = nullptr;
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
@@ -2988,17 +3060,19 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOM
 
   // Setup for next cell
   mSelectedCellIndex++;
 
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetFirstSelectedCellInTable(int32_t *aRowIndex, int32_t *aColIndex, nsIDOMElement **aCell)
+HTMLEditor::GetFirstSelectedCellInTable(int32_t* aRowIndex,
+                                        int32_t* aColIndex,
+                                        nsIDOMElement** aCell)
 {
   NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
   *aCell = nullptr;
   if (aRowIndex)
     *aRowIndex = 0;
   if (aColIndex)
     *aColIndex = 0;
 
@@ -3023,18 +3097,21 @@ nsHTMLEditor::GetFirstSelectedCellInTabl
     if (aColIndex)
       *aColIndex = startColIndex;
   }
 
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::SetSelectionAfterTableEdit(nsIDOMElement* aTable, int32_t aRow, int32_t aCol,
-                                     int32_t aDirection, bool aSelected)
+HTMLEditor::SetSelectionAfterTableEdit(nsIDOMElement* aTable,
+                                       int32_t aRow,
+                                       int32_t aCol,
+                                       int32_t aDirection,
+                                       bool aSelected)
 {
   NS_ENSURE_TRUE(aTable, NS_ERROR_NOT_INITIALIZED);
 
   RefPtr<Selection> selection = GetSelection();
   nsresult res;
 
   if (!selection)
   {
@@ -3113,19 +3190,19 @@ nsHTMLEditor::SetSelectionAfterTableEdit
     return selection->Collapse(tableParent, tableOffset);
   }
   // Last resort: Set selection to start of doc
   // (it's very bad to not have a valid selection!)
   return SetSelectionAtDocumentStart(selection);
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName,
-                                              int32_t *aSelectedCount,
-                                              nsIDOMElement** aTableElement)
+HTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName,
+                                            int32_t* aSelectedCount,
+                                            nsIDOMElement** aTableElement)
 {
   NS_ENSURE_ARG_POINTER(aTableElement);
   NS_ENSURE_ARG_POINTER(aSelectedCount);
   *aTableElement = nullptr;
   aTagName.Truncate();
   *aSelectedCount = 0;
 
   RefPtr<Selection> selection = GetSelection();
@@ -3207,17 +3284,18 @@ nsHTMLEditor::GetSelectedOrParentTableEl
   {
     *aTableElement = tableOrCellElement.get();
     NS_ADDREF(*aTableElement);
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsHTMLEditor::GetSelectedCellsType(nsIDOMElement *aElement, uint32_t *aSelectionType)
+HTMLEditor::GetSelectedCellsType(nsIDOMElement* aElement,
+                                 uint32_t* aSelectionType)
 {
   NS_ENSURE_ARG_POINTER(aSelectionType);
   *aSelectionType = 0;
 
   // Be sure we have a table element
   //  (if aElement is null, this uses selection's anchor node)
   nsCOMPtr<nsIDOMElement> table;
 
@@ -3289,17 +3367,19 @@ nsHTMLEditor::GetSelectedCellsType(nsIDO
   }
   if (allCellsInColAreSelected)
     *aSelectionType = nsISelectionPrivate::TABLESELECTION_COLUMN;
 
   return NS_OK;
 }
 
 bool
-nsHTMLEditor::AllCellsInRowSelected(nsIDOMElement *aTable, int32_t aRowIndex, int32_t aNumberOfColumns)
+HTMLEditor::AllCellsInRowSelected(nsIDOMElement* aTable,
+                                  int32_t aRowIndex,
+                                  int32_t aNumberOfColumns)
 {
   NS_ENSURE_TRUE(aTable, false);
 
   int32_t curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool    isSelected;
 
   for( int32_t col = 0; col < aNumberOfColumns; col += std::max(actualColSpan, 1))
   {
@@ -3318,17 +3398,19 @@ nsHTMLEditor::AllCellsInRowSelected(nsID
     NS_ENSURE_TRUE(isSelected, false);
 
     NS_ASSERTION((actualColSpan > 0),"ActualColSpan = 0 in AllCellsInRowSelected");
   }
   return true;
 }
 
 bool
-nsHTMLEditor::AllCellsInColumnSelected(nsIDOMElement *aTable, int32_t aColIndex, int32_t aNumberOfRows)
+HTMLEditor::AllCellsInColumnSelected(nsIDOMElement* aTable,
+                                     int32_t aColIndex,
+                                     int32_t aNumberOfRows)
 {
   NS_ENSURE_TRUE(aTable, false);
 
   int32_t curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool    isSelected;
 
   for( int32_t row = 0; row < aNumberOfRows; row += std::max(actualRowSpan, 1))
   {
@@ -3345,17 +3427,17 @@ nsHTMLEditor::AllCellsInColumnSelected(n
 
     // Return as soon as a non-selected cell is found
     NS_ENSURE_TRUE(isSelected, false);
   }
   return true;
 }
 
 bool
-nsHTMLEditor::IsEmptyCell(dom::Element* aCell)
+HTMLEditor::IsEmptyCell(dom::Element* aCell)
 {
   MOZ_ASSERT(aCell);
 
   // Check if target only contains empty text node or <br>
   nsCOMPtr<nsINode> cellChild = aCell->GetFirstChild();
   if (!cellChild) {
     return false;
   }
@@ -3372,8 +3454,10 @@ nsHTMLEditor::IsEmptyCell(dom::Element* 
   }
 
   bool isEmpty;
   // Or check if no real content
   nsresult rv = IsEmptyNode(cellChild, &isEmpty, false, false);
   NS_ENSURE_SUCCESS(rv, false);
   return isEmpty;
 }
+
+} // namespace mozilla
--- a/editor/libeditor/WSRunObject.cpp
+++ b/editor/libeditor/WSRunObject.cpp
@@ -3,43 +3,43 @@
  * 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 "WSRunObject.h"
 
 #include "EditorUtils.h"
 #include "TextEditUtils.h"
 
-#include "mozilla/OwningNonNull.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Casting.h"
+#include "mozilla/HTMLEditor.h"
 #include "mozilla/mozalloc.h"
+#include "mozilla/OwningNonNull.h"
 #include "mozilla/SelectionState.h"
 
 #include "nsAString.h"
 #include "nsCRT.h"
 #include "nsContentUtils.h"
 #include "nsDebug.h"
 #include "nsError.h"
-#include "nsHTMLEditor.h"
 #include "nsIContent.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNode.h"
 #include "nsISupportsImpl.h"
 #include "nsRange.h"
 #include "nsString.h"
 #include "nsTextFragment.h"
 
 namespace mozilla {
 
 using namespace dom;
 
 const char16_t nbsp = 160;
 
-WSRunObject::WSRunObject(nsHTMLEditor* aHTMLEditor,
+WSRunObject::WSRunObject(HTMLEditor* aHTMLEditor,
                          nsINode* aNode,
                          int32_t aOffset)
   : mNode(aNode)
   , mOffset(aOffset)
   , mPRE(false)
   , mStartOffset(0)
   , mEndOffset(0)
   , mFirstNBSPOffset(0)
@@ -47,17 +47,17 @@ WSRunObject::WSRunObject(nsHTMLEditor* a
   , mStartRun(nullptr)
   , mEndRun(nullptr)
   , mHTMLEditor(aHTMLEditor)
 {
   GetWSNodes();
   GetRuns();
 }
 
-WSRunObject::WSRunObject(nsHTMLEditor* aHTMLEditor,
+WSRunObject::WSRunObject(HTMLEditor* aHTMLEditor,
                          nsIDOMNode* aNode,
                          int32_t aOffset)
   : mNode(do_QueryInterface(aNode))
   , mOffset(aOffset)
   , mPRE(false)
   , mStartOffset(0)
   , mEndOffset(0)
   , mFirstNBSPOffset(0)
@@ -71,17 +71,17 @@ WSRunObject::WSRunObject(nsHTMLEditor* a
 }
 
 WSRunObject::~WSRunObject()
 {
   ClearRuns();
 }
 
 nsresult
-WSRunObject::ScrubBlockBoundary(nsHTMLEditor* aHTMLEditor,
+WSRunObject::ScrubBlockBoundary(HTMLEditor* aHTMLEditor,
                                 BlockBoundary aBoundary,
                                 nsINode* aBlock,
                                 int32_t aOffset)
 {
   NS_ENSURE_TRUE(aHTMLEditor && aBlock, NS_ERROR_NULL_POINTER);
 
   int32_t offset;
   if (aBoundary == kBlockStart) {
@@ -95,31 +95,31 @@ WSRunObject::ScrubBlockBoundary(nsHTMLEd
     offset = aOffset;
   }
 
   WSRunObject theWSObj(aHTMLEditor, aBlock, offset);
   return theWSObj.Scrub();
 }
 
 nsresult
-WSRunObject::PrepareToJoinBlocks(nsHTMLEditor* aHTMLEditor,
+WSRunObject::PrepareToJoinBlocks(HTMLEditor* aHTMLEditor,
                                  Element* aLeftBlock,
                                  Element* aRightBlock)
 {
   NS_ENSURE_TRUE(aLeftBlock && aRightBlock && aHTMLEditor,
                  NS_ERROR_NULL_POINTER);
 
   WSRunObject leftWSObj(aHTMLEditor, aLeftBlock, aLeftBlock->Length());
   WSRunObject rightWSObj(aHTMLEditor, aRightBlock, 0);
 
   return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
 }
 
 nsresult
-WSRunObject::PrepareToDeleteRange(nsHTMLEditor* aHTMLEditor,
+WSRunObject::PrepareToDeleteRange(HTMLEditor* aHTMLEditor,
                                   nsCOMPtr<nsINode>* aStartNode,
                                   int32_t* aStartOffset,
                                   nsCOMPtr<nsINode>* aEndNode,
                                   int32_t* aEndOffset)
 {
   NS_ENSURE_TRUE(aHTMLEditor && aStartNode && *aStartNode && aStartOffset &&
                  aEndNode && *aEndNode && aEndOffset, NS_ERROR_NULL_POINTER);
 
@@ -130,33 +130,33 @@ WSRunObject::PrepareToDeleteRange(nsHTML
 
   WSRunObject leftWSObj(aHTMLEditor, *aStartNode, *aStartOffset);
   WSRunObject rightWSObj(aHTMLEditor, *aEndNode, *aEndOffset);
 
   return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
 }
 
 nsresult
-WSRunObject::PrepareToDeleteNode(nsHTMLEditor* aHTMLEditor,
+WSRunObject::PrepareToDeleteNode(HTMLEditor* aHTMLEditor,
                                  nsIContent* aContent)
 {
   NS_ENSURE_TRUE(aContent && aHTMLEditor, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsINode> parent = aContent->GetParentNode();
   NS_ENSURE_STATE(parent);
   int32_t offset = parent->IndexOf(aContent);
 
   WSRunObject leftWSObj(aHTMLEditor, parent, offset);
   WSRunObject rightWSObj(aHTMLEditor, parent, offset + 1);
 
   return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
 }
 
 nsresult
-WSRunObject::PrepareToSplitAcrossBlocks(nsHTMLEditor* aHTMLEditor,
+WSRunObject::PrepareToSplitAcrossBlocks(HTMLEditor* aHTMLEditor,
                                         nsCOMPtr<nsINode>* aSplitNode,
                                         int32_t* aSplitOffset)
 {
   NS_ENSURE_TRUE(aHTMLEditor && aSplitNode && *aSplitNode && aSplitOffset,
                  NS_ERROR_NULL_POINTER);
 
   AutoTrackDOMPoint tracker(aHTMLEditor->mRangeUpdater,
                             aSplitNode, aSplitOffset);
@@ -1923,12 +1923,12 @@ WSRunObject::Scrub()
   }
   return NS_OK;
 }
 
 bool
 WSRunObject::IsBlockNode(nsINode* aNode)
 {
   return aNode && aNode->IsElement() &&
-         nsHTMLEditor::NodeIsBlockStatic(aNode->AsElement());
+         HTMLEditor::NodeIsBlockStatic(aNode->AsElement());
 }
 
 } // namespace mozilla
--- a/editor/libeditor/WSRunObject.h
+++ b/editor/libeditor/WSRunObject.h
@@ -8,21 +8,21 @@
 
 #include "nsCOMPtr.h"
 #include "nsIEditor.h" // for EDirection
 #include "nsINode.h"
 #include "nscore.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Text.h"
 
-class nsHTMLEditor;
 class nsIDOMNode;
 
 namespace mozilla {
 
+class HTMLEditor;
 class HTMLEditRules;
 struct EditorDOMPoint;
 
 // class WSRunObject represents the entire whitespace situation
 // around a given point.  It collects up a list of nodes that contain
 // whitespace and categorizes in up to 3 different WSFragments (detailed
 // below).  Each WSFragment is a collection of whitespace that is
 // either all insignificant, or that is significant.  A WSFragment could
@@ -160,59 +160,59 @@ public:
     kBlockEnd,
     kAfterBlock
   };
 
   enum {eBefore = 1};
   enum {eAfter  = 1 << 1};
   enum {eBoth   = eBefore | eAfter};
 
-  WSRunObject(nsHTMLEditor* aHTMLEditor, nsINode* aNode, int32_t aOffset);
-  WSRunObject(nsHTMLEditor* aHTMLEditor, nsIDOMNode* aNode, int32_t aOffset);
+  WSRunObject(HTMLEditor* aHTMLEditor, nsINode* aNode, int32_t aOffset);
+  WSRunObject(HTMLEditor* aHTMLEditor, nsIDOMNode* aNode, int32_t aOffset);
   ~WSRunObject();
 
   // ScrubBlockBoundary removes any non-visible whitespace at the specified
   // location relative to a block node.
-  static nsresult ScrubBlockBoundary(nsHTMLEditor* aHTMLEditor,
+  static nsresult ScrubBlockBoundary(HTMLEditor* aHTMLEditor,
                                      BlockBoundary aBoundary,
                                      nsINode* aBlock,
                                      int32_t aOffset = -1);
 
   // PrepareToJoinBlocks fixes up ws at the end of aLeftBlock and the
   // beginning of aRightBlock in preperation for them to be joined.  Example
   // of fixup: trailingws in aLeftBlock needs to be removed.
-  static nsresult PrepareToJoinBlocks(nsHTMLEditor* aHTMLEditor,
+  static nsresult PrepareToJoinBlocks(HTMLEditor* aHTMLEditor,
                                       dom::Element* aLeftBlock,
                                       dom::Element* aRightBlock);
 
   // PrepareToDeleteRange fixes up ws before {aStartNode,aStartOffset}
   // and after {aEndNode,aEndOffset} in preperation for content
   // in that range to be deleted.  Note that the nodes and offsets
   // are adjusted in response to any dom changes we make while
   // adjusting ws.
   // example of fixup: trailingws before {aStartNode,aStartOffset}
   //                   needs to be removed.
-  static nsresult PrepareToDeleteRange(nsHTMLEditor* aHTMLEditor,
+  static nsresult PrepareToDeleteRange(HTMLEditor* aHTMLEditor,
                                        nsCOMPtr<nsINode>* aStartNode,
                                        int32_t* aStartOffset,
                                        nsCOMPtr<nsINode>* aEndNode,
                                        int32_t* aEndOffset);
 
   // PrepareToDeleteNode fixes up ws before and after aContent in preparation
   // for aContent to be deleted.  Example of fixup: trailingws before
   // aContent needs to be removed.
-  static nsresult PrepareToDeleteNode(nsHTMLEditor* aHTMLEditor,
+  static nsresult PrepareToDeleteNode(HTMLEditor* aHTMLEditor,
                                       nsIContent* aContent);
 
   // PrepareToSplitAcrossBlocks fixes up ws before and after
   // {aSplitNode,aSplitOffset} in preparation for a block parent to be split.
   // Note that the aSplitNode and aSplitOffset are adjusted in response to
   // any DOM changes we make while adjusting ws.  Example of fixup: normalws
   // before {aSplitNode,aSplitOffset} needs to end with nbsp.
-  static nsresult PrepareToSplitAcrossBlocks(nsHTMLEditor* aHTMLEditor,
+  static nsresult PrepareToSplitAcrossBlocks(HTMLEditor* aHTMLEditor,
                                              nsCOMPtr<nsINode>* aSplitNode,
                                              int32_t* aSplitOffset);
 
   // InsertBreak inserts a br node at {aInOutParent,aInOutOffset}
   // and makes any needed adjustments to ws around that point.
   // example of fixup: normalws after {aInOutParent,aInOutOffset}
   //                   needs to begin with nbsp.
   dom::Element* InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
@@ -393,19 +393,19 @@ protected:
   nsTArray<RefPtr<dom::Text>> mNodeArray;
 
   // The first WSFragment in the run.
   WSFragment* mStartRun;
   // The last WSFragment in the run, may be same as first.
   WSFragment* mEndRun;
 
   // Non-owning.
-  nsHTMLEditor* mHTMLEditor;
+  HTMLEditor* mHTMLEditor;
 
   // Opening this class up for pillaging.
   friend class HTMLEditRules;
   // Opening this class up for more pillaging.
-  friend class nsHTMLEditor;
+  friend class HTMLEditor;
 };
 
 } // namespace mozilla
 
 #endif // #ifndef WSRunObject_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -15,16 +15,17 @@ BROWSER_CHROME_MANIFESTS += ['tests/brow
 
 EXPORTS += [
     'nsEditor.h',
     'nsIEditRules.h',
 ]
 
 EXPORTS.mozilla += [
     'EditorController.h',
+    'HTMLEditor.h',
     'SelectionState.h',
     'TextEditRules.h',
 ]
 
 UNIFIED_SOURCES += [
     'ChangeAttributeTransaction.cpp',
     'ChangeStyleTransaction.cpp',
     'CompositionTransaction.cpp',
@@ -34,35 +35,35 @@ UNIFIED_SOURCES += [
     'DeleteRangeTransaction.cpp',
     'DeleteTextTransaction.cpp',
     'EditAggregateTransaction.cpp',
     'EditorCommands.cpp',
     'EditorController.cpp',
     'EditorEventListener.cpp',
     'EditorUtils.cpp',
     'EditTransactionBase.cpp',
+    'HTMLAbsPositionEditor.cpp',
+    'HTMLAnonymousNodeEditor.cpp',
+    'HTMLEditor.cpp',
+    'HTMLEditorDataTransfer.cpp',
     'HTMLEditorEventListener.cpp',
+    'HTMLEditorObjectResizer.cpp',
     'HTMLEditRules.cpp',
     'HTMLEditUtils.cpp',
+    'HTMLInlineTableEditor.cpp',
+    'HTMLStyleEditor.cpp',
+    'HTMLTableEditor.cpp',
     'HTMLURIRefObject.cpp',
     'InsertNodeTransaction.cpp',
     'InsertTextTransaction.cpp',
     'InternetCiter.cpp',
     'JoinNodeTransaction.cpp',
     'nsEditor.cpp',
-    'nsHTMLAbsPosition.cpp',
-    'nsHTMLAnonymousUtils.cpp',
-    'nsHTMLDataTransfer.cpp',
-    'nsHTMLEditor.cpp',
-    'nsHTMLEditorStyle.cpp',
-    'nsHTMLInlineTableEditor.cpp',
-    'nsHTMLObjectResizer.cpp',
     'nsPlaintextDataTransfer.cpp',
     'nsPlaintextEditor.cpp',
-    'nsTableEditor.cpp',
     'PlaceholderTransaction.cpp',
     'SelectionState.cpp',
     'SetDocumentTitleTransaction.cpp',
     'SplitNodeTransaction.cpp',
     'StyleSheetTransactions.cpp',
     'TextEditorTest.cpp',
     'TextEditRules.cpp',
     'TextEditRulesBidi.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -3251,20 +3251,20 @@ nsEditor::GetLeftmostChild(nsINode *aCur
 
   NS_NOTREACHED("What part of for(;;) do you not understand?");
   return nullptr;
 }
 
 bool
 nsEditor::IsBlockNode(nsINode* aNode)
 {
-  // stub to be overridden in nsHTMLEditor.
+  // stub to be overridden in HTMLEditor.
   // screwing around with the class hierarchy here in order
   // to not duplicate the code in GetNextNode/GetPrevNode
-  // across both nsEditor/nsHTMLEditor.
+  // across both nsEditor/HTMLEditor.
   return false;
 }
 
 bool
 nsEditor::CanContain(nsINode& aParent, nsIContent& aChild)
 {
   switch (aParent.NodeType()) {
   case nsIDOMNode::ELEMENT_NODE:
--- a/editor/libeditor/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/nsPlaintextDataTransfer.cpp
@@ -219,17 +219,17 @@ nsresult nsPlaintextEditor::InsertFromDr
   rv = uiEvent->GetRangeOffset(&newSelectionOffset);
   NS_ENSURE_SUCCESS(rv, rv);
 
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
 
   bool isCollapsed = selection->Collapsed();
 
-  // Only the nsHTMLEditor::FindUserSelectAllNode returns a node.
+  // Only the HTMLEditor::FindUserSelectAllNode returns a node.
   nsCOMPtr<nsIDOMNode> userSelectNode = FindUserSelectAllNode(newSelectionParent);
   if (userSelectNode)
   {
     // The drop is happening over a "-moz-user-select: all"
     // subtree so make sure the content we insert goes before
     // the root of the subtree.
     //
     // XXX: Note that inserting before the subtree matches the
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/nsPlaintextEditor.cpp
@@ -134,17 +134,17 @@ NS_IMETHODIMP nsPlaintextEditor::Init(ns
 
     // Init the base editor
     res = nsEditor::Init(aDoc, aRoot, aSelCon, aFlags, aInitialValue);
   }
 
   NS_ENSURE_SUCCESS(rulesRes, rulesRes);
 
   // mRules may not have been initialized yet, when this is called via
-  // nsHTMLEditor::Init.
+  // HTMLEditor::Init.
   if (mRules) {
     mRules->SetInitialValue(aInitialValue);
   }
 
   return res;
 }
 
 static int32_t sNewlineHandlingPref = -1,
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -1561,17 +1561,17 @@ RestyleManager::RestyleForInsertOrChange
 
 void
 RestyleManager::RestyleForRemove(Element* aContainer,
                                  nsIContent* aOldChild,
                                  nsIContent* aFollowingSibling)
 {
   if (aOldChild->IsRootOfAnonymousSubtree()) {
     // This should be an assert, but this is called incorrectly in
-    // nsHTMLEditor::DeleteRefToAnonymousNode and the assertions were clogging
+    // HTMLEditor::DeleteRefToAnonymousNode and the assertions were clogging
     // up the logs.  Make it an assert again when that's fixed.
     MOZ_ASSERT(aOldChild->GetProperty(nsGkAtoms::restylableAnonymousNode),
                "anonymous nodes should not be in child lists (bug 439258)");
   }
   uint32_t selectorFlags =
     aContainer ? (aContainer->GetFlags() & NODE_ALL_SELECTOR_FLAGS) : 0;
   if (selectorFlags == 0)
     return;
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -134,50 +134,33 @@ using mozilla::dom::PushNotifier;
 #include "AudioChannelAgent.h"
 using mozilla::dom::AudioChannelAgent;
 
 // Editor stuff
 #include "nsEditorCID.h"
 #include "nsEditor.h"
 #include "nsPlaintextEditor.h"
 #include "mozilla/EditorController.h" //CID
+#include "mozilla/HTMLEditor.h"
 
-#include "nsHTMLEditor.h"
 #include "nsTextServicesDocument.h"
 #include "nsTextServicesCID.h"
 
 #include "nsScriptSecurityManager.h"
 #include "nsPrincipal.h"
 #include "nsSystemPrincipal.h"
 #include "nsNullPrincipal.h"
 #include "nsNetCID.h"
 #ifndef MOZ_WIDGET_GONK
 #if defined(MOZ_WIDGET_ANDROID)
 #include "nsHapticFeedback.h"
 #endif
 #endif
 #include "nsParserUtils.h"
 
-#define NS_EDITORCOMMANDTABLE_CID \
-{ 0x4f5e62b8, 0xd659, 0x4156, { 0x84, 0xfc, 0x2f, 0x60, 0x99, 0x40, 0x03, 0x69 }}
-
-#define NS_EDITINGCOMMANDTABLE_CID \
-{ 0xcb38a746, 0xbeb8, 0x43f3, { 0x94, 0x29, 0x77, 0x96, 0xe1, 0xa9, 0x3f, 0xb4 }}
-
-#define NS_HAPTICFEEDBACK_CID \
-{ 0x1f15dbc8, 0xbfaa, 0x45de, \
-{ 0x8a, 0x46, 0x08, 0xe2, 0xe2, 0x63, 0x26, 0xb0 } }
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsPlaintextEditor)
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserUtils)
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextServicesDocument)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLEditor)
-
 #include "nsHTMLCanvasFrame.h"
 
 #include "nsIDOMWebGLRenderingContext.h"
 
 class nsIDocumentLoaderFactory;
 
 #define PRODUCT_NAME "Gecko"
 
@@ -277,16 +260,36 @@ using mozilla::dom::quota::QuotaManagerS
 using mozilla::dom::workers::ServiceWorkerManager;
 using mozilla::dom::workers::WorkerDebuggerManager;
 using mozilla::dom::UDPSocketChild;
 using mozilla::dom::time::TimeService;
 using mozilla::net::StreamingProtocolControllerService;
 using mozilla::gmp::GeckoMediaPluginService;
 using mozilla::dom::NotificationTelemetryService;
 
+#define NS_EDITORCOMMANDTABLE_CID \
+{ 0x4f5e62b8, 0xd659, 0x4156, \
+  { 0x84, 0xfc, 0x2f, 0x60, 0x99, 0x40, 0x03, 0x69 } }
+
+#define NS_EDITINGCOMMANDTABLE_CID \
+{ 0xcb38a746, 0xbeb8, 0x43f3, \
+  { 0x94, 0x29, 0x77, 0x96, 0xe1, 0xa9, 0x3f, 0xb4 } }
+
+#define NS_HAPTICFEEDBACK_CID \
+{ 0x1f15dbc8, 0xbfaa, 0x45de, \
+  { 0x8a, 0x46, 0x08, 0xe2, 0xe2, 0x63, 0x26, 0xb0 } }
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsPlaintextEditor)
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserUtils)
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextServicesDocument)
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(HTMLEditor)
+
 // Transformiix
 /* 5d5d92cd-6bf8-11d9-bf4a-000a95dc234c */
 #define TRANSFORMIIX_NODESET_CID \
 { 0x5d5d92cd, 0x6bf8, 0x11d9, { 0xbf, 0x4a, 0x0, 0x0a, 0x95, 0xdc, 0x23, 0x4c } }
 
 #define TRANSFORMIIX_NODESET_CONTRACTID \
 "@mozilla.org/transformiix-nodeset;1"
 
@@ -1081,17 +1084,17 @@ static const mozilla::Module::CIDEntry k
 #ifdef MOZ_B2G_BT
   { &kBLUETOOTHSERVICE_CID, true, nullptr, BluetoothServiceConstructor },
 #endif
 #ifdef MOZ_WIDGET_GONK
   { &kNS_AUDIOMANAGER_CID, true, nullptr, AudioManagerConstructor },
   { &kNS_VOLUMESERVICE_CID, true, nullptr, nsVolumeServiceConstructor },
 #endif
   { &kNS_AUDIOCHANNELAGENT_CID, true, nullptr, AudioChannelAgentConstructor },
-  { &kNS_HTMLEDITOR_CID, false, nullptr, nsHTMLEditorConstructor },
+  { &kNS_HTMLEDITOR_CID, false, nullptr, HTMLEditorConstructor },
   { &kNS_EDITORCONTROLLER_CID, false, nullptr, EditorControllerConstructor },
   { &kNS_EDITINGCONTROLLER_CID, false, nullptr, nsEditingControllerConstructor },
   { &kNS_EDITORCOMMANDTABLE_CID, false, nullptr, nsEditorCommandTableConstructor },
   { &kNS_EDITINGCOMMANDTABLE_CID, false, nullptr, nsEditingCommandTableConstructor },
   { &kNS_TEXTSERVICESDOCUMENT_CID, false, nullptr, nsTextServicesDocumentConstructor },
   { &kNS_GEOLOCATION_SERVICE_CID, false, nullptr, nsGeolocationServiceConstructor },
   { &kNS_GEOLOCATION_CID, false, nullptr, GeolocationConstructor },
   { &kNS_AUDIOCHANNEL_SERVICE_CID, false, nullptr, AudioChannelServiceConstructor },
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -78,17 +78,16 @@
 #include "nsXULPrototypeCache.h"
 #include "nsXULTooltipListener.h"
 
 #include "inDOMView.h"
 
 #include "nsMenuBarListener.h"
 #endif
 
-#include "nsHTMLEditor.h"
 #include "nsTextServicesDocument.h"
 
 #ifdef MOZ_WEBSPEECH
 #include "nsSynthVoiceRegistry.h"
 #endif
 
 #ifdef MOZ_ANDROID_OMX
 #include "AndroidMediaPluginHost.h"
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -73,21 +73,23 @@ static NS_DEFINE_CID(kFrameTraversalCID,
 #include "nsIBidiKeyboard.h"
 
 #include "nsError.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ShadowRoot.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/SelectionBinding.h"
 #include "mozilla/AsyncEventDispatcher.h"
-#include "nsHTMLEditor.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/layers/ScrollInputMethods.h"
 #include "nsViewManager.h"
 
+#include "nsIEditor.h"
+#include "nsIHTMLEditor.h"
+
 using namespace mozilla;
 using namespace mozilla::dom;
 using mozilla::layers::ScrollInputMethod;
 
 //#define DEBUG_TABLE 1
 
 static bool IsValidSelectionPoint(nsFrameSelection *aFrameSel, nsINode *aNode);
 
--- a/widget/windows/nsClipboard.cpp
+++ b/widget/windows/nsClipboard.cpp
@@ -768,17 +768,17 @@ nsClipboard :: FindPlatformHTML ( IDataO
   // (Note that we've handled all cases of negative endOfData above, so we can
   // safely cast it to be unsigned here.)
   if (!endOfData || startOfData >= endOfData || 
       static_cast<uint32_t>(endOfData) > *outDataLen) {
     return false;
   }
   
   // We want to return the buffer not offset by startOfData because it will be 
-  // parsed out later (probably by nsHTMLEditor::ParseCFHTML) when it is still
+  // parsed out later (probably by HTMLEditor::ParseCFHTML) when it is still
   // in CF_HTML format.
 
   // We return the byte offset from the start of the data buffer to where the
   // HTML data starts. The caller might want to extract the HTML only.
   *outStartOfData = startOfData;
   *outDataLen = endOfData;
   return true;
 }