Bug 1260651 part.47 Rename nsWSRunObject to mozilla::WSRunObject (and also their file names) r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 07 Jul 2016 19:00:51 +0900
changeset 385879 df3e3119d2af671aab4e1689c2afc014a2851a3e
parent 385878 fb6ffa5d6f8e4346a76f3d1bc5a1229566c351ac
child 385880 593e7cea66b1bced3797f95c0b0abe2083c1f45f
push id22587
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 06:59:31 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.47 Rename nsWSRunObject to mozilla::WSRunObject (and also their file names) r=mccr8 Perhaps, there may be better name like WhitespaceRunObject or something, however, for now keep using the term because I don't understand well what it does. With this patch, following objects are renamed: nsWSRunObject -> mozilla::WSRunObject WSType -> mozilla::WSType nsWSRunObject::WSFragment -> mozilla::WSRunObject::WSFragment nsWSRunObject::WSPoint -> mozilla::WSRunObject::WSPoint MozReview-Commit-ID: JgAWiPjOtMW
editor/libeditor/WSRunObject.cpp
editor/libeditor/WSRunObject.h
editor/libeditor/moz.build
editor/libeditor/nsHTMLDataTransfer.cpp
editor/libeditor/nsHTMLEditRules.cpp
editor/libeditor/nsHTMLEditor.cpp
editor/libeditor/nsHTMLEditor.h
editor/libeditor/nsWSRunObject.cpp
editor/libeditor/nsWSRunObject.h
rename from editor/libeditor/nsWSRunObject.cpp
rename to editor/libeditor/WSRunObject.cpp
--- a/editor/libeditor/nsWSRunObject.cpp
+++ b/editor/libeditor/WSRunObject.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 "nsWSRunObject.h"
+#include "WSRunObject.h"
 
 #include "EditorUtils.h"
 #include "SelectionState.h"
 #include "TextEditUtils.h"
 
 #include "mozilla/OwningNonNull.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Casting.h"
@@ -23,179 +23,158 @@
 #include "nsIContent.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNode.h"
 #include "nsISupportsImpl.h"
 #include "nsRange.h"
 #include "nsString.h"
 #include "nsTextFragment.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
 const char16_t nbsp = 160;
 
-//- constructor / destructor -----------------------------------------------
-nsWSRunObject::nsWSRunObject(nsHTMLEditor* aEd, nsINode* aNode, int32_t aOffset)
+WSRunObject::WSRunObject(nsHTMLEditor* aHTMLEditor,
+                         nsINode* aNode,
+                         int32_t aOffset)
   : mNode(aNode)
   , mOffset(aOffset)
   , mPRE(false)
-  , mStartNode()
   , mStartOffset(0)
-  , mStartReason()
-  , mStartReasonNode()
-  , mEndNode()
   , mEndOffset(0)
-  , mEndReason()
-  , mEndReasonNode()
-  , mFirstNBSPNode()
   , mFirstNBSPOffset(0)
-  , mLastNBSPNode()
   , mLastNBSPOffset(0)
-  , mNodeArray()
   , mStartRun(nullptr)
   , mEndRun(nullptr)
-  , mHTMLEditor(aEd)
+  , mHTMLEditor(aHTMLEditor)
 {
   GetWSNodes();
   GetRuns();
 }
 
-nsWSRunObject::nsWSRunObject(nsHTMLEditor *aEd, nsIDOMNode *aNode, int32_t aOffset) :
-mNode(do_QueryInterface(aNode))
-,mOffset(aOffset)
-,mPRE(false)
-,mStartNode()
-,mStartOffset(0)
-,mStartReason()
-,mStartReasonNode()
-,mEndNode()
-,mEndOffset(0)
-,mEndReason()
-,mEndReasonNode()
-,mFirstNBSPNode()
-,mFirstNBSPOffset(0)
-,mLastNBSPNode()
-,mLastNBSPOffset(0)
-,mNodeArray()
-,mStartRun(nullptr)
-,mEndRun(nullptr)
-,mHTMLEditor(aEd)
+WSRunObject::WSRunObject(nsHTMLEditor* aHTMLEditor,
+                         nsIDOMNode* aNode,
+                         int32_t aOffset)
+  : mNode(do_QueryInterface(aNode))
+  , mOffset(aOffset)
+  , mPRE(false)
+  , mStartOffset(0)
+  , mEndOffset(0)
+  , mFirstNBSPOffset(0)
+  , mLastNBSPOffset(0)
+  , mStartRun(nullptr)
+  , mEndRun(nullptr)
+  , mHTMLEditor(aHTMLEditor)
 {
   GetWSNodes();
   GetRuns();
 }
 
-nsWSRunObject::~nsWSRunObject()
+WSRunObject::~WSRunObject()
 {
   ClearRuns();
 }
 
-
-
-//--------------------------------------------------------------------------------------------
-//   public static methods
-//--------------------------------------------------------------------------------------------
-
 nsresult
-nsWSRunObject::ScrubBlockBoundary(nsHTMLEditor* aHTMLEd,
-                                  BlockBoundary aBoundary,
-                                  nsINode* aBlock,
-                                  int32_t aOffset)
+WSRunObject::ScrubBlockBoundary(nsHTMLEditor* aHTMLEditor,
+                                BlockBoundary aBoundary,
+                                nsINode* aBlock,
+                                int32_t aOffset)
 {
-  NS_ENSURE_TRUE(aHTMLEd && aBlock, NS_ERROR_NULL_POINTER);
+  NS_ENSURE_TRUE(aHTMLEditor && aBlock, NS_ERROR_NULL_POINTER);
 
   int32_t offset;
   if (aBoundary == kBlockStart) {
     offset = 0;
   } else if (aBoundary == kBlockEnd) {
     offset = aBlock->Length();
   } else {
     // Else we are scrubbing an outer boundary - just before or after a block
     // element.
     NS_ENSURE_STATE(aOffset >= 0);
     offset = aOffset;
   }
 
-  nsWSRunObject theWSObj(aHTMLEd, aBlock, offset);
+  WSRunObject theWSObj(aHTMLEditor, aBlock, offset);
   return theWSObj.Scrub();
 }
 
 nsresult
-nsWSRunObject::PrepareToJoinBlocks(nsHTMLEditor* aHTMLEd,
-                                   Element* aLeftBlock,
-                                   Element* aRightBlock)
+WSRunObject::PrepareToJoinBlocks(nsHTMLEditor* aHTMLEditor,
+                                 Element* aLeftBlock,
+                                 Element* aRightBlock)
 {
-  NS_ENSURE_TRUE(aLeftBlock && aRightBlock && aHTMLEd, NS_ERROR_NULL_POINTER);
-
-  nsWSRunObject leftWSObj(aHTMLEd, aLeftBlock, aLeftBlock->Length());
-  nsWSRunObject rightWSObj(aHTMLEd, aRightBlock, 0);
-
-  return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
-}
+  NS_ENSURE_TRUE(aLeftBlock && aRightBlock && aHTMLEditor,
+                 NS_ERROR_NULL_POINTER);
 
-nsresult
-nsWSRunObject::PrepareToDeleteRange(nsHTMLEditor* aHTMLEd,
-                                    nsCOMPtr<nsINode>* aStartNode,
-                                    int32_t* aStartOffset,
-                                    nsCOMPtr<nsINode>* aEndNode,
-                                    int32_t* aEndOffset)
-{
-  NS_ENSURE_TRUE(aHTMLEd && aStartNode && *aStartNode && aStartOffset &&
-                 aEndNode && *aEndNode && aEndOffset, NS_ERROR_NULL_POINTER);
-
-  AutoTrackDOMPoint trackerStart(aHTMLEd->mRangeUpdater, aStartNode,
-                                 aStartOffset);
-  AutoTrackDOMPoint trackerEnd(aHTMLEd->mRangeUpdater, aEndNode, aEndOffset);
-
-  nsWSRunObject leftWSObj(aHTMLEd, *aStartNode, *aStartOffset);
-  nsWSRunObject rightWSObj(aHTMLEd, *aEndNode, *aEndOffset);
+  WSRunObject leftWSObj(aHTMLEditor, aLeftBlock, aLeftBlock->Length());
+  WSRunObject rightWSObj(aHTMLEditor, aRightBlock, 0);
 
   return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
 }
 
 nsresult
-nsWSRunObject::PrepareToDeleteNode(nsHTMLEditor* aHTMLEd,
-                                   nsIContent* aContent)
+WSRunObject::PrepareToDeleteRange(nsHTMLEditor* aHTMLEditor,
+                                  nsCOMPtr<nsINode>* aStartNode,
+                                  int32_t* aStartOffset,
+                                  nsCOMPtr<nsINode>* aEndNode,
+                                  int32_t* aEndOffset)
 {
-  NS_ENSURE_TRUE(aContent && aHTMLEd, NS_ERROR_NULL_POINTER);
+  NS_ENSURE_TRUE(aHTMLEditor && aStartNode && *aStartNode && aStartOffset &&
+                 aEndNode && *aEndNode && aEndOffset, NS_ERROR_NULL_POINTER);
 
-  nsCOMPtr<nsINode> parent = aContent->GetParentNode();
-  NS_ENSURE_STATE(parent);
-  int32_t offset = parent->IndexOf(aContent);
+  AutoTrackDOMPoint trackerStart(aHTMLEditor->mRangeUpdater,
+                                 aStartNode, aStartOffset);
+  AutoTrackDOMPoint trackerEnd(aHTMLEditor->mRangeUpdater,
+                               aEndNode, aEndOffset);
 
-  nsWSRunObject leftWSObj(aHTMLEd, parent, offset);
-  nsWSRunObject rightWSObj(aHTMLEd, parent, offset + 1);
+  WSRunObject leftWSObj(aHTMLEditor, *aStartNode, *aStartOffset);
+  WSRunObject rightWSObj(aHTMLEditor, *aEndNode, *aEndOffset);
 
   return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
 }
 
 nsresult
-nsWSRunObject::PrepareToSplitAcrossBlocks(nsHTMLEditor* aHTMLEd,
-                                          nsCOMPtr<nsINode>* aSplitNode,
-                                          int32_t* aSplitOffset)
+WSRunObject::PrepareToDeleteNode(nsHTMLEditor* aHTMLEditor,
+                                 nsIContent* aContent)
 {
-  NS_ENSURE_TRUE(aHTMLEd && aSplitNode && *aSplitNode && aSplitOffset,
+  NS_ENSURE_TRUE(aContent && aHTMLEditor, NS_ERROR_NULL_POINTER);
+
+  nsCOMPtr<nsINode> parent = aContent->GetParentNode();
+  NS_ENSURE_STATE(parent);
+  int32_t offset = parent->IndexOf(aContent);
+
+  WSRunObject leftWSObj(aHTMLEditor, parent, offset);
+  WSRunObject rightWSObj(aHTMLEditor, parent, offset + 1);
+
+  return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
+}
+
+nsresult
+WSRunObject::PrepareToSplitAcrossBlocks(nsHTMLEditor* aHTMLEditor,
+                                        nsCOMPtr<nsINode>* aSplitNode,
+                                        int32_t* aSplitOffset)
+{
+  NS_ENSURE_TRUE(aHTMLEditor && aSplitNode && *aSplitNode && aSplitOffset,
                  NS_ERROR_NULL_POINTER);
 
-  AutoTrackDOMPoint tracker(aHTMLEd->mRangeUpdater, aSplitNode, aSplitOffset);
+  AutoTrackDOMPoint tracker(aHTMLEditor->mRangeUpdater,
+                            aSplitNode, aSplitOffset);
 
-  nsWSRunObject wsObj(aHTMLEd, *aSplitNode, *aSplitOffset);
+  WSRunObject wsObj(aHTMLEditor, *aSplitNode, *aSplitOffset);
 
   return wsObj.PrepareToSplitAcrossBlocksPriv();
 }
 
-//--------------------------------------------------------------------------------------------
-//   public instance methods
-//--------------------------------------------------------------------------------------------
-
 Element*
-nsWSRunObject::InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
-                           int32_t* aInOutOffset,
-                           nsIEditor::EDirection aSelect)
+WSRunObject::InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
+                         int32_t* aInOutOffset,
+                         nsIEditor::EDirection aSelect)
 {
   // MOOSE: for now, we always assume non-PRE formatting.  Fix this later.
   // meanwhile, the pre case is handled in WillInsertText in
   // nsHTMLEditRules.cpp
   NS_ENSURE_TRUE(aInOutParent && aInOutOffset, nullptr);
 
   nsresult res = NS_OK;
   WSFragment *beforeRun, *afterRun;
@@ -250,20 +229,20 @@ nsWSRunObject::InsertBreak(nsCOMPtr<nsIN
     }
   }
 
   // ready, aim, fire!
   return mHTMLEditor->CreateBRImpl(aInOutParent, aInOutOffset, aSelect);
 }
 
 nsresult
-nsWSRunObject::InsertText(const nsAString& aStringToInsert,
-                          nsCOMPtr<nsINode>* aInOutParent,
-                          int32_t* aInOutOffset,
-                          nsIDocument* aDoc)
+WSRunObject::InsertText(const nsAString& aStringToInsert,
+                        nsCOMPtr<nsINode>* aInOutParent,
+                        int32_t* aInOutOffset,
+                        nsIDocument* aDoc)
 {
   // MOOSE: for now, we always assume non-PRE formatting.  Fix this later.
   // meanwhile, the pre case is handled in WillInsertText in
   // nsHTMLEditRules.cpp
 
   // MOOSE: for now, just getting the ws logic straight.  This implementation
   // is very slow.  Will need to replace edit rules impl with a more efficient
   // text sink here that does the minimal amount of searching/replacing/copying
@@ -379,17 +358,17 @@ nsWSRunObject::InsertText(const nsAStrin
 
   // Ready, aim, fire!
   res = mHTMLEditor->InsertTextImpl(theString, aInOutParent, aInOutOffset,
                                     aDoc);
   return NS_OK;
 }
 
 nsresult
-nsWSRunObject::DeleteWSBackward()
+WSRunObject::DeleteWSBackward()
 {
   WSPoint point = GetCharBefore(mNode, mOffset);
   NS_ENSURE_TRUE(point.mTextNode, NS_OK);  // nothing to delete
 
   if (mPRE) {
     // easy case, preformatted ws
     if (nsCRT::IsAsciiSpace(point.mChar) || point.mChar == nbsp) {
       return DeleteChars(point.mTextNode, point.mOffset,
@@ -405,42 +384,42 @@ nsWSRunObject::DeleteWSBackward()
     GetAsciiWSBounds(eBoth, point.mTextNode, point.mOffset + 1,
                      getter_AddRefs(startNodeText), &startOffset,
                      getter_AddRefs(endNodeText), &endOffset);
 
     // adjust surrounding ws
     nsCOMPtr<nsINode> startNode = startNodeText.get();
     nsCOMPtr<nsINode> endNode = endNodeText.get();
     nsresult res =
-      nsWSRunObject::PrepareToDeleteRange(mHTMLEditor,
-                                          address_of(startNode), &startOffset,
-                                          address_of(endNode), &endOffset);
+      WSRunObject::PrepareToDeleteRange(mHTMLEditor,
+                                        address_of(startNode), &startOffset,
+                                        address_of(endNode), &endOffset);
     NS_ENSURE_SUCCESS(res, res);
 
     // finally, delete that ws
     return DeleteChars(startNode, startOffset, endNode, endOffset);
   } else if (point.mChar == nbsp) {
     nsCOMPtr<nsINode> node(point.mTextNode);
     // adjust surrounding ws
     int32_t startOffset = point.mOffset;
     int32_t endOffset = point.mOffset + 1;
     nsresult res =
-      nsWSRunObject::PrepareToDeleteRange(mHTMLEditor,
-                                          address_of(node), &startOffset,
-                                          address_of(node), &endOffset);
+      WSRunObject::PrepareToDeleteRange(mHTMLEditor,
+                                        address_of(node), &startOffset,
+                                        address_of(node), &endOffset);
     NS_ENSURE_SUCCESS(res, res);
 
     // finally, delete that ws
     return DeleteChars(node, startOffset, node, endOffset);
   }
   return NS_OK;
 }
 
 nsresult
-nsWSRunObject::DeleteWSForward()
+WSRunObject::DeleteWSForward()
 {
   WSPoint point = GetCharAfter(mNode, mOffset);
   NS_ENSURE_TRUE(point.mTextNode, NS_OK); // nothing to delete
 
   if (mPRE) {
     // easy case, preformatted ws
     if (nsCRT::IsAsciiSpace(point.mChar) || point.mChar == nbsp) {
       return DeleteChars(point.mTextNode, point.mOffset,
@@ -454,43 +433,43 @@ nsWSRunObject::DeleteWSForward()
     RefPtr<Text> startNodeText, endNodeText;
     int32_t startOffset, endOffset;
     GetAsciiWSBounds(eBoth, point.mTextNode, point.mOffset + 1,
                      getter_AddRefs(startNodeText), &startOffset,
                      getter_AddRefs(endNodeText), &endOffset);
 
     // Adjust surrounding ws
     nsCOMPtr<nsINode> startNode(startNodeText), endNode(endNodeText);
-    nsresult res = nsWSRunObject::PrepareToDeleteRange(mHTMLEditor,
+    nsresult res = WSRunObject::PrepareToDeleteRange(mHTMLEditor,
         address_of(startNode), &startOffset, address_of(endNode), &endOffset);
     NS_ENSURE_SUCCESS(res, res);
 
     // Finally, delete that ws
     return DeleteChars(startNode, startOffset, endNode, endOffset);
   } else if (point.mChar == nbsp) {
     nsCOMPtr<nsINode> node(point.mTextNode);
     // Adjust surrounding ws
     int32_t startOffset = point.mOffset;
     int32_t endOffset = point.mOffset+1;
-    nsresult res = nsWSRunObject::PrepareToDeleteRange(mHTMLEditor,
+    nsresult res = WSRunObject::PrepareToDeleteRange(mHTMLEditor,
         address_of(node), &startOffset, address_of(node), &endOffset);
     NS_ENSURE_SUCCESS(res, res);
 
     // Finally, delete that ws
     return DeleteChars(node, startOffset, node, endOffset);
   }
   return NS_OK;
 }
 
 void
-nsWSRunObject::PriorVisibleNode(nsINode* aNode,
-                                int32_t aOffset,
-                                nsCOMPtr<nsINode>* outVisNode,
-                                int32_t* outVisOffset,
-                                WSType* outType)
+WSRunObject::PriorVisibleNode(nsINode* aNode,
+                              int32_t aOffset,
+                              nsCOMPtr<nsINode>* outVisNode,
+                              int32_t* outVisOffset,
+                              WSType* outType)
 {
   // Find first visible thing before the point.  Position
   // outVisNode/outVisOffset just _after_ that thing.  If we don't find
   // anything return start of ws.
   MOZ_ASSERT(aNode && outVisNode && outVisOffset && outType);
 
   WSFragment* run;
   FindRun(aNode, aOffset, &run, false);
@@ -520,21 +499,21 @@ nsWSRunObject::PriorVisibleNode(nsINode*
   *outVisNode = mStartReasonNode;
   // This really isn't meaningful if mStartReasonNode != mStartNode
   *outVisOffset = mStartOffset;
   *outType = mStartReason;
 }
 
 
 void
-nsWSRunObject::NextVisibleNode(nsINode* aNode,
-                               int32_t aOffset,
-                               nsCOMPtr<nsINode>* outVisNode,
-                               int32_t* outVisOffset,
-                               WSType* outType)
+WSRunObject::NextVisibleNode(nsINode* aNode,
+                             int32_t aOffset,
+                             nsCOMPtr<nsINode>* outVisNode,
+                             int32_t* outVisOffset,
+                             WSType* outType)
 {
   // Find first visible thing after the point.  Position
   // outVisNode/outVisOffset just _before_ that thing.  If we don't find
   // anything return end of ws.
   MOZ_ASSERT(aNode && outVisNode && outVisOffset && outType);
 
   WSFragment* run;
   FindRun(aNode, aOffset, &run, true);
@@ -563,17 +542,17 @@ nsWSRunObject::NextVisibleNode(nsINode* 
   // If we get here, then nothing in ws data to find.  Return end reason
   *outVisNode = mEndReasonNode;
   // This really isn't meaningful if mEndReasonNode != mEndNode
   *outVisOffset = mEndOffset;
   *outType = mEndReason;
 }
 
 nsresult
-nsWSRunObject::AdjustWhitespace()
+WSRunObject::AdjustWhitespace()
 {
   // this routine examines a run of ws and tries to get rid of some unneeded nbsp's,
   // replacing them with regualr ascii space if possible.  Keeping things simple
   // for now and just trying to fix up the trailing ws in the run.
   if (!mLastNBSPNode) {
     // nothing to do!
     return NS_OK;
   }
@@ -592,32 +571,32 @@ nsWSRunObject::AdjustWhitespace()
 }
 
 
 //--------------------------------------------------------------------------------------------
 //   protected methods
 //--------------------------------------------------------------------------------------------
 
 nsINode*
-nsWSRunObject::GetWSBoundingParent()
+WSRunObject::GetWSBoundingParent()
 {
   NS_ENSURE_TRUE(mNode, nullptr);
   OwningNonNull<nsINode> wsBoundingParent = *mNode;
   while (!IsBlockNode(wsBoundingParent)) {
     nsCOMPtr<nsINode> parent = wsBoundingParent->GetParentNode();
     if (!parent || !mHTMLEditor->IsEditable(parent)) {
       break;
     }
     wsBoundingParent = parent;
   }
   return wsBoundingParent;
 }
 
 nsresult
-nsWSRunObject::GetWSNodes()
+WSRunObject::GetWSNodes()
 {
   // collect up an array of nodes that are contiguous with the insertion point
   // and which contain only whitespace.  Stop if you reach non-ws text or a new
   // block boundary.
   EditorDOMPoint start(mNode, mOffset), end(mNode, mOffset);
   nsCOMPtr<nsINode> wsBoundingParent = GetWSBoundingParent();
 
   // first look backwards to find preceding ws nodes
@@ -833,17 +812,17 @@ nsWSRunObject::GetWSNodes()
       mEndReasonNode = wsBoundingParent;
     }
   }
 
   return NS_OK;
 }
 
 void
-nsWSRunObject::GetRuns()
+WSRunObject::GetRuns()
 {
   ClearRuns();
 
   // handle some easy cases first
   mHTMLEditor->IsPreformatted(GetAsDOMNode(mNode), &mPRE);
   // if it's preformatedd, or if we are surrounded by text or special, it's all one
   // big normal ws run
   if (mPRE ||
@@ -963,49 +942,49 @@ nsWSRunObject::GetRuns()
       mEndRun = lastRun;
       mStartRun->mRight = lastRun;
       mStartRun->mRightType = WSType::trailingWS;
     }
   }
 }
 
 void
-nsWSRunObject::ClearRuns()
+WSRunObject::ClearRuns()
 {
   WSFragment *tmp, *run;
   run = mStartRun;
   while (run)
   {
     tmp = run->mRight;
     delete run;
     run = tmp;
   }
   mStartRun = 0;
   mEndRun = 0;
 }
 
 void
-nsWSRunObject::MakeSingleWSRun(WSType aType)
+WSRunObject::MakeSingleWSRun(WSType aType)
 {
   mStartRun = new WSFragment();
 
   mStartRun->mStartNode   = mStartNode;
   mStartRun->mStartOffset = mStartOffset;
   mStartRun->mType        = aType;
   mStartRun->mEndNode     = mEndNode;
   mStartRun->mEndOffset   = mEndOffset;
   mStartRun->mLeftType    = mStartReason;
   mStartRun->mRightType   = mEndReason;
 
   mEndRun  = mStartRun;
 }
 
 nsIContent*
-nsWSRunObject::GetPreviousWSNodeInner(nsINode* aStartNode,
-                                      nsINode* aBlockParent)
+WSRunObject::GetPreviousWSNodeInner(nsINode* aStartNode,
+                                    nsINode* aBlockParent)
 {
   // Can't really recycle various getnext/prior routines because we have
   // special needs here.  Need to step into inline containers but not block
   // containers.
   MOZ_ASSERT(aStartNode && aBlockParent);
 
   nsCOMPtr<nsIContent> priorNode = aStartNode->GetPreviousSibling();
   OwningNonNull<nsINode> curNode = *aStartNode;
@@ -1033,18 +1012,18 @@ nsWSRunObject::GetPreviousWSNodeInner(ns
       return child;
     }
   }
   // Else return the node itself
   return priorNode;
 }
 
 nsIContent*
-nsWSRunObject::GetPreviousWSNode(EditorDOMPoint aPoint,
-                                 nsINode* aBlockParent)
+WSRunObject::GetPreviousWSNode(EditorDOMPoint aPoint,
+                               nsINode* aBlockParent)
 {
   // Can't really recycle various getnext/prior routines because we
   // have special needs here.  Need to step into inline containers but
   // not block containers.
   MOZ_ASSERT(aPoint.node && aBlockParent);
 
   if (aPoint.node->NodeType() == nsIDOMNode::TEXT_NODE) {
     return GetPreviousWSNodeInner(aPoint.node, aBlockParent);
@@ -1078,18 +1057,18 @@ nsWSRunObject::GetPreviousWSNode(EditorD
       return child;
     }
   }
   // Else return the node itself
   return priorNode;
 }
 
 nsIContent*
-nsWSRunObject::GetNextWSNodeInner(nsINode* aStartNode,
-                                  nsINode* aBlockParent)
+WSRunObject::GetNextWSNodeInner(nsINode* aStartNode,
+                                nsINode* aBlockParent)
 {
   // Can't really recycle various getnext/prior routines because we have
   // special needs here.  Need to step into inline containers but not block
   // containers.
   MOZ_ASSERT(aStartNode && aBlockParent);
 
   nsCOMPtr<nsIContent> nextNode = aStartNode->GetNextSibling();
   nsCOMPtr<nsINode> curNode = aStartNode;
@@ -1117,17 +1096,18 @@ nsWSRunObject::GetNextWSNodeInner(nsINod
       return child;
     }
   }
   // Else return the node itself
   return nextNode;
 }
 
 nsIContent*
-nsWSRunObject::GetNextWSNode(EditorDOMPoint aPoint, nsINode* aBlockParent)
+WSRunObject::GetNextWSNode(EditorDOMPoint aPoint,
+                           nsINode* aBlockParent)
 {
   // Can't really recycle various getnext/prior routines because we have
   // special needs here.  Need to step into inline containers but not block
   // containers.
   MOZ_ASSERT(aPoint.node && aBlockParent);
 
   if (aPoint.node->NodeType() == nsIDOMNode::TEXT_NODE) {
     return GetNextWSNodeInner(aPoint.node, aBlockParent);
@@ -1161,17 +1141,17 @@ nsWSRunObject::GetNextWSNode(EditorDOMPo
       return child;
     }
   }
   // Else return the node itself
   return nextNode;
 }
 
 nsresult
-nsWSRunObject::PrepareToDeleteRangePriv(nsWSRunObject* aEndObject)
+WSRunObject::PrepareToDeleteRangePriv(WSRunObject* aEndObject)
 {
   // this routine adjust whitespace before *this* and after aEndObject
   // in preperation for the two areas to become adjacent after the
   // intervening content is deleted.  It's overly agressive right
   // now.  There might be a block boundary remaining between them after
   // the deletion, in which case these adjstments are unneeded (though
   // I don't think they can ever be harmful?)
 
@@ -1229,17 +1209,17 @@ nsWSRunObject::PrepareToDeleteRangePriv(
         NS_ENSURE_SUCCESS(res, res);
       }
     }
   }
   return res;
 }
 
 nsresult
-nsWSRunObject::PrepareToSplitAcrossBlocksPriv()
+WSRunObject::PrepareToSplitAcrossBlocksPriv()
 {
   // used to prepare ws to be split across two blocks.  The main issue
   // here is make sure normalWS doesn't end up becoming non-significant
   // leading or trailing ws after the split.
   nsresult res = NS_OK;
 
   // get the runs before and after selection
   WSFragment *beforeRun, *afterRun;
@@ -1273,19 +1253,21 @@ nsWSRunObject::PrepareToSplitAcrossBlock
       res = ConvertToNBSP(point);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
   return res;
 }
 
 nsresult
-nsWSRunObject::DeleteChars(nsINode* aStartNode, int32_t aStartOffset,
-                           nsINode* aEndNode, int32_t aEndOffset,
-                           AreaRestriction aAR)
+WSRunObject::DeleteChars(nsINode* aStartNode,
+                         int32_t aStartOffset,
+                         nsINode* aEndNode,
+                         int32_t aEndOffset,
+                         AreaRestriction aAR)
 {
   // MOOSE: this routine needs to be modified to preserve the integrity of the
   // wsFragment info.
   NS_ENSURE_TRUE(aStartNode && aEndNode, NS_ERROR_NULL_POINTER);
 
   if (aAR == eOutsideUserSelectAll) {
     nsCOMPtr<nsIDOMNode> san =
       mHTMLEditor->FindUserSelectAllNode(GetAsDOMNode(aStartNode));
@@ -1362,48 +1344,50 @@ nsWSRunObject::DeleteChars(nsINode* aSta
         --count;
         --idx;
       }
     }
   }
   return NS_OK;
 }
 
-nsWSRunObject::WSPoint
-nsWSRunObject::GetCharAfter(nsINode* aNode, int32_t aOffset)
+WSRunObject::WSPoint
+WSRunObject::GetCharAfter(nsINode* aNode,
+                          int32_t aOffset)
 {
   MOZ_ASSERT(aNode);
 
   int32_t idx = mNodeArray.IndexOf(aNode);
   if (idx == -1) {
     // Use range comparisons to get right ws node
     return GetWSPointAfter(aNode, aOffset);
   } else {
     // Use WSPoint version of GetCharAfter()
     return GetCharAfter(WSPoint(mNodeArray[idx], aOffset, 0));
   }
 }
 
-nsWSRunObject::WSPoint
-nsWSRunObject::GetCharBefore(nsINode* aNode, int32_t aOffset)
+WSRunObject::WSPoint
+WSRunObject::GetCharBefore(nsINode* aNode,
+                           int32_t aOffset)
 {
   MOZ_ASSERT(aNode);
 
   int32_t idx = mNodeArray.IndexOf(aNode);
   if (idx == -1) {
     // Use range comparisons to get right ws node
     return GetWSPointBefore(aNode, aOffset);
   } else {
     // Use WSPoint version of GetCharBefore()
     return GetCharBefore(WSPoint(mNodeArray[idx], aOffset, 0));
   }
 }
 
-nsWSRunObject::WSPoint
-nsWSRunObject::GetCharAfter(const WSPoint &aPoint)
+WSRunObject::WSPoint
+WSRunObject::GetCharAfter(const WSPoint &aPoint)
 {
   MOZ_ASSERT(aPoint.mTextNode);
 
   WSPoint outPoint;
   outPoint.mTextNode = nullptr;
   outPoint.mOffset = 0;
   outPoint.mChar = 0;
 
@@ -1422,18 +1406,18 @@ nsWSRunObject::GetCharAfter(const WSPoin
     outPoint.mTextNode = mNodeArray[idx + 1];
     MOZ_ASSERT(outPoint.mTextNode);
     outPoint.mOffset = 0;
     outPoint.mChar = GetCharAt(outPoint.mTextNode, 0);
   }
   return outPoint;
 }
 
-nsWSRunObject::WSPoint
-nsWSRunObject::GetCharBefore(const WSPoint &aPoint)
+WSRunObject::WSPoint
+WSRunObject::GetCharBefore(const WSPoint &aPoint)
 {
   MOZ_ASSERT(aPoint.mTextNode);
 
   WSPoint outPoint;
   outPoint.mTextNode = nullptr;
   outPoint.mOffset = 0;
   outPoint.mChar = 0;
 
@@ -1456,17 +1440,17 @@ nsWSRunObject::GetCharBefore(const WSPoi
       outPoint.mOffset = len - 1;
       outPoint.mChar = GetCharAt(outPoint.mTextNode, len - 1);
     }
   }
   return outPoint;
 }
 
 nsresult
-nsWSRunObject::ConvertToNBSP(WSPoint aPoint, AreaRestriction aAR)
+WSRunObject::ConvertToNBSP(WSPoint aPoint, AreaRestriction aAR)
 {
   // MOOSE: this routine needs to be modified to preserve the integrity of the
   // wsFragment info.
   NS_ENSURE_TRUE(aPoint.mTextNode, NS_ERROR_NULL_POINTER);
 
   if (aAR == eOutsideUserSelectAll) {
     nsCOMPtr<nsIDOMNode> san =
       mHTMLEditor->FindUserSelectAllNode(GetAsDOMNode(aPoint.mTextNode));
@@ -1495,19 +1479,23 @@ nsWSRunObject::ConvertToNBSP(WSPoint aPo
     res = DeleteChars(startNode, startOffset, endNode, endOffset);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   return NS_OK;
 }
 
 void
-nsWSRunObject::GetAsciiWSBounds(int16_t aDir, nsINode* aNode, int32_t aOffset,
-                                Text** outStartNode, int32_t* outStartOffset,
-                                Text** outEndNode, int32_t* outEndOffset)
+WSRunObject::GetAsciiWSBounds(int16_t aDir,
+                              nsINode* aNode,
+                              int32_t aOffset,
+                              Text** outStartNode,
+                              int32_t* outStartOffset,
+                              Text** outEndNode,
+                              int32_t* outEndOffset)
 {
   MOZ_ASSERT(aNode && outStartNode && outStartOffset && outEndNode &&
              outEndOffset);
 
   RefPtr<Text> startNode, endNode;
   int32_t startOffset = 0, endOffset = 0;
 
   if (aDir & eAfter) {
@@ -1554,18 +1542,20 @@ nsWSRunObject::GetAsciiWSBounds(int16_t 
   *outEndOffset = endOffset;
 }
 
 /**
  * Given a dompoint, find the ws run that is before or after it, as caller
  * needs
  */
 void
-nsWSRunObject::FindRun(nsINode* aNode, int32_t aOffset, WSFragment** outRun,
-                       bool after)
+WSRunObject::FindRun(nsINode* aNode,
+                     int32_t aOffset,
+                     WSFragment** outRun,
+                     bool after)
 {
   MOZ_ASSERT(aNode && outRun);
   *outRun = nullptr;
 
   for (WSFragment* run = mStartRun; run; run = run->mRight) {
     int32_t comp = run->mStartNode ? nsContentUtils::ComparePoints(aNode,
         aOffset, run->mStartNode, run->mStartOffset) : -1;
     if (comp <= 0) {
@@ -1599,30 +1589,32 @@ nsWSRunObject::FindRun(nsINode* aNode, i
         *outRun = run;
       }
       return;
     }
   }
 }
 
 char16_t
-nsWSRunObject::GetCharAt(Text* aTextNode, int32_t aOffset)
+WSRunObject::GetCharAt(Text* aTextNode,
+                       int32_t aOffset)
 {
   // return 0 if we can't get a char, for whatever reason
   NS_ENSURE_TRUE(aTextNode, 0);
 
   int32_t len = int32_t(aTextNode->TextLength());
   if (aOffset < 0 || aOffset >= len)
     return 0;
 
   return aTextNode->GetText()->CharAt(aOffset);
 }
 
-nsWSRunObject::WSPoint
-nsWSRunObject::GetWSPointAfter(nsINode* aNode, int32_t aOffset)
+WSRunObject::WSPoint
+WSRunObject::GetWSPointAfter(nsINode* aNode,
+                             int32_t aOffset)
 {
   // Note: only to be called if aNode is not a ws node.
 
   // Binary search on wsnodes
   uint32_t numNodes = mNodeArray.Length();
 
   if (!numNodes) {
     // Do nothing if there are no nodes to search
@@ -1660,18 +1652,19 @@ nsWSRunObject::GetWSPointAfter(nsINode* 
   } else {
     // The char after the point is the first character of our range.
     RefPtr<Text> textNode(mNodeArray[curNum]);
     WSPoint point(textNode, 0, 0);
     return GetCharAfter(point);
   }
 }
 
-nsWSRunObject::WSPoint
-nsWSRunObject::GetWSPointBefore(nsINode* aNode, int32_t aOffset)
+WSRunObject::WSPoint
+WSRunObject::GetWSPointBefore(nsINode* aNode,
+                              int32_t aOffset)
 {
   // Note: only to be called if aNode is not a ws node.
 
   // Binary search on wsnodes
   uint32_t numNodes = mNodeArray.Length();
 
   if (!numNodes) {
     // Do nothing if there are no nodes to search
@@ -1712,17 +1705,17 @@ nsWSRunObject::GetWSPointBefore(nsINode*
     // appropriate character
     RefPtr<Text> textNode(mNodeArray[curNum]);
     WSPoint point(textNode, 0, 0);
     return GetCharBefore(point);
   }
 }
 
 nsresult
-nsWSRunObject::CheckTrailingNBSPOfRun(WSFragment *aRun)
+WSRunObject::CheckTrailingNBSPOfRun(WSFragment *aRun)
 {
   // Try to change an nbsp to a space, if possible, just to prevent nbsp
   // proliferation.  Examine what is before and after the trailing nbsp, if
   // any.
   NS_ENSURE_TRUE(aRun, NS_ERROR_NULL_POINTER);
   nsresult res;
   bool leftCheck = false;
   bool spaceNBSP = false;
@@ -1828,18 +1821,19 @@ nsWSRunObject::CheckTrailingNBSPOfRun(WS
                                                     startOffset, true);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
   return NS_OK;
 }
 
 nsresult
-nsWSRunObject::CheckTrailingNBSP(WSFragment* aRun, nsINode* aNode,
-                                 int32_t aOffset)
+WSRunObject::CheckTrailingNBSP(WSFragment* aRun,
+                               nsINode* aNode,
+                               int32_t aOffset)
 {
   // Try to change an nbsp to a space, if possible, just to prevent nbsp
   // proliferation.  This routine is called when we are about to make this
   // point in the ws abut an inserted break or text, so we don't have to worry
   // about what is after it.  What is after it now will end up after the
   // inserted object.
   NS_ENSURE_TRUE(aRun && aNode, NS_ERROR_NULL_POINTER);
   bool canConvert = false;
@@ -1867,18 +1861,19 @@ nsWSRunObject::CheckTrailingNBSP(WSFragm
     res = DeleteChars(thePoint.mTextNode, thePoint.mOffset + 1,
                       thePoint.mTextNode, thePoint.mOffset + 2);
     NS_ENSURE_SUCCESS(res, res);
   }
   return NS_OK;
 }
 
 nsresult
-nsWSRunObject::CheckLeadingNBSP(WSFragment* aRun, nsINode* aNode,
-                                int32_t aOffset)
+WSRunObject::CheckLeadingNBSP(WSFragment* aRun,
+                              nsINode* aNode,
+                              int32_t aOffset)
 {
   // Try to change an nbsp to a space, if possible, just to prevent nbsp
   // proliferation This routine is called when we are about to make this point
   // in the ws abut an inserted text, so we don't have to worry about what is
   // before it.  What is before it now will end up before the inserted text.
   bool canConvert = false;
   WSPoint thePoint = GetCharAfter(aNode, aOffset);
   if (thePoint.mChar == nbsp) {
@@ -1909,29 +1904,31 @@ nsWSRunObject::CheckLeadingNBSP(WSFragme
                       thePoint.mTextNode, thePoint.mOffset + 2);
     NS_ENSURE_SUCCESS(res, res);
   }
   return NS_OK;
 }
 
 
 nsresult
-nsWSRunObject::Scrub()
+WSRunObject::Scrub()
 {
   WSFragment *run = mStartRun;
   while (run)
   {
     if (run->mType & (WSType::leadingWS | WSType::trailingWS)) {
       nsresult res = DeleteChars(run->mStartNode, run->mStartOffset,
                                  run->mEndNode, run->mEndOffset);
       NS_ENSURE_SUCCESS(res, res);
     }
     run = run->mRight;
   }
   return NS_OK;
 }
 
 bool
-nsWSRunObject::IsBlockNode(nsINode* aNode)
+WSRunObject::IsBlockNode(nsINode* aNode)
 {
   return aNode && aNode->IsElement() &&
          nsHTMLEditor::NodeIsBlockStatic(aNode->AsElement());
 }
+
+} // namespace mozilla
rename from editor/libeditor/nsWSRunObject.h
rename to editor/libeditor/WSRunObject.h
--- a/editor/libeditor/nsWSRunObject.h
+++ b/editor/libeditor/WSRunObject.h
@@ -1,30 +1,32 @@
 /* -*- 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 __wsrunobject_h__
-#define __wsrunobject_h__
+#ifndef WSRunObject_h
+#define WSRunObject_h
 
 #include "nsCOMPtr.h"
 #include "nsIEditor.h" // for EDirection
 #include "nsINode.h"
 #include "nscore.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Text.h"
 
 class nsHTMLEditor;
+class nsHTMLEditRules;
 class nsIDOMNode;
+
 namespace mozilla {
+
 struct EditorDOMPoint;
-} // namespace mozilla
 
-// class nsWSRunObject represents the entire whitespace situation
+// class WSRunObject represents the entire whitespace situation
 // around a given point.  It collects up a list of nodes that contain
 // whitespace and categorizes in up to 3 different WSFragments (detailed
 // below).  Each WSFragment is a collection of whitespace that is
 // either all insignificant, or that is significant.  A WSFragment could
 // consist of insignificant whitespace because it is after a block
 // boundary or after a break.  Or it could be insignificant because it
 // is before a block.  Or it could be significant because it is
 // surrounded by text, or starts and ends with nbsps, etc.
@@ -34,24 +36,26 @@ struct EditorDOMPoint;
 // are adjacent to block boundaries, or after a break.  NormalWS is ws that
 // does cause soem rendering.  Note that not all the ws in a NormalWS run need
 // render.  For example, two ascii spaces surrounded by text on both sides
 // will only render as one space (in non-preformatted stlye html), yet both
 // spaces count as NormalWS.  Together, they render as the one visible space.
 
 /**
  * A type-safe bitfield indicating various types of whitespace or other things.
- * Used as a member variable in nsWSRunObject and WSFragment.
+ * Used as a member variable in WSRunObject and WSFragment.
  *
  * XXX: If this idea is useful in other places, we should generalize it using a
  * template.
  */
-class WSType {
+class WSType
+{
 public:
-  enum Enum {
+  enum Enum
+  {
     none       = 0,
     leadingWS  = 1,      // leading insignificant ws, ie, after block or br
     trailingWS = 1 << 1, // trailing insignificant ws, ie, before block
     normalWS   = 1 << 2, // normal significant ws, ie, after text, image, ...
     text       = 1 << 3, // indicates regular (non-ws) text
     special    = 1 << 4, // indicates an inline non-container, like image
     br         = 1 << 5, // indicates a br node
     otherBlock = 1 << 6, // indicates a block other than one ws run is in
@@ -59,37 +63,45 @@ public:
     block      = otherBlock | thisBlock // block found
   };
 
   /**
    * Implicit constructor, because the enums are logically just WSTypes
    * themselves, and are only a separate type because there's no other obvious
    * way to name specific WSType values.
    */
-  MOZ_IMPLICIT WSType(const Enum& aEnum = none) : mEnum(aEnum) {}
+  MOZ_IMPLICIT WSType(const Enum& aEnum = none)
+    : mEnum(aEnum)
+  {}
+
   // operator==, &, and | need to access mEnum
   friend bool operator==(const WSType& aLeft, const WSType& aRight);
   friend const WSType operator&(const WSType& aLeft, const WSType& aRight);
   friend const WSType operator|(const WSType& aLeft, const WSType& aRight);
-  WSType& operator=(const WSType& aOther) {
+  WSType& operator=(const WSType& aOther)
+  {
     // This handles self-assignment fine
     mEnum = aOther.mEnum;
     return *this;
   }
-  WSType& operator&=(const WSType& aOther) {
+  WSType& operator&=(const WSType& aOther)
+  {
     mEnum &= aOther.mEnum;
     return *this;
   }
-  WSType& operator|=(const WSType& aOther) {
+  WSType& operator|=(const WSType& aOther)
+  {
     mEnum |= aOther.mEnum;
     return *this;
   }
+
 private:
   uint16_t mEnum;
   void bool_conversion_helper() {}
+
 public:
   // Allow boolean conversion with no numeric conversion
   typedef void (WSType::*bool_type)();
   operator bool_type() const
   {
     return mEnum ? &WSType::bool_conversion_helper : nullptr;
   }
 };
@@ -97,292 +109,303 @@ public:
 /**
  * These are declared as global functions so "WSType::Enum == WSType" et al.
  * will work using the implicit constructor.
  */
 inline bool operator==(const WSType& aLeft, const WSType& aRight)
 {
   return aLeft.mEnum == aRight.mEnum;
 }
+
 inline bool operator!=(const WSType& aLeft, const WSType& aRight)
 {
   return !(aLeft == aRight);
 }
+
 inline const WSType operator&(const WSType& aLeft, const WSType& aRight)
 {
   WSType ret;
   ret.mEnum = aLeft.mEnum & aRight.mEnum;
   return ret;
 }
+
 inline const WSType operator|(const WSType& aLeft, const WSType& aRight)
 {
   WSType ret;
   ret.mEnum = aLeft.mEnum | aRight.mEnum;
   return ret;
 }
 
 /**
  * Make sure that & and | of WSType::Enum creates a WSType instead of an int,
  * because operators between WSType and int shouldn't work
  */
 inline const WSType operator&(const WSType::Enum& aLeft,
                               const WSType::Enum& aRight)
 {
   return WSType(aLeft) & WSType(aRight);
 }
+
 inline const WSType operator|(const WSType::Enum& aLeft,
                               const WSType::Enum& aRight)
 {
   return WSType(aLeft) | WSType(aRight);
 }
 
-
-class MOZ_STACK_CLASS nsWSRunObject
+class MOZ_STACK_CLASS WSRunObject final
 {
-  public:
+public:
+  enum BlockBoundary
+  {
+    kBeforeBlock,
+    kBlockStart,
+    kBlockEnd,
+    kAfterBlock
+  };
 
-    // public enums ---------------------------------------------------------
-    enum BlockBoundary
-    {
-      kBeforeBlock,
-      kBlockStart,
-      kBlockEnd,
-      kAfterBlock
-    };
+  enum {eBefore = 1};
+  enum {eAfter  = 1 << 1};
+  enum {eBoth   = eBefore | eAfter};
 
-    enum {eBefore = 1};
-    enum {eAfter  = 1 << 1};
-    enum {eBoth   = eBefore | eAfter};
+  WSRunObject(nsHTMLEditor* aHTMLEditor, nsINode* aNode, int32_t aOffset);
+  WSRunObject(nsHTMLEditor* aHTMLEditor, nsIDOMNode* aNode, int32_t aOffset);
+  ~WSRunObject();
 
-    // constructor / destructor -----------------------------------------------
-    nsWSRunObject(nsHTMLEditor* aEd, nsINode* aNode, int32_t aOffset);
-    nsWSRunObject(nsHTMLEditor *aEd, nsIDOMNode *aNode, int32_t aOffset);
-    ~nsWSRunObject();
-
-    // public methods ---------------------------------------------------------
+  // ScrubBlockBoundary removes any non-visible whitespace at the specified
+  // location relative to a block node.
+  static nsresult ScrubBlockBoundary(nsHTMLEditor* aHTMLEditor,
+                                     BlockBoundary aBoundary,
+                                     nsINode* aBlock,
+                                     int32_t aOffset = -1);
 
-    // ScrubBlockBoundary removes any non-visible whitespace at the specified
-    // location relative to a block node.
-    static nsresult ScrubBlockBoundary(nsHTMLEditor* aHTMLEd,
-                                       BlockBoundary aBoundary,
-                                       nsINode* aBlock,
-                                       int32_t aOffset = -1);
-
-    // PrepareToJoinBlocks fixes up ws at the end of aLeftBlock and the
-    // beginning of aRightBlock in preperation for them to be joined.  Example
-    // of fixup: trailingws in aLeftBlock needs to be removed.
-    static nsresult PrepareToJoinBlocks(nsHTMLEditor* aEd,
-                                        mozilla::dom::Element* aLeftBlock,
-                                        mozilla::dom::Element* aRightBlock);
+  // PrepareToJoinBlocks fixes up ws at the end of aLeftBlock and the
+  // beginning of aRightBlock in preperation for them to be joined.  Example
+  // of fixup: trailingws in aLeftBlock needs to be removed.
+  static nsresult PrepareToJoinBlocks(nsHTMLEditor* aHTMLEditor,
+                                      dom::Element* aLeftBlock,
+                                      dom::Element* aRightBlock);
 
-    // PrepareToDeleteRange fixes up ws before {aStartNode,aStartOffset}
-    // and after {aEndNode,aEndOffset} in preperation for content
-    // in that range to be deleted.  Note that the nodes and offsets
-    // are adjusted in response to any dom changes we make while
-    // adjusting ws.
-    // example of fixup: trailingws before {aStartNode,aStartOffset}
-    //                   needs to be removed.
-    static nsresult PrepareToDeleteRange(nsHTMLEditor* aHTMLEd,
-                                         nsCOMPtr<nsINode>* aStartNode,
-                                         int32_t* aStartOffset,
-                                         nsCOMPtr<nsINode>* aEndNode,
-                                         int32_t* aEndOffset);
+  // PrepareToDeleteRange fixes up ws before {aStartNode,aStartOffset}
+  // and after {aEndNode,aEndOffset} in preperation for content
+  // in that range to be deleted.  Note that the nodes and offsets
+  // are adjusted in response to any dom changes we make while
+  // adjusting ws.
+  // example of fixup: trailingws before {aStartNode,aStartOffset}
+  //                   needs to be removed.
+  static nsresult PrepareToDeleteRange(nsHTMLEditor* aHTMLEditor,
+                                       nsCOMPtr<nsINode>* aStartNode,
+                                       int32_t* aStartOffset,
+                                       nsCOMPtr<nsINode>* aEndNode,
+                                       int32_t* aEndOffset);
 
-    // PrepareToDeleteNode fixes up ws before and after aContent in preparation
-    // for aContent to be deleted.  Example of fixup: trailingws before
-    // aContent needs to be removed.
-    static nsresult PrepareToDeleteNode(nsHTMLEditor *aHTMLEd,
-                                        nsIContent* aContent);
+  // PrepareToDeleteNode fixes up ws before and after aContent in preparation
+  // for aContent to be deleted.  Example of fixup: trailingws before
+  // aContent needs to be removed.
+  static nsresult PrepareToDeleteNode(nsHTMLEditor* aHTMLEditor,
+                                      nsIContent* aContent);
+
+  // PrepareToSplitAcrossBlocks fixes up ws before and after
+  // {aSplitNode,aSplitOffset} in preparation for a block parent to be split.
+  // Note that the aSplitNode and aSplitOffset are adjusted in response to
+  // any DOM changes we make while adjusting ws.  Example of fixup: normalws
+  // before {aSplitNode,aSplitOffset} needs to end with nbsp.
+  static nsresult PrepareToSplitAcrossBlocks(nsHTMLEditor* aHTMLEditor,
+                                             nsCOMPtr<nsINode>* aSplitNode,
+                                             int32_t* aSplitOffset);
 
-    // PrepareToSplitAcrossBlocks fixes up ws before and after
-    // {aSplitNode,aSplitOffset} in preparation for a block parent to be split.
-    // Note that the aSplitNode and aSplitOffset are adjusted in response to
-    // any DOM changes we make while adjusting ws.  Example of fixup: normalws
-    // before {aSplitNode,aSplitOffset} needs to end with nbsp.
-    static nsresult PrepareToSplitAcrossBlocks(nsHTMLEditor* aHTMLEd,
-                                               nsCOMPtr<nsINode>* aSplitNode,
-                                               int32_t* aSplitOffset);
+  // InsertBreak inserts a br node at {aInOutParent,aInOutOffset}
+  // and makes any needed adjustments to ws around that point.
+  // example of fixup: normalws after {aInOutParent,aInOutOffset}
+  //                   needs to begin with nbsp.
+  dom::Element* InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
+                            int32_t* aInOutOffset,
+                            nsIEditor::EDirection aSelect);
 
-    // InsertBreak inserts a br node at {aInOutParent,aInOutOffset}
-    // and makes any needed adjustments to ws around that point.
-    // example of fixup: normalws after {aInOutParent,aInOutOffset}
-    //                   needs to begin with nbsp.
-    mozilla::dom::Element* InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
-                                       int32_t* aInOutOffset,
-                                       nsIEditor::EDirection aSelect);
+  // InsertText inserts a string at {aInOutParent,aInOutOffset} and makes any
+  // needed adjustments to ws around that point.  Example of fixup:
+  // trailingws before {aInOutParent,aInOutOffset} needs to be removed.
+  nsresult InsertText(const nsAString& aStringToInsert,
+                      nsCOMPtr<nsINode>* aInOutNode,
+                      int32_t* aInOutOffset,
+                      nsIDocument* aDoc);
 
-    // InsertText inserts a string at {aInOutParent,aInOutOffset} and makes any
-    // needed adjustments to ws around that point.  Example of fixup:
-    // trailingws before {aInOutParent,aInOutOffset} needs to be removed.
-    nsresult InsertText(const nsAString& aStringToInsert,
-                        nsCOMPtr<nsINode>* aInOutNode,
-                        int32_t* aInOutOffset,
-                        nsIDocument* aDoc);
+  // DeleteWSBackward deletes a single visible piece of ws before the ws
+  // point (the point to create the wsRunObject, passed to its constructor).
+  // It makes any needed conversion to adjacent ws to retain its
+  // significance.
+  nsresult DeleteWSBackward();
 
-    // DeleteWSBackward deletes a single visible piece of ws before the ws
-    // point (the point to create the wsRunObject, passed to its constructor).
-    // It makes any needed conversion to adjacent ws to retain its
-    // significance.
-    nsresult DeleteWSBackward();
+  // DeleteWSForward deletes a single visible piece of ws after the ws point
+  // (the point to create the wsRunObject, passed to its constructor).  It
+  // makes any needed conversion to adjacent ws to retain its significance.
+  nsresult DeleteWSForward();
 
-    // DeleteWSForward deletes a single visible piece of ws after the ws point
-    // (the point to create the wsRunObject, passed to its constructor).  It
-    // makes any needed conversion to adjacent ws to retain its significance.
-    nsresult DeleteWSForward();
-
-    // PriorVisibleNode returns the first piece of visible thing before
-    // {aNode,aOffset}.  If there is no visible ws qualifying it returns what
-    // is before the ws run.  Note that {outVisNode,outVisOffset} is set to
-    // just AFTER the visible object.
-    void PriorVisibleNode(nsINode* aNode,
-                          int32_t aOffset,
-                          nsCOMPtr<nsINode>* outVisNode,
-                          int32_t* outVisOffset,
-                          WSType* outType);
+  // PriorVisibleNode returns the first piece of visible thing before
+  // {aNode,aOffset}.  If there is no visible ws qualifying it returns what
+  // is before the ws run.  Note that {outVisNode,outVisOffset} is set to
+  // just AFTER the visible object.
+  void PriorVisibleNode(nsINode* aNode,
+                        int32_t aOffset,
+                        nsCOMPtr<nsINode>* outVisNode,
+                        int32_t* outVisOffset,
+                        WSType* outType);
 
-    // NextVisibleNode returns the first piece of visible thing after
-    // {aNode,aOffset}.  If there is no visible ws qualifying it returns what
-    // is after the ws run.  Note that {outVisNode,outVisOffset} is set to just
-    // BEFORE the visible object.
-    void NextVisibleNode(nsINode* aNode,
-                         int32_t aOffset,
-                         nsCOMPtr<nsINode>* outVisNode,
-                         int32_t* outVisOffset,
-                         WSType* outType);
+  // NextVisibleNode returns the first piece of visible thing after
+  // {aNode,aOffset}.  If there is no visible ws qualifying it returns what
+  // is after the ws run.  Note that {outVisNode,outVisOffset} is set to just
+  // BEFORE the visible object.
+  void NextVisibleNode(nsINode* aNode,
+                       int32_t aOffset,
+                       nsCOMPtr<nsINode>* outVisNode,
+                       int32_t* outVisOffset,
+                       WSType* outType);
+
+  // AdjustWhitespace examines the ws object for nbsp's that can
+  // be safely converted to regular ascii space and converts them.
+  nsresult AdjustWhitespace();
 
-    // AdjustWhitespace examines the ws object for nbsp's that can
-    // be safely converted to regular ascii space and converts them.
-    nsresult AdjustWhitespace();
-
-  protected:
+protected:
+  // WSFragment represents a single run of ws (all leadingws, or all normalws,
+  // or all trailingws, or all leading+trailingws).  Note that this single run
+  // may still span multiple nodes.
+  struct WSFragment final
+  {
+    nsCOMPtr<nsINode> mStartNode;  // node where ws run starts
+    nsCOMPtr<nsINode> mEndNode;    // node where ws run ends
+    int32_t mStartOffset;          // offset where ws run starts
+    int32_t mEndOffset;            // offset where ws run ends
+    // type of ws, and what is to left and right of it
+    WSType mType, mLeftType, mRightType;
+    // other ws runs to left or right.  may be null.
+    WSFragment *mLeft, *mRight;
 
-    // WSFragment struct ---------------------------------------------------------
-    // WSFragment represents a single run of ws (all leadingws, or all normalws,
-    // or all trailingws, or all leading+trailingws).  Note that this single run may
-    // still span multiple nodes.
-    struct WSFragment
-    {
-      nsCOMPtr<nsINode> mStartNode;  // node where ws run starts
-      nsCOMPtr<nsINode> mEndNode;    // node where ws run ends
-      int32_t mStartOffset;          // offset where ws run starts
-      int32_t mEndOffset;            // offset where ws run ends
-      // type of ws, and what is to left and right of it
-      WSType mType, mLeftType, mRightType;
-      // other ws runs to left or right.  may be null.
-      WSFragment *mLeft, *mRight;
+    WSFragment()
+      : mStartOffset(0)
+      , mEndOffset(0)
+      , mLeft(nullptr)
+      , mRight(nullptr)
+    {}
+  };
 
-      WSFragment() : mStartNode(0), mEndNode(0),
-                     mStartOffset(0), mEndOffset(0),
-                     mType(), mLeftType(), mRightType(),
-                     mLeft(0), mRight(0)
-      {
-      }
-    };
+  // A WSPoint struct represents a unique location within the ws run.  It is
+  // always within a textnode that is one of the nodes stored in the list
+  // in the wsRunObject.  For convenience, the character at that point is also
+  // stored in the struct.
+  struct MOZ_STACK_CLASS WSPoint final
+  {
+    RefPtr<dom::Text> mTextNode;
+    uint32_t mOffset;
+    char16_t mChar;
 
-    // WSPoint struct ------------------------------------------------------------
-    // A WSPoint struct represents a unique location within the ws run.  It is
-    // always within a textnode that is one of the nodes stored in the list
-    // in the wsRunObject.  For convenience, the character at that point is also
-    // stored in the struct.
-    struct MOZ_STACK_CLASS WSPoint
-    {
-      RefPtr<mozilla::dom::Text> mTextNode;
-      uint32_t mOffset;
-      char16_t mChar;
+    WSPoint()
+      : mTextNode(0)
+      , mOffset(0)
+      , mChar(0)
+    {}
 
-      WSPoint() : mTextNode(0),mOffset(0),mChar(0) {}
-      WSPoint(mozilla::dom::Text* aTextNode, int32_t aOffset, char16_t aChar) :
-                     mTextNode(aTextNode),mOffset(aOffset),mChar(aChar) {}
-    };
-
-    enum AreaRestriction
-    {
-      eAnywhere, eOutsideUserSelectAll
-    };
+    WSPoint(dom::Text* aTextNode, int32_t aOffset, char16_t aChar)
+      : mTextNode(aTextNode)
+      , mOffset(aOffset)
+      , mChar(aChar)
+    {}
+  };
 
-    // protected methods ---------------------------------------------------------
-    // tons of utility methods.
+  enum AreaRestriction
+  {
+    eAnywhere, eOutsideUserSelectAll
+  };
 
-    /**
-     * Return the node which we will handle white-space under. This is the
-     * closest block within the DOM subtree we're editing, or if none is
-     * found, the (inline) root of the editable subtree.
-     */
-    nsINode* GetWSBoundingParent();
+  /**
+   * Return the node which we will handle white-space under. This is the
+   * closest block within the DOM subtree we're editing, or if none is
+   * found, the (inline) root of the editable subtree.
+   */
+  nsINode* GetWSBoundingParent();
 
-    nsresult GetWSNodes();
-    void     GetRuns();
-    void     ClearRuns();
-    void     MakeSingleWSRun(WSType aType);
-    nsIContent* GetPreviousWSNodeInner(nsINode* aStartNode,
-                                       nsINode* aBlockParent);
-    nsIContent* GetPreviousWSNode(mozilla::EditorDOMPoint aPoint,
-                                  nsINode* aBlockParent);
-    nsIContent* GetNextWSNodeInner(nsINode* aStartNode, nsINode* aBlockParent);
-    nsIContent* GetNextWSNode(mozilla::EditorDOMPoint aPoint,
-                              nsINode* aBlockParent);
-    nsresult PrepareToDeleteRangePriv(nsWSRunObject* aEndObject);
-    nsresult PrepareToSplitAcrossBlocksPriv();
-    nsresult DeleteChars(nsINode* aStartNode, int32_t aStartOffset,
-                         nsINode* aEndNode, int32_t aEndOffset,
+  nsresult GetWSNodes();
+  void GetRuns();
+  void ClearRuns();
+  void MakeSingleWSRun(WSType aType);
+  nsIContent* GetPreviousWSNodeInner(nsINode* aStartNode,
+                                     nsINode* aBlockParent);
+  nsIContent* GetPreviousWSNode(EditorDOMPoint aPoint, nsINode* aBlockParent);
+  nsIContent* GetNextWSNodeInner(nsINode* aStartNode, nsINode* aBlockParent);
+  nsIContent* GetNextWSNode(EditorDOMPoint aPoint, nsINode* aBlockParent);
+  nsresult PrepareToDeleteRangePriv(WSRunObject* aEndObject);
+  nsresult PrepareToSplitAcrossBlocksPriv();
+  nsresult DeleteChars(nsINode* aStartNode, int32_t aStartOffset,
+                       nsINode* aEndNode, int32_t aEndOffset,
+                       AreaRestriction aAR = eAnywhere);
+  WSPoint GetCharAfter(nsINode* aNode, int32_t aOffset);
+  WSPoint GetCharBefore(nsINode* aNode, int32_t aOffset);
+  WSPoint GetCharAfter(const WSPoint& aPoint);
+  WSPoint GetCharBefore(const WSPoint& aPoint);
+  nsresult ConvertToNBSP(WSPoint aPoint,
                          AreaRestriction aAR = eAnywhere);
-    WSPoint  GetCharAfter(nsINode* aNode, int32_t aOffset);
-    WSPoint  GetCharBefore(nsINode* aNode, int32_t aOffset);
-    WSPoint  GetCharAfter(const WSPoint& aPoint);
-    WSPoint  GetCharBefore(const WSPoint& aPoint);
-    nsresult ConvertToNBSP(WSPoint aPoint,
-                           AreaRestriction aAR = eAnywhere);
-    void     GetAsciiWSBounds(int16_t aDir, nsINode* aNode, int32_t aOffset,
-                              mozilla::dom::Text** outStartNode,
-                              int32_t* outStartOffset,
-                              mozilla::dom::Text** outEndNode,
-                              int32_t* outEndOffset);
-    void     FindRun(nsINode* aNode, int32_t aOffset, WSFragment** outRun,
-                     bool after);
-    char16_t GetCharAt(mozilla::dom::Text* aTextNode, int32_t aOffset);
-    WSPoint  GetWSPointAfter(nsINode* aNode, int32_t aOffset);
-    WSPoint  GetWSPointBefore(nsINode* aNode, int32_t aOffset);
-    nsresult CheckTrailingNBSPOfRun(WSFragment *aRun);
-    nsresult CheckTrailingNBSP(WSFragment* aRun, nsINode* aNode,
-                               int32_t aOffset);
-    nsresult CheckLeadingNBSP(WSFragment* aRun, nsINode* aNode,
-                              int32_t aOffset);
+  void GetAsciiWSBounds(int16_t aDir, nsINode* aNode, int32_t aOffset,
+                        dom::Text** outStartNode, int32_t* outStartOffset,
+                        dom::Text** outEndNode, int32_t* outEndOffset);
+  void FindRun(nsINode* aNode, int32_t aOffset, WSFragment** outRun,
+               bool after);
+  char16_t GetCharAt(dom::Text* aTextNode, int32_t aOffset);
+  WSPoint GetWSPointAfter(nsINode* aNode, int32_t aOffset);
+  WSPoint GetWSPointBefore(nsINode* aNode, int32_t aOffset);
+  nsresult CheckTrailingNBSPOfRun(WSFragment *aRun);
+  nsresult CheckTrailingNBSP(WSFragment* aRun, nsINode* aNode,
+                             int32_t aOffset);
+  nsresult CheckLeadingNBSP(WSFragment* aRun, nsINode* aNode,
+                            int32_t aOffset);
 
-    nsresult Scrub();
-    bool IsBlockNode(nsINode* aNode);
+  nsresult Scrub();
+  bool IsBlockNode(nsINode* aNode);
 
-    // member variables ---------------------------------------------------------
+  // The node passed to our constructor.
+  nsCOMPtr<nsINode> mNode;
+  // The offset passed to our contructor.
+  int32_t mOffset;
+  // Together, the above represent the point at which we are building up ws info.
 
-    nsCOMPtr<nsINode> mNode;           // the node passed to our constructor
-    int32_t mOffset;                   // the offset passed to our contructor
-    // together, the above represent the point at which we are building up ws info.
+  // true if we are in preformatted whitespace context.
+  bool mPRE;
+  // Node/offset where ws starts.
+  nsCOMPtr<nsINode> mStartNode;
+  int32_t mStartOffset;
+  // Reason why ws starts (eText, eOtherBlock, etc).
+  WSType mStartReason;
+  // The node that implicated by start reason.
+  nsCOMPtr<nsINode> mStartReasonNode;
 
-    bool    mPRE;                      // true if we are in preformatted whitespace context
-    nsCOMPtr<nsINode> mStartNode;      // node/offset where ws starts
-    int32_t mStartOffset;              // ...
-    WSType mStartReason;               // reason why ws starts (eText, eOtherBlock, etc)
-    nsCOMPtr<nsINode> mStartReasonNode;// the node that implicated by start reason
-
-    nsCOMPtr<nsINode> mEndNode;        // node/offset where ws ends
-    int32_t mEndOffset;                // ...
-    WSType mEndReason;                 // reason why ws ends (eText, eOtherBlock, etc)
-    nsCOMPtr<nsINode> mEndReasonNode;  // the node that implicated by end reason
+  // Node/offset where ws ends.
+  nsCOMPtr<nsINode> mEndNode;
+  int32_t mEndOffset;
+  // Reason why ws ends (eText, eOtherBlock, etc).
+  WSType mEndReason;
+  // The node that implicated by end reason.
+  nsCOMPtr<nsINode> mEndReasonNode;
 
-    RefPtr<mozilla::dom::Text> mFirstNBSPNode; // location of first nbsp in ws run, if any
-    int32_t mFirstNBSPOffset;          // ...
+  // Location of first nbsp in ws run, if any.
+  RefPtr<dom::Text> mFirstNBSPNode;
+  int32_t mFirstNBSPOffset;
 
-    RefPtr<mozilla::dom::Text> mLastNBSPNode; // location of last nbsp in ws run, if any
-    int32_t mLastNBSPOffset;           // ...
+  // Location of last nbsp in ws run, if any.
+  RefPtr<dom::Text> mLastNBSPNode;
+  int32_t mLastNBSPOffset;
+
+  // The list of nodes containing ws in this run.
+  nsTArray<RefPtr<dom::Text>> mNodeArray;
 
-    // the list of nodes containing ws in this run
-    nsTArray<RefPtr<mozilla::dom::Text>> mNodeArray;
+  // The first WSFragment in the run.
+  WSFragment* mStartRun;
+  // The last WSFragment in the run, may be same as first.
+  WSFragment* mEndRun;
 
-    WSFragment *mStartRun;             // the first WSFragment in the run
-    WSFragment *mEndRun;               // the last WSFragment in the run, may be same as first
+  // Non-owning.
+  nsHTMLEditor* mHTMLEditor;
 
-    nsHTMLEditor *mHTMLEditor;         // non-owning.
-
-    friend class nsHTMLEditRules;  // opening this class up for pillaging
-    friend class nsHTMLEditor;     // opening this class up for more pillaging
+  // Opening this class up for pillaging.
+  friend class nsHTMLEditRules;
+  // Opening this class up for more pillaging.
+  friend class nsHTMLEditor;
 };
 
-#endif
+} // namespace mozilla
 
+#endif // #ifndef WSRunObject_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -48,25 +48,25 @@ UNIFIED_SOURCES += [
     'nsHTMLEditRules.cpp',
     'nsHTMLInlineTableEditor.cpp',
     'nsHTMLObjectResizer.cpp',
     'nsPlaintextDataTransfer.cpp',
     'nsPlaintextEditor.cpp',
     'nsTableEditor.cpp',
     'nsTextEditRules.cpp',
     'nsTextEditRulesBidi.cpp',
-    'nsWSRunObject.cpp',
     'PlaceholderTransaction.cpp',
     'SelectionState.cpp',
     'SetDocumentTitleTransaction.cpp',
     'SplitNodeTransaction.cpp',
     'StyleSheetTransactions.cpp',
     'TextEditorTest.cpp',
     'TextEditUtils.cpp',
     'TypeInState.cpp',
+    'WSRunObject.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
     '/editor/txmgr',
     '/extensions/spellcheck/src',
     '/layout/generic',
     '/layout/style',
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <string.h>
 
 #include "EditorUtils.h"
 #include "HTMLEditUtils.h"
 #include "SelectionState.h"
 #include "TextEditUtils.h"
+#include "WSRunObject.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/DOMStringList.h"
 #include "mozilla/OwningNonNull.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Base64.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/Preferences.h"
@@ -76,17 +77,16 @@
 #include "nsServiceManagerUtils.h"
 #include "nsStreamUtils.h"
 #include "nsString.h"
 #include "nsStringFwd.h"
 #include "nsStringIterator.h"
 #include "nsSubstringTuple.h"
 #include "nsTextEditRules.h"
 #include "nsTreeSanitizer.h"
-#include "nsWSRunObject.h"
 #include "nsXPCOM.h"
 #include "nscore.h"
 #include "nsContentUtils.h"
 
 class nsIAtom;
 class nsILoadContext;
 class nsISupports;
 
@@ -384,17 +384,17 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
 
     // Adjust position based on the first node we are going to insert.
     NormalizeEOLInsertPosition(nodeList[0], address_of(parentNode),
                                &offsetOfNewNode);
 
     // if there are any invisible br's after our insertion point, remove them.
     // this is because if there is a br at end of what we paste, it will make
     // the invisible br visible.
-    nsWSRunObject wsObj(this, parentNode, offsetOfNewNode);
+    WSRunObject wsObj(this, parentNode, offsetOfNewNode);
     if (wsObj.mEndReasonNode &&
         TextEditUtils::IsBreak(wsObj.mEndReasonNode) &&
         !IsVisBreak(wsObj.mEndReasonNode)) {
       rv = DeleteNode(wsObj.mEndReasonNode);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     // Remember if we are in a link.
@@ -642,35 +642,35 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
         selNode = GetNodeLocation(tmp, &selOffset);
         // selNode might be null in case a mutation listener removed
         // the stuff we just inserted from the DOM.
         NS_ENSURE_STATE(selNode);
         ++selOffset;  // want to be *after* last leaf node in paste
       }
 
       // make sure we don't end up with selection collapsed after an invisible break node
-      nsWSRunObject wsRunObj(this, selNode, selOffset);
+      WSRunObject wsRunObj(this, selNode, selOffset);
       nsCOMPtr<nsINode> visNode;
       int32_t outVisOffset=0;
       WSType visType;
       nsCOMPtr<nsINode> selNode_(do_QueryInterface(selNode));
       wsRunObj.PriorVisibleNode(selNode_, selOffset, address_of(visNode),
                                 &outVisOffset, &visType);
       if (visType == WSType::br) {
         // we are after a break.  Is it visible?  Despite the name,
         // PriorVisibleNode does not make that determination for breaks.
         // It also may not return the break in visNode.  We have to pull it
-        // out of the nsWSRunObject's state.
+        // out of the WSRunObject's state.
         if (!IsVisBreak(wsRunObj.mStartReasonNode))
         {
           // don't leave selection past an invisible break;
           // reset {selNode,selOffset} to point before break
           selNode = GetNodeLocation(GetAsDOMNode(wsRunObj.mStartReasonNode), &selOffset);
           // we want to be inside any inline style prior to break
-          nsWSRunObject wsRunObj(this, selNode, selOffset);
+          WSRunObject wsRunObj(this, selNode, selOffset);
           selNode_ = do_QueryInterface(selNode);
           wsRunObj.PriorVisibleNode(selNode_, selOffset, address_of(visNode),
                                     &outVisOffset, &visType);
           if (visType == WSType::text || visType == WSType::normalWS) {
             selNode = GetAsDOMNode(visNode);
             selOffset = outVisOffset;  // PriorVisibleNode already set offset to _after_ the text or ws
           } else if (visType == WSType::special) {
             // prior visible thing is an image or some other non-text thingy.
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -7,16 +7,17 @@
 #include "nsHTMLEditRules.h"
 
 #include <stdlib.h>
 
 #include "CSSEditUtils.h"
 #include "EditorUtils.h"
 #include "HTMLEditUtils.h"
 #include "TextEditUtils.h"
+#include "WSRunObject.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/OwningNonNull.h"
 #include "mozilla/mozalloc.h"
 #include "nsAutoPtr.h"
@@ -48,17 +49,16 @@
 #include "nsRange.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "nsTextNode.h"
 #include "nsThreadUtils.h"
 #include "nsUnicharUtils.h"
-#include "nsWSRunObject.h"
 #include <algorithm>
 
 // Workaround for windows headers
 #ifdef SetProp
 #undef SetProp
 #endif
 
 class nsISupports;
@@ -509,24 +509,24 @@ nsHTMLEditRules::AfterEditInner(EditActi
     {
       res = AdjustWhitespace(selection);
       NS_ENSURE_SUCCESS(res, res);
 
       // also do this for original selection endpoints.
       NS_ENSURE_STATE(mHTMLEditor);
       NS_ENSURE_STATE(mRangeItem->startNode);
       NS_ENSURE_STATE(mRangeItem->endNode);
-      nsWSRunObject(mHTMLEditor, mRangeItem->startNode,
-                    mRangeItem->startOffset).AdjustWhitespace();
+      WSRunObject(mHTMLEditor, mRangeItem->startNode,
+                  mRangeItem->startOffset).AdjustWhitespace();
       // we only need to handle old selection endpoint if it was different from start
       if (mRangeItem->startNode != mRangeItem->endNode ||
           mRangeItem->startOffset != mRangeItem->endOffset) {
         NS_ENSURE_STATE(mHTMLEditor);
-        nsWSRunObject(mHTMLEditor, mRangeItem->endNode,
-                      mRangeItem->endOffset).AdjustWhitespace();
+        WSRunObject(mHTMLEditor, mRangeItem->endNode,
+                    mRangeItem->endOffset).AdjustWhitespace();
       }
     }
 
     // if we created a new block, make sure selection lands in it
     if (mNewBlock)
     {
       res = PinSelectionToNewBlock(selection);
       mNewBlock = 0;
@@ -1299,34 +1299,34 @@ nsHTMLEditRules::WillInsertText(EditActi
   NS_ENSURE_STATE(mHTMLEditor);
   if (!mHTMLEditor->IsTextNode(selNode) &&
       (!mHTMLEditor || !mHTMLEditor->CanContainTag(*selNode,
                                                    *nsGkAtoms::textTagName))) {
     return NS_ERROR_FAILURE;
   }
 
   if (aAction == EditAction::insertIMEText) {
-    // Right now the nsWSRunObject code bails on empty strings, but IME needs
+    // Right now the WSRunObject code bails on empty strings, but IME needs
     // the InsertTextImpl() call to still happen since empty strings are meaningful there.
     NS_ENSURE_STATE(mHTMLEditor);
     // If there is one or more IME selections, its minimum offset should be
     // the insertion point.
     int32_t IMESelectionOffset =
       mHTMLEditor->GetIMESelectionStartOffsetIn(selNode);
     if (IMESelectionOffset >= 0) {
       selOffset = IMESelectionOffset;
     }
     if (inString->IsEmpty())
     {
       res = mHTMLEditor->InsertTextImpl(*inString, address_of(selNode),
                                         &selOffset, doc);
     }
     else
     {
-      nsWSRunObject wsObj(mHTMLEditor, selNode, selOffset);
+      WSRunObject wsObj(mHTMLEditor, selNode, selOffset);
       res = wsObj.InsertText(*inString, address_of(selNode), &selOffset, doc);
     }
     NS_ENSURE_SUCCESS(res, res);
   }
   else // aAction == kInsertText
   {
     // find where we are
     nsCOMPtr<nsINode> curNode = selNode;
@@ -1419,17 +1419,17 @@ nsHTMLEditRules::WillInsertText(EditActi
         else
         {
           subStrLen = tString.Length() - oldPos;
           pos = tString.Length();
         }
 
         nsDependentSubstring subStr(tString, oldPos, subStrLen);
         NS_ENSURE_STATE(mHTMLEditor);
-        nsWSRunObject wsObj(mHTMLEditor, curNode, curOffset);
+        WSRunObject wsObj(mHTMLEditor, curNode, curOffset);
 
         // is it a tab?
         if (subStr.Equals(tabStr))
         {
           res =
             wsObj.InsertText(spacesStr, address_of(curNode), &curOffset, doc);
           NS_ENSURE_SUCCESS(res, res);
           pos++;
@@ -1599,17 +1599,17 @@ nsHTMLEditRules::StandardBreakImpl(nsINo
   bool bBeforeBlock = false;
   nsCOMPtr<nsINode> node = &aNode;
   nsresult res;
 
   if (IsPlaintextEditor()) {
     brNode = mHTMLEditor->CreateBR(node, aOffset);
     NS_ENSURE_STATE(brNode);
   } else {
-    nsWSRunObject wsObj(mHTMLEditor, node, aOffset);
+    WSRunObject wsObj(mHTMLEditor, node, aOffset);
     int32_t visOffset = 0;
     WSType wsType;
     nsCOMPtr<nsINode> visNode;
     wsObj.PriorVisibleNode(node, aOffset, address_of(visNode),
                            &visOffset, &wsType);
     if (wsType & WSType::block) {
       bAfterBlock = true;
     }
@@ -1639,17 +1639,17 @@ nsHTMLEditRules::StandardBreakImpl(nsINo
   if (bAfterBlock && bBeforeBlock) {
     // We just placed a br between block boundaries.  This is the one case
     // where we want the selection to be before the br we just placed, as the
     // br will be on a new line, rather than at end of prior line.
     aSelection.SetInterlinePosition(true);
     res = aSelection.Collapse(node, offset);
     NS_ENSURE_SUCCESS(res, res);
   } else {
-    nsWSRunObject wsObj(mHTMLEditor, node, offset + 1);
+    WSRunObject wsObj(mHTMLEditor, node, offset + 1);
     nsCOMPtr<nsINode> secondBR;
     int32_t visOffset = 0;
     WSType wsType;
     wsObj.NextVisibleNode(node, offset + 1, address_of(secondBR),
                           &visOffset, &wsType);
     if (wsType == WSType::br) {
       // The next thing after the break we inserted is another break.  Move the
       // second break to be the first break's sibling.  This will prevent them
@@ -1709,17 +1709,17 @@ nsHTMLEditRules::SplitMailCites(Selectio
     // just after it.  This does two things for us.  It saves us the trouble of having to add
     // a break here ourselves to preserve the "blockness" of the inline span mailquote
     // (in the inline case), and :
     // it means the break won't end up making an empty line that happens to be inside a
     // mailquote (in either inline or block case).
     // The latter can confuse a user if they click there and start typing,
     // because being in the mailquote may affect wrapping behavior, or font color, etc.
     NS_ENSURE_STATE(mHTMLEditor);
-    nsWSRunObject wsObj(mHTMLEditor, selNode, selOffset);
+    WSRunObject wsObj(mHTMLEditor, selNode, selOffset);
     nsCOMPtr<nsINode> visNode;
     int32_t visOffset=0;
     WSType wsType;
     wsObj.NextVisibleNode(selNode, selOffset, address_of(visNode),
                           &visOffset, &wsType);
     if (wsType == WSType::br) {
       // ok, we are just before a break.  is it inside the mailquote?
       if (visNode != citeNode && citeNode->Contains(visNode)) {
@@ -1745,26 +1745,26 @@ nsHTMLEditRules::SplitMailCites(Selectio
     res = aSelection->Collapse(selNode, newOffset);
     NS_ENSURE_SUCCESS(res, res);
     // if citeNode wasn't a block, we might also want another break before it.
     // We need to examine the content both before the br we just added and also
     // just after it.  If we don't have another br or block boundary adjacent,
     // then we will need a 2nd br added to achieve blank line that user expects.
     if (IsInlineNode(*citeNode)) {
       NS_ENSURE_STATE(mHTMLEditor);
-      nsWSRunObject wsObj(mHTMLEditor, selNode, newOffset);
+      WSRunObject wsObj(mHTMLEditor, selNode, newOffset);
       nsCOMPtr<nsINode> visNode;
       int32_t visOffset=0;
       WSType wsType;
       wsObj.PriorVisibleNode(selNode, newOffset, address_of(visNode),
                              &visOffset, &wsType);
       if (wsType == WSType::normalWS || wsType == WSType::text ||
           wsType == WSType::special) {
         NS_ENSURE_STATE(mHTMLEditor);
-        nsWSRunObject wsObjAfterBR(mHTMLEditor, selNode, newOffset+1);
+        WSRunObject wsObjAfterBR(mHTMLEditor, selNode, newOffset+1);
         wsObjAfterBR.NextVisibleNode(selNode, newOffset + 1,
                                      address_of(visNode), &visOffset, &wsType);
         if (wsType == WSType::normalWS || wsType == WSType::text ||
             wsType == WSType::special) {
           NS_ENSURE_STATE(mHTMLEditor);
           brNode = mHTMLEditor->CreateBR(selNode, newOffset);
           NS_ENSURE_STATE(brNode);
         }
@@ -1890,17 +1890,17 @@ nsHTMLEditRules::WillDeleteSelection(Sel
     NS_ENSURE_TRUE(startNode, NS_ERROR_FAILURE);
 
     bCollapsed = aSelection->Collapsed();
   }
 
   if (bCollapsed) {
     // What's in the direction we are deleting?
     NS_ENSURE_STATE(mHTMLEditor);
-    nsWSRunObject wsObj(mHTMLEditor, startNode, startOffset);
+    WSRunObject wsObj(mHTMLEditor, startNode, startOffset);
     nsCOMPtr<nsINode> visNode;
     int32_t visOffset;
     WSType wsType;
 
     // Find next visible node
     if (aAction == nsIEditor::eNext) {
       wsObj.NextVisibleNode(startNode, startOffset, address_of(visNode),
                             &visOffset, &wsType);
@@ -1955,17 +1955,17 @@ nsHTMLEditRules::WillDeleteSelection(Sel
                      "selection start not in visNode");
         NS_ASSERTION(range->GetEndParent() == visNode,
                      "selection end not in visNode");
 
         so = range->StartOffset();
         eo = range->EndOffset();
       }
       NS_ENSURE_STATE(mHTMLEditor);
-      res = nsWSRunObject::PrepareToDeleteRange(mHTMLEditor,
+      res = WSRunObject::PrepareToDeleteRange(mHTMLEditor,
           address_of(visNode), &so, address_of(visNode), &eo);
       NS_ENSURE_SUCCESS(res, res);
       NS_ENSURE_STATE(mHTMLEditor);
       res = mHTMLEditor->DeleteText(nodeAsText, std::min(so, eo),
                                     DeprecatedAbs(eo - so));
       *aHandled = true;
       NS_ENSURE_SUCCESS(res, res);
 
@@ -2046,33 +2046,33 @@ nsHTMLEditRules::WillDeleteSelection(Sel
           wsObj.NextVisibleNode(startNode, startOffset, address_of(otherNode),
                                 &otherOffset, &otherWSType);
 
           if (otherWSType == WSType::br) {
             // Delete the <br>
 
             NS_ENSURE_STATE(mHTMLEditor);
             nsCOMPtr<nsIContent> otherContent(do_QueryInterface(otherNode));
-            res = nsWSRunObject::PrepareToDeleteNode(mHTMLEditor, otherContent);
+            res = WSRunObject::PrepareToDeleteNode(mHTMLEditor, otherContent);
             NS_ENSURE_SUCCESS(res, res);
             NS_ENSURE_STATE(mHTMLEditor);
             res = mHTMLEditor->DeleteNode(otherNode);
             NS_ENSURE_SUCCESS(res, res);
           }
 
           return NS_OK;
         }
         // Else continue with normal delete code
       }
 
       // Found break or image, or hr.
       NS_ENSURE_STATE(mHTMLEditor);
       NS_ENSURE_STATE(visNode->IsContent());
-      res = nsWSRunObject::PrepareToDeleteNode(mHTMLEditor,
-                                               visNode->AsContent());
+      res = WSRunObject::PrepareToDeleteNode(mHTMLEditor,
+                                             visNode->AsContent());
       NS_ENSURE_SUCCESS(res, res);
       // Remember sibling to visnode, if any
       NS_ENSURE_STATE(mHTMLEditor);
       nsCOMPtr<nsIContent> sibling = mHTMLEditor->GetPriorHTMLSibling(visNode);
       // Delete the node, and join like nodes if appropriate
       NS_ENSURE_STATE(mHTMLEditor);
       res = mHTMLEditor->DeleteNode(visNode);
       NS_ENSURE_SUCCESS(res, res);
@@ -2249,19 +2249,19 @@ nsHTMLEditRules::WillDeleteSelection(Sel
   int32_t endOffset = aSelection->GetRangeAt(0)->EndOffset();
   NS_ENSURE_TRUE(endNode, NS_ERROR_FAILURE);
 
   // Figure out if the endpoints are in nodes that can be merged.  Adjust
   // surrounding whitespace in preparation to delete selection.
   if (!IsPlaintextEditor()) {
     NS_ENSURE_STATE(mHTMLEditor);
     AutoTransactionsConserveSelection dontSpazMySelection(mHTMLEditor);
-    res = nsWSRunObject::PrepareToDeleteRange(mHTMLEditor,
-                                           address_of(startNode), &startOffset,
-                                           address_of(endNode), &endOffset);
+    res = WSRunObject::PrepareToDeleteRange(mHTMLEditor,
+                                            address_of(startNode), &startOffset,
+                                            address_of(endNode), &endOffset);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   {
     // Track location of where we are deleting
     NS_ENSURE_STATE(mHTMLEditor);
     AutoTrackDOMPoint startTracker(mHTMLEditor->mRangeUpdater,
                                    address_of(startNode), &startOffset);
@@ -2487,17 +2487,17 @@ nsHTMLEditRules::InsertBRIfNeeded(Select
 
   // inline elements don't need any br
   if (!IsBlockNode(*node)) {
     return NS_OK;
   }
 
   // examine selection
   NS_ENSURE_STATE(mHTMLEditor);
-  nsWSRunObject wsObj(mHTMLEditor, node, offset);
+  WSRunObject wsObj(mHTMLEditor, node, offset);
   if (((wsObj.mStartReason & WSType::block) ||
        (wsObj.mStartReason & WSType::br)) &&
       (wsObj.mEndReason & WSType::block)) {
     // if we are tucked between block boundaries then insert a br
     // first check that we are allowed to
     NS_ENSURE_STATE(mHTMLEditor);
     if (mHTMLEditor->CanContainTag(*node, *nsGkAtoms::br)) {
       NS_ENSURE_STATE(mHTMLEditor);
@@ -2624,29 +2624,29 @@ nsHTMLEditRules::JoinBlocks(nsIContent& 
   int32_t leftOffset = -1;
 
   // offset below is where you find yourself in rightBlock when you traverse
   // upwards from leftBlock
   if (EditorUtils::IsDescendantOf(leftBlock, rightBlock, &rightOffset)) {
     // Tricky case.  Left block is inside right block.  Do ws adjustment.  This
     // just destroys non-visible ws at boundaries we will be joining.
     rightOffset++;
-    res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
-                                            nsWSRunObject::kBlockEnd,
-                                            leftBlock);
+    res = WSRunObject::ScrubBlockBoundary(mHTMLEditor,
+                                          WSRunObject::kBlockEnd,
+                                          leftBlock);
     NS_ENSURE_SUCCESS(res, res);
 
     {
       // We can't just track rightBlock because it's an Element.
       nsCOMPtr<nsINode> trackingRightBlock(rightBlock);
       AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
                                 address_of(trackingRightBlock), &rightOffset);
-      res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
-                                              nsWSRunObject::kAfterBlock,
-                                              rightBlock, rightOffset);
+      res = WSRunObject::ScrubBlockBoundary(mHTMLEditor,
+                                            WSRunObject::kAfterBlock,
+                                            rightBlock, rightOffset);
       NS_ENSURE_SUCCESS(res, res);
       if (trackingRightBlock->IsElement()) {
         rightBlock = trackingRightBlock->AsElement();
       } else {
         NS_ENSURE_STATE(trackingRightBlock->GetParentElement());
         rightBlock = trackingRightBlock->GetParentElement();
       }
     }
@@ -2667,29 +2667,29 @@ nsHTMLEditRules::JoinBlocks(nsIContent& 
     if (brNode) {
       mHTMLEditor->DeleteNode(brNode);
     }
   // Offset below is where you find yourself in leftBlock when you traverse
   // upwards from rightBlock
   } else if (EditorUtils::IsDescendantOf(rightBlock, leftBlock, &leftOffset)) {
     // Tricky case.  Right block is inside left block.  Do ws adjustment.  This
     // just destroys non-visible ws at boundaries we will be joining.
-    res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
-                                            nsWSRunObject::kBlockStart,
-                                            rightBlock);
+    res = WSRunObject::ScrubBlockBoundary(mHTMLEditor,
+                                          WSRunObject::kBlockStart,
+                                          rightBlock);
     NS_ENSURE_SUCCESS(res, res);
     {
       // We can't just track leftBlock because it's an Element, so track
       // something else.
       nsCOMPtr<nsINode> trackingLeftBlock(leftBlock);
       AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
                                 address_of(trackingLeftBlock), &leftOffset);
-      res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
-                                              nsWSRunObject::kBeforeBlock,
-                                              leftBlock, leftOffset);
+      res = WSRunObject::ScrubBlockBoundary(mHTMLEditor,
+                                            WSRunObject::kBeforeBlock,
+                                            leftBlock, leftOffset);
       NS_ENSURE_SUCCESS(res, res);
       if (trackingLeftBlock->IsElement()) {
         leftBlock = trackingLeftBlock->AsElement();
       } else {
         NS_ENSURE_STATE(trackingLeftBlock->GetParentElement());
         leftBlock = trackingLeftBlock->GetParentElement();
       }
     }
@@ -2761,17 +2761,17 @@ nsHTMLEditRules::JoinBlocks(nsIContent& 
     }
   } else {
     // Normal case.  Blocks are siblings, or at least close enough.  An example
     // of the latter is <p>paragraph</p><ul><li>one<li>two<li>three</ul>.  The
     // first li and the p are not true siblings, but we still want to join them
     // if you backspace from li into p.
 
     // Adjust whitespace at block boundaries
-    res = nsWSRunObject::PrepareToJoinBlocks(mHTMLEditor, leftBlock, rightBlock);
+    res = WSRunObject::PrepareToJoinBlocks(mHTMLEditor, leftBlock, rightBlock);
     NS_ENSURE_SUCCESS(res, res);
     // Do br adjustment.
     nsCOMPtr<Element> brNode =
       CheckForInvisibleBR(*leftBlock, BRLocation::blockEnd);
     if (mergeLists || leftBlock->NodeInfo()->NameAtom() ==
                       rightBlock->NodeInfo()->NameAtom()) {
       // Nodes are same type.  merge them.
       EditorDOMPoint pt = JoinNodesSmart(*leftBlock, *rightBlock);
@@ -4888,17 +4888,17 @@ nsHTMLEditRules::CheckForInvisibleBR(Ele
   } else if (aOffset) {
     testNode = &aBlock;
     // We'll check everything to the left of the input position
     testOffset = aOffset;
   } else {
     return nullptr;
   }
 
-  nsWSRunObject wsTester(mHTMLEditor, testNode, testOffset);
+  WSRunObject wsTester(mHTMLEditor, testNode, testOffset);
   if (WSType::br == wsTester.mStartReason) {
     return wsTester.mStartReasonNode->AsElement();
   }
 
   return nullptr;
 }
 
 
@@ -4967,17 +4967,17 @@ nsHTMLEditRules::ExpandSelectionForDelet
   int32_t visOffset = 0, firstBROffset = 0;
   WSType wsType;
   nsCOMPtr<Element> root = mHTMLEditor->GetActiveEditingHost();
   NS_ENSURE_TRUE(root, NS_ERROR_FAILURE);
 
   // Find previous visible thingy before start of selection
   if (selStartNode != selCommon && selStartNode != root) {
     while (true) {
-      nsWSRunObject wsObj(mHTMLEditor, selStartNode, selStartOffset);
+      WSRunObject wsObj(mHTMLEditor, selStartNode, selStartOffset);
       wsObj.PriorVisibleNode(selStartNode, selStartOffset, address_of(unused),
                              &visOffset, &wsType);
       if (wsType != WSType::thisBlock) {
         break;
       }
       // We want to keep looking up.  But stop if we are crossing table
       // element boundaries, or if we hit the root.
       if (HTMLEditUtils::IsTableElement(wsObj.mStartReasonNode) ||
@@ -4989,17 +4989,17 @@ nsHTMLEditRules::ExpandSelectionForDelet
       selStartOffset = selStartNode ?
         selStartNode->IndexOf(wsObj.mStartReasonNode) : -1;
     }
   }
 
   // Find next visible thingy after end of selection
   if (selEndNode != selCommon && selEndNode != root) {
     while (true) {
-      nsWSRunObject wsObj(mHTMLEditor, selEndNode, selEndOffset);
+      WSRunObject wsObj(mHTMLEditor, selEndNode, selEndOffset);
       wsObj.NextVisibleNode(selEndNode, selEndOffset, address_of(unused),
                             &visOffset, &wsType);
       if (wsType == WSType::br) {
         if (mHTMLEditor->IsVisBreak(wsObj.mEndReasonNode)) {
           break;
         }
         if (!firstBRParent) {
           firstBRParent = selEndNode;
@@ -5112,17 +5112,17 @@ nsHTMLEditRules::NormalizeSelection(Sele
   newEndOffset = endOffset;
 
   // some locals we need for whitespace code
   nsCOMPtr<nsINode> unused;
   int32_t offset;
   WSType wsType;
 
   // let the whitespace code do the heavy lifting
-  nsWSRunObject wsEndObj(mHTMLEditor, endNode, endOffset);
+  WSRunObject wsEndObj(mHTMLEditor, endNode, endOffset);
   // is there any intervening visible whitespace?  if so we can't push selection past that,
   // it would visibly change maening of users selection
   nsCOMPtr<nsINode> endNode_(do_QueryInterface(endNode));
   wsEndObj.PriorVisibleNode(endNode_, endOffset, address_of(unused),
                             &offset, &wsType);
   if (wsType != WSType::text && wsType != WSType::normalWS) {
     // eThisBlock and eOtherBlock conveniently distinquish cases
     // of going "down" into a block and "up" out of a block.
@@ -5152,17 +5152,17 @@ nsHTMLEditRules::NormalizeSelection(Sele
       // endpoint is just after break.  lets adjust it to before it.
       newEndNode = nsEditor::GetNodeLocation(GetAsDOMNode(wsEndObj.mStartReasonNode),
                                              &newEndOffset);
     }
   }
 
 
   // similar dealio for start of range
-  nsWSRunObject wsStartObj(mHTMLEditor, startNode, startOffset);
+  WSRunObject wsStartObj(mHTMLEditor, startNode, startOffset);
   // is there any intervening visible whitespace?  if so we can't push selection past that,
   // it would visibly change maening of users selection
   nsCOMPtr<nsINode> startNode_(do_QueryInterface(startNode));
   wsStartObj.NextVisibleNode(startNode_, startOffset, address_of(unused),
                              &offset, &wsType);
   if (wsType != WSType::text && wsType != WSType::normalWS) {
     // eThisBlock and eOtherBlock conveniently distinquish cases
     // of going "down" into a block and "up" out of a block.
@@ -6138,19 +6138,19 @@ nsHTMLEditRules::ReturnInHeader(Selectio
   nsCOMPtr<nsIEditor> kungFuDeathGrip(mHTMLEditor);
 
   // Remember where the header is
   nsCOMPtr<nsINode> headerParent = aHeader.GetParentNode();
   int32_t offset = headerParent ? headerParent->IndexOf(&aHeader) : -1;
 
   // Get ws code to adjust any ws
   nsCOMPtr<nsINode> node = &aNode;
-  nsresult res = nsWSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor,
-                                                           address_of(node),
-                                                           &aOffset);
+  nsresult res = WSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor,
+                                                         address_of(node),
+                                                         &aOffset);
   NS_ENSURE_SUCCESS(res, res);
 
   // Split the header
   NS_ENSURE_STATE(node->IsContent());
   mHTMLEditor->SplitNodeDeep(aHeader, *node->AsContent(), aOffset);
 
   // If the left-hand heading is empty, put a mozbr in it
   nsCOMPtr<nsIContent> prevItem = mHTMLEditor->GetPriorHTMLSibling(&aHeader);
@@ -6335,17 +6335,18 @@ nsHTMLEditRules::SplitParagraph(nsIDOMNo
                  aSelection, NS_ERROR_NULL_POINTER);
   nsresult res = NS_OK;
 
   // split para
   // get ws code to adjust any ws
   nsCOMPtr<nsIContent> leftPara, rightPara;
   NS_ENSURE_STATE(mHTMLEditor);
   nsCOMPtr<nsINode> selNode(do_QueryInterface(*aSelNode));
-  res = nsWSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor, address_of(selNode), aOffset);
+  res = WSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor,
+                                                address_of(selNode), aOffset);
   *aSelNode = GetAsDOMNode(selNode);
   NS_ENSURE_SUCCESS(res, res);
   // split the paragraph
   NS_ENSURE_STATE(mHTMLEditor);
   NS_ENSURE_STATE(selNode->IsContent());
   mHTMLEditor->SplitNodeDeep(*para, *selNode->AsContent(), *aOffset,
                              nsHTMLEditor::EmptyContainers::yes,
                              getter_AddRefs(leftPara),
@@ -6460,19 +6461,19 @@ nsHTMLEditRules::ReturnInListItem(Select
       NS_ENSURE_SUCCESS(res, res);
     }
     return NS_OK;
   }
 
   // Else we want a new list item at the same list level.  Get ws code to
   // adjust any ws.
   nsCOMPtr<nsINode> selNode = &aNode;
-  res = nsWSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor,
-                                                  address_of(selNode),
-                                                  &aOffset);
+  res = WSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor,
+                                                address_of(selNode),
+                                                &aOffset);
   NS_ENSURE_SUCCESS(res, res);
   // Now split list item
   NS_ENSURE_STATE(selNode->IsContent());
   mHTMLEditor->SplitNodeDeep(aListItem, *selNode->AsContent(), aOffset);
 
   // Hack: until I can change the damaged doc range code back to being
   // extra-inclusive, I have to manually detect certain list items that may be
   // left empty.
@@ -6514,17 +6515,17 @@ nsHTMLEditRules::ReturnInListItem(Select
           nsCOMPtr<nsINode> brParent = brNode->GetParentNode();
           int32_t offset = brParent ? brParent->IndexOf(brNode) : -1;
           res = aSelection.Collapse(brParent, offset);
           NS_ENSURE_SUCCESS(res, res);
 
           return NS_OK;
         }
       } else {
-        nsWSRunObject wsObj(mHTMLEditor, &aListItem, 0);
+        WSRunObject wsObj(mHTMLEditor, &aListItem, 0);
         nsCOMPtr<nsINode> visNode;
         int32_t visOffset = 0;
         WSType wsType;
         wsObj.NextVisibleNode(&aListItem, 0, address_of(visNode),
                               &visOffset, &wsType);
         if (wsType == WSType::special || wsType == WSType::br ||
             visNode->IsHTMLElement(nsGkAtoms::hr)) {
           nsCOMPtr<nsINode> parent = visNode->GetParentNode();
@@ -7126,17 +7127,17 @@ nsHTMLEditRules::AdjustWhitespace(Select
   nsCOMPtr<nsIDOMNode> selNode;
   int32_t selOffset;
   NS_ENSURE_STATE(mHTMLEditor);
   nsresult res = mHTMLEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
   NS_ENSURE_SUCCESS(res, res);
 
   // ask whitespace object to tweak nbsp's
   NS_ENSURE_STATE(mHTMLEditor);
-  return nsWSRunObject(mHTMLEditor, selNode, selOffset).AdjustWhitespace();
+  return WSRunObject(mHTMLEditor, selNode, selOffset).AdjustWhitespace();
 }
 
 nsresult
 nsHTMLEditRules::PinSelectionToNewBlock(Selection* aSelection)
 {
   NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER);
   if (!aSelection->Collapsed()) {
     return NS_OK;
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -54,17 +54,17 @@
 
 // netwerk
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 
 // Misc
 #include "EditorUtils.h"
 #include "TextEditorTest.h"
-#include "nsWSRunObject.h"
+#include "WSRunObject.h"
 #include "nsGkAtoms.h"
 #include "nsIWidget.h"
 
 #include "nsIFrame.h"
 #include "nsIParserService.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/Element.h"
@@ -544,32 +544,32 @@ nsHTMLEditor::BeginningOfDocument()
     return NS_OK;
   }
 
   // Find first editable thingy
   bool done = false;
   nsCOMPtr<nsINode> curNode = rootElement.get(), selNode;
   int32_t curOffset = 0, selOffset = 0;
   while (!done) {
-    nsWSRunObject wsObj(this, curNode, curOffset);
+    WSRunObject wsObj(this, curNode, curOffset);
     int32_t visOffset = 0;
     WSType visType;
     nsCOMPtr<nsINode> visNode;
     wsObj.NextVisibleNode(curNode, curOffset, address_of(visNode), &visOffset,
                           &visType);
     if (visType == WSType::normalWS || visType == WSType::text) {
       selNode = visNode;
       selOffset = visOffset;
       done = true;
     } else if (visType == WSType::br || visType == WSType::special) {
       selNode = visNode->GetParentNode();
       selOffset = selNode ? selNode->IndexOf(visNode) : -1;
       done = true;
     } else if (visType == WSType::otherBlock) {
-      // By definition of nsWSRunObject, a block element terminates a
+      // By definition of WSRunObject, a block element terminates a
       // whitespace run. That is, although we are calling a method that is
       // named "NextVisibleNode", the node returned might not be
       // visible/editable!
       //
       // If the given block does not contain any visible/editable items, we
       // want to skip it and continue our search.
 
       if (!IsContainer(visNode)) {
@@ -978,17 +978,17 @@ nsHTMLEditor::IsVisBreak(nsINode* aNode)
   }
 
   // Sigh.  We have to use expensive whitespace calculation code to
   // determine what is going on
   int32_t selOffset;
   nsCOMPtr<nsINode> selNode = GetNodeLocation(aNode, &selOffset);
   // Let's look after the break
   selOffset++;
-  nsWSRunObject wsObj(this, selNode, selOffset);
+  WSRunObject wsObj(this, selNode, selOffset);
   nsCOMPtr<nsINode> unused;
   int32_t visOffset = 0;
   WSType visType;
   wsObj.NextVisibleNode(selNode, selOffset, address_of(unused),
                         &visOffset, &visType);
   if (visType & WSType::block) {
     return false;
   }
@@ -1439,17 +1439,17 @@ nsHTMLEditor::NormalizeEOLInsertPosition
 
     4) We do not want to skip if the previous visible thing is in a different block
        than the insertion position.
   */
 
   if (!IsBlockNode(firstNodeToInsert))
     return;
 
-  nsWSRunObject wsObj(this, *insertParentNode, *insertOffset);
+  WSRunObject wsObj(this, *insertParentNode, *insertOffset);
   nsCOMPtr<nsINode> nextVisNode, prevVisNode;
   int32_t nextVisOffset=0;
   WSType nextVisType;
   int32_t prevVisOffset=0;
   WSType prevVisType;
 
   nsCOMPtr<nsINode> parent(do_QueryInterface(*insertParentNode));
   wsObj.NextVisibleNode(parent, *insertOffset, address_of(nextVisNode), &nextVisOffset, &nextVisType);
@@ -4240,17 +4240,17 @@ nsHTMLEditor::IsVisTextNode(nsIContent* 
     {
       *outIsEmptyNode = false;
     }
   }
   else if (length)
   {
     if (aNode->TextIsOnlyWhitespace())
     {
-      nsWSRunObject wsRunObj(this, aNode, 0);
+      WSRunObject wsRunObj(this, aNode, 0);
       nsCOMPtr<nsINode> visNode;
       int32_t outVisOffset=0;
       WSType visType;
       wsRunObj.NextVisibleNode(aNode, 0, address_of(visNode),
                                &outVisOffset, &visType);
       if (visType == WSType::normalWS || visType == WSType::text) {
         *outIsEmptyNode = (aNode != visNode);
       }
--- a/editor/libeditor/nsHTMLEditor.h
+++ b/editor/libeditor/nsHTMLEditor.h
@@ -50,16 +50,17 @@ class nsITransferable;
 class nsIClipboard;
 class nsILinkHandler;
 class nsTableWrapperFrame;
 class nsIDOMRange;
 class nsRange;
 
 namespace mozilla {
 class TypeInState;
+class WSRunObject;
 struct PropItem;
 template<class T> class OwningNonNull;
 namespace dom {
 class DocumentFragment;
 } // namespace dom
 namespace widget {
 struct IMEState;
 } // namespace widget
@@ -968,19 +969,19 @@ protected:
   void     AddMouseClickListener(nsIDOMElement * aElement);
   void     RemoveMouseClickListener(nsIDOMElement * aElement);
 
   nsCOMPtr<nsILinkHandler> mLinkHandler;
 
 public:
 
 // friends
+friend class mozilla::WSRunObject;
 friend class nsHTMLEditRules;
 friend class nsTextEditRules;
-friend class nsWSRunObject;
 friend class nsHTMLEditorEventListener;
 
 private:
   // Helpers
   bool IsSimpleModifiableNode(nsIContent* aContent,
                               nsIAtom* aProperty,
                               const nsAString* aAttribute,
                               const nsAString* aValue);