Bug 1375502 - part5: Rename startIndx of nsContentIterator::InitInternal() to aStartOffset r?mats draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 16 Aug 2017 22:13:47 +0900
changeset 648166 b4be874c42f8fb5f4329813c870c92fe6a0cef0e
parent 648165 dfccd1c610f8be18e1759f7197dd34aff323942a
child 648167 267df6704f7b06636ce748cd2499cc7b3199317a
push id74653
push usermasayuki@d-toybox.com
push dateThu, 17 Aug 2017 10:09:29 +0000
reviewersmats
bugs1375502
milestone57.0a1
Bug 1375502 - part5: Rename startIndx of nsContentIterator::InitInternal() to aStartOffset r?mats MozReview-Commit-ID: 9NGxFjM5Mox
dom/base/nsContentIterator.cpp
--- a/dom/base/nsContentIterator.cpp
+++ b/dom/base/nsContentIterator.cpp
@@ -339,17 +339,17 @@ 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,
+nsContentIterator::InitInternal(nsINode* aStartContainer, uint32_t aStartOffset,
                                 nsINode* aEndContainer, uint32_t endIndx)
 {
   // get common content parent
   mCommonParent =
     nsContentUtils::GetCommonAncestor(aStartContainer, aEndContainer);
   if (NS_WARN_IF(!mCommonParent)) {
     return NS_ERROR_FAILURE;
   }
@@ -360,17 +360,17 @@ nsContentIterator::InitInternal(nsINode*
   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) {
+    if (!startIsData && aStartOffset == endIndx) {
       MakeEmpty();
       return NS_OK;
     }
 
     if (startIsData) {
       // It's a character data node.
       mFirst   = aStartContainer->AsContent();
       mLast    = mFirst;
@@ -381,51 +381,51 @@ nsContentIterator::InitInternal(nsINode*
       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) < aStartContainer->GetChildCount()) {
-    cChild = aStartContainer->GetChildAt(startIndx);
+  // Valid start indices are 0 <= aStartOffset <= childCount. That means if
+  // start node has no children, only offset 0 is valid.
+  if (!startIsData && aStartOffset < aStartContainer->GetChildCount()) {
+    cChild = aStartContainer->GetChildAt(aStartOffset);
     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.
+      // of the range in pre mode. However, if aStartOffset == 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 (aStartContainer->IsHTMLElement()) {
         if (nsIParserService* ps = nsContentUtils::GetParserService()) {
           nsIAtom* name = aStartContainer->NodeInfo()->NameAtom();
           ps->IsContainer(ps->HTMLAtomTagToId(name), startIsContainer);
         }
       }
-      if (!startIsData && (startIsContainer || startIndx)) {
+      if (!startIsData && (startIsContainer || aStartOffset)) {
         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,
+                                               aStartContainer, aStartOffset,
                                                aEndContainer, endIndx))) {
           mFirst = nullptr;
         }
       } else {
         mFirst = aStartContainer->AsContent();
       }
     } else {
       // post-order
@@ -443,17 +443,17 @@ nsContentIterator::InitInternal(nsINode*
       // 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, aStartContainer, startIndx,
+          !NodeIsInTraversalRange(mFirst, mPre, aStartContainer, aStartOffset,
                                   aEndContainer, endIndx)) {
         mFirst = nullptr;
       }
     }
   }
 
 
   // Find last node in range.
@@ -495,17 +495,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(aEndContainer);
         NS_WARNING_ASSERTION(mLast, "GetPrevSibling returned null");
 
         if (!NodeIsInTraversalRange(mLast, mPre,
-                                    aStartContainer, startIndx,
+                                    aStartContainer, aStartOffset,
                                     aEndContainer, endIndx)) {
           mLast = nullptr;
         }
       } else {
         mLast = aEndContainer->AsContent();
       }
     }
   } else {
@@ -519,17 +519,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,
-                                             aStartContainer, startIndx,
+                                             aStartContainer, aStartOffset,
                                              aEndContainer, endIndx))) {
         mLast = nullptr;
       }
     } else {
       // post-order
       mLast = cChild;
     }
   }