Bug 1375502 - part4: Rename endNode of nsContentIterator::InitInternal() to aEndContainer r?mats draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 16 Aug 2017 22:12:28 +0900
changeset 648165 dfccd1c610f8be18e1759f7197dd34aff323942a
parent 648164 7cf8ef15209e8345d37f5eb6ec15e5e57a55d196
child 648166 b4be874c42f8fb5f4329813c870c92fe6a0cef0e
push id74653
push usermasayuki@d-toybox.com
push dateThu, 17 Aug 2017 10:09:29 +0000
reviewersmats
bugs1375502
milestone57.0a1
Bug 1375502 - part4: Rename endNode of nsContentIterator::InitInternal() to aEndContainer r?mats MozReview-Commit-ID: 3Dq8Ptpy6pN
dom/base/nsContentIterator.cpp
--- a/dom/base/nsContentIterator.cpp
+++ b/dom/base/nsContentIterator.cpp
@@ -340,29 +340,29 @@ nsContentIterator::Init(nsINode* aStartC
 
   return InitInternal(aStartContainer, aStartOffset,
                       aEndContainer, aEndOffset);
 }
 
 // XXX Argument names will be replaced in the following patch.
 nsresult
 nsContentIterator::InitInternal(nsINode* aStartContainer, uint32_t startIndx,
-                                nsINode* endNode, uint32_t endIndx)
+                                nsINode* aEndContainer, uint32_t endIndx)
 {
   // get common content parent
   mCommonParent =
-    nsContentUtils::GetCommonAncestor(aStartContainer, endNode);
+    nsContentUtils::GetCommonAncestor(aStartContainer, aEndContainer);
   if (NS_WARN_IF(!mCommonParent)) {
     return NS_ERROR_FAILURE;
   }
 
   bool startIsData = aStartContainer->IsNodeOfType(nsINode::eDATA_NODE);
 
   // short circuit when start node == end node
-  if (aStartContainer == endNode) {
+  if (aStartContainer == aEndContainer) {
     // 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) {
@@ -414,18 +414,19 @@ nsContentIterator::InitInternal(nsINode*
       }
       if (!startIsData && (startIsContainer || startIndx)) {
         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, aStartContainer,
-                                               startIndx, endNode, endIndx))) {
+            NS_WARN_IF(!NodeIsInTraversalRange(mFirst, mPre,
+                                               aStartContainer, startIndx,
+                                               aEndContainer, endIndx))) {
           mFirst = nullptr;
         }
       } else {
         mFirst = aStartContainer->AsContent();
       }
     } else {
       // post-order
       if (NS_WARN_IF(!aStartContainer->IsContent())) {
@@ -443,93 +444,93 @@ nsContentIterator::InitInternal(nsINode*
       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, aStartContainer, startIndx,
-                                  endNode, endIndx)) {
+                                  aEndContainer, endIndx)) {
         mFirst = nullptr;
       }
     }
   }
 
 
   // Find last node in range.
 
-  bool endIsData = endNode->IsNodeOfType(nsINode::eDATA_NODE);
+  bool endIsData = aEndContainer->IsNodeOfType(nsINode::eDATA_NODE);
 
-  if (endIsData || !endNode->HasChildren() || endIndx == 0) {
+  if (endIsData || !aEndContainer->HasChildren() || endIndx == 0) {
     if (mPre) {
-      if (NS_WARN_IF(!endNode->IsContent())) {
+      if (NS_WARN_IF(!aEndContainer->IsContent())) {
         // Not much else to do here...
         mLast = nullptr;
       } else {
         // If the end node is a non-container element and the end offset is 0,
         // the last element should be the previous node (i.e., shouldn't
         // include the end node in the range).
         bool endIsContainer = true;
-        if (endNode->IsHTMLElement()) {
+        if (aEndContainer->IsHTMLElement()) {
           if (nsIParserService* ps = nsContentUtils::GetParserService()) {
-            nsIAtom* name = endNode->NodeInfo()->NameAtom();
+            nsIAtom* name = aEndContainer->NodeInfo()->NameAtom();
             ps->IsContainer(ps->HTMLAtomTagToId(name), endIsContainer);
           }
         }
         if (!endIsData && !endIsContainer && !endIndx) {
-          mLast = PrevNode(endNode);
+          mLast = PrevNode(aEndContainer);
           NS_WARNING_ASSERTION(mLast, "PrevNode returned null");
           if (mLast && mLast != mFirst &&
               NS_WARN_IF(!NodeIsInTraversalRange(mLast, mPre,
                                                  mFirst, 0,
-                                                 endNode, endIndx))) {
+                                                 aEndContainer, endIndx))) {
             mLast = nullptr;
           }
         } else {
-          mLast = endNode->AsContent();
+          mLast = aEndContainer->AsContent();
         }
       }
     } else {
       // post-order
       //
       // 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);
+        mLast = GetPrevSibling(aEndContainer);
         NS_WARNING_ASSERTION(mLast, "GetPrevSibling returned null");
 
         if (!NodeIsInTraversalRange(mLast, mPre,
                                     aStartContainer, startIndx,
-                                    endNode, endIndx)) {
+                                    aEndContainer, endIndx)) {
           mLast = nullptr;
         }
       } else {
-        mLast = endNode->AsContent();
+        mLast = aEndContainer->AsContent();
       }
     }
   } else {
     int32_t indx = endIndx;
 
-    cChild = endNode->GetChildAt(--indx);
+    cChild = aEndContainer->GetChildAt(--indx);
 
     if (NS_WARN_IF(!cChild)) {
       // No child at offset!
       NS_NOTREACHED("nsContentIterator::nsContentIterator");
       return NS_ERROR_FAILURE;
     }
 
     if (mPre) {
       mLast  = GetDeepLastChild(cChild);
       NS_WARNING_ASSERTION(mLast, "GetDeepLastChild returned null");
 
       if (NS_WARN_IF(!NodeIsInTraversalRange(mLast, mPre,
                                              aStartContainer, startIndx,
-                                             endNode, endIndx))) {
+                                             aEndContainer, endIndx))) {
         mLast = nullptr;
       }
     } else {
       // post-order
       mLast = cChild;
     }
   }