Bug 1260651 part.40 Rename nsAutoTrackDOMPoint to mozilla::AutoTrackDOMPoint r?mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 24 Jun 2016 15:08:16 +0900
changeset 385730 99018adff8e5a515a67c25af65be182cc817376b
parent 385729 a4082c294175bcdbbfdb63317fbcce684f833910
child 385731 c4b5d7931f9ecacbe973f26e567f1ad1c793ce4d
push id22582
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 03:13:39 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.40 Rename nsAutoTrackDOMPoint to mozilla::AutoTrackDOMPoint r?mccr8 MozReview-Commit-ID: 775stH3pteA
editor/libeditor/SelectionState.h
editor/libeditor/nsHTMLDataTransfer.cpp
editor/libeditor/nsHTMLEditRules.cpp
editor/libeditor/nsHTMLEditorStyle.cpp
editor/libeditor/nsPlaintextDataTransfer.cpp
editor/libeditor/nsWSRunObject.cpp
--- a/editor/libeditor/SelectionState.h
+++ b/editor/libeditor/SelectionState.h
@@ -165,83 +165,79 @@ ImplCycleCollectionTraverse(nsCycleColle
 }
 
 inline void
 ImplCycleCollectionUnlink(RangeUpdater& aField)
 {
   ImplCycleCollectionUnlink(aField.mArray);
 }
 
-} // namespace mozilla
-
-/***************************************************************************
- * helper class for using SelectionState.  stack based class for doing
- * preservation of dom points across editor actions
+/**
+ * Helper class for using SelectionState.  Stack based class for doing
+ * preservation of dom points across editor actions.
  */
 
-class MOZ_STACK_CLASS nsAutoTrackDOMPoint
+class MOZ_STACK_CLASS AutoTrackDOMPoint final
 {
-  private:
-    mozilla::RangeUpdater& mRU;
-    // Allow tracking either nsIDOMNode or nsINode until nsIDOMNode is gone
-    nsCOMPtr<nsINode>* mNode;
-    nsCOMPtr<nsIDOMNode>* mDOMNode;
-    int32_t* mOffset;
-    RefPtr<mozilla::RangeItem> mRangeItem;
-  public:
-    nsAutoTrackDOMPoint(mozilla::RangeUpdater& aRangeUpdater,
-                        nsCOMPtr<nsINode>* aNode, int32_t* aOffset)
-      : mRU(aRangeUpdater)
-      , mNode(aNode)
-      , mDOMNode(nullptr)
-      , mOffset(aOffset)
-    {
-      mRangeItem = new mozilla::RangeItem();
-      mRangeItem->startNode = *mNode;
-      mRangeItem->endNode = *mNode;
-      mRangeItem->startOffset = *mOffset;
-      mRangeItem->endOffset = *mOffset;
-      mRU.RegisterRangeItem(mRangeItem);
-    }
+private:
+  RangeUpdater& mRangeUpdater;
+  // Allow tracking either nsIDOMNode or nsINode until nsIDOMNode is gone
+  nsCOMPtr<nsINode>* mNode;
+  nsCOMPtr<nsIDOMNode>* mDOMNode;
+  int32_t* mOffset;
+  RefPtr<RangeItem> mRangeItem;
+
+public:
+  AutoTrackDOMPoint(RangeUpdater& aRangeUpdater,
+                    nsCOMPtr<nsINode>* aNode, int32_t* aOffset)
+    : mRangeUpdater(aRangeUpdater)
+    , mNode(aNode)
+    , mDOMNode(nullptr)
+    , mOffset(aOffset)
+  {
+    mRangeItem = new RangeItem();
+    mRangeItem->startNode = *mNode;
+    mRangeItem->endNode = *mNode;
+    mRangeItem->startOffset = *mOffset;
+    mRangeItem->endOffset = *mOffset;
+    mRangeUpdater.RegisterRangeItem(mRangeItem);
+  }
 
-    nsAutoTrackDOMPoint(mozilla::RangeUpdater& aRangeUpdater,
-                        nsCOMPtr<nsIDOMNode>* aNode, int32_t* aOffset)
-      : mRU(aRangeUpdater)
-      , mNode(nullptr)
-      , mDOMNode(aNode)
-      , mOffset(aOffset)
-    {
-      mRangeItem = new mozilla::RangeItem();
-      mRangeItem->startNode = do_QueryInterface(*mDOMNode);
-      mRangeItem->endNode = do_QueryInterface(*mDOMNode);
-      mRangeItem->startOffset = *mOffset;
-      mRangeItem->endOffset = *mOffset;
-      mRU.RegisterRangeItem(mRangeItem);
+  AutoTrackDOMPoint(RangeUpdater& aRangeUpdater,
+                    nsCOMPtr<nsIDOMNode>* aNode, int32_t* aOffset)
+    : mRangeUpdater(aRangeUpdater)
+    , mNode(nullptr)
+    , mDOMNode(aNode)
+    , mOffset(aOffset)
+  {
+    mRangeItem = new RangeItem();
+    mRangeItem->startNode = do_QueryInterface(*mDOMNode);
+    mRangeItem->endNode = do_QueryInterface(*mDOMNode);
+    mRangeItem->startOffset = *mOffset;
+    mRangeItem->endOffset = *mOffset;
+    mRangeUpdater.RegisterRangeItem(mRangeItem);
+  }
+
+  ~AutoTrackDOMPoint()
+  {
+    mRangeUpdater.DropRangeItem(mRangeItem);
+    if (mNode) {
+      *mNode = mRangeItem->startNode;
+    } else {
+      *mDOMNode = GetAsDOMNode(mRangeItem->startNode);
     }
-
-    ~nsAutoTrackDOMPoint()
-    {
-      mRU.DropRangeItem(mRangeItem);
-      if (mNode) {
-        *mNode = mRangeItem->startNode;
-      } else {
-        *mDOMNode = GetAsDOMNode(mRangeItem->startNode);
-      }
-      *mOffset = mRangeItem->startOffset;
-    }
+    *mOffset = mRangeItem->startOffset;
+  }
 };
 
-
-
 /******************************************************************************
  * another helper class for SelectionState.  stack based class for doing
  * Will/DidReplaceContainer()
  */
 
-namespace mozilla {
 namespace dom {
 class MOZ_STACK_CLASS AutoReplaceContainerSelNotify
 {
   private:
     RangeUpdater& mRU;
     Element* mOriginalElement;
     Element* mNewElement;
 
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -270,17 +270,17 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
   // scenarios where we are dropping in an editor (and may want to delete
   // the selection before collapsing the selection in the new destination)
   if (aDestNode)
   {
     if (aDeleteSelection)
     {
       // Use an auto tracker so that our drop point is correctly
       // positioned after the delete.
-      nsAutoTrackDOMPoint tracker(mRangeUpdater, &targetNode, &targetOffset);
+      AutoTrackDOMPoint tracker(mRangeUpdater, &targetNode, &targetOffset);
       rv = DeleteSelection(eNone, eStrip);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     rv = selection->Collapse(targetNode, targetOffset);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -2161,18 +2161,18 @@ nsHTMLEditRules::WillDeleteSelection(Sel
       }
 
       // Else we are joining content to block
 
       nsCOMPtr<nsINode> selPointNode = startNode;
       int32_t selPointOffset = startOffset;
       {
         NS_ENSURE_STATE(mHTMLEditor);
-        nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
-                                    address_of(selPointNode), &selPointOffset);
+        AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
+                                  address_of(selPointNode), &selPointOffset);
         NS_ENSURE_STATE(leftNode && leftNode->IsContent() &&
                         rightNode && rightNode->IsContent());
         res = JoinBlocks(*leftNode->AsContent(), *rightNode->AsContent(),
                          aCancel);
         *aHandled = true;
         NS_ENSURE_SUCCESS(res, res);
       }
       aSelection->Collapse(selPointNode, selPointOffset);
@@ -2213,18 +2213,18 @@ nsHTMLEditRules::WillDeleteSelection(Sel
         *aCancel = true;
         return NS_OK;
       }
 
       nsCOMPtr<nsINode> selPointNode = startNode;
       int32_t selPointOffset = startOffset;
       {
         NS_ENSURE_STATE(mHTMLEditor);
-        nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
-                                    address_of(selPointNode), &selPointOffset);
+        AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
+                                  address_of(selPointNode), &selPointOffset);
         NS_ENSURE_STATE(leftNode->IsContent() && rightNode->IsContent());
         res = JoinBlocks(*leftNode->AsContent(), *rightNode->AsContent(),
                          aCancel);
         *aHandled = true;
         NS_ENSURE_SUCCESS(res, res);
       }
       aSelection->Collapse(selPointNode, selPointOffset);
       return NS_OK;
@@ -2257,20 +2257,20 @@ nsHTMLEditRules::WillDeleteSelection(Sel
                                            address_of(startNode), &startOffset,
                                            address_of(endNode), &endOffset);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   {
     // Track location of where we are deleting
     NS_ENSURE_STATE(mHTMLEditor);
-    nsAutoTrackDOMPoint startTracker(mHTMLEditor->mRangeUpdater,
-                                     address_of(startNode), &startOffset);
-    nsAutoTrackDOMPoint endTracker(mHTMLEditor->mRangeUpdater,
-                                   address_of(endNode), &endOffset);
+    AutoTrackDOMPoint startTracker(mHTMLEditor->mRangeUpdater,
+                                   address_of(startNode), &startOffset);
+    AutoTrackDOMPoint endTracker(mHTMLEditor->mRangeUpdater,
+                                 address_of(endNode), &endOffset);
     // We are handling all ranged deletions directly now.
     *aHandled = true;
 
     if (endNode == startNode) {
       NS_ENSURE_STATE(mHTMLEditor);
       res = mHTMLEditor->DeleteSelectionImpl(aAction, aStripWrappers);
       NS_ENSURE_SUCCESS(res, res);
     } else {
@@ -2413,20 +2413,20 @@ nsHTMLEditRules::WillDeleteSelection(Sel
           NS_ENSURE_SUCCESS(res, res);
         }
       }
     }
   }
 
   // We might have left only collapsed whitespace in the start/end nodes
   {
-    nsAutoTrackDOMPoint startTracker(mHTMLEditor->mRangeUpdater,
-                                     address_of(startNode), &startOffset);
-    nsAutoTrackDOMPoint endTracker(mHTMLEditor->mRangeUpdater,
-                                   address_of(endNode), &endOffset);
+    AutoTrackDOMPoint startTracker(mHTMLEditor->mRangeUpdater,
+                                   address_of(startNode), &startOffset);
+    AutoTrackDOMPoint endTracker(mHTMLEditor->mRangeUpdater,
+                                 address_of(endNode), &endOffset);
 
     DeleteNodeIfCollapsedText(*startNode);
     DeleteNodeIfCollapsedText(*endNode);
   }
 
   // If we're joining blocks: if deleting forward the selection should be
   // collapsed to the end of the selection, if deleting backward the selection
   // should be collapsed to the beginning of the selection. But if we're not
@@ -2631,19 +2631,18 @@ nsHTMLEditRules::JoinBlocks(nsIContent& 
     res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
                                             nsWSRunObject::kBlockEnd,
                                             leftBlock);
     NS_ENSURE_SUCCESS(res, res);
 
     {
       // We can't just track rightBlock because it's an Element.
       nsCOMPtr<nsINode> trackingRightBlock(rightBlock);
-      nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
-                                  address_of(trackingRightBlock),
-                                  &rightOffset);
+      AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
+                                address_of(trackingRightBlock), &rightOffset);
       res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
                                               nsWSRunObject::kAfterBlock,
                                               rightBlock, rightOffset);
       NS_ENSURE_SUCCESS(res, res);
       if (trackingRightBlock->IsElement()) {
         rightBlock = trackingRightBlock->AsElement();
       } else {
         NS_ENSURE_STATE(trackingRightBlock->GetParentElement());
@@ -2675,18 +2674,18 @@ nsHTMLEditRules::JoinBlocks(nsIContent& 
     res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
                                             nsWSRunObject::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);
-      nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
-                                  address_of(trackingLeftBlock), &leftOffset);
+      AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater,
+                                address_of(trackingLeftBlock), &leftOffset);
       res = nsWSRunObject::ScrubBlockBoundary(mHTMLEditor,
                                               nsWSRunObject::kBeforeBlock,
                                               leftBlock, leftOffset);
       NS_ENSURE_SUCCESS(res, res);
       if (trackingLeftBlock->IsElement()) {
         leftBlock = trackingLeftBlock->AsElement();
       } else {
         NS_ENSURE_STATE(trackingLeftBlock->GetParentElement());
--- a/editor/libeditor/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/nsHTMLEditorStyle.cpp
@@ -526,17 +526,17 @@ nsHTMLEditor::SplitStyleAboveRange(nsRan
   int32_t startOffset = inRange->StartOffset();
   nsCOMPtr<nsINode> endNode = inRange->GetEndParent();
   int32_t endOffset = inRange->EndOffset();
 
   nsCOMPtr<nsINode> origStartNode = startNode;
 
   // split any matching style nodes above the start of range
   {
-    nsAutoTrackDOMPoint tracker(mRangeUpdater, address_of(endNode), &endOffset);
+    AutoTrackDOMPoint tracker(mRangeUpdater, address_of(endNode), &endOffset);
     res = SplitStyleAbovePoint(address_of(startNode), &startOffset, aProperty,
                                aAttribute);
     NS_ENSURE_SUCCESS(res, res);
   }
 
   // second verse, same as the first...
   res = SplitStyleAbovePoint(address_of(endNode), &endOffset, aProperty,
                              aAttribute);
@@ -664,18 +664,18 @@ nsHTMLEditor::ClearStyle(nsCOMPtr<nsINod
     // remove the style on this new hierarchy
     int32_t newSelOffset = 0;
     {
       // Track the point at the new hierarchy.  This is so we can know where
       // to put the selection after we call RemoveStyleInside().
       // RemoveStyleInside() could remove any and all of those nodes, so I
       // have to use the range tracking system to find the right spot to put
       // selection.
-      nsAutoTrackDOMPoint tracker(mRangeUpdater,
-                                  address_of(newSelParent), &newSelOffset);
+      AutoTrackDOMPoint tracker(mRangeUpdater,
+                                address_of(newSelParent), &newSelOffset);
       res = RemoveStyleInside(*leftNode, aProperty, aAttribute);
       NS_ENSURE_SUCCESS(res, res);
     }
     // reset our node offset values to the resulting new sel point
     *aNode = newSelParent;
     *aOffset = newSelOffset;
   }
 
--- a/editor/libeditor/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/nsPlaintextDataTransfer.cpp
@@ -82,17 +82,17 @@ nsresult nsPlaintextEditor::InsertTextAt
 
     nsCOMPtr<nsIDOMNode> targetNode = aDestinationNode;
     int32_t targetOffset = aDestOffset;
 
     if (aDoDeleteSelection)
     {
       // Use an auto tracker so that our drop point is correctly
       // positioned after the delete.
-      nsAutoTrackDOMPoint tracker(mRangeUpdater, &targetNode, &targetOffset);
+      AutoTrackDOMPoint tracker(mRangeUpdater, &targetNode, &targetOffset);
       res = DeleteSelection(eNone, eStrip);
       NS_ENSURE_SUCCESS(res, res);
     }
 
     res = selection->Collapse(targetNode, targetOffset);
     NS_ENSURE_SUCCESS(res, res);
   }
 
--- a/editor/libeditor/nsWSRunObject.cpp
+++ b/editor/libeditor/nsWSRunObject.cpp
@@ -143,19 +143,19 @@ nsWSRunObject::PrepareToDeleteRange(nsHT
                                     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);
 
-  nsAutoTrackDOMPoint trackerStart(aHTMLEd->mRangeUpdater, aStartNode,
-                                   aStartOffset);
-  nsAutoTrackDOMPoint trackerEnd(aHTMLEd->mRangeUpdater, aEndNode, aEndOffset);
+  AutoTrackDOMPoint trackerStart(aHTMLEd->mRangeUpdater, aStartNode,
+                                 aStartOffset);
+  AutoTrackDOMPoint trackerEnd(aHTMLEd->mRangeUpdater, aEndNode, aEndOffset);
 
   nsWSRunObject leftWSObj(aHTMLEd, *aStartNode, *aStartOffset);
   nsWSRunObject rightWSObj(aHTMLEd, *aEndNode, *aEndOffset);
 
   return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
 }
 
 nsresult
@@ -177,17 +177,17 @@ nsWSRunObject::PrepareToDeleteNode(nsHTM
 nsresult
 nsWSRunObject::PrepareToSplitAcrossBlocks(nsHTMLEditor* aHTMLEd,
                                           nsCOMPtr<nsINode>* aSplitNode,
                                           int32_t* aSplitOffset)
 {
   NS_ENSURE_TRUE(aHTMLEd && aSplitNode && *aSplitNode && aSplitOffset,
                  NS_ERROR_NULL_POINTER);
 
-  nsAutoTrackDOMPoint tracker(aHTMLEd->mRangeUpdater, aSplitNode, aSplitOffset);
+  AutoTrackDOMPoint tracker(aHTMLEd->mRangeUpdater, aSplitNode, aSplitOffset);
 
   nsWSRunObject wsObj(aHTMLEd, *aSplitNode, *aSplitOffset);
 
   return wsObj.PrepareToSplitAcrossBlocksPriv();
 }
 
 //--------------------------------------------------------------------------------------------
 //   public instance methods
@@ -204,20 +204,20 @@ nsWSRunObject::InsertBreak(nsCOMPtr<nsIN
   NS_ENSURE_TRUE(aInOutParent && aInOutOffset, nullptr);
 
   nsresult res = NS_OK;
   WSFragment *beforeRun, *afterRun;
   FindRun(*aInOutParent, *aInOutOffset, &beforeRun, false);
   FindRun(*aInOutParent, *aInOutOffset, &afterRun, true);
 
   {
-    // Some scoping for nsAutoTrackDOMPoint.  This will track our insertion
+    // Some scoping for AutoTrackDOMPoint.  This will track our insertion
     // point while we tweak any surrounding whitespace
-    nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, aInOutParent,
-                                aInOutOffset);
+    AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, aInOutParent,
+                              aInOutOffset);
 
     // Handle any changes needed to ws run after inserted br
     if (!afterRun || (afterRun->mType & WSType::trailingWS)) {
       // Don't need to do anything.  Just insert break.  ws won't change.
     } else if (afterRun->mType & WSType::leadingWS) {
       // Delete the leading ws that is after insertion point.  We don't
       // have to (it would still not be significant after br), but it's
       // just more aesthetically pleasing to.
@@ -283,20 +283,20 @@ nsWSRunObject::InsertText(const nsAStrin
   nsAutoString theString(aStringToInsert);
 
   WSFragment *beforeRun, *afterRun;
   FindRun(*aInOutParent, *aInOutOffset, &beforeRun, false);
   FindRun(*aInOutParent, *aInOutOffset, &afterRun, true);
 
   nsresult res;
   {
-    // Some scoping for nsAutoTrackDOMPoint.  This will track our insertion
+    // Some scoping for AutoTrackDOMPoint.  This will track our insertion
     // point while we tweak any surrounding whitespace
-    nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, aInOutParent,
-                                aInOutOffset);
+    AutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, aInOutParent,
+                              aInOutOffset);
 
     // Handle any changes needed to ws run after inserted text
     if (!afterRun || afterRun->mType & WSType::trailingWS) {
       // Don't need to do anything.  Just insert text.  ws won't change.
     } else if (afterRun->mType & WSType::leadingWS) {
       // Delete the leading ws that is after insertion point, because it
       // would become significant after text inserted.
       res = DeleteChars(*aInOutParent, *aInOutOffset, afterRun->mEndNode,