Bug 1375502 - part3: Rename startNode of nsContentIterator::InitInternal() to aStartContainer r?mats draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 16 Aug 2017 22:11:11 +0900
changeset 648164 7cf8ef15209e8345d37f5eb6ec15e5e57a55d196
parent 648163 4d2154739d0f8a8a2d5c06854f4b3f5a6d874271
child 648165 dfccd1c610f8be18e1759f7197dd34aff323942a
push id74653
push usermasayuki@d-toybox.com
push dateThu, 17 Aug 2017 10:09:29 +0000
reviewersmats
bugs1375502
milestone57.0a1
Bug 1375502 - part3: Rename startNode of nsContentIterator::InitInternal() to aStartContainer r?mats MozReview-Commit-ID: 9fXIKhB03Mx
dom/base/nsContentIterator.cpp
--- a/dom/base/nsContentIterator.cpp
+++ b/dom/base/nsContentIterator.cpp
@@ -339,120 +339,120 @@ nsContentIterator::Init(nsINode* aStartC
   }
 
   return InitInternal(aStartContainer, aStartOffset,
                       aEndContainer, aEndOffset);
 }
 
 // XXX Argument names will be replaced in the following patch.
 nsresult
-nsContentIterator::InitInternal(nsINode* startNode, uint32_t startIndx,
+nsContentIterator::InitInternal(nsINode* aStartContainer, uint32_t startIndx,
                                 nsINode* endNode, uint32_t endIndx)
 {
   // get common content parent
   mCommonParent =
-    nsContentUtils::GetCommonAncestor(startNode, endNode);
+    nsContentUtils::GetCommonAncestor(aStartContainer, endNode);
   if (NS_WARN_IF(!mCommonParent)) {
     return NS_ERROR_FAILURE;
   }
 
-  bool startIsData = startNode->IsNodeOfType(nsINode::eDATA_NODE);
+  bool startIsData = aStartContainer->IsNodeOfType(nsINode::eDATA_NODE);
 
   // short circuit when start node == end node
-  if (startNode == endNode) {
+  if (aStartContainer == endNode) {
     // Check to see if we have a collapsed range, if so, there is nothing to
     // iterate over.
     //
     // XXX: CharacterDataNodes (text nodes) are currently an exception, since
     //      we always want to be able to iterate text nodes at the end points
     //      of a range.
 
     if (!startIsData && startIndx == endIndx) {
       MakeEmpty();
       return NS_OK;
     }
 
     if (startIsData) {
       // It's a character data node.
-      mFirst   = startNode->AsContent();
+      mFirst   = aStartContainer->AsContent();
       mLast    = mFirst;
       mCurNode = mFirst;
 
       DebugOnly<nsresult> rv = RebuildIndexStack();
       NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RebuildIndexStack failed");
       return NS_OK;
     }
   }
 
   // Find first node in range.
 
   nsIContent* cChild = nullptr;
 
   // Valid start indices are 0 <= startIndx <= childCount. That means if start
   // node has no children, only offset 0 is valid.
-  if (!startIsData && uint32_t(startIndx) < startNode->GetChildCount()) {
-    cChild = startNode->GetChildAt(startIndx);
+  if (!startIsData && uint32_t(startIndx) < aStartContainer->GetChildCount()) {
+    cChild = aStartContainer->GetChildAt(startIndx);
     NS_WARNING_ASSERTION(cChild, "GetChildAt returned null");
   }
 
   if (!cChild) {
     // No children (possibly a <br> or text node), or index is after last child.
 
     if (mPre) {
       // XXX: In the future, if start offset is after the last
       //      character in the cdata node, should we set mFirst to
       //      the next sibling?
 
       // Normally we would skip the start node because the start node is outside
       // of the range in pre mode. However, if startIndx == 0, and the node is a
       // non-container node (e.g. <br>), we don't skip the node in this case in
       // order to address bug 1215798.
       bool startIsContainer = true;
-      if (startNode->IsHTMLElement()) {
+      if (aStartContainer->IsHTMLElement()) {
         if (nsIParserService* ps = nsContentUtils::GetParserService()) {
-          nsIAtom* name = startNode->NodeInfo()->NameAtom();
+          nsIAtom* name = aStartContainer->NodeInfo()->NameAtom();
           ps->IsContainer(ps->HTMLAtomTagToId(name), startIsContainer);
         }
       }
       if (!startIsData && (startIsContainer || startIndx)) {
-        mFirst = GetNextSibling(startNode);
+        mFirst = GetNextSibling(aStartContainer);
         NS_WARNING_ASSERTION(mFirst, "GetNextSibling returned null");
 
         // Does mFirst node really intersect the range?  The range could be
         // 'degenerate', i.e., not collapsed but still contain no content.
         if (mFirst &&
-            NS_WARN_IF(!NodeIsInTraversalRange(mFirst, mPre, startNode,
+            NS_WARN_IF(!NodeIsInTraversalRange(mFirst, mPre, aStartContainer,
                                                startIndx, endNode, endIndx))) {
           mFirst = nullptr;
         }
       } else {
-        mFirst = startNode->AsContent();
+        mFirst = aStartContainer->AsContent();
       }
     } else {
       // post-order
-      if (NS_WARN_IF(!startNode->IsContent())) {
+      if (NS_WARN_IF(!aStartContainer->IsContent())) {
         // What else can we do?
         mFirst = nullptr;
       } else {
-        mFirst = startNode->AsContent();
+        mFirst = aStartContainer->AsContent();
       }
     }
   } else {
     if (mPre) {
       mFirst = cChild;
     } else {
       // post-order
       mFirst = GetDeepFirstChild(cChild);
       NS_WARNING_ASSERTION(mFirst, "GetDeepFirstChild returned null");
 
       // Does mFirst node really intersect the range?  The range could be
       // 'degenerate', i.e., not collapsed but still contain no content.
 
       if (mFirst &&
-          !NodeIsInTraversalRange(mFirst, mPre, startNode, startIndx,
+          !NodeIsInTraversalRange(mFirst, mPre, aStartContainer, startIndx,
                                   endNode, endIndx)) {
         mFirst = nullptr;
       }
     }
   }
 
 
   // Find last node in range.
@@ -494,17 +494,17 @@ nsContentIterator::InitInternal(nsINode*
       // XXX: In the future, if end offset is before the first character in the
       //      cdata node, should we set mLast to the prev sibling?
 
       if (!endIsData) {
         mLast = GetPrevSibling(endNode);
         NS_WARNING_ASSERTION(mLast, "GetPrevSibling returned null");
 
         if (!NodeIsInTraversalRange(mLast, mPre,
-                                    startNode, startIndx,
+                                    aStartContainer, startIndx,
                                     endNode, endIndx)) {
           mLast = nullptr;
         }
       } else {
         mLast = endNode->AsContent();
       }
     }
   } else {
@@ -518,17 +518,17 @@ nsContentIterator::InitInternal(nsINode*
       return NS_ERROR_FAILURE;
     }
 
     if (mPre) {
       mLast  = GetDeepLastChild(cChild);
       NS_WARNING_ASSERTION(mLast, "GetDeepLastChild returned null");
 
       if (NS_WARN_IF(!NodeIsInTraversalRange(mLast, mPre,
-                                             startNode, startIndx,
+                                             aStartContainer, startIndx,
                                              endNode, endIndx))) {
         mLast = nullptr;
       }
     } else {
       // post-order
       mLast = cChild;
     }
   }