Bug 1260651 part.58 Rename nsPlaintextEditor to mozilla::TextEditor (and their file names too) r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 09 Jul 2016 11:54:50 +0900
changeset 385890 81b95b59e8ceb1019a57a7d682d94c79a06e4b6e
parent 385889 4b047618bddf0c4ea4f859569e69f130c220eaaa
child 385891 a28afa05c708437c9d73a817721b494a55e9e0e2
push id22587
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 06:59:31 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.58 Rename nsPlaintextEditor to mozilla::TextEditor (and their file names too) r=mccr8 This patch renames nsPlaintextEditor to mozilla::TextEditor. Additionally, renames TextEditRules::mEditor to TextEditRules::mTextEditor for making its type clearer. Finally, renaming following files: nsPlaintextEditor.h -> TextEditor.h (exposed as mozilla/editor/TextEditor.h) nsPlaintextEditor.cpp -> TextEditor.cpp nsPlaintextDataTransfer.cpp -> TextEditorDataTransfer.cpp MozReview-Commit-ID: Lw8oJi4WglA
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditRules.h
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorDataTransfer.cpp
editor/libeditor/TextEditRules.cpp
editor/libeditor/TextEditRules.h
editor/libeditor/TextEditRulesBidi.cpp
editor/libeditor/TextEditUtils.cpp
editor/libeditor/TextEditUtils.h
editor/libeditor/TextEditor.cpp
editor/libeditor/TextEditor.h
editor/libeditor/TextEditorDataTransfer.cpp
editor/libeditor/moz.build
editor/libeditor/nsIEditRules.h
editor/libeditor/nsPlaintextDataTransfer.cpp
editor/libeditor/nsPlaintextEditor.cpp
editor/libeditor/nsPlaintextEditor.h
layout/build/nsLayoutModule.cpp
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -40,17 +40,16 @@
 #include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMText.h"
 #include "nsIHTMLAbsPosEditor.h"
 #include "nsIHTMLDocument.h"
 #include "nsINode.h"
 #include "nsLiteralString.h"
-#include "nsPlaintextEditor.h"
 #include "nsRange.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "nsTextNode.h"
 #include "nsThreadUtils.h"
 #include "nsUnicharUtils.h"
@@ -224,17 +223,17 @@ NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION
   NS_INTERFACE_TABLE_INHERITED(HTMLEditRules, nsIEditActionListener)
 NS_INTERFACE_TABLE_TAIL_INHERITING(TextEditRules)
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLEditRules, TextEditRules,
                                    mDocChangeRange, mUtilRange, mNewBlock,
                                    mRangeItem)
 
 NS_IMETHODIMP
-HTMLEditRules::Init(nsPlaintextEditor* aTextEditor)
+HTMLEditRules::Init(TextEditor* aTextEditor)
 {
   InitFields();
 
   mHTMLEditor = static_cast<HTMLEditor*>(aTextEditor);
   nsresult res;
 
   // call through to base class Init
   res = TextEditRules::Init(aTextEditor);
@@ -1461,17 +1460,17 @@ HTMLEditRules::WillLoadHTML(Selection* a
 
   *aCancel = false;
 
   // Delete mBogusNode if it exists. If we really need one,
   // it will be added during post-processing in AfterEditInner().
 
   if (mBogusNode)
   {
-    mEditor->DeleteNode(mBogusNode);
+    mTextEditor->DeleteNode(mBogusNode);
     mBogusNode = nullptr;
   }
 
   return NS_OK;
 }
 
 nsresult
 HTMLEditRules::WillInsertBreak(Selection& aSelection,
@@ -2465,17 +2464,19 @@ HTMLEditRules::DeleteNodeIfCollapsedText
 nsresult
 HTMLEditRules::InsertBRIfNeeded(Selection* aSelection)
 {
   NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER);
 
   // get selection
   nsCOMPtr<nsINode> node;
   int32_t offset;
-  nsresult res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(node), &offset);
+  nsresult res = mTextEditor->GetStartNodeAndOffset(aSelection,
+                                                    getter_AddRefs(node),
+                                                    &offset);
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
 
   // inline elements don't need any br
   if (!IsBlockNode(*node)) {
     return NS_OK;
   }
 
@@ -2905,17 +2906,19 @@ HTMLEditRules::DidDeleteSelection(Select
                                   nsIEditor::EDirection aDir,
                                   nsresult aResult)
 {
   if (!aSelection) { return NS_ERROR_NULL_POINTER; }
 
   // find where we are
   nsCOMPtr<nsINode> startNode;
   int32_t startOffset;
-  nsresult res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode), &startOffset);
+  nsresult res = mTextEditor->GetStartNodeAndOffset(aSelection,
+                                                    getter_AddRefs(startNode),
+                                                    &startOffset);
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_TRUE(startNode, NS_ERROR_FAILURE);
 
   // find any enclosing mailcite
   nsCOMPtr<Element> citeNode = GetTopEnclosingMailCite(*startNode);
   if (citeNode) {
     bool isEmpty = true, seenBR = false;
     NS_ENSURE_STATE(mHTMLEditor);
@@ -3658,17 +3661,17 @@ HTMLEditRules::WillCSSIndent(Selection* 
       if (curNode && IsBlockNode(*curNode)) {
         ChangeIndentation(*curNode->AsElement(), Change::plus);
         curQuote = nullptr;
       }
       else {
         if (!curQuote)
         {
           // First, check that our element can contain a div.
-          if (!mEditor->CanContainTag(*curParent, *nsGkAtoms::div)) {
+          if (!mTextEditor->CanContainTag(*curParent, *nsGkAtoms::div)) {
             return NS_OK; // cancelled
           }
 
           res = SplitAsNeeded(*nsGkAtoms::div, curParent, offset);
           NS_ENSURE_SUCCESS(res, res);
           NS_ENSURE_STATE(mHTMLEditor);
           curQuote = mHTMLEditor->CreateNode(nsGkAtoms::div, curParent,
                                              offset);
@@ -3889,17 +3892,17 @@ HTMLEditRules::WillHTMLIndent(Selection*
         // in a different table cell.
         if (curQuote && InDifferentTableElements(curQuote, curNode)) {
           curQuote = nullptr;
         }
 
         if (!curQuote)
         {
           // First, check that our element can contain a blockquote.
-          if (!mEditor->CanContainTag(*curParent, *nsGkAtoms::blockquote)) {
+          if (!mTextEditor->CanContainTag(*curParent, *nsGkAtoms::blockquote)) {
             return NS_OK; // cancelled
           }
 
           res = SplitAsNeeded(*nsGkAtoms::blockquote, curParent, offset);
           NS_ENSURE_SUCCESS(res, res);
           NS_ENSURE_STATE(mHTMLEditor);
           curQuote = mHTMLEditor->CreateNode(nsGkAtoms::blockquote, curParent,
                                              offset);
@@ -4639,17 +4642,17 @@ HTMLEditRules::WillAlign(Selection& aSel
       }
       // Clear out curDiv so that we don't put nodes after this one into it
     }
 
     // Need to make a div to put things in if we haven't already, or if this
     // node doesn't go in div we used earlier.
     if (!curDiv || transitionList[i]) {
       // First, check that our element can contain a div.
-      if (!mEditor->CanContainTag(*curParent, *nsGkAtoms::div)) {
+      if (!mTextEditor->CanContainTag(*curParent, *nsGkAtoms::div)) {
         // Cancelled
         return NS_OK;
       }
 
       rv = SplitAsNeeded(*nsGkAtoms::div, curParent, offset);
       NS_ENSURE_SUCCESS(rv, rv);
       curDiv = mHTMLEditor->CreateNode(nsGkAtoms::div, curParent, offset);
       NS_ENSURE_STATE(curDiv);
@@ -6255,17 +6258,17 @@ HTMLEditRules::ReturnInParagraph(Selecti
           TextEditUtils::HasMozAttr(GetAsDOMNode(sibling))) {
         NS_ENSURE_STATE(mHTMLEditor);
         newBRneeded = true;
         offset++;
       }
     } else {
       if (doesCRCreateNewP) {
         nsCOMPtr<nsIDOMNode> tmp;
-        res = mEditor->SplitNode(aNode, aOffset, getter_AddRefs(tmp));
+        res = mTextEditor->SplitNode(aNode, aOffset, getter_AddRefs(tmp));
         NS_ENSURE_SUCCESS(res, res);
         selNode = tmp;
       }
 
       newBRneeded = true;
       offset++;
     }
   } else {
@@ -6483,17 +6486,17 @@ HTMLEditRules::ReturnInListItem(Selectio
           nsCOMPtr<nsINode> list = aListItem.GetParentNode();
           int32_t itemOffset = list ? list->IndexOf(&aListItem) : -1;
 
           nsIAtom* listAtom = nodeAtom == nsGkAtoms::dt ? nsGkAtoms::dd
                                                         : nsGkAtoms::dt;
           nsCOMPtr<Element> newListItem =
             mHTMLEditor->CreateNode(listAtom, list, itemOffset + 1);
           NS_ENSURE_STATE(newListItem);
-          res = mEditor->DeleteNode(&aListItem);
+          res = mTextEditor->DeleteNode(&aListItem);
           NS_ENSURE_SUCCESS(res, res);
           res = aSelection.Collapse(newListItem, 0);
           NS_ENSURE_SUCCESS(res, res);
 
           return NS_OK;
         }
 
         nsCOMPtr<Element> brNode;
@@ -8733,17 +8736,17 @@ HTMLEditRules::DocumentModifiedWorker()
   RefPtr<Selection> selection = mHTMLEditor->GetSelection();
   if (!selection) {
     return;
   }
 
   // Delete our bogus node, if we have one, since the document might not be
   // empty any more.
   if (mBogusNode) {
-    mEditor->DeleteNode(mBogusNode);
+    mTextEditor->DeleteNode(mBogusNode);
     mBogusNode = nullptr;
   }
 
   // Try to recreate the bogus node if needed.
   CreateBogusNodeIfNeeded(selection);
 }
 
 } // namespace mozilla
--- a/editor/libeditor/HTMLEditRules.h
+++ b/editor/libeditor/HTMLEditRules.h
@@ -20,23 +20,23 @@
 
 class nsIAtom;
 class nsIDOMCharacterData;
 class nsIDOMDocument;
 class nsIDOMElement;
 class nsIDOMNode;
 class nsIEditor;
 class nsINode;
-class nsPlaintextEditor;
 class nsRange;
 
 namespace mozilla {
 
 class HTMLEditor;
 class RulesInfo;
+class TextEditor;
 struct EditorDOMPoint;
 namespace dom {
 class Element;
 class Selection;
 } // namespace dom
 
 struct StyleCache final : public PropItem
 {
@@ -71,17 +71,17 @@ class HTMLEditRules : public TextEditRul
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLEditRules, TextEditRules)
 
   HTMLEditRules();
 
   // nsIEditRules methods
-  NS_IMETHOD Init(nsPlaintextEditor* aTextEditor) override;
+  NS_IMETHOD Init(TextEditor* aTextEditor) override;
   NS_IMETHOD DetachEditor() override;
   NS_IMETHOD BeforeEdit(EditAction action,
                         nsIEditor::EDirection aDirection) override;
   NS_IMETHOD AfterEdit(EditAction action,
                        nsIEditor::EDirection aDirection) override;
   NS_IMETHOD WillDoAction(Selection* aSelection, RulesInfo* aInfo,
                           bool* aCancel, bool* aHandled) override;
   NS_IMETHOD DidDoAction(Selection* aSelection, RulesInfo* aInfo,
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -188,24 +188,24 @@ HTMLEditor::HideAnonymousEditingUIs()
   if (mInlineEditedCell)
     HideInlineTableEditingUI();
   if (mResizedObject)
     HideResizers();
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLEditor)
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLEditor, nsPlaintextEditor)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLEditor, TextEditor)
   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(HTMLEditor, nsPlaintextEditor)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLEditor, TextEditor)
   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)
@@ -241,17 +241,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_
   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_INTERFACE_MAP_END_INHERITING(TextEditor)
 
 NS_IMETHODIMP
 HTMLEditor::Init(nsIDOMDocument* aDoc,
                  nsIContent* aRoot,
                  nsISelectionController* aSelCon,
                  uint32_t aFlags,
                  const nsAString& aInitialValue)
 {
@@ -262,17 +262,17 @@ HTMLEditor::Init(nsIDOMDocument* aDoc,
   nsresult result = NS_OK, rulesRes = NS_OK;
 
   if (1)
   {
     // block to scope AutoEditInitRulesTrigger
     AutoEditInitRulesTrigger rulesTrigger(this, rulesRes);
 
     // Init the plaintext editor
-    result = nsPlaintextEditor::Init(aDoc, aRoot, nullptr, aFlags, aInitialValue);
+    result = TextEditor::Init(aDoc, aRoot, nullptr, aFlags, aInitialValue);
     if (NS_FAILED(result)) { return result; }
 
     // Init mutation observer
     nsCOMPtr<nsINode> document = do_QueryInterface(aDoc);
     document->AddMutationObserverUnlessExists(this);
 
     // disable Composer-only features
     if (IsMailEditor())
@@ -341,17 +341,17 @@ HTMLEditor::PreDestroy(bool aDestroyingF
   {
     RemoveOverrideStyleSheet(mStyleSheetURLs[0]);
   }
 
   // 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);
+  return TextEditor::PreDestroy(aDestroyingFrames);
 }
 
 NS_IMETHODIMP
 HTMLEditor::GetRootElement(nsIDOMElement** aRootElement)
 {
   NS_ENSURE_ARG_POINTER(aRootElement);
 
   if (mRootElement) {
@@ -491,23 +491,23 @@ HTMLEditor::RemoveEventListeners()
       target->RemoveEventListener(NS_LITERAL_STRING("resize"),
                                   mResizeEventListenerP, false);
     }
   }
 
   mMouseMotionListenerP = nullptr;
   mResizeEventListenerP = nullptr;
 
-  nsPlaintextEditor::RemoveEventListeners();
+  TextEditor::RemoveEventListeners();
 }
 
 NS_IMETHODIMP
 HTMLEditor::SetFlags(uint32_t aFlags)
 {
-  nsresult rv = nsPlaintextEditor::SetFlags(aFlags);
+  nsresult rv = TextEditor::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;
@@ -515,17 +515,17 @@ HTMLEditor::SetFlags(uint32_t aFlags)
 
 NS_IMETHODIMP
 HTMLEditor::InitRules()
 {
   if (!mRules) {
     // instantiate the rules for the html editor
     mRules = new HTMLEditRules();
   }
-  return mRules->Init(static_cast<nsPlaintextEditor*>(this));
+  return mRules->Init(static_cast<TextEditor*>(this));
 }
 
 NS_IMETHODIMP
 HTMLEditor::BeginningOfDocument()
 {
   if (!mDocWeak) {
     return NS_ERROR_NOT_INITIALIZED;
   }
@@ -604,17 +604,17 @@ HTMLEditor::BeginningOfDocument()
 nsresult
 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.
+    // bypass TextEditor.
     return nsEditor::HandleKeyPressEvent(aKeyEvent);
   }
 
   WidgetKeyboardEvent* nativeKeyEvent =
     aKeyEvent->AsEvent()->WidgetEventPtr()->AsKeyboardEvent();
   NS_ENSURE_TRUE(nativeKeyEvent, NS_ERROR_UNEXPECTED);
   NS_ASSERTION(nativeKeyEvent->mMessage == eKeyPress,
                "HandleKeyPressEvent gets non-keypress event");
@@ -623,23 +623,23 @@ HTMLEditor::HandleKeyPressEvent(nsIDOMKe
     case NS_VK_META:
     case NS_VK_WIN:
     case NS_VK_SHIFT:
     case NS_VK_CONTROL:
     case NS_VK_ALT:
     case NS_VK_BACK:
     case NS_VK_DELETE:
       // These keys are handled on nsEditor, so, we can bypass
-      // nsPlaintextEditor.
+      // TextEditor.
       return nsEditor::HandleKeyPressEvent(aKeyEvent);
     case NS_VK_TAB: {
       if (IsPlaintextEditor()) {
         // If this works as plain text editor, e.g., mail editor for plain
-        // text, should be handled on nsPlaintextEditor.
-        return nsPlaintextEditor::HandleKeyPressEvent(aKeyEvent);
+        // text, should be handled on TextEditor.
+        return TextEditor::HandleKeyPressEvent(aKeyEvent);
       }
 
       if (IsTabbable()) {
         return NS_OK; // let it be used for focus switching
       }
 
       if (nativeKeyEvent->IsControl() || nativeKeyEvent->IsAlt() ||
           nativeKeyEvent->IsMeta() || nativeKeyEvent->IsOS()) {
@@ -1040,17 +1040,17 @@ HTMLEditor::TypedText(const nsAString& a
   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);
+  return TextEditor::TypedText(aString, aAction);
 }
 
 NS_IMETHODIMP
 HTMLEditor::TabInTable(bool inIsShift,
                        bool* outHandled)
 {
   NS_ENSURE_TRUE(outHandled, NS_ERROR_NULL_POINTER);
   *outHandled = false;
@@ -5278,17 +5278,17 @@ HTMLEditor::GetInputEventTargetContent()
 {
   nsCOMPtr<nsIContent> target = GetActiveEditingHost();
   return target.forget();
 }
 
 bool
 HTMLEditor::IsEditable(nsINode* aNode)
 {
-  if (!nsPlaintextEditor::IsEditable(aNode)) {
+  if (!TextEditor::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.
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -5,16 +5,17 @@
 
 #ifndef mozilla_HTMLEditor_h
 #define mozilla_HTMLEditor_h
 
 #include "CSSEditUtils.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/StyleSheetHandle.h"
+#include "mozilla/TextEditor.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"
@@ -28,17 +29,16 @@
 #include "nsIEditRules.h"
 #include "nsIHTMLAbsPosEditor.h"
 #include "nsIHTMLEditor.h"
 #include "nsIHTMLInlineTableEditor.h"
 #include "nsIHTMLObjectResizeListener.h"
 #include "nsIHTMLObjectResizer.h"
 #include "nsISelectionListener.h"
 #include "nsITableEditor.h"
-#include "nsPlaintextEditor.h"
 #include "nsPoint.h"
 #include "nsStubMutationObserver.h"
 #include "nsTArray.h"
 
 class nsDocumentFragment;
 class nsIDOMKeyEvent;
 class nsITransferable;
 class nsIClipboard;
@@ -62,17 +62,17 @@ class DocumentFragment;
 namespace widget {
 struct IMEState;
 } // namespace widget
 
 /**
  * The HTML editor implementation.<br>
  * Use to edit HTML document represented as a DOM tree.
  */
-class HTMLEditor final : public nsPlaintextEditor
+class HTMLEditor final : public TextEditor
                        , public nsIHTMLEditor
                        , public nsIHTMLObjectResizer
                        , public nsIHTMLAbsPosEditor
                        , public nsITableEditor
                        , public nsIHTMLInlineTableEditor
                        , public nsIEditorStyleSheets
                        , public nsICSSLoaderObserver
                        , public nsStubMutationObserver
@@ -92,24 +92,24 @@ public:
   {
     kX      = 0,
     kY      = 1,
     kWidth  = 2,
     kHeight = 3
   };
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLEditor, nsPlaintextEditor)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLEditor, TextEditor)
 
   HTMLEditor();
 
   bool GetReturnInParagraphCreatesNewParagraph();
   Element* GetSelectionContainer();
 
-  // nsPlaintextEditor overrides
+  // TextEditor 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<dom::EventTarget> GetDOMEventTarget() override;
   virtual Element* GetEditorRoot() override;
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -67,17 +67,16 @@
 #include "nsISupportsPrimitives.h"
 #include "nsISupportsUtils.h"
 #include "nsITransferable.h"
 #include "nsIURI.h"
 #include "nsIVariant.h"
 #include "nsLinebreakConverter.h"
 #include "nsLiteralString.h"
 #include "nsNetUtil.h"
-#include "nsPlaintextEditor.h"
 #include "nsRange.h"
 #include "nsReadableUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStreamUtils.h"
 #include "nsString.h"
 #include "nsStringFwd.h"
 #include "nsStringIterator.h"
 #include "nsSubstringTuple.h"
@@ -1551,19 +1550,19 @@ HTMLEditor::PasteNoFormatting(int32_t aS
   ForceCompositionEnd();
 
   // Get Clipboard Service
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the nsITransferable interface for getting the data from the clipboard.
-  // use nsPlaintextEditor::PrepareTransferable() to force unicode plaintext data.
+  // use TextEditor::PrepareTransferable() to force unicode plaintext data.
   nsCOMPtr<nsITransferable> trans;
-  rv = nsPlaintextEditor::PrepareTransferable(getter_AddRefs(trans));
+  rv = TextEditor::PrepareTransferable(getter_AddRefs(trans));
   if (NS_SUCCEEDED(rv) && trans)
   {
     // Get the Data from the clipboard
     if (NS_SUCCEEDED(clipboard->GetData(trans, aSelectionType)) && IsModifiable())
     {
       const nsAFlatString& empty = EmptyString();
       rv = InsertFromTransferable(trans, nullptr, empty, empty, false, nullptr, 0,
                                   true);
@@ -1857,17 +1856,17 @@ HTMLEditor::InsertAsQuotation(const nsAS
     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
+// This differs from its corresponding method in TextEditor
 // in that here, quoted material is enclosed in a <pre> tag
 // in order to preserve the original line wrapping.
 NS_IMETHODIMP
 HTMLEditor::InsertAsPlaintextQuotation(const nsAString& aQuotedText,
                                        bool aAddCites,
                                        nsIDOMNode** aNodeInserted)
 {
   // get selection
@@ -1905,19 +1904,19 @@ HTMLEditor::InsertAsPlaintextQuotation(c
     newNode->SetAttr(kNameSpaceID_None, nsGkAtoms::style,
                      NS_LITERAL_STRING("white-space: pre-wrap;"), true);
 
     // and set the selection inside it:
     selection->Collapse(newNode, 0);
   }
 
   if (aAddCites)
-    rv = nsPlaintextEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
+    rv = TextEditor::InsertAsQuotation(aQuotedText, aNodeInserted);
   else
-    rv = nsPlaintextEditor::InsertText(aQuotedText);
+    rv = TextEditor::InsertText(aQuotedText);
   // Note that if !aAddCites, aNodeInserted isn't set.
   // That's okay because the routines that use aAddCites
   // don't need to know the inserted node.
 
   if (aNodeInserted && NS_SUCCEEDED(rv))
   {
     *aNodeInserted = GetAsDOMNode(newNode);
     NS_IF_ADDREF(*aNodeInserted);
@@ -1933,23 +1932,23 @@ HTMLEditor::InsertAsPlaintextQuotation(c
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
 HTMLEditor::StripCites()
 {
-  return nsPlaintextEditor::StripCites();
+  return TextEditor::StripCites();
 }
 
 NS_IMETHODIMP
 HTMLEditor::Rewrap(bool aRespectNewlines)
 {
-  return nsPlaintextEditor::Rewrap(aRespectNewlines);
+  return TextEditor::Rewrap(aRespectNewlines);
 }
 
 NS_IMETHODIMP
 HTMLEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
                                    const nsAString& aCitation,
                                    bool aInsertHTML,
                                    nsIDOMNode** aNodeInserted)
 {
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -6,16 +6,17 @@
 #include "mozilla/TextEditRules.h"
 
 #include "EditorUtils.h"
 #include "TextEditUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextComposition.h"
+#include "mozilla/TextEditor.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/NodeIterator.h"
 #include "mozilla/dom/Selection.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
 #include "nsCRTGlue.h"
 #include "nsComponentManagerUtils.h"
@@ -33,17 +34,16 @@
 #include "nsIDOMNodeIterator.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMText.h"
 #include "nsNameSpaceManager.h"
 #include "nsINode.h"
 #include "nsIPlaintextEditor.h"
 #include "nsISupportsBase.h"
 #include "nsLiteralString.h"
-#include "nsPlaintextEditor.h"
 #include "nsUnicharUtils.h"
 
 namespace mozilla {
 
 using namespace dom;
 
 #define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
   if (IsReadonly() || IsDisabled()) \
@@ -52,34 +52,34 @@ using namespace dom;
     return NS_OK;       \
   };
 
 /********************************************************
  * mozilla::TextEditRules
  ********************************************************/
 
 TextEditRules::TextEditRules()
-  : mEditor(nullptr)
+  : mTextEditor(nullptr)
   , mPasswordIMEIndex(0)
   , mCachedSelectionOffset(0)
   , mActionNesting(0)
   , mLockRulesSniffing(false)
   , mDidExplicitlySetInterline(false)
   , mDeleteBidiImmediately(false)
   , mTheAction(EditAction::none)
   , mLastStart(0)
   , mLastLength(0)
 {
   InitFields();
 }
 
 void
 TextEditRules::InitFields()
 {
-  mEditor = nullptr;
+  mTextEditor = nullptr;
   mPasswordText.Truncate();
   mPasswordIMEText.Truncate();
   mPasswordIMEIndex = 0;
   mBogusNode = nullptr;
   mCachedSelectionNode = nullptr;
   mCachedSelectionOffset = 0;
   mActionNesting = 0;
   mLockRulesSniffing = false;
@@ -88,17 +88,18 @@ TextEditRules::InitFields()
   mTheAction = EditAction::none;
   mTimer = nullptr;
   mLastStart = 0;
   mLastLength = 0;
 }
 
 TextEditRules::~TextEditRules()
 {
-   // do NOT delete mEditor here.  We do not hold a ref count to mEditor.  mEditor owns our lifespan.
+   // do NOT delete mTextEditor here.  We do not hold a ref count to
+   // mTextEditor.  mTextEditor owns our lifespan.
 
   if (mTimer)
     mTimer->Cancel();
 }
 
 NS_IMPL_CYCLE_COLLECTION(TextEditRules, mBogusNode, mCachedSelectionNode)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TextEditRules)
@@ -106,41 +107,41 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIEditRules)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(TextEditRules)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(TextEditRules)
 
 NS_IMETHODIMP
-TextEditRules::Init(nsPlaintextEditor* aTextEditor)
+TextEditRules::Init(TextEditor* aTextEditor)
 {
   if (!aTextEditor) {
     return NS_ERROR_NULL_POINTER;
   }
 
   InitFields();
 
   // We hold a non-refcounted reference back to our editor.
-  mEditor = aTextEditor;
-  RefPtr<Selection> selection = mEditor->GetSelection();
+  mTextEditor = aTextEditor;
+  RefPtr<Selection> selection = mTextEditor->GetSelection();
   NS_WARN_IF_FALSE(selection, "editor cannot get selection");
 
   // Put in a magic br if needed. This method handles null selection,
   // which should never happen anyway
   nsresult res = CreateBogusNodeIfNeeded(selection);
   NS_ENSURE_SUCCESS(res, res);
 
   // If the selection hasn't been set up yet, set it up collapsed to the end of
   // our editable content.
   int32_t rangeCount;
   res = selection->GetRangeCount(&rangeCount);
   NS_ENSURE_SUCCESS(res, res);
   if (!rangeCount) {
-    res = mEditor->EndOfDocument();
+    res = mTextEditor->EndOfDocument();
     NS_ENSURE_SUCCESS(res, res);
   }
 
   if (IsPlaintextEditor())
   {
     // ensure trailing br node
     res = CreateTrailingBRIfNeeded();
     NS_ENSURE_SUCCESS(res, res);
@@ -162,17 +163,17 @@ TextEditRules::SetInitialValue(const nsA
 }
 
 NS_IMETHODIMP
 TextEditRules::DetachEditor()
 {
   if (mTimer)
     mTimer->Cancel();
 
-  mEditor = nullptr;
+  mTextEditor = nullptr;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextEditRules::BeforeEdit(EditAction action,
                           nsIEditor::EDirection aDirection)
 {
   if (mLockRulesSniffing) return NS_OK;
@@ -182,18 +183,18 @@ TextEditRules::BeforeEdit(EditAction act
   if (!mActionNesting)
   {
     // let rules remember the top level action
     mTheAction = action;
   }
   mActionNesting++;
 
   // get the selection and cache the position before editing
-  NS_ENSURE_STATE(mEditor);
-  RefPtr<Selection> selection = mEditor->GetSelection();
+  NS_ENSURE_STATE(mTextEditor);
+  RefPtr<Selection> selection = mTextEditor->GetSelection();
   NS_ENSURE_STATE(selection);
 
   selection->GetAnchorNode(getter_AddRefs(mCachedSelectionNode));
   selection->GetAnchorOffset(&mCachedSelectionOffset);
 
   return NS_OK;
 }
 
@@ -204,24 +205,25 @@ TextEditRules::AfterEdit(EditAction acti
   if (mLockRulesSniffing) return NS_OK;
 
   AutoLockRulesSniffing lockIt(this);
 
   NS_PRECONDITION(mActionNesting>0, "bad action nesting!");
   nsresult res = NS_OK;
   if (!--mActionNesting)
   {
-    NS_ENSURE_STATE(mEditor);
-    RefPtr<Selection> selection = mEditor->GetSelection();
+    NS_ENSURE_STATE(mTextEditor);
+    RefPtr<Selection> selection = mTextEditor->GetSelection();
     NS_ENSURE_STATE(selection);
 
-    NS_ENSURE_STATE(mEditor);
-    res = mEditor->HandleInlineSpellCheck(action, selection,
-                                          mCachedSelectionNode, mCachedSelectionOffset,
-                                          nullptr, 0, nullptr, 0);
+    NS_ENSURE_STATE(mTextEditor);
+    res = mTextEditor->HandleInlineSpellCheck(action, selection,
+                                              mCachedSelectionNode,
+                                              mCachedSelectionOffset,
+                                              nullptr, 0, nullptr, 0);
     NS_ENSURE_SUCCESS(res, res);
 
     // if only trailing <br> remaining remove it
     res = RemoveRedundantTrailingBR();
     if (NS_FAILED(res))
       return res;
 
     // detect empty doc
@@ -286,20 +288,20 @@ TextEditRules::WillDoAction(Selection* a
   }
 }
 
 NS_IMETHODIMP
 TextEditRules::DidDoAction(Selection* aSelection,
                            RulesInfo* aInfo,
                            nsresult aResult)
 {
-  NS_ENSURE_STATE(mEditor);
+  NS_ENSURE_STATE(mTextEditor);
   // don't let any txns in here move the selection around behind our back.
   // Note that this won't prevent explicit selection setting from working.
-  AutoTransactionsConserveSelection dontSpazMySelection(mEditor);
+  AutoTransactionsConserveSelection dontSpazMySelection(mTextEditor);
 
   NS_ENSURE_TRUE(aSelection && aInfo, NS_ERROR_NULL_POINTER);
 
   // my kingdom for dynamic cast
   TextRulesInfo* info = static_cast<TextRulesInfo*>(aInfo);
 
   switch (info->action)
   {
@@ -345,18 +347,18 @@ TextEditRules::WillInsert(Selection& aSe
     return;
   }
 
   // initialize out param
   *aCancel = false;
 
   // check for the magic content node and delete it if it exists
   if (mBogusNode) {
-    NS_ENSURE_TRUE_VOID(mEditor);
-    mEditor->DeleteNode(mBogusNode);
+    NS_ENSURE_TRUE_VOID(mTextEditor);
+    mTextEditor->DeleteNode(mBogusNode);
     mBogusNode = nullptr;
   }
 }
 
 nsresult
 TextEditRules::DidInsert(Selection* aSelection,
                          nsresult aResult)
 {
@@ -393,18 +395,18 @@ TextEditRules::WillInsertBreak(Selection
     *aCancel = false;
 
     // if the selection isn't collapsed, delete it.
     bool bCollapsed;
     res = aSelection->GetIsCollapsed(&bCollapsed);
     NS_ENSURE_SUCCESS(res, res);
     if (!bCollapsed)
     {
-      NS_ENSURE_STATE(mEditor);
-      res = mEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
+      NS_ENSURE_STATE(mTextEditor);
+      res = mTextEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
       NS_ENSURE_SUCCESS(res, res);
     }
 
     WillInsert(*aSelection, aCancel);
     // initialize out param
     // we want to ignore result of WillInsert()
     *aCancel = false;
 
@@ -424,54 +426,55 @@ TextEditRules::CollapseSelectionToTraili
 {
   // we only need to execute the stuff below if we are a plaintext editor.
   // html editors have a different mechanism for putting in mozBR's
   // (because there are a bunch more places you have to worry about it in html)
   if (!IsPlaintextEditor()) {
     return NS_OK;
   }
 
-  NS_ENSURE_STATE(mEditor);
+  NS_ENSURE_STATE(mTextEditor);
 
   // If there is no selection ranges, we should set to the end of the editor.
   // This is usually performed in TextEditRules::Init(), however, if the
   // editor is reframed, this may be called by AfterEdit().
   if (!aSelection->RangeCount()) {
-    mEditor->EndOfDocument();
+    mTextEditor->EndOfDocument();
   }
 
   // if we are at the end of the textarea, we need to set the
   // selection to stick to the mozBR at the end of the textarea.
   int32_t selOffset;
   nsCOMPtr<nsIDOMNode> selNode;
   nsresult res;
-  res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
+  res = mTextEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode),
+                                           &selOffset);
   NS_ENSURE_SUCCESS(res, res);
 
   nsCOMPtr<nsIDOMText> nodeAsText = do_QueryInterface(selNode);
   if (!nodeAsText) return NS_OK; // nothing to do if we're not at a text node
 
   uint32_t length;
   res = nodeAsText->GetLength(&length);
   NS_ENSURE_SUCCESS(res, res);
 
   // nothing to do if we're not at the end of the text node
   if (selOffset != int32_t(length))
     return NS_OK;
 
   int32_t parentOffset;
   nsCOMPtr<nsIDOMNode> parentNode = nsEditor::GetNodeLocation(selNode, &parentOffset);
 
-  NS_ENSURE_STATE(mEditor);
-  nsCOMPtr<nsIDOMNode> root = do_QueryInterface(mEditor->GetRoot());
+  NS_ENSURE_STATE(mTextEditor);
+  nsCOMPtr<nsIDOMNode> root = do_QueryInterface(mTextEditor->GetRoot());
   NS_ENSURE_TRUE(root, NS_ERROR_NULL_POINTER);
   if (parentNode != root) return NS_OK;
 
-  nsCOMPtr<nsIDOMNode> nextNode = mEditor->GetChildAt(parentNode,
-                                                      parentOffset + 1);
+  nsCOMPtr<nsIDOMNode> nextNode = mTextEditor->GetChildAt(parentNode,
+                                                          parentOffset + 1);
   if (nextNode && TextEditUtils::IsMozBR(nextNode)) {
     res = aSelection->Collapse(parentNode, parentOffset + 1);
     NS_ENSURE_SUCCESS(res, res);
   }
   return res;
 }
 
 static inline already_AddRefed<nsIDOMNode>
@@ -493,34 +496,34 @@ GetTextNode(Selection* selection, nsEdit
         return nullptr;
       }
     }
   }
   return selNode.forget();
 }
 #ifdef DEBUG
 #define ASSERT_PASSWORD_LENGTHS_EQUAL()                                \
-  if (IsPasswordEditor() && mEditor->GetRoot()) {                      \
+  if (IsPasswordEditor() && mTextEditor->GetRoot()) {                  \
     int32_t txtLen;                                                    \
-    mEditor->GetTextLength(&txtLen);                                   \
+    mTextEditor->GetTextLength(&txtLen);                               \
     NS_ASSERTION(mPasswordText.Length() == uint32_t(txtLen),           \
                  "password length not equal to number of asterisks");  \
   }
 #else
 #define ASSERT_PASSWORD_LENGTHS_EQUAL()
 #endif
 
 // static
 void
 TextEditRules::HandleNewLines(nsString& aString,
                               int32_t aNewlineHandling)
 {
   if (aNewlineHandling < 0) {
     int32_t caretStyle;
-    nsPlaintextEditor::GetDefaultEditorPrefs(aNewlineHandling, caretStyle);
+    TextEditor::GetDefaultEditorPrefs(aNewlineHandling, caretStyle);
   }
 
   switch(aNewlineHandling)
   {
   case nsIPlaintextEditor::eNewlinesReplaceWithSpaces:
     // Strip trailing newlines first so we don't wind up with trailing spaces
     aString.Trim(CRLF, false, true);
     aString.ReplaceChar(CRLF, ' ');
@@ -620,29 +623,30 @@ TextEditRules::WillInsertText(EditAction
     return NS_OK;
   }
 
   int32_t start = 0;
   int32_t end = 0;
 
   // handle password field docs
   if (IsPasswordEditor()) {
-    NS_ENSURE_STATE(mEditor);
-    nsContentUtils::GetSelectionInTextControl(aSelection, mEditor->GetRoot(),
+    NS_ENSURE_STATE(mTextEditor);
+    nsContentUtils::GetSelectionInTextControl(aSelection,
+                                              mTextEditor->GetRoot(),
                                               start, end);
   }
 
   // if the selection isn't collapsed, delete it.
   bool bCollapsed;
   res = aSelection->GetIsCollapsed(&bCollapsed);
   NS_ENSURE_SUCCESS(res, res);
   if (!bCollapsed)
   {
-    NS_ENSURE_STATE(mEditor);
-    res = mEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
+    NS_ENSURE_STATE(mTextEditor);
+    res = mTextEditor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   WillInsert(*aSelection, aCancel);
   // initialize out param
   // we want to ignore result of WillInsert()
   *aCancel = false;
 
@@ -665,18 +669,18 @@ TextEditRules::WillInsertText(EditAction
   // 3. strip newlines
   // 4. replace with commas
   // 5. strip newlines and surrounding whitespace
   // So find out what we're expected to do:
   if (IsSingleLineEditor())
   {
     nsAutoString tString(*outString);
 
-    NS_ENSURE_STATE(mEditor);
-    HandleNewLines(tString, mEditor->mNewlineHandling);
+    NS_ENSURE_STATE(mTextEditor);
+    HandleNewLines(tString, mTextEditor->mNewlineHandling);
 
     outString->Assign(tString);
   }
 
   if (IsPasswordEditor())
   {
     // manage the password buffer
     mPasswordText.Insert(*outString, start);
@@ -705,50 +709,52 @@ TextEditRules::WillInsertText(EditAction
 
   // get the (collapsed) selection location
   NS_ENSURE_STATE(aSelection->GetRangeAt(0));
   nsCOMPtr<nsINode> selNode = aSelection->GetRangeAt(0)->GetStartParent();
   int32_t selOffset = aSelection->GetRangeAt(0)->StartOffset();
   NS_ENSURE_STATE(selNode);
 
   // don't put text in places that can't have it
-  NS_ENSURE_STATE(mEditor);
-  if (!mEditor->IsTextNode(selNode) &&
-      !mEditor->CanContainTag(*selNode, *nsGkAtoms::textTagName)) {
+  NS_ENSURE_STATE(mTextEditor);
+  if (!mTextEditor->IsTextNode(selNode) &&
+      !mTextEditor->CanContainTag(*selNode, *nsGkAtoms::textTagName)) {
     return NS_ERROR_FAILURE;
   }
 
   // we need to get the doc
-  NS_ENSURE_STATE(mEditor);
-  nsCOMPtr<nsIDocument> doc = mEditor->GetDocument();
+  NS_ENSURE_STATE(mTextEditor);
+  nsCOMPtr<nsIDocument> doc = mTextEditor->GetDocument();
   NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
 
   if (aAction == EditAction::insertIMEText) {
-    NS_ENSURE_STATE(mEditor);
+    NS_ENSURE_STATE(mTextEditor);
     // Find better insertion point to insert text.
-    mEditor->FindBetterInsertionPoint(selNode, selOffset);
+    mTextEditor->FindBetterInsertionPoint(selNode, selOffset);
     // If there is one or more IME selections, its minimum offset should be
     // the insertion point.
-    int32_t IMESelectionOffset = mEditor->GetIMESelectionStartOffsetIn(selNode);
+    int32_t IMESelectionOffset =
+      mTextEditor->GetIMESelectionStartOffsetIn(selNode);
     if (IMESelectionOffset >= 0) {
       selOffset = IMESelectionOffset;
     }
-    res = mEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc);
+    res = mTextEditor->InsertTextImpl(*outString, address_of(selNode),
+                                      &selOffset, doc);
     NS_ENSURE_SUCCESS(res, res);
   } else {
     // aAction == EditAction::insertText; find where we are
     nsCOMPtr<nsINode> curNode = selNode;
     int32_t curOffset = selOffset;
 
     // don't spaz my selection in subtransactions
-    NS_ENSURE_STATE(mEditor);
-    AutoTransactionsConserveSelection dontSpazMySelection(mEditor);
+    NS_ENSURE_STATE(mTextEditor);
+    AutoTransactionsConserveSelection dontSpazMySelection(mTextEditor);
 
-    res = mEditor->InsertTextImpl(*outString, address_of(curNode),
-                                  &curOffset, doc);
+    res = mTextEditor->InsertTextImpl(*outString, address_of(curNode),
+                                      &curOffset, doc);
     NS_ENSURE_SUCCESS(res, res);
 
     if (curNode)
     {
       // Make the caret attach to the inserted text, unless this text ends with a LF,
       // in which case make the caret attach to the next line.
       bool endsWithLF =
         !outString->IsEmpty() && outString->Last() == nsCRT::LF;
@@ -841,23 +847,24 @@ TextEditRules::WillDeleteSelection(Selec
   // batch the selectionchange events, such that a single event fires after
   // the AutoHideSelectionChanges destructor has been run.
   SelectionBatcher selectionBatcher(aSelection);
   AutoHideSelectionChanges hideSelection(aSelection);
   nsAutoScriptBlocker scriptBlocker;
 
   if (IsPasswordEditor())
   {
-    NS_ENSURE_STATE(mEditor);
-    res = mEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
+    NS_ENSURE_STATE(mTextEditor);
+    res = mTextEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
     NS_ENSURE_SUCCESS(res, res);
 
     // manage the password buffer
     int32_t start, end;
-    nsContentUtils::GetSelectionInTextControl(aSelection, mEditor->GetRoot(),
+    nsContentUtils::GetSelectionInTextControl(aSelection,
+                                              mTextEditor->GetRoot(),
                                               start, end);
 
     if (LookAndFeel::GetEchoPassword()) {
       HideLastPWInput();
       mLastStart = start;
       mLastLength = 0;
       if (mTimer)
       {
@@ -878,71 +885,74 @@ TextEditRules::WillDeleteSelection(Selec
     else {  // extended selection
       mPasswordText.Cut(start, end-start);
     }
   }
   else
   {
     nsCOMPtr<nsIDOMNode> startNode;
     int32_t startOffset;
-    NS_ENSURE_STATE(mEditor);
-    res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode), &startOffset);
+    NS_ENSURE_STATE(mTextEditor);
+    res = mTextEditor->GetStartNodeAndOffset(aSelection,
+                                             getter_AddRefs(startNode),
+                                             &startOffset);
     NS_ENSURE_SUCCESS(res, res);
     NS_ENSURE_TRUE(startNode, NS_ERROR_FAILURE);
 
     bool bCollapsed;
     res = aSelection->GetIsCollapsed(&bCollapsed);
     NS_ENSURE_SUCCESS(res, res);
 
     if (!bCollapsed)
       return NS_OK;
 
     // Test for distance between caret and text that will be deleted
     res = CheckBidiLevelForDeletion(aSelection, startNode, startOffset, aCollapsedAction, aCancel);
     NS_ENSURE_SUCCESS(res, res);
     if (*aCancel) return NS_OK;
 
-    NS_ENSURE_STATE(mEditor);
-    res = mEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
+    NS_ENSURE_STATE(mTextEditor);
+    res = mTextEditor->ExtendSelectionForDelete(aSelection, &aCollapsedAction);
     NS_ENSURE_SUCCESS(res, res);
   }
 
-  NS_ENSURE_STATE(mEditor);
-  res = mEditor->DeleteSelectionImpl(aCollapsedAction, nsIEditor::eStrip);
+  NS_ENSURE_STATE(mTextEditor);
+  res = mTextEditor->DeleteSelectionImpl(aCollapsedAction, nsIEditor::eStrip);
   NS_ENSURE_SUCCESS(res, res);
 
   *aHandled = true;
   ASSERT_PASSWORD_LENGTHS_EQUAL()
   return NS_OK;
 }
 
 nsresult
 TextEditRules::DidDeleteSelection(Selection* aSelection,
                                   nsIEditor::EDirection aCollapsedAction,
                                   nsresult aResult)
 {
   nsCOMPtr<nsIDOMNode> startNode;
   int32_t startOffset;
-  NS_ENSURE_STATE(mEditor);
-  nsresult res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(startNode), &startOffset);
+  NS_ENSURE_STATE(mTextEditor);
+  nsresult res = mTextEditor->GetStartNodeAndOffset(aSelection,
+                                                    getter_AddRefs(startNode),
+                                                    &startOffset);
   NS_ENSURE_SUCCESS(res, res);
   NS_ENSURE_TRUE(startNode, NS_ERROR_FAILURE);
 
   // delete empty text nodes at selection
-  if (mEditor->IsTextNode(startNode))
-  {
+  if (mTextEditor->IsTextNode(startNode)) {
     nsCOMPtr<nsIDOMText> textNode = do_QueryInterface(startNode);
     uint32_t strLength;
     res = textNode->GetLength(&strLength);
     NS_ENSURE_SUCCESS(res, res);
 
     // are we in an empty text node?
     if (!strLength)
     {
-      res = mEditor->DeleteNode(startNode);
+      res = mTextEditor->DeleteNode(startNode);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
   if (!mDidExplicitlySetInterline)
   {
     // We prevent the caret from sticking on the left of prior BR
     // (i.e. the end of previous line) after this deletion.  Bug 92124
     res = aSelection->SetInterlinePosition(true);
@@ -973,21 +983,21 @@ TextEditRules::WillUndo(Selection* aSele
 nsresult
 TextEditRules::DidUndo(Selection* aSelection,
                        nsresult aResult)
 {
   NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER);
   // If aResult is an error, we return it.
   NS_ENSURE_SUCCESS(aResult, aResult);
 
-  NS_ENSURE_STATE(mEditor);
-  dom::Element* theRoot = mEditor->GetRoot();
+  NS_ENSURE_STATE(mTextEditor);
+  dom::Element* theRoot = mTextEditor->GetRoot();
   NS_ENSURE_TRUE(theRoot, NS_ERROR_FAILURE);
-  nsIContent* node = mEditor->GetLeftmostChild(theRoot);
-  if (node && mEditor->IsMozEditorBogusNode(node)) {
+  nsIContent* node = mTextEditor->GetLeftmostChild(theRoot);
+  if (node && mTextEditor->IsMozEditorBogusNode(node)) {
     mBogusNode = do_QueryInterface(node);
   } else {
     mBogusNode = nullptr;
   }
   return aResult;
 }
 
 nsresult
@@ -1006,18 +1016,18 @@ TextEditRules::WillRedo(Selection* aSele
 nsresult
 TextEditRules::DidRedo(Selection* aSelection,
                        nsresult aResult)
 {
   nsresult res = aResult;  // if aResult is an error, we return it.
   if (!aSelection) { return NS_ERROR_NULL_POINTER; }
   if (NS_SUCCEEDED(res))
   {
-    NS_ENSURE_STATE(mEditor);
-    nsCOMPtr<nsIDOMElement> theRoot = do_QueryInterface(mEditor->GetRoot());
+    NS_ENSURE_STATE(mTextEditor);
+    nsCOMPtr<nsIDOMElement> theRoot = do_QueryInterface(mTextEditor->GetRoot());
     NS_ENSURE_TRUE(theRoot, NS_ERROR_FAILURE);
 
     nsCOMPtr<nsIDOMHTMLCollection> nodeList;
     res = theRoot->GetElementsByTagName(NS_LITERAL_STRING("br"),
                                         getter_AddRefs(nodeList));
     NS_ENSURE_SUCCESS(res, res);
     if (nodeList)
     {
@@ -1029,17 +1039,17 @@ TextEditRules::DidRedo(Selection* aSelec
         mBogusNode = nullptr;
         return NS_OK;
       }
 
       nsCOMPtr<nsIDOMNode> node;
       nodeList->Item(0, getter_AddRefs(node));
       nsCOMPtr<nsIContent> content = do_QueryInterface(node);
       MOZ_ASSERT(content);
-      if (mEditor->IsMozEditorBogusNode(content)) {
+      if (mTextEditor->IsMozEditorBogusNode(content)) {
         mBogusNode = node;
       } else {
         mBogusNode = nullptr;
       }
     }
   }
   return res;
 }
@@ -1090,18 +1100,18 @@ TextEditRules::RemoveRedundantTrailingBR
   // If the bogus node exists, we have no work to do
   if (mBogusNode)
     return NS_OK;
 
   // Likewise, nothing to be done if we could never have inserted a trailing br
   if (IsSingleLineEditor())
     return NS_OK;
 
-  NS_ENSURE_STATE(mEditor);
-  RefPtr<dom::Element> body = mEditor->GetRoot();
+  NS_ENSURE_STATE(mTextEditor);
+  RefPtr<dom::Element> body = mTextEditor->GetRoot();
   if (!body)
     return NS_ERROR_NULL_POINTER;
 
   uint32_t childCount = body->GetChildCount();
   if (childCount > 1) {
     // The trailing br is redundant if it is the only remaining child node
     return NS_OK;
   }
@@ -1132,97 +1142,99 @@ TextEditRules::RemoveRedundantTrailingBR
 nsresult
 TextEditRules::CreateTrailingBRIfNeeded()
 {
   // but only if we aren't a single line edit field
   if (IsSingleLineEditor()) {
     return NS_OK;
   }
 
-  NS_ENSURE_STATE(mEditor);
-  dom::Element* body = mEditor->GetRoot();
+  NS_ENSURE_STATE(mTextEditor);
+  dom::Element* body = mTextEditor->GetRoot();
   NS_ENSURE_TRUE(body, NS_ERROR_NULL_POINTER);
 
   nsIContent* lastChild = body->GetLastChild();
   // assuming CreateBogusNodeIfNeeded() has been called first
   NS_ENSURE_TRUE(lastChild, NS_ERROR_NULL_POINTER);
 
   if (!lastChild->IsHTMLElement(nsGkAtoms::br)) {
-    AutoTransactionsConserveSelection dontSpazMySelection(mEditor);
+    AutoTransactionsConserveSelection dontSpazMySelection(mTextEditor);
     nsCOMPtr<nsIDOMNode> domBody = do_QueryInterface(body);
     return CreateMozBR(domBody, body->Length());
   }
 
   // Check to see if the trailing BR is a former bogus node - this will have
   // stuck around if we previously morphed a trailing node into a bogus node.
-  if (!mEditor->IsMozEditorBogusNode(lastChild)) {
+  if (!mTextEditor->IsMozEditorBogusNode(lastChild)) {
     return NS_OK;
   }
 
   // Morph it back to a mozBR
   lastChild->UnsetAttr(kNameSpaceID_None, kMOZEditorBogusNodeAttrAtom, false);
   lastChild->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
                      NS_LITERAL_STRING("_moz"), true);
   return NS_OK;
 }
 
 nsresult
 TextEditRules::CreateBogusNodeIfNeeded(Selection* aSelection)
 {
   NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER);
-  NS_ENSURE_TRUE(mEditor, NS_ERROR_NULL_POINTER);
+  NS_ENSURE_TRUE(mTextEditor, NS_ERROR_NULL_POINTER);
 
   if (mBogusNode) {
     // Let's not create more than one, ok?
     return NS_OK;
   }
 
   // tell rules system to not do any post-processing
-  AutoRules beginRulesSniffing(mEditor, EditAction::ignore, nsIEditor::eNone);
+  AutoRules beginRulesSniffing(mTextEditor, EditAction::ignore,
+                               nsIEditor::eNone);
 
-  nsCOMPtr<dom::Element> body = mEditor->GetRoot();
+  nsCOMPtr<dom::Element> body = mTextEditor->GetRoot();
   if (!body) {
     // We don't even have a body yet, don't insert any bogus nodes at
     // this point.
     return NS_OK;
   }
 
   // Now we've got the body element. Iterate over the body element's children,
   // looking for editable content. If no editable content is found, insert the
   // bogus node.
   for (nsCOMPtr<nsIContent> bodyChild = body->GetFirstChild();
        bodyChild;
        bodyChild = bodyChild->GetNextSibling()) {
-    if (mEditor->IsMozEditorBogusNode(bodyChild) ||
-        !mEditor->IsEditable(body) || // XXX hoist out of the loop?
-        mEditor->IsEditable(bodyChild) || mEditor->IsBlockNode(bodyChild)) {
+    if (mTextEditor->IsMozEditorBogusNode(bodyChild) ||
+        !mTextEditor->IsEditable(body) || // XXX hoist out of the loop?
+        mTextEditor->IsEditable(bodyChild) ||
+        mTextEditor->IsBlockNode(bodyChild)) {
       return NS_OK;
     }
   }
 
   // Skip adding the bogus node if body is read-only.
-  if (!mEditor->IsModifiableNode(body)) {
+  if (!mTextEditor->IsModifiableNode(body)) {
     return NS_OK;
   }
 
   // Create a br.
-  nsCOMPtr<Element> newContent = mEditor->CreateHTMLContent(nsGkAtoms::br);
+  nsCOMPtr<Element> newContent = mTextEditor->CreateHTMLContent(nsGkAtoms::br);
   NS_ENSURE_STATE(newContent);
 
   // set mBogusNode to be the newly created <br>
   mBogusNode = do_QueryInterface(newContent);
   NS_ENSURE_TRUE(mBogusNode, NS_ERROR_NULL_POINTER);
 
   // Give it a special attribute.
   newContent->SetAttr(kNameSpaceID_None, kMOZEditorBogusNodeAttrAtom,
                       kMOZEditorBogusNodeValue, false);
 
   // Put the node in the document.
   nsCOMPtr<nsIDOMNode> bodyNode = do_QueryInterface(body);
-  nsresult rv = mEditor->InsertNode(mBogusNode, bodyNode, 0);
+  nsresult rv = mTextEditor->InsertNode(mBogusNode, bodyNode, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Set selection.
   aSelection->CollapseNative(body, 0);
   return NS_OK;
 }
 
 
@@ -1238,40 +1250,41 @@ TextEditRules::TruncateInsertionIfNeeded
   nsresult res = NS_OK;
   if (!aOutString->Assign(*aInString, mozilla::fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
   if (aTruncated) {
     *aTruncated = false;
   }
 
-  NS_ENSURE_STATE(mEditor);
-  if ((-1 != aMaxLength) && IsPlaintextEditor() && !mEditor->IsIMEComposing() )
-  {
+  NS_ENSURE_STATE(mTextEditor);
+  if (-1 != aMaxLength && IsPlaintextEditor() &&
+      !mTextEditor->IsIMEComposing()) {
     // Get the current text length.
     // Get the length of inString.
     // Get the length of the selection.
     //   If selection is collapsed, it is length 0.
     //   Subtract the length of the selection from the len(doc)
     //   since we'll delete the selection on insert.
     //   This is resultingDocLength.
     // Get old length of IME composing string
     //   which will be replaced by new one.
     // If (resultingDocLength) is at or over max, cancel the insert
     // If (resultingDocLength) + (length of input) > max,
     //    set aOutString to subset of inString so length = max
     int32_t docLength;
-    res = mEditor->GetTextLength(&docLength);
+    res = mTextEditor->GetTextLength(&docLength);
     if (NS_FAILED(res)) { return res; }
 
     int32_t start, end;
-    nsContentUtils::GetSelectionInTextControl(aSelection, mEditor->GetRoot(),
+    nsContentUtils::GetSelectionInTextControl(aSelection,
+                                              mTextEditor->GetRoot(),
                                               start, end);
 
-    TextComposition* composition = mEditor->GetComposition();
+    TextComposition* composition = mTextEditor->GetComposition();
     int32_t oldCompStrLength = composition ? composition->String().Length() : 0;
 
     const int32_t selectionLength = end - start;
     const int32_t resultingDocLength = docLength - selectionLength - oldCompStrLength;
     if (resultingDocLength >= aMaxLength)
     {
       // This call is guaranteed to reduce the capacity of the string, so it
       // cannot cause an OOM.
@@ -1351,24 +1364,24 @@ TextEditRules::HideLastPWInput()
   if (!mLastLength) {
     // Special case, we're trying to replace a range that no longer exists
     return NS_OK;
   }
 
   nsAutoString hiddenText;
   FillBufWithPWChars(&hiddenText, mLastLength);
 
-  NS_ENSURE_STATE(mEditor);
-  RefPtr<Selection> selection = mEditor->GetSelection();
+  NS_ENSURE_STATE(mTextEditor);
+  RefPtr<Selection> selection = mTextEditor->GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
   int32_t start, end;
-  nsContentUtils::GetSelectionInTextControl(selection, mEditor->GetRoot(),
+  nsContentUtils::GetSelectionInTextControl(selection, mTextEditor->GetRoot(),
                                             start, end);
 
-  nsCOMPtr<nsIDOMNode> selNode = GetTextNode(selection, mEditor);
+  nsCOMPtr<nsIDOMNode> selNode = GetTextNode(selection, mTextEditor);
   NS_ENSURE_TRUE(selNode, NS_OK);
 
   nsCOMPtr<nsIDOMCharacterData> nodeAsText(do_QueryInterface(selNode));
   NS_ENSURE_TRUE(nodeAsText, NS_OK);
 
   nodeAsText->ReplaceData(mLastStart, mLastLength, hiddenText);
   selection->Collapse(selNode, start);
   if (start != end)
@@ -1398,24 +1411,25 @@ TextEditRules::FillBufWithPWChars(nsAStr
 nsresult
 TextEditRules::CreateMozBR(nsIDOMNode* inParent,
                            int32_t inOffset,
                            nsIDOMNode** outBRNode)
 {
   NS_ENSURE_TRUE(inParent, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIDOMNode> brNode;
-  NS_ENSURE_STATE(mEditor);
-  nsresult res = mEditor->CreateBR(inParent, inOffset, address_of(brNode));
+  NS_ENSURE_STATE(mTextEditor);
+  nsresult res = mTextEditor->CreateBR(inParent, inOffset, address_of(brNode));
   NS_ENSURE_SUCCESS(res, res);
 
   // give it special moz attr
   nsCOMPtr<nsIDOMElement> brElem = do_QueryInterface(brNode);
   if (brElem) {
-    res = mEditor->SetAttribute(brElem, NS_LITERAL_STRING("type"), NS_LITERAL_STRING("_moz"));
+    res = mTextEditor->SetAttribute(brElem, NS_LITERAL_STRING("type"),
+                                    NS_LITERAL_STRING("_moz"));
     NS_ENSURE_SUCCESS(res, res);
   }
 
   if (outBRNode) {
     brNode.forget(outBRNode);
   }
   return NS_OK;
 }
@@ -1424,47 +1438,47 @@ NS_IMETHODIMP
 TextEditRules::DocumentModified()
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 bool
 TextEditRules::IsPasswordEditor() const
 {
-  return mEditor ? mEditor->IsPasswordEditor() : false;
+  return mTextEditor ? mTextEditor->IsPasswordEditor() : false;
 }
 
 bool
 TextEditRules::IsSingleLineEditor() const
 {
-  return mEditor ? mEditor->IsSingleLineEditor() : false;
+  return mTextEditor ? mTextEditor->IsSingleLineEditor() : false;
 }
 
 bool
 TextEditRules::IsPlaintextEditor() const
 {
-  return mEditor ? mEditor->IsPlaintextEditor() : false;
+  return mTextEditor ? mTextEditor->IsPlaintextEditor() : false;
 }
 
 bool
 TextEditRules::IsReadonly() const
 {
-  return mEditor ? mEditor->IsReadonly() : false;
+  return mTextEditor ? mTextEditor->IsReadonly() : false;
 }
 
 bool
 TextEditRules::IsDisabled() const
 {
-  return mEditor ? mEditor->IsDisabled() : false;
+  return mTextEditor ? mTextEditor->IsDisabled() : false;
 }
 bool
 TextEditRules::IsMailEditor() const
 {
-  return mEditor ? mEditor->IsMailEditor() : false;
+  return mTextEditor ? mTextEditor->IsMailEditor() : false;
 }
 
 bool
 TextEditRules::DontEchoPassword() const
 {
-  return mEditor ? mEditor->DontEchoPassword() : false;
+  return mTextEditor ? mTextEditor->DontEchoPassword() : false;
 }
 
 } // namespace mozilla
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -13,21 +13,21 @@
 #include "nsIEditor.h"
 #include "nsISupportsImpl.h"
 #include "nsITimer.h"
 #include "nsString.h"
 #include "nscore.h"
 
 class nsIDOMElement;
 class nsIDOMNode;
-class nsPlaintextEditor;
 
 namespace mozilla {
 
 class AutoLockRulesSniffing;
+class TextEditor;
 namespace dom {
 class Selection;
 } // namespace dom
 
 /**
  * Object that encapsulates HTML text-specific editing rules.
  *
  * To be a good citizen, edit rules must live by these restrictions:
@@ -50,17 +50,17 @@ public:
 
   NS_DECL_NSITIMERCALLBACK
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(TextEditRules, nsIEditRules)
 
   TextEditRules();
 
   // nsIEditRules methods
-  NS_IMETHOD Init(nsPlaintextEditor* aTextEditor) override;
+  NS_IMETHOD Init(TextEditor* aTextEditor) override;
   NS_IMETHOD SetInitialValue(const nsAString& aValue) override;
   NS_IMETHOD DetachEditor() override;
   NS_IMETHOD BeforeEdit(EditAction action,
                         nsIEditor::EDirection aDirection) override;
   NS_IMETHOD AfterEdit(EditAction action,
                        nsIEditor::EDirection aDirection) override;
   NS_IMETHOD WillDoAction(Selection* aSelection, RulesInfo* aInfo,
                           bool* aCancel, bool* aHandled) override;
@@ -220,17 +220,17 @@ protected:
   bool IsSingleLineEditor() const;
   bool IsPlaintextEditor() const;
   bool IsReadonly() const;
   bool IsDisabled() const;
   bool IsMailEditor() const;
   bool DontEchoPassword() const;
 
   // Note that we do not refcount the editor.
-  nsPlaintextEditor* mEditor;
+  TextEditor* mTextEditor;
   // A buffer we use to store the real value of password editors.
   nsString mPasswordText;
   // A buffer we use to track the IME composition string.
   nsString mPasswordIMEText;
   uint32_t mPasswordIMEIndex;
   // Magic node acts as placeholder in empty doc.
   nsCOMPtr<nsIDOMNode> mBogusNode;
   // Cached selected node.
--- a/editor/libeditor/TextEditRulesBidi.cpp
+++ b/editor/libeditor/TextEditRulesBidi.cpp
@@ -1,26 +1,26 @@
 /* -*- 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/TextEditRules.h"
 
+#include "mozilla/TextEditor.h"
+#include "mozilla/dom/Selection.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsError.h"
 #include "nsFrameSelection.h"
 #include "nsIContent.h"
 #include "nsIDOMNode.h"
 #include "nsIEditor.h"
 #include "nsIPresShell.h"
-#include "mozilla/dom/Selection.h"
 #include "nsISupportsImpl.h"
-#include "nsPlaintextEditor.h"
 #include "nsPresContext.h"
 #include "nscore.h"
 
 namespace mozilla {
 
 using namespace dom;
 
 // Test for distance between caret and text that will be deleted
@@ -29,17 +29,17 @@ TextEditRules::CheckBidiLevelForDeletion
                                          nsIDOMNode* aSelNode,
                                          int32_t aSelOffset,
                                          nsIEditor::EDirection aAction,
                                          bool* aCancel)
 {
   NS_ENSURE_ARG_POINTER(aCancel);
   *aCancel = false;
 
-  nsCOMPtr<nsIPresShell> shell = mEditor->GetPresShell();
+  nsCOMPtr<nsIPresShell> shell = mTextEditor->GetPresShell();
   NS_ENSURE_TRUE(shell, NS_ERROR_NOT_INITIALIZED);
 
   nsPresContext *context = shell->GetPresContext();
   NS_ENSURE_TRUE(context, NS_ERROR_NULL_POINTER);
 
   if (!context->BidiEnabled())
     return NS_OK;
 
--- a/editor/libeditor/TextEditUtils.cpp
+++ b/editor/libeditor/TextEditUtils.cpp
@@ -1,29 +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 "TextEditUtils.h"
 
 #include "mozilla/Assertions.h"
+#include "mozilla/TextEditor.h"
 #include "mozilla/dom/Element.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsCaseTreatment.h"
 #include "nsDebug.h"
 #include "nsEditor.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNode.h"
 #include "nsNameSpaceManager.h"
 #include "nsLiteralString.h"
-#include "nsPlaintextEditor.h"
 #include "nsString.h"
 
 namespace mozilla {
 
 /******************************************************************************
  * TextEditUtils
  ******************************************************************************/
 
@@ -89,19 +89,18 @@ TextEditUtils::HasMozAttr(nsIDOMNode* aN
   nsresult rv = element->GetAttribute(NS_LITERAL_STRING("type"), typeAttrVal);
   return NS_SUCCEEDED(rv) && typeAttrVal.LowerCaseEqualsLiteral("_moz");
 }
 
 /******************************************************************************
  * AutoEditInitRulesTrigger
  ******************************************************************************/
 
-AutoEditInitRulesTrigger::AutoEditInitRulesTrigger(
-                            nsPlaintextEditor* aTextEditor,
-                            nsresult& aResult)
+AutoEditInitRulesTrigger::AutoEditInitRulesTrigger(TextEditor* aTextEditor,
+                                                   nsresult& aResult)
   : mTextEditor(aTextEditor)
   , mResult(aResult)
 {
   if (mTextEditor) {
     mTextEditor->BeginEditorInit();
   }
 }
 
--- a/editor/libeditor/TextEditUtils.h
+++ b/editor/libeditor/TextEditUtils.h
@@ -5,20 +5,21 @@
 
 #ifndef TextEditUtils_h
 #define TextEditUtils_h
 
 #include "nscore.h"
 
 class nsIDOMNode;
 class nsINode;
-class nsPlaintextEditor;
 
 namespace mozilla {
 
+class TextEditor;
+
 class TextEditUtils final
 {
 public:
   // from TextEditRules:
   static bool IsBody(nsIDOMNode* aNode);
   static bool IsBreak(nsIDOMNode* aNode);
   static bool IsBreak(nsINode* aNode);
   static bool IsMozBR(nsIDOMNode* aNode);
@@ -28,19 +29,19 @@ public:
 
 /***************************************************************************
  * stack based helper class for detecting end of editor initialization, in
  * order to trigger "end of init" initialization of the edit rules.
  */
 class AutoEditInitRulesTrigger final
 {
 private:
-  nsPlaintextEditor* mTextEditor;
+  TextEditor* mTextEditor;
   nsresult& mResult;
 
 public:
-  AutoEditInitRulesTrigger(nsPlaintextEditor* aTextEditor, nsresult& aResult);
+  AutoEditInitRulesTrigger(TextEditor* aTextEditor, nsresult& aResult);
   ~AutoEditInitRulesTrigger();
 };
 
 } // naemspace mozilla
 
 #endif // #ifndef TextEditUtils_h
rename from editor/libeditor/nsPlaintextEditor.cpp
rename to editor/libeditor/TextEditor.cpp
--- a/editor/libeditor/nsPlaintextEditor.cpp
+++ b/editor/libeditor/TextEditor.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 "nsPlaintextEditor.h"
+#include "mozilla/TextEditor.h"
 
 #include "EditorUtils.h"  // AutoEditBatch, AutoRules
 #include "InternetCiter.h"
 #include "TextEditUtils.h"
 #include "gfxFontUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/mozalloc.h"
 #include "mozilla/Preferences.h"
@@ -57,73 +57,73 @@
 #include "nsSubstringTuple.h"
 #include "nsUnicharUtils.h"
 #include "nsXPCOM.h"
 
 class nsIOutputStream;
 class nsISupports;
 class nsISupportsArray;
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
-nsPlaintextEditor::nsPlaintextEditor()
-: nsEditor()
-, mRules(nullptr)
-, mWrapColumn(0)
-, mMaxTextLength(-1)
-, mInitTriggerCounter(0)
-, mNewlineHandling(nsIPlaintextEditor::eNewlinesPasteToFirst)
+TextEditor::TextEditor()
+  : mWrapColumn(0)
+  , mMaxTextLength(-1)
+  , mInitTriggerCounter(0)
+  , mNewlineHandling(nsIPlaintextEditor::eNewlinesPasteToFirst)
 #ifdef XP_WIN
-, mCaretStyle(1)
+  , mCaretStyle(1)
 #else
-, mCaretStyle(0)
+  , mCaretStyle(0)
 #endif
 {
   // check the "single line editor newline handling"
   // and "caret behaviour in selection" prefs
   GetDefaultEditorPrefs(mNewlineHandling, mCaretStyle);
 }
 
-nsPlaintextEditor::~nsPlaintextEditor()
+TextEditor::~TextEditor()
 {
   // Remove event listeners. Note that if we had an HTML editor,
   //  it installed its own instead of these
   RemoveEventListeners();
 
   if (mRules)
     mRules->DetachEditor();
 }
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsPlaintextEditor)
+NS_IMPL_CYCLE_COLLECTION_CLASS(TextEditor)
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsPlaintextEditor, nsEditor)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(TextEditor, nsEditor)
   if (tmp->mRules)
     tmp->mRules->DetachEditor();
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mRules)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsPlaintextEditor, nsEditor)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(TextEditor, nsEditor)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRules)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_ADDREF_INHERITED(nsPlaintextEditor, nsEditor)
-NS_IMPL_RELEASE_INHERITED(nsPlaintextEditor, nsEditor)
+NS_IMPL_ADDREF_INHERITED(TextEditor, nsEditor)
+NS_IMPL_RELEASE_INHERITED(TextEditor, nsEditor)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsPlaintextEditor)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TextEditor)
   NS_INTERFACE_MAP_ENTRY(nsIPlaintextEditor)
   NS_INTERFACE_MAP_ENTRY(nsIEditorMailSupport)
 NS_INTERFACE_MAP_END_INHERITING(nsEditor)
 
 
-NS_IMETHODIMP nsPlaintextEditor::Init(nsIDOMDocument *aDoc,
-                                      nsIContent *aRoot,
-                                      nsISelectionController *aSelCon,
-                                      uint32_t aFlags,
-                                      const nsAString& aInitialValue)
+NS_IMETHODIMP
+TextEditor::Init(nsIDOMDocument* aDoc,
+                 nsIContent* aRoot,
+                 nsISelectionController* aSelCon,
+                 uint32_t aFlags,
+                 const nsAString& aInitialValue)
 {
   NS_PRECONDITION(aDoc, "bad arg");
   NS_ENSURE_TRUE(aDoc, NS_ERROR_NULL_POINTER);
 
   nsresult res = NS_OK, rulesRes = NS_OK;
   if (mRules) {
     mRules->DetachEditor();
   }
@@ -146,17 +146,17 @@ NS_IMETHODIMP nsPlaintextEditor::Init(ns
 
   return res;
 }
 
 static int32_t sNewlineHandlingPref = -1,
                sCaretStylePref = -1;
 
 static void
-EditorPrefsChangedCallback(const char *aPrefName, void *)
+EditorPrefsChangedCallback(const char* aPrefName, void *)
 {
   if (nsCRT::strcmp(aPrefName, "editor.singleLine.pasteNewlines") == 0) {
     sNewlineHandlingPref =
       Preferences::GetInt("editor.singleLine.pasteNewlines",
                           nsIPlaintextEditor::eNewlinesPasteToFirst);
   } else if (nsCRT::strcmp(aPrefName, "layout.selection.caret_style") == 0) {
     sCaretStylePref = Preferences::GetInt("layout.selection.caret_style",
 #ifdef XP_WIN
@@ -166,40 +166,40 @@ EditorPrefsChangedCallback(const char *a
 #else
                                                  0);
 #endif
   }
 }
 
 // static
 void
-nsPlaintextEditor::GetDefaultEditorPrefs(int32_t &aNewlineHandling,
-                                         int32_t &aCaretStyle)
+TextEditor::GetDefaultEditorPrefs(int32_t& aNewlineHandling,
+                                  int32_t& aCaretStyle)
 {
   if (sNewlineHandlingPref == -1) {
     Preferences::RegisterCallback(EditorPrefsChangedCallback,
                                   "editor.singleLine.pasteNewlines");
     EditorPrefsChangedCallback("editor.singleLine.pasteNewlines", nullptr);
     Preferences::RegisterCallback(EditorPrefsChangedCallback,
                                   "layout.selection.caret_style");
     EditorPrefsChangedCallback("layout.selection.caret_style", nullptr);
   }
 
   aNewlineHandling = sNewlineHandlingPref;
   aCaretStyle = sCaretStylePref;
 }
 
 void
-nsPlaintextEditor::BeginEditorInit()
+TextEditor::BeginEditorInit()
 {
   mInitTriggerCounter++;
 }
 
 nsresult
-nsPlaintextEditor::EndEditorInit()
+TextEditor::EndEditorInit()
 {
   nsresult res = NS_OK;
   NS_PRECONDITION(mInitTriggerCounter > 0, "ended editor init before we began?");
   mInitTriggerCounter--;
   if (mInitTriggerCounter == 0)
   {
     res = InitRules();
     if (NS_SUCCEEDED(res)) {
@@ -208,17 +208,17 @@ nsPlaintextEditor::EndEditorInit()
       EnableUndo(false);
       EnableUndo(true);
     }
   }
   return res;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::SetDocumentCharacterSet(const nsACString& characterSet)
+TextEditor::SetDocumentCharacterSet(const nsACString& characterSet)
 {
   nsresult rv = nsEditor::SetDocumentCharacterSet(characterSet);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Update META charset element.
   nsCOMPtr<nsIDOMDocument> domdoc = GetDOMDocument();
   NS_ENSURE_TRUE(domdoc, NS_ERROR_NOT_INITIALIZED);
 
@@ -257,18 +257,18 @@ nsPlaintextEditor::SetDocumentCharacterS
   metaElement->SetAttr(kNameSpaceID_None, nsGkAtoms::content,
                        NS_LITERAL_STRING("text/html;charset=") +
                          NS_ConvertASCIItoUTF16(characterSet),
                        true);
   return NS_OK;
 }
 
 bool
-nsPlaintextEditor::UpdateMetaCharset(nsIDOMDocument* aDocument,
-                                     const nsACString& aCharacterSet)
+TextEditor::UpdateMetaCharset(nsIDOMDocument* aDocument,
+                              const nsACString& aCharacterSet)
 {
   MOZ_ASSERT(aDocument);
   // get a list of META tags
   nsCOMPtr<nsIDOMNodeList> list;
   nsresult rv = aDocument->GetElementsByTagName(NS_LITERAL_STRING("meta"),
                                                 getter_AddRefs(list));
   NS_ENSURE_SUCCESS(rv, false);
   NS_ENSURE_TRUE(list, false);
@@ -313,44 +313,46 @@ nsPlaintextEditor::UpdateMetaCharset(nsI
                                 Substring(originalStart, start) +
                                   charsetEquals +
                                   NS_ConvertASCIItoUTF16(aCharacterSet));
     return NS_SUCCEEDED(rv);
   }
   return false;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::InitRules()
+NS_IMETHODIMP
+TextEditor::InitRules()
 {
   if (!mRules) {
     // instantiate the rules for this text editor
     mRules = new TextEditRules();
   }
   return mRules->Init(this);
 }
 
 
 NS_IMETHODIMP
-nsPlaintextEditor::GetIsDocumentEditable(bool *aIsDocumentEditable)
+TextEditor::GetIsDocumentEditable(bool* aIsDocumentEditable)
 {
   NS_ENSURE_ARG_POINTER(aIsDocumentEditable);
 
   nsCOMPtr<nsIDOMDocument> doc = GetDOMDocument();
   *aIsDocumentEditable = doc && IsModifiable();
 
   return NS_OK;
 }
 
-bool nsPlaintextEditor::IsModifiable()
+bool
+TextEditor::IsModifiable()
 {
   return !IsReadonly();
 }
 
 nsresult
-nsPlaintextEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
+TextEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
 {
   // NOTE: When you change this method, you should also change:
   //   * editor/libeditor/tests/test_texteditor_keyevent_handling.html
   //   * editor/libeditor/tests/test_htmleditor_keyevent_handling.html
   //
   // And also when you add new key handling, you need to change the subclass's
   // HandleKeyPressEvent()'s switch statement.
 
@@ -415,50 +417,50 @@ nsPlaintextEditor::HandleKeyPressEvent(n
 
 /* 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
-nsPlaintextEditor::TypedText(const nsAString& aString, ETypingAction aAction)
+TextEditor::TypedText(const nsAString& aString, ETypingAction aAction)
 {
   AutoPlaceHolderBatch batch(this, nsGkAtoms::TypingTxnName);
 
   switch (aAction) {
     case eTypedText:
       return InsertText(aString);
     case eTypedBreak:
       return InsertLineBreak();
     default:
       // eTypedBR is only for HTML
       return NS_ERROR_FAILURE;
   }
 }
 
 Element*
-nsPlaintextEditor::CreateBRImpl(nsCOMPtr<nsINode>* aInOutParent,
-                                int32_t* aInOutOffset,
-                                EDirection aSelect)
+TextEditor::CreateBRImpl(nsCOMPtr<nsINode>* aInOutParent,
+                         int32_t* aInOutOffset,
+                         EDirection aSelect)
 {
   nsCOMPtr<nsIDOMNode> parent(GetAsDOMNode(*aInOutParent));
   nsCOMPtr<nsIDOMNode> br;
   // We ignore the retval, and assume it's fine if the br is non-null
   CreateBRImpl(address_of(parent), aInOutOffset, address_of(br), aSelect);
   *aInOutParent = do_QueryInterface(parent);
   nsCOMPtr<Element> ret(do_QueryInterface(br));
   return ret;
 }
 
 nsresult
-nsPlaintextEditor::CreateBRImpl(nsCOMPtr<nsIDOMNode>* aInOutParent,
-                                int32_t* aInOutOffset,
-                                nsCOMPtr<nsIDOMNode>* outBRNode,
-                                EDirection aSelect)
+TextEditor::CreateBRImpl(nsCOMPtr<nsIDOMNode>* aInOutParent,
+                         int32_t* aInOutOffset,
+                         nsCOMPtr<nsIDOMNode>* outBRNode,
+                         EDirection aSelect)
 {
   NS_ENSURE_TRUE(aInOutParent && *aInOutParent && aInOutOffset && outBRNode, NS_ERROR_NULL_POINTER);
   *outBRNode = nullptr;
   nsresult res;
 
   // we need to insert a br.  unfortunately, we may have to split a text node to do it.
   nsCOMPtr<nsIDOMNode> node = *aInOutParent;
   int32_t theOffset = *aInOutOffset;
@@ -521,25 +523,29 @@ nsPlaintextEditor::CreateBRImpl(nsCOMPtr
       selection->SetInterlinePosition(true);
       res = selection->Collapse(parent, offset);
     }
   }
   return NS_OK;
 }
 
 
-NS_IMETHODIMP nsPlaintextEditor::CreateBR(nsIDOMNode *aNode, int32_t aOffset, nsCOMPtr<nsIDOMNode> *outBRNode, EDirection aSelect)
+NS_IMETHODIMP
+TextEditor::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);
 }
 
 nsresult
-nsPlaintextEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
+TextEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
 {
   NS_ENSURE_TRUE(outBRNode, NS_ERROR_NULL_POINTER);
   *outBRNode = nullptr;
 
   // calling it text insertion to trigger moz br treatment by rules
   AutoRules beginRulesSniffing(this, EditAction::insertText, nsIEditor::eNext);
 
   RefPtr<Selection> selection = GetSelection();
@@ -561,18 +567,18 @@ nsPlaintextEditor::InsertBR(nsCOMPtr<nsI
 
   // position selection after br
   selNode = GetNodeLocation(*outBRNode, &selOffset);
   selection->SetInterlinePosition(true);
   return selection->Collapse(selNode, selOffset+1);
 }
 
 nsresult
-nsPlaintextEditor::ExtendSelectionForDelete(Selection* aSelection,
-                                            nsIEditor::EDirection *aAction)
+TextEditor::ExtendSelectionForDelete(Selection* aSelection,
+                                     nsIEditor::EDirection* aAction)
 {
   nsresult result = NS_OK;
 
   bool bCollapsed = aSelection->Collapsed();
 
   if (*aAction == eNextWord || *aAction == ePreviousWord
       || (*aAction == eNext && bCollapsed)
       || (*aAction == ePrevious && bCollapsed)
@@ -641,18 +647,18 @@ nsPlaintextEditor::ExtendSelectionForDel
         result = NS_OK;
         break;
     }
   }
   return result;
 }
 
 nsresult
-nsPlaintextEditor::DeleteSelection(EDirection aAction,
-                                   EStripWrappers aStripWrappers)
+TextEditor::DeleteSelection(EDirection aAction,
+                            EStripWrappers aStripWrappers)
 {
   MOZ_ASSERT(aStripWrappers == eStrip || aStripWrappers == eNoStrip);
 
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
@@ -700,17 +706,18 @@ nsPlaintextEditor::DeleteSelection(EDire
   {
     // post-process
     result = mRules->DidDoAction(selection, &ruleInfo, result);
   }
 
   return result;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
+NS_IMETHODIMP
+TextEditor::InsertText(const nsAString& aStringToInsert)
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   EditAction opID = EditAction::insertText;
   if (ShouldHandleIMEComposition()) {
@@ -741,17 +748,18 @@ NS_IMETHODIMP nsPlaintextEditor::InsertT
   if (!cancel)
   {
     // post-process
     res = mRules->DidDoAction(selection, &ruleInfo, res);
   }
   return res;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
+NS_IMETHODIMP
+TextEditor::InsertLineBreak()
 {
   if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   AutoEditBatch beginBatching(this);
   AutoRules beginRulesSniffing(this, EditAction::insertBreak, nsIEditor::eNext);
@@ -818,34 +826,34 @@ NS_IMETHODIMP nsPlaintextEditor::InsertL
     // post-process, always called if WillInsertBreak didn't return cancel==true
     res = mRules->DidDoAction(selection, &ruleInfo, res);
   }
 
   return res;
 }
 
 nsresult
-nsPlaintextEditor::BeginIMEComposition(WidgetCompositionEvent* aEvent)
+TextEditor::BeginIMEComposition(WidgetCompositionEvent* aEvent)
 {
   NS_ENSURE_TRUE(!mComposition, NS_OK);
 
   if (IsPasswordEditor()) {
     NS_ENSURE_TRUE(mRules, NS_ERROR_NULL_POINTER);
     // Protect the edit rules object from dying
     nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
     TextEditRules* textEditRules = static_cast<TextEditRules*>(mRules.get());
     textEditRules->ResetIMETextPWBuf();
   }
 
   return nsEditor::BeginIMEComposition(aEvent);
 }
 
 nsresult
-nsPlaintextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent)
+TextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent)
 {
   MOZ_ASSERT(aDOMTextEvent, "aDOMTextEvent must not be nullptr");
 
   WidgetCompositionEvent* compositionChangeEvent =
     aDOMTextEvent->WidgetEventPtr()->AsCompositionEvent();
   NS_ENSURE_TRUE(compositionChangeEvent, NS_ERROR_INVALID_ARG);
   MOZ_ASSERT(compositionChangeEvent->mMessage == eCompositionChange,
              "The internal event should be eCompositionChange");
@@ -894,37 +902,37 @@ nsPlaintextEditor::UpdateIMEComposition(
   if (!compositionChangeEvent->IsFollowedByCompositionEnd()) {
     NotifyEditorObservers(eNotifyEditorObserversOfEnd);
   }
 
   return rv;
 }
 
 already_AddRefed<nsIContent>
-nsPlaintextEditor::GetInputEventTargetContent()
+TextEditor::GetInputEventTargetContent()
 {
   nsCOMPtr<nsIContent> target = do_QueryInterface(mEventTarget);
   return target.forget();
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::GetDocumentIsEmpty(bool *aDocumentIsEmpty)
+TextEditor::GetDocumentIsEmpty(bool* aDocumentIsEmpty)
 {
   NS_ENSURE_TRUE(aDocumentIsEmpty, NS_ERROR_NULL_POINTER);
 
   NS_ENSURE_TRUE(mRules, NS_ERROR_NOT_INITIALIZED);
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   return mRules->DocumentIsEmpty(aDocumentIsEmpty);
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::GetTextLength(int32_t *aCount)
+TextEditor::GetTextLength(int32_t* aCount)
 {
   NS_ASSERTION(aCount, "null pointer");
 
   // initialize out params
   *aCount = 0;
 
   // special-case for empty document, to account for the bogus node
   bool docEmpty;
@@ -952,35 +960,32 @@ nsPlaintextEditor::GetTextLength(int32_t
     }
   }
 
   *aCount = totalLength;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::SetMaxTextLength(int32_t aMaxTextLength)
+TextEditor::SetMaxTextLength(int32_t aMaxTextLength)
 {
   mMaxTextLength = aMaxTextLength;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::GetMaxTextLength(int32_t* aMaxTextLength)
+TextEditor::GetMaxTextLength(int32_t* aMaxTextLength)
 {
   NS_ENSURE_TRUE(aMaxTextLength, NS_ERROR_INVALID_POINTER);
   *aMaxTextLength = mMaxTextLength;
   return NS_OK;
 }
 
-//
-// Get the wrap width
-//
 NS_IMETHODIMP
-nsPlaintextEditor::GetWrapWidth(int32_t *aWrapColumn)
+TextEditor::GetWrapWidth(int32_t* aWrapColumn)
 {
   NS_ENSURE_TRUE( aWrapColumn, NS_ERROR_NULL_POINTER);
 
   *aWrapColumn = mWrapColumn;
   return NS_OK;
 }
 
 //
@@ -996,21 +1001,18 @@ static void CutStyle(const char* stylena
     int32_t styleEnd = styleValue.Find(";", false, styleStart);
     if (styleEnd > styleStart)
       styleValue.Cut(styleStart, styleEnd - styleStart + 1);
     else
       styleValue.Cut(styleStart, styleValue.Length() - styleStart);
   }
 }
 
-//
-// Change the wrap width on the root of this document.
-//
 NS_IMETHODIMP
-nsPlaintextEditor::SetWrapWidth(int32_t aWrapColumn)
+TextEditor::SetWrapWidth(int32_t aWrapColumn)
 {
   SetWrapColumn(aWrapColumn);
 
   // Make sure we're a plaintext editor, otherwise we shouldn't
   // do the rest of this.
   if (!IsPlaintextEditor())
     return NS_OK;
 
@@ -1053,47 +1055,41 @@ nsPlaintextEditor::SetWrapWidth(int32_t 
   } else {
     styleValue.AppendLiteral("white-space: pre;");
   }
 
   return rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::style, styleValue, true);
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::SetWrapColumn(int32_t aWrapColumn)
+TextEditor::SetWrapColumn(int32_t aWrapColumn)
 {
   mWrapColumn = aWrapColumn;
   return NS_OK;
 }
 
-//
-// Get the newline handling for this editor
-//
 NS_IMETHODIMP
-nsPlaintextEditor::GetNewlineHandling(int32_t *aNewlineHandling)
+TextEditor::GetNewlineHandling(int32_t* aNewlineHandling)
 {
   NS_ENSURE_ARG_POINTER(aNewlineHandling);
 
   *aNewlineHandling = mNewlineHandling;
   return NS_OK;
 }
 
-//
-// Change the newline handling for this editor
-//
 NS_IMETHODIMP
-nsPlaintextEditor::SetNewlineHandling(int32_t aNewlineHandling)
+TextEditor::SetNewlineHandling(int32_t aNewlineHandling)
 {
   mNewlineHandling = aNewlineHandling;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::Undo(uint32_t aCount)
+TextEditor::Undo(uint32_t aCount)
 {
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   AutoUpdateViewBatch beginViewBatching(this);
 
   ForceCompositionEnd();
 
@@ -1112,17 +1108,17 @@ nsPlaintextEditor::Undo(uint32_t aCount)
     result = mRules->DidDoAction(selection, &ruleInfo, result);
   }
 
   NotifyEditorObservers(eNotifyEditorObserversOfEnd);
   return result;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::Redo(uint32_t aCount)
+TextEditor::Redo(uint32_t aCount)
 {
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   AutoUpdateViewBatch beginViewBatching(this);
 
   ForceCompositionEnd();
 
@@ -1141,34 +1137,34 @@ nsPlaintextEditor::Redo(uint32_t aCount)
     result = mRules->DidDoAction(selection, &ruleInfo, result);
   }
 
   NotifyEditorObservers(eNotifyEditorObserversOfEnd);
   return result;
 }
 
 bool
-nsPlaintextEditor::CanCutOrCopy(PasswordFieldAllowed aPasswordFieldAllowed)
+TextEditor::CanCutOrCopy(PasswordFieldAllowed aPasswordFieldAllowed)
 {
   RefPtr<Selection> selection = GetSelection();
   if (!selection) {
     return false;
   }
 
   if (aPasswordFieldAllowed == ePasswordFieldNotAllowed &&
       IsPasswordEditor())
     return false;
 
   return !selection->Collapsed();
 }
 
 bool
-nsPlaintextEditor::FireClipboardEvent(EventMessage aEventMessage,
-                                      int32_t aSelectionType,
-                                      bool* aActionTaken)
+TextEditor::FireClipboardEvent(EventMessage aEventMessage,
+                               int32_t aSelectionType,
+                               bool* aActionTaken)
 {
   if (aEventMessage == ePaste) {
     ForceCompositionEnd();
   }
 
   nsCOMPtr<nsIPresShell> presShell = GetPresShell();
   NS_ENSURE_TRUE(presShell, false);
 
@@ -1182,66 +1178,71 @@ nsPlaintextEditor::FireClipboardEvent(Ev
     return false;
   }
 
   // If the event handler caused the editor to be destroyed, return false.
   // Otherwise return true to indicate that the event was not cancelled.
   return !mDidPreDestroy;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::Cut()
+NS_IMETHODIMP
+TextEditor::Cut()
 {
   bool actionTaken = false;
   if (FireClipboardEvent(eCut, nsIClipboard::kGlobalClipboard, &actionTaken)) {
     DeleteSelection(eNone, eStrip);
   }
   return actionTaken ? NS_OK : NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanCut(bool *aCanCut)
+NS_IMETHODIMP
+TextEditor::CanCut(bool* aCanCut)
 {
   NS_ENSURE_ARG_POINTER(aCanCut);
   // Cut is always enabled in HTML documents
   nsCOMPtr<nsIDocument> doc = GetDocument();
   *aCanCut = (doc && doc->IsHTMLOrXHTML()) ||
     (IsModifiable() && CanCutOrCopy(ePasswordFieldNotAllowed));
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::Copy()
+NS_IMETHODIMP
+TextEditor::Copy()
 {
   bool actionTaken = false;
   FireClipboardEvent(eCopy, nsIClipboard::kGlobalClipboard, &actionTaken);
 
   return actionTaken ? NS_OK : NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanCopy(bool *aCanCopy)
+NS_IMETHODIMP
+TextEditor::CanCopy(bool* aCanCopy)
 {
   NS_ENSURE_ARG_POINTER(aCanCopy);
   // Copy is always enabled in HTML documents
   nsCOMPtr<nsIDocument> doc = GetDocument();
   *aCanCopy = (doc && doc->IsHTMLOrXHTML()) ||
     CanCutOrCopy(ePasswordFieldNotAllowed);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanDelete(bool *aCanDelete)
+NS_IMETHODIMP
+TextEditor::CanDelete(bool* aCanDelete)
 {
   NS_ENSURE_ARG_POINTER(aCanDelete);
   *aCanDelete = IsModifiable() && CanCutOrCopy(ePasswordFieldAllowed);
   return NS_OK;
 }
 
 // Shared between OutputToString and OutputToStream
 NS_IMETHODIMP
-nsPlaintextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
-                                        uint32_t aFlags,
-                                        const nsACString& aCharset,
-                                        nsIDocumentEncoder** encoder)
+TextEditor::GetAndInitDocEncoder(const nsAString& aFormatType,
+                                 uint32_t aFlags,
+                                 const nsACString& aCharset,
+                                 nsIDocumentEncoder** encoder)
 {
   nsresult rv = NS_OK;
 
   nsAutoCString formatType(NS_DOC_ENCODER_CONTRACTID_BASE);
   LossyAppendUTF16toASCII(aFormatType, formatType);
   nsCOMPtr<nsIDocumentEncoder> docEncoder (do_CreateInstance(formatType.get(), &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -1283,19 +1284,19 @@ nsPlaintextEditor::GetAndInitDocEncoder(
   }
 
   docEncoder.forget(encoder);
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsPlaintextEditor::OutputToString(const nsAString& aFormatType,
-                                  uint32_t aFlags,
-                                  nsAString& aOutputString)
+TextEditor::OutputToString(const nsAString& aFormatType,
+                           uint32_t aFlags,
+                           nsAString& aOutputString)
 {
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   nsString resultString;
   TextRulesInfo ruleInfo(EditAction::outputText);
   ruleInfo.outString = &resultString;
   // XXX Struct should store a nsAReadable*
@@ -1317,20 +1318,20 @@ nsPlaintextEditor::OutputToString(const 
 
   nsCOMPtr<nsIDocumentEncoder> encoder;
   rv = GetAndInitDocEncoder(aFormatType, aFlags, charsetStr, getter_AddRefs(encoder));
   NS_ENSURE_SUCCESS(rv, rv);
   return encoder->EncodeToString(aOutputString);
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream,
-                             const nsAString& aFormatType,
-                             const nsACString& aCharset,
-                             uint32_t aFlags)
+TextEditor::OutputToStream(nsIOutputStream* aOutputStream,
+                           const nsAString& aFormatType,
+                           const nsACString& aCharset,
+                           uint32_t aFlags)
 {
   nsresult rv;
 
   // special-case for empty document when requesting plain text,
   // to account for the bogus text node.
   // XXX Should there be a similar test in OutputToString?
   if (aFormatType.EqualsLiteral("text/plain"))
   {
@@ -1347,23 +1348,23 @@ nsPlaintextEditor::OutputToStream(nsIOut
                             getter_AddRefs(encoder));
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   return encoder->EncodeToStream(aOutputStream);
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::InsertTextWithQuotations(const nsAString &aStringToInsert)
+TextEditor::InsertTextWithQuotations(const nsAString& aStringToInsert)
 {
   return InsertText(aStringToInsert);
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::PasteAsQuotation(int32_t aSelectionType)
+TextEditor::PasteAsQuotation(int32_t aSelectionType)
 {
   // Get Clipboard Service
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the nsITransferable interface for getting the data from the clipboard
   nsCOMPtr<nsITransferable> trans;
@@ -1400,18 +1401,18 @@ nsPlaintextEditor::PasteAsQuotation(int3
     }
     free(flav);
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText,
-                                     nsIDOMNode **aNodeInserted)
+TextEditor::InsertAsQuotation(const nsAString& aQuotedText,
+                              nsIDOMNode** aNodeInserted)
 {
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   // Let the citer quote it for us:
   nsString quotedStuff;
   nsresult rv = InternetCiter::GetCiteString(aQuotedText, quotedStuff);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1444,50 +1445,50 @@ nsPlaintextEditor::InsertAsQuotation(con
       *aNodeInserted = 0;
       //NS_IF_ADDREF(*aNodeInserted);
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::PasteAsCitedQuotation(const nsAString& aCitation,
-                                         int32_t aSelectionType)
+TextEditor::PasteAsCitedQuotation(const nsAString& aCitation,
+                                  int32_t aSelectionType)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
-                                          const nsAString& aCitation,
-                                          bool aInsertHTML,
-                                          nsIDOMNode **aNodeInserted)
+TextEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
+                                   const nsAString& aCitation,
+                                   bool aInsertHTML,
+                                   nsIDOMNode** aNodeInserted)
 {
   return InsertAsQuotation(aQuotedText, aNodeInserted);
 }
 
 nsresult
-nsPlaintextEditor::SharedOutputString(uint32_t aFlags,
-                                      bool* aIsCollapsed,
-                                      nsAString& aResult)
+TextEditor::SharedOutputString(uint32_t aFlags,
+                               bool* aIsCollapsed,
+                               nsAString& aResult)
 {
   RefPtr<Selection> selection = GetSelection();
   NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
 
   *aIsCollapsed = selection->Collapsed();
 
   if (!*aIsCollapsed)
     aFlags |= nsIDocumentEncoder::OutputSelectionOnly;
   // If the selection isn't collapsed, we'll use the whole document.
 
   return OutputToString(NS_LITERAL_STRING("text/plain"), aFlags, aResult);
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::Rewrap(bool aRespectNewlines)
+TextEditor::Rewrap(bool aRespectNewlines)
 {
   int32_t wrapCol;
   nsresult rv = GetWrapWidth(&wrapCol);
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
   // Rewrap makes no sense if there's no wrap column; default to 72.
   if (wrapCol <= 0)
     wrapCol = 72;
@@ -1507,17 +1508,17 @@ nsPlaintextEditor::Rewrap(bool aRespectN
 
   if (isCollapsed)    // rewrap the whole document
     SelectAll();
 
   return InsertTextWithQuotations(wrapped);
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::StripCites()
+TextEditor::StripCites()
 {
   nsAutoString current;
   bool isCollapsed;
   nsresult rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted,
                                    &isCollapsed, current);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString stripped;
@@ -1529,56 +1530,57 @@ nsPlaintextEditor::StripCites()
     rv = SelectAll();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return InsertText(stripped);
 }
 
 NS_IMETHODIMP
-nsPlaintextEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
+TextEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
 {
   *aNodeList = 0;
   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
-nsPlaintextEditor::StartOperation(EditAction opID,
-                                  nsIEditor::EDirection aDirection)
+TextEditor::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
-nsPlaintextEditor::EndOperation()
+TextEditor::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;
 }
 
-
 nsresult
-nsPlaintextEditor::SelectEntireDocument(Selection* aSelection)
+TextEditor::SelectEntireDocument(Selection* aSelection)
 {
   if (!aSelection || !mRules) { return NS_ERROR_NULL_POINTER; }
 
   // Protect the edit rules object from dying
   nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
 
   // is doc empty?
   bool bDocIsEmpty;
@@ -1609,32 +1611,34 @@ nsPlaintextEditor::SelectEntireDocument(
     nsCOMPtr<nsIDOMNode> parentNode = GetNodeLocation(childNode, &parentOffset);
 
     return aSelection->Extend(parentNode, parentOffset);
   }
 
   return NS_OK;
 }
 
-already_AddRefed<mozilla::dom::EventTarget>
-nsPlaintextEditor::GetDOMEventTarget()
+already_AddRefed<EventTarget>
+TextEditor::GetDOMEventTarget()
 {
-  nsCOMPtr<mozilla::dom::EventTarget> copy = mEventTarget;
+  nsCOMPtr<EventTarget> copy = mEventTarget;
   return copy.forget();
 }
 
 
 nsresult
-nsPlaintextEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
-                                            const nsAString & aAttribute,
-                                            const nsAString & aValue,
-                                            bool aSuppressTransaction)
+TextEditor::SetAttributeOrEquivalent(nsIDOMElement* aElement,
+                                     const nsAString& aAttribute,
+                                     const nsAString& aValue,
+                                     bool aSuppressTransaction)
 {
   return nsEditor::SetAttribute(aElement, aAttribute, aValue);
 }
 
 nsresult
-nsPlaintextEditor::RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
-                                               const nsAString & aAttribute,
-                                               bool aSuppressTransaction)
+TextEditor::RemoveAttributeOrEquivalent(nsIDOMElement* aElement,
+                                        const nsAString& aAttribute,
+                                        bool aSuppressTransaction)
 {
   return nsEditor::RemoveAttribute(aElement, aAttribute);
 }
+
+} // namespace mozilla
rename from editor/libeditor/nsPlaintextEditor.h
rename to editor/libeditor/TextEditor.h
--- a/editor/libeditor/nsPlaintextEditor.h
+++ b/editor/libeditor/TextEditor.h
@@ -1,15 +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/. */
 
-#ifndef nsPlaintextEditor_h__
-#define nsPlaintextEditor_h__
+#ifndef mozilla_TextEditor_h
+#define mozilla_TextEditor_h
 
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsEditor.h"
 #include "nsIEditor.h"
 #include "nsIEditorMailSupport.h"
 #include "nsIPlaintextEditor.h"
 #include "nsISupportsImpl.h"
@@ -23,214 +23,223 @@ class nsIDOMKeyEvent;
 class nsIDOMNode;
 class nsIDocumentEncoder;
 class nsIEditRules;
 class nsIOutputStream;
 class nsISelectionController;
 class nsITransferable;
 
 namespace mozilla {
+
 class AutoEditInitRulesTrigger;
 class HTMLEditRules;
 class TextEditRules;
 namespace dom {
 class Selection;
 } // namespace dom
-} // namespace mozilla
 
 /**
  * The text editor implementation.
  * Use to edit text document represented as a DOM tree.
  */
-class nsPlaintextEditor : public nsEditor,
-                          public nsIPlaintextEditor,
-                          public nsIEditorMailSupport
+class TextEditor : public nsEditor
+                 , public nsIPlaintextEditor
+                 , public nsIEditorMailSupport
 {
-
 public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextEditor, nsEditor)
 
-// 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(nsPlaintextEditor, nsEditor)
-
-  /* below used by TypedText() */
-  enum ETypingAction {
+  enum ETypingAction
+  {
     eTypedText,  /* user typed text */
     eTypedBR,    /* user typed shift-enter to get a br */
     eTypedBreak  /* user typed enter */
   };
 
-  nsPlaintextEditor();
+  TextEditor();
 
-  /* ------------ nsIPlaintextEditor methods -------------- */
+  // nsIPlaintextEditor methods
   NS_DECL_NSIPLAINTEXTEDITOR
 
-  /* ------------ nsIEditorMailSupport overrides -------------- */
+  // nsIEditorMailSupport overrides
   NS_DECL_NSIEDITORMAILSUPPORT
 
-  /* ------------ Overrides of nsEditor interface methods -------------- */
-  NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
-                                      const nsAString & aAttribute,
-                                      const nsAString & aValue,
+  // Overrides of nsEditor interface methods
+  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;
 
-  /** 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 GetDocumentIsEmpty(bool *aDocumentIsEmpty) override;
-  NS_IMETHOD GetIsDocumentEditable(bool *aIsDocumentEditable) override;
+  NS_IMETHOD GetDocumentIsEmpty(bool* aDocumentIsEmpty) override;
+  NS_IMETHOD GetIsDocumentEditable(bool* aIsDocumentEditable) override;
 
   NS_IMETHOD DeleteSelection(EDirection aAction,
                              EStripWrappers aStripWrappers) override;
 
-  NS_IMETHOD SetDocumentCharacterSet(const nsACString & characterSet) override;
+  NS_IMETHOD SetDocumentCharacterSet(const nsACString& characterSet) override;
 
   NS_IMETHOD Undo(uint32_t aCount) override;
   NS_IMETHOD Redo(uint32_t aCount) override;
 
   NS_IMETHOD Cut() override;
-  NS_IMETHOD CanCut(bool *aCanCut) override;
+  NS_IMETHOD CanCut(bool* aCanCut) override;
   NS_IMETHOD Copy() override;
-  NS_IMETHOD CanCopy(bool *aCanCopy) override;
-  NS_IMETHOD CanDelete(bool *aCanDelete) override;
+  NS_IMETHOD CanCopy(bool* aCanCopy) override;
+  NS_IMETHOD CanDelete(bool* aCanDelete) override;
   NS_IMETHOD Paste(int32_t aSelectionType) 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 CanPaste(int32_t aSelectionType, bool* aCanPaste) override;
+  NS_IMETHOD PasteTransferable(nsITransferable* aTransferable) override;
+  NS_IMETHOD CanPasteTransferable(nsITransferable* aTransferable,
+                                  bool* aCanPaste) override;
 
   NS_IMETHOD OutputToString(const nsAString& aFormatType,
                             uint32_t aFlags,
                             nsAString& aOutputString) override;
 
   NS_IMETHOD OutputToStream(nsIOutputStream* aOutputStream,
                             const nsAString& aFormatType,
                             const nsACString& aCharsetOverride,
                             uint32_t aFlags) 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;
 
-  /** make the given selection span the entire document */
+  /**
+   * Make the given selection span the entire document.
+   */
   virtual nsresult SelectEntireDocument(Selection* aSelection) override;
 
   virtual nsresult HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) override;
 
-  virtual already_AddRefed<mozilla::dom::EventTarget> GetDOMEventTarget() override;
+  virtual already_AddRefed<dom::EventTarget> GetDOMEventTarget() override;
 
-  virtual nsresult BeginIMEComposition(mozilla::WidgetCompositionEvent* aEvent) override;
+  virtual nsresult BeginIMEComposition(WidgetCompositionEvent* aEvent) override;
   virtual nsresult UpdateIMEComposition(nsIDOMEvent* aTextEvent) override;
 
   virtual already_AddRefed<nsIContent> GetInputEventTargetContent() override;
 
-  /* ------------ Utility Routines, not part of public API -------------- */
+  // Utility Routines, not part of public API
   NS_IMETHOD TypedText(const nsAString& aString, ETypingAction aAction);
 
-  nsresult InsertTextAt(const nsAString &aStringToInsert,
-                        nsIDOMNode *aDestinationNode,
+  nsresult InsertTextAt(const nsAString& aStringToInsert,
+                        nsIDOMNode* aDestinationNode,
                         int32_t aDestOffset,
                         bool aDoDeleteSelection);
 
-  virtual nsresult InsertFromDataTransfer(mozilla::dom::DataTransfer *aDataTransfer,
+  virtual nsresult InsertFromDataTransfer(dom::DataTransfer* aDataTransfer,
                                           int32_t aIndex,
-                                          nsIDOMDocument *aSourceDoc,
-                                          nsIDOMNode *aDestinationNode,
+                                          nsIDOMDocument* aSourceDoc,
+                                          nsIDOMNode* aDestinationNode,
                                           int32_t aDestOffset,
                                           bool aDoDeleteSelection) override;
 
   virtual nsresult InsertFromDrop(nsIDOMEvent* aDropEvent) override;
 
   /**
    * Extends the selection for given deletion operation
    * If done, also update aAction to what's actually left to do after the
    * extension.
    */
   nsresult ExtendSelectionForDelete(Selection* aSelection,
-                                    nsIEditor::EDirection *aAction);
+                                    nsIEditor::EDirection* aAction);
 
-  // Return true if the data is safe to insert as the source and destination
-  // principals match, or we are in a editor context where this doesn't matter.
-  // Otherwise, the data must be sanitized first.
+  /**
+   * Return true if the data is safe to insert as the source and destination
+   * principals match, or we are in a editor context where this doesn't matter.
+   * Otherwise, the data must be sanitized first.
+   */
   bool IsSafeToInsertData(nsIDOMDocument* aSourceDoc);
 
-  static void GetDefaultEditorPrefs(int32_t &aNewLineHandling,
-                                    int32_t &aCaretStyle);
+  static void GetDefaultEditorPrefs(int32_t& aNewLineHandling,
+                                    int32_t& aCaretStyle);
 
 protected:
-  virtual  ~nsPlaintextEditor();
+  virtual ~TextEditor();
 
-  NS_IMETHOD  InitRules();
-  void        BeginEditorInit();
-  nsresult    EndEditorInit();
+  NS_IMETHOD InitRules();
+  void BeginEditorInit();
+  nsresult EndEditorInit();
 
-  // Helpers for output routines
   NS_IMETHOD GetAndInitDocEncoder(const nsAString& aFormatType,
                                   uint32_t aFlags,
                                   const nsACString& aCharset,
                                   nsIDocumentEncoder** encoder);
 
-  // key event helpers
-  NS_IMETHOD CreateBR(nsIDOMNode *aNode, int32_t aOffset,
-                      nsCOMPtr<nsIDOMNode> *outBRNode, EDirection aSelect = eNone);
+  NS_IMETHOD CreateBR(nsIDOMNode* aNode, int32_t aOffset,
+                      nsCOMPtr<nsIDOMNode>* outBRNode,
+                      EDirection aSelect = eNone);
   Element* CreateBRImpl(nsCOMPtr<nsINode>* aInOutParent, int32_t* aInOutOffset,
                         EDirection aSelect);
   nsresult CreateBRImpl(nsCOMPtr<nsIDOMNode>* aInOutParent,
                         int32_t* aInOutOffset,
                         nsCOMPtr<nsIDOMNode>* outBRNode,
                         EDirection aSelect);
   nsresult InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode);
 
-  // factored methods for handling insertion of data from transferables (drag&drop or clipboard)
-  NS_IMETHOD PrepareTransferable(nsITransferable **transferable);
-  NS_IMETHOD InsertTextFromTransferable(nsITransferable *transferable,
-                                        nsIDOMNode *aDestinationNode,
+  /**
+   * Factored methods for handling insertion of data from transferables
+   * (drag&drop or clipboard).
+   */
+  NS_IMETHOD PrepareTransferable(nsITransferable** transferable);
+  NS_IMETHOD InsertTextFromTransferable(nsITransferable* transferable,
+                                        nsIDOMNode* aDestinationNode,
                                         int32_t aDestOffset,
                                         bool aDoDeleteSelection);
 
-  /** shared outputstring; returns whether selection is collapsed and resulting string */
-  nsresult SharedOutputString(uint32_t aFlags, bool* aIsCollapsed, nsAString& aResult);
+  /**
+   * Shared outputstring; returns whether selection is collapsed and resulting
+   * string.
+   */
+  nsresult SharedOutputString(uint32_t aFlags, bool* aIsCollapsed,
+                              nsAString& aResult);
 
-  /* small utility routine to test the eEditorReadonly bit */
+  /**
+   * Small utility routine to test the eEditorReadonly bit.
+   */
   bool IsModifiable();
 
-  enum PasswordFieldAllowed {
+  enum PasswordFieldAllowed
+  {
     ePasswordFieldAllowed,
     ePasswordFieldNotAllowed
   };
   bool CanCutOrCopy(PasswordFieldAllowed aPasswordFieldAllowed);
-  bool FireClipboardEvent(mozilla::EventMessage aEventMessage,
+  bool FireClipboardEvent(EventMessage aEventMessage,
                           int32_t aSelectionType,
                           bool* aActionTaken = nullptr);
 
   bool UpdateMetaCharset(nsIDOMDocument* aDocument,
                          const nsACString& aCharacterSet);
 
-// Data members
 protected:
-
-  nsCOMPtr<nsIEditRules>        mRules;
+  nsCOMPtr<nsIEditRules> mRules;
   int32_t mWrapColumn;
   int32_t mMaxTextLength;
   int32_t mInitTriggerCounter;
   int32_t mNewlineHandling;
   int32_t mCaretStyle;
 
-  // friends
-  friend class mozilla::AutoEditInitRulesTrigger;
-  friend class mozilla::HTMLEditRules;
-  friend class mozilla::TextEditRules;
+  friend class AutoEditInitRulesTrigger;
+  friend class HTMLEditRules;
+  friend class TextEditRules;
 };
 
-#endif //nsPlaintextEditor_h__
+} // namespace mozilla
 
+#endif // #ifndef mozilla_TextEditor_h
rename from editor/libeditor/nsPlaintextDataTransfer.cpp
rename to editor/libeditor/TextEditorDataTransfer.cpp
--- a/editor/libeditor/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/TextEditorDataTransfer.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/TextEditor.h"
+
 #include "EditorUtils.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/SelectionState.h"
 #include "mozilla/dom/Selection.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
@@ -33,30 +35,31 @@
 #include "nsIDocShellTreeItem.h"
 #include "nsIPrincipal.h"
 #include "nsIFormControl.h"
 #include "nsIPlaintextEditor.h"
 #include "nsISupportsPrimitives.h"
 #include "nsITransferable.h"
 #include "nsIVariant.h"
 #include "nsLiteralString.h"
-#include "nsPlaintextEditor.h"
 #include "nsRange.h"
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "nsXPCOM.h"
 #include "nscore.h"
 
 class nsILoadContext;
 class nsISupports;
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
 
-NS_IMETHODIMP nsPlaintextEditor::PrepareTransferable(nsITransferable **transferable)
+using namespace dom;
+
+NS_IMETHODIMP
+TextEditor::PrepareTransferable(nsITransferable** transferable)
 {
   // Create generic Transferable for getting the data
   nsresult rv = CallCreateInstance("@mozilla.org/widget/transferable;1", transferable);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the nsITransferable interface for getting the data from the clipboard
   if (transferable) {
     nsCOMPtr<nsIDocument> destdoc = GetDocument();
@@ -64,20 +67,21 @@ NS_IMETHODIMP nsPlaintextEditor::Prepare
     (*transferable)->Init(loadContext);
 
     (*transferable)->AddDataFlavor(kUnicodeMime);
     (*transferable)->AddDataFlavor(kMozTextInternal);
   };
   return NS_OK;
 }
 
-nsresult nsPlaintextEditor::InsertTextAt(const nsAString &aStringToInsert,
-                                         nsIDOMNode *aDestinationNode,
-                                         int32_t aDestOffset,
-                                         bool aDoDeleteSelection)
+nsresult
+TextEditor::InsertTextAt(const nsAString& aStringToInsert,
+                         nsIDOMNode* aDestinationNode,
+                         int32_t aDestOffset,
+                         bool aDoDeleteSelection)
 {
   if (aDestinationNode)
   {
     nsresult res;
     RefPtr<Selection> selection = GetSelection();
     NS_ENSURE_STATE(selection);
 
     nsCOMPtr<nsIDOMNode> targetNode = aDestinationNode;
@@ -94,20 +98,21 @@ nsresult nsPlaintextEditor::InsertTextAt
 
     res = selection->Collapse(targetNode, targetOffset);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   return InsertText(aStringToInsert);
 }
 
-NS_IMETHODIMP nsPlaintextEditor::InsertTextFromTransferable(nsITransferable *aTransferable,
-                                                            nsIDOMNode *aDestinationNode,
-                                                            int32_t aDestOffset,
-                                                            bool aDoDeleteSelection)
+NS_IMETHODIMP
+TextEditor::InsertTextFromTransferable(nsITransferable* aTransferable,
+                                       nsIDOMNode* aDestinationNode,
+                                       int32_t aDestOffset,
+                                       bool aDoDeleteSelection)
 {
   nsresult rv = NS_OK;
   char* bestFlavor = nullptr;
   nsCOMPtr<nsISupports> genericDataObj;
   uint32_t len = 0;
   if (NS_SUCCEEDED(aTransferable->GetAnyTransferData(&bestFlavor, getter_AddRefs(genericDataObj), &len))
       && bestFlavor && (0 == nsCRT::strcmp(bestFlavor, kUnicodeMime) ||
                         0 == nsCRT::strcmp(bestFlavor, kMozTextInternal)))
@@ -132,39 +137,41 @@ NS_IMETHODIMP nsPlaintextEditor::InsertT
   // Try to scroll the selection into view if the paste/drop succeeded
 
   if (NS_SUCCEEDED(rv))
     ScrollSelectionIntoView(false);
 
   return rv;
 }
 
-nsresult nsPlaintextEditor::InsertFromDataTransfer(DataTransfer *aDataTransfer,
-                                                   int32_t aIndex,
-                                                   nsIDOMDocument *aSourceDoc,
-                                                   nsIDOMNode *aDestinationNode,
-                                                   int32_t aDestOffset,
-                                                   bool aDoDeleteSelection)
+nsresult
+TextEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
+                                   int32_t aIndex,
+                                   nsIDOMDocument* aSourceDoc,
+                                   nsIDOMNode* aDestinationNode,
+                                   int32_t aDestOffset,
+                                   bool aDoDeleteSelection)
 {
   nsCOMPtr<nsIVariant> data;
   DataTransfer::Cast(aDataTransfer)->GetDataAtNoSecurityCheck(NS_LITERAL_STRING("text/plain"), aIndex,
                                                               getter_AddRefs(data));
   if (data) {
     nsAutoString insertText;
     data->GetAsAString(insertText);
     nsContentUtils::PlatformToDOMLineBreaks(insertText);
 
     AutoEditBatch beginBatching(this);
     return InsertTextAt(insertText, aDestinationNode, aDestOffset, aDoDeleteSelection);
   }
 
   return NS_OK;
 }
 
-nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
+nsresult
+TextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
 {
   ForceCompositionEnd();
 
   nsCOMPtr<nsIDOMDragEvent> dragEvent(do_QueryInterface(aDropEvent));
   NS_ENSURE_TRUE(dragEvent, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDOMDataTransfer> domDataTransfer;
   dragEvent->GetDataTransfer(getter_AddRefs(domDataTransfer));
@@ -315,17 +322,18 @@ nsresult nsPlaintextEditor::InsertFromDr
   }
 
   if (NS_SUCCEEDED(rv))
     ScrollSelectionIntoView(false);
 
   return rv;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::Paste(int32_t aSelectionType)
+NS_IMETHODIMP
+TextEditor::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));
@@ -348,17 +356,18 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(i
 
       rv = InsertTextFromTransferable(trans, nullptr, 0, true);
     }
   }
 
   return rv;
 }
 
-NS_IMETHODIMP nsPlaintextEditor::PasteTransferable(nsITransferable *aTransferable)
+NS_IMETHODIMP
+TextEditor::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, -1)) {
     return NS_OK;
   }
 
   if (!IsModifiable())
@@ -368,17 +377,19 @@ NS_IMETHODIMP nsPlaintextEditor::PasteTr
   nsCOMPtr<nsIDOMDocument> domdoc = GetDOMDocument();
   if (!EditorHookUtils::DoInsertionHook(domdoc, nullptr, aTransferable)) {
     return NS_OK;
   }
 
   return InsertTextFromTransferable(aTransferable, nullptr, 0, true);
 }
 
-NS_IMETHODIMP nsPlaintextEditor::CanPaste(int32_t aSelectionType, bool *aCanPaste)
+NS_IMETHODIMP
+TextEditor::CanPaste(int32_t aSelectionType,
+                     bool* aCanPaste)
 {
   NS_ENSURE_ARG_POINTER(aCanPaste);
   *aCanPaste = false;
 
   // can't paste if readonly
   if (!IsModifiable())
     return NS_OK;
 
@@ -395,17 +406,19 @@ NS_IMETHODIMP nsPlaintextEditor::CanPast
                                          aSelectionType, &haveFlavors);
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aCanPaste = haveFlavors;
   return NS_OK;
 }
 
 
-NS_IMETHODIMP nsPlaintextEditor::CanPasteTransferable(nsITransferable *aTransferable, bool *aCanPaste)
+NS_IMETHODIMP
+TextEditor::CanPasteTransferable(nsITransferable* aTransferable,
+                                 bool* aCanPaste)
 {
   NS_ENSURE_ARG_POINTER(aCanPaste);
 
   // can't paste if readonly
   if (!IsModifiable()) {
     *aCanPaste = false;
     return NS_OK;
   }
@@ -424,17 +437,18 @@ NS_IMETHODIMP nsPlaintextEditor::CanPast
   if (NS_SUCCEEDED(rv) && data)
     *aCanPaste = true;
   else
     *aCanPaste = false;
 
   return NS_OK;
 }
 
-bool nsPlaintextEditor::IsSafeToInsertData(nsIDOMDocument* aSourceDoc)
+bool
+TextEditor::IsSafeToInsertData(nsIDOMDocument* aSourceDoc)
 {
   // Try to determine whether we should use a sanitizing fragment sink
   bool isSafe = false;
 
   nsCOMPtr<nsIDocument> destdoc = GetDocument();
   NS_ASSERTION(destdoc, "Where is our destination doc?");
   nsCOMPtr<nsIDocShellTreeItem> dsti = destdoc->GetDocShell();
   nsCOMPtr<nsIDocShellTreeItem> root;
@@ -452,8 +466,9 @@ bool nsPlaintextEditor::IsSafeToInsertDa
     nsIPrincipal* destPrincipal = destdoc->NodePrincipal();
     NS_ASSERTION(srcPrincipal && destPrincipal, "How come we don't have a principal?");
     srcPrincipal->Subsumes(destPrincipal, &isSafe);
   }
 
   return isSafe;
 }
 
+} // namespace mozilla
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -17,16 +17,17 @@ EXPORTS += [
     'nsEditor.h',
     'nsIEditRules.h',
 ]
 
 EXPORTS.mozilla += [
     'EditorController.h',
     'HTMLEditor.h',
     'SelectionState.h',
+    'TextEditor.h',
     'TextEditRules.h',
 ]
 
 UNIFIED_SOURCES += [
     'ChangeAttributeTransaction.cpp',
     'ChangeStyleTransaction.cpp',
     'CompositionTransaction.cpp',
     'CreateElementTransaction.cpp',
@@ -52,23 +53,23 @@ UNIFIED_SOURCES += [
     'HTMLStyleEditor.cpp',
     'HTMLTableEditor.cpp',
     'HTMLURIRefObject.cpp',
     'InsertNodeTransaction.cpp',
     'InsertTextTransaction.cpp',
     'InternetCiter.cpp',
     'JoinNodeTransaction.cpp',
     'nsEditor.cpp',
-    'nsPlaintextDataTransfer.cpp',
-    'nsPlaintextEditor.cpp',
     'PlaceholderTransaction.cpp',
     'SelectionState.cpp',
     'SetDocumentTitleTransaction.cpp',
     'SplitNodeTransaction.cpp',
     'StyleSheetTransactions.cpp',
+    'TextEditor.cpp',
+    'TextEditorDataTransfer.cpp',
     'TextEditorTest.cpp',
     'TextEditRules.cpp',
     'TextEditRulesBidi.cpp',
     'TextEditUtils.cpp',
     'TypeInState.cpp',
     'WSRunObject.cpp',
 ]
 
--- a/editor/libeditor/nsIEditRules.h
+++ b/editor/libeditor/nsIEditRules.h
@@ -7,20 +7,19 @@
 #define nsIEditRules_h
 
 #define NS_IEDITRULES_IID \
 { 0x3836386d, 0x806a, 0x488d, \
   { 0x8b, 0xab, 0xaf, 0x42, 0xbb, 0x4c, 0x90, 0x66 } }
 
 #include "nsEditor.h" // for EditAction enum
 
-class nsPlaintextEditor;
-
 namespace mozilla {
 
+class TextEditor;
 namespace dom {
 class Selection;
 } // namespace dom
 
 /**
  * Base for an object to encapsulate any additional info needed to be passed
  * to rules system by the editor.
  */
@@ -43,17 +42,17 @@ public:
 class nsIEditRules : public nsISupports
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IEDITRULES_IID)
 
 //Interfaces for addref and release and queryinterface
 //NOTE: Use   NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsIEditRules
 
-  NS_IMETHOD Init(nsPlaintextEditor* aEditor) = 0;
+  NS_IMETHOD Init(mozilla::TextEditor* aTextEditor) = 0;
   NS_IMETHOD SetInitialValue(const nsAString& aValue) = 0;
   NS_IMETHOD DetachEditor() = 0;
   NS_IMETHOD BeforeEdit(EditAction action,
                         nsIEditor::EDirection aDirection) = 0;
   NS_IMETHOD AfterEdit(EditAction action,
                        nsIEditor::EDirection aDirection) = 0;
   NS_IMETHOD WillDoAction(mozilla::dom::Selection* aSelection,
                           mozilla::RulesInfo* aInfo, bool* aCancel,
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -132,17 +132,16 @@ using mozilla::dom::PushNotifier;
 #endif
 
 #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 "nsTextServicesDocument.h"
 #include "nsTextServicesCID.h"
 
 #include "nsScriptSecurityManager.h"
 #include "nsPrincipal.h"
@@ -272,17 +271,17 @@ using mozilla::dom::NotificationTelemetr
 #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(TextEditor)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserUtils)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextServicesDocument)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(HTMLEditor)
 
 // Transformiix
@@ -1064,17 +1063,17 @@ static const mozilla::Module::CIDEntry k
   { &kNS_FORMDATA_CID, false, nullptr, FormDataConstructor },
   { &kNS_HOSTOBJECTURI_CID, false, nullptr, nsHostObjectURIConstructor },
   { &kNS_XMLHTTPREQUEST_CID, false, nullptr, XMLHttpRequestMainThreadConstructor },
   { &kNS_DOMPARSER_CID, false, nullptr, DOMParserConstructor },
   { &kNS_XPCEXCEPTION_CID, false, nullptr, ExceptionConstructor },
   { &kNS_DOMSESSIONSTORAGEMANAGER_CID, false, nullptr, DOMSessionStorageManagerConstructor },
   { &kNS_DOMLOCALSTORAGEMANAGER_CID, false, nullptr, DOMLocalStorageManagerConstructor },
   { &kNS_DOMJSON_CID, false, nullptr, NS_NewJSON },
-  { &kNS_TEXTEDITOR_CID, false, nullptr, nsPlaintextEditorConstructor },
+  { &kNS_TEXTEDITOR_CID, false, nullptr, TextEditorConstructor },
   { &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor },
   { &kQUOTAMANAGER_SERVICE_CID, false, nullptr, QuotaManagerServiceConstructor },
   { &kSERVICEWORKERMANAGER_CID, false, nullptr, ServiceWorkerManagerConstructor },
   { &kNOTIFICATIONTELEMETRYSERVICE_CID, false, nullptr, NotificationTelemetryServiceConstructor },
 #ifndef MOZ_SIMPLEPUSH
   { &kPUSHNOTIFIER_CID, false, nullptr, PushNotifierConstructor },
 #endif
   { &kWORKERDEBUGGERMANAGER_CID, true, nullptr, WorkerDebuggerManagerConstructor },