Rename Node::childNode(index) to traverseToChildAt(index) for clarity
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Sep 2014 02:00:40 +0000 (02:00 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Sep 2014 02:00:40 +0000 (02:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136825

Reviewed by Benjamin Poulain.

Rename Node::childNode(index) to traverseToChildAt(index) to make it
clearer that the method is actually traversing the children and thus
potentially expensive.

This patch also avoids calling traverseToChildAt() in a couple of
easily avoidable cases.

No new tests, no behavior change.

* WebCore.exp.in:
* WebCore.order:
Remove symbol for ContainerNode::childNode() as it was renamed. It does
not seem we need to expose ContainerNode::traverseToChildAt().

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::stringForVisiblePositionRange):
(WebCore::AccessibilityObject::lengthForVisiblePositionRange):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper arrayOfTextForTextMarkers:attributed:]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]):
Mechanical renaming.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::traverseToChildAt):
(WebCore::ContainerNode::childNode): Deleted.
* dom/ContainerNode.h:
(WebCore::Node::traverseToChildAt):
(WebCore::Node::childNode): Deleted.
* dom/Node.h:
- Rename Node / ContainerNode's childNode(index) to
  traverseToChildAt(index) to make it clear that it is actually
  traversing the children and thus potentially expensive.
- Clean up the implementation of ContainerNode::traverseToChildAt()
  to avoid the use of an extra |i| variable.

* dom/Position.cpp:
(WebCore::Position::computeNodeBeforePosition):
Avoid calling traverseToChildAt(-1). Relying on the unsigned argument
wrapping and the method returning null in this case is a bit obscure
and causes unnecessary traversal of all children.

(WebCore::Position::computeNodeAfterPosition):
(WebCore::Position::previous):
(WebCore::Position::next):
Mechanical renaming and update variable names to stop using
abbreviations as per coding style.

* dom/PositionIterator.h:
(WebCore::PositionIterator::PositionIterator):
* dom/Range.cpp:
(WebCore::Range::insertNode):
(WebCore::Range::checkNodeWOffset):
(WebCore::Range::firstNode):
(WebCore::Range::pastLastNode):
* dom/RangeBoundaryPoint.h:
(WebCore::RangeBoundaryPoint::set):
* editing/BreakBlockquoteCommand.cpp:
(WebCore::BreakBlockquoteCommand::doApply):
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::removeChildrenInRange):
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleGeneralDelete):
* editing/InsertParagraphSeparatorCommand.cpp:
(WebCore::InsertParagraphSeparatorCommand::doApply):
* editing/TextIterator.cpp:
(WebCore::nextInPreOrderCrossingShadowBoundaries):
(WebCore::TextIterator::node):
(WebCore::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator):
* editing/VisibleUnits.cpp:
(WebCore::nextLinePosition):
* editing/cocoa/HTMLConverter.mm:
(WebCore::editingAttributedStringFromRange):
Mechanical renaming.

* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::innerPatchChildren):
Iterate over children while incrementing the |i| variable to avoid
calling traverseToChildAt(index) repeatedly and thus traversing the
children from the beginning every time.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173684 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.order
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNode.h
Source/WebCore/dom/Node.h
Source/WebCore/dom/Position.cpp
Source/WebCore/dom/PositionIterator.h
Source/WebCore/dom/Range.cpp
Source/WebCore/dom/RangeBoundaryPoint.h
Source/WebCore/editing/BreakBlockquoteCommand.cpp
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/DeleteSelectionCommand.cpp
Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/VisibleUnits.cpp
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/inspector/DOMPatchSupport.cpp

index 40bc195..7dff6e6 100644 (file)
@@ -1,3 +1,91 @@
+2014-09-16  Chris Dumez  <cdumez@apple.com>
+
+        Rename Node::childNode(index) to traverseToChildAt(index) for clarity
+        https://bugs.webkit.org/show_bug.cgi?id=136825
+
+        Reviewed by Benjamin Poulain.
+
+        Rename Node::childNode(index) to traverseToChildAt(index) to make it
+        clearer that the method is actually traversing the children and thus
+        potentially expensive.
+
+        This patch also avoids calling traverseToChildAt() in a couple of
+        easily avoidable cases.
+
+        No new tests, no behavior change.
+
+        * WebCore.exp.in:
+        * WebCore.order:
+        Remove symbol for ContainerNode::childNode() as it was renamed. It does
+        not seem we need to expose ContainerNode::traverseToChildAt().
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::stringForVisiblePositionRange):
+        (WebCore::AccessibilityObject::lengthForVisiblePositionRange):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper arrayOfTextForTextMarkers:attributed:]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]):
+        Mechanical renaming.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::traverseToChildAt):
+        (WebCore::ContainerNode::childNode): Deleted.
+        * dom/ContainerNode.h:
+        (WebCore::Node::traverseToChildAt):
+        (WebCore::Node::childNode): Deleted.
+        * dom/Node.h:
+        - Rename Node / ContainerNode's childNode(index) to
+          traverseToChildAt(index) to make it clear that it is actually
+          traversing the children and thus potentially expensive.
+        - Clean up the implementation of ContainerNode::traverseToChildAt()
+          to avoid the use of an extra |i| variable.
+
+        * dom/Position.cpp:
+        (WebCore::Position::computeNodeBeforePosition):
+        Avoid calling traverseToChildAt(-1). Relying on the unsigned argument
+        wrapping and the method returning null in this case is a bit obscure
+        and causes unnecessary traversal of all children.
+
+        (WebCore::Position::computeNodeAfterPosition):
+        (WebCore::Position::previous):
+        (WebCore::Position::next):
+        Mechanical renaming and update variable names to stop using
+        abbreviations as per coding style.
+
+        * dom/PositionIterator.h:
+        (WebCore::PositionIterator::PositionIterator):
+        * dom/Range.cpp:
+        (WebCore::Range::insertNode):
+        (WebCore::Range::checkNodeWOffset):
+        (WebCore::Range::firstNode):
+        (WebCore::Range::pastLastNode):
+        * dom/RangeBoundaryPoint.h:
+        (WebCore::RangeBoundaryPoint::set):
+        * editing/BreakBlockquoteCommand.cpp:
+        (WebCore::BreakBlockquoteCommand::doApply):
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::removeChildrenInRange):
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::handleGeneralDelete):
+        * editing/InsertParagraphSeparatorCommand.cpp:
+        (WebCore::InsertParagraphSeparatorCommand::doApply):
+        * editing/TextIterator.cpp:
+        (WebCore::nextInPreOrderCrossingShadowBoundaries):
+        (WebCore::TextIterator::node):
+        (WebCore::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator):
+        * editing/VisibleUnits.cpp:
+        (WebCore::nextLinePosition):
+        * editing/cocoa/HTMLConverter.mm:
+        (WebCore::editingAttributedStringFromRange):
+        Mechanical renaming.
+
+        * inspector/DOMPatchSupport.cpp:
+        (WebCore::DOMPatchSupport::innerPatchChildren):
+        Iterate over children while incrementing the |i| variable to avoid
+        calling traverseToChildAt(index) repeatedly and thus traversing the
+        children from the beginning every time.
+
 2014-09-16  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Reduce a bit of churn setting initial remote inspection state
index 1aa86cf..b13faa2 100644 (file)
@@ -1626,7 +1626,6 @@ __ZNK7WebCore12TextEncoding6decodeEPKcmbRb
 __ZNK7WebCore12TextIterator4nodeEv
 __ZNK7WebCore12TextIterator5rangeEv
 __ZNK7WebCore13ContainerNode15countChildNodesEv
-__ZNK7WebCore13ContainerNode9childNodeEj
 __ZNK7WebCore13GraphicsLayer18accumulatedOpacityEv
 __ZNK7WebCore13GraphicsLayer18getDebugBorderInfoERNS_5ColorERf
 __ZNK7WebCore13GraphicsLayer26backingStoreMemoryEstimateEv
index 0c2e6b1..3313e4a 100644 (file)
@@ -8133,7 +8133,6 @@ __ZN7WebCore5Range10selectNodeEPNS_4NodeERi
 __ZN7WebCore5Range14setStartBeforeEPNS_4NodeERi
 __ZNK7WebCore4Node16computeNodeIndexEv
 __ZN7WebCore5Range8setStartEN3WTF10PassRefPtrINS_4NodeEEEiRi
-__ZNK7WebCore13ContainerNode9childNodeEj
 __ZN7WebCoreL30checkForDifferentRootContainerERKNS_18RangeBoundaryPointES2_
 __ZN7WebCore5Range21compareBoundaryPointsEPNS_4NodeEiS2_iRi
 __ZN7WebCore5Range8collapseEbRi
index 530a853..4999040 100644 (file)
@@ -1139,7 +1139,7 @@ String AccessibilityObject::stringForVisiblePositionRange(const VisiblePositionR
             Node* node = it.range()->startContainer();
             ASSERT(node == it.range()->endContainer());
             int offset = it.range()->startOffset();
-            if (replacedNodeNeedsCharacter(node->childNode(offset)))
+            if (replacedNodeNeedsCharacter(node->traverseToChildAt(offset)))
                 builder.append(objectReplacementCharacter);
         }
     }
@@ -1166,7 +1166,7 @@ int AccessibilityObject::lengthForVisiblePositionRange(const VisiblePositionRang
             ASSERT(node == it.range()->endContainer(exception));
             int offset = it.range()->startOffset(exception);
 
-            if (replacedNodeNeedsCharacter(node->childNode(offset)))
+            if (replacedNodeNeedsCharacter(node->traverseToChildAt(offset)))
                 length++;
         }
     }
index f3f1a6b..cdf1251 100644 (file)
@@ -1844,7 +1844,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
                 [attrString release];
             }
         } else {
-            Node* replacedNode = node->childNode(offset);
+            Node* replacedNode = node->traverseToChildAt(offset);
             if (replacedNode) {
                 AccessibilityObject* obj = m_object->axObjectCache()->getOrCreate(replacedNode->renderer());
                 if (obj && !obj->accessibilityIsIgnored())
index 48bd667..48b9aee 100644 (file)
@@ -1102,7 +1102,7 @@ static NSString* nsStringForReplacedNode(Node* replacedNode)
                 AXAttributedStringAppendText(attrString, node, listMarkerText);
             AXAttributedStringAppendText(attrString, node, it.text());
         } else {
-            Node* replacedNode = node->childNode(offset);
+            Node* replacedNode = node->traverseToChildAt(offset);
             NSString *attachmentString = nsStringForReplacedNode(replacedNode);
             if (attachmentString) {
                 NSRange attrStringRange = NSMakeRange([attrString length], [attachmentString length]);
index 63e1791..d5ce05d 100644 (file)
@@ -939,13 +939,12 @@ unsigned ContainerNode::countChildNodes() const
     return count;
 }
 
-Node *ContainerNode::childNode(unsigned index) const
+Node* ContainerNode::traverseToChildAt(unsigned index) const
 {
-    unsigned i;
-    Node *n = firstChild();
-    for (i = 0; n != 0 && i < index; i++)
-        n = n->nextSibling();
-    return n;
+    Node* child = firstChild();
+    for (; child && index > 0; --index)
+        child = child->nextSibling();
+    return child;
 }
 
 static void dispatchChildInsertionEvents(Node& child)
index 5563392..5f04c33 100644 (file)
@@ -93,7 +93,7 @@ public:
     void setDirectChildNeedsStyleRecalc() { setFlag(DirectChildNeedsStyleRecalcFlag); }
 
     WEBCORE_EXPORT unsigned countChildNodes() const;
-    WEBCORE_EXPORT Node* childNode(unsigned index) const;
+    WEBCORE_EXPORT Node* traverseToChildAt(unsigned) const;
 
     bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
     bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
@@ -192,11 +192,11 @@ inline unsigned Node::countChildNodes() const
     return toContainerNode(this)->countChildNodes();
 }
 
-inline Node* Node::childNode(unsigned index) const
+inline Node* Node::traverseToChildAt(unsigned index) const
 {
     if (!isContainerNode())
         return 0;
-    return toContainerNode(this)->childNode(index);
+    return toContainerNode(this)->traverseToChildAt(index);
 }
 
 inline Node* Node::firstChild() const
index 51b6fce..f469fe5 100644 (file)
@@ -417,7 +417,7 @@ public:
     bool isDocumentTypeNode() const { return nodeType() == DOCUMENT_TYPE_NODE; }
     virtual bool childTypeAllowed(NodeType) const { return false; }
     unsigned countChildNodes() const;
-    Node* childNode(unsigned index) const;
+    Node* traverseToChildAt(unsigned) const;
 
     void checkSetPrefix(const AtomicString& prefix, ExceptionCode&);
 
index 72cd6d5..232d777 100644 (file)
@@ -246,7 +246,7 @@ Node* Position::computeNodeBeforePosition() const
     case PositionIsAfterChildren:
         return m_anchorNode->lastChild();
     case PositionIsOffsetInAnchor:
-        return m_anchorNode->childNode(m_offset - 1); // -1 converts to childNode((unsigned)-1) and returns null.
+        return m_offset ? m_anchorNode->traverseToChildAt(m_offset - 1) : nullptr;
     case PositionIsBeforeAnchor:
         return m_anchorNode->previousSibling();
     case PositionIsAfterAnchor:
@@ -267,7 +267,7 @@ Node* Position::computeNodeAfterPosition() const
     case PositionIsAfterChildren:
         return 0;
     case PositionIsOffsetInAnchor:
-        return m_anchorNode->childNode(m_offset);
+        return m_anchorNode->traverseToChildAt(m_offset);
     case PositionIsBeforeAnchor:
         return m_anchorNode.get();
     case PositionIsAfterAnchor:
@@ -298,17 +298,16 @@ Element* Position::element() const
 
 Position Position::previous(PositionMoveType moveType) const
 {
-    Node* n = deprecatedNode();
-    if (!n)
+    Node* node = deprecatedNode();
+    if (!node)
         return *this;
 
-    int o = deprecatedEditingOffset();
+    int offset = deprecatedEditingOffset();
     // FIXME: Negative offsets shouldn't be allowed. We should catch this earlier.
-    ASSERT(o >= 0);
+    ASSERT(offset >= 0);
 
-    if (o > 0) {
-        Node* child = n->childNode(o - 1);
-        if (child)
+    if (offset > 0) {
+        if (Node* child = node->traverseToChildAt(offset - 1))
             return lastPositionInOrAfterNode(child);
 
         // There are two reasons child might be 0:
@@ -318,35 +317,35 @@ Position Position::previous(PositionMoveType moveType) const
         //      Going from 1 to 0 is correct.
         switch (moveType) {
         case CodePoint:
-            return createLegacyEditingPosition(n, o - 1);
+            return createLegacyEditingPosition(node, offset - 1);
         case Character:
-            return createLegacyEditingPosition(n, uncheckedPreviousOffset(n, o));
+            return createLegacyEditingPosition(node, uncheckedPreviousOffset(node, offset));
         case BackwardDeletion:
-            return createLegacyEditingPosition(n, uncheckedPreviousOffsetForBackwardDeletion(n, o));
+            return createLegacyEditingPosition(node, uncheckedPreviousOffsetForBackwardDeletion(node, offset));
         }
     }
 
-    ContainerNode* parent = findParent(n);
+    ContainerNode* parent = findParent(node);
     if (!parent)
         return *this;
 
-    return createLegacyEditingPosition(parent, n->computeNodeIndex());
+    return createLegacyEditingPosition(parent, node->computeNodeIndex());
 }
 
 Position Position::next(PositionMoveType moveType) const
 {
     ASSERT(moveType != BackwardDeletion);
 
-    Node* n = deprecatedNode();
-    if (!n)
+    Node* node = deprecatedNode();
+    if (!node)
         return *this;
 
-    int o = deprecatedEditingOffset();
+    int offset = deprecatedEditingOffset();
     // FIXME: Negative offsets shouldn't be allowed. We should catch this earlier.
-    ASSERT(o >= 0);
+    ASSERT(offset >= 0);
 
-    Node* child = n->childNode(o);
-    if (child || (!n->hasChildNodes() && o < lastOffsetForEditing(n))) {
+    Node* child = node->traverseToChildAt(offset);
+    if (child || (!node->hasChildNodes() && offset < lastOffsetForEditing(node))) {
         if (child)
             return firstPositionInOrBeforeNode(child);
 
@@ -355,14 +354,14 @@ Position Position::next(PositionMoveType moveType) const
         //      Going forward one character at a time is correct.
         //   2) The new offset is a bogus offset like (<br>, 1), and there is no child.
         //      Going from 0 to 1 is correct.
-        return createLegacyEditingPosition(n, (moveType == Character) ? uncheckedNextOffset(n, o) : o + 1);
+        return createLegacyEditingPosition(node, (moveType == Character) ? uncheckedNextOffset(node, offset) : offset + 1);
     }
 
-    ContainerNode* parent = findParent(n);
+    ContainerNode* parent = findParent(node);
     if (!parent)
         return *this;
 
-    return createLegacyEditingPosition(parent, n->computeNodeIndex() + 1);
+    return createLegacyEditingPosition(parent, node->computeNodeIndex() + 1);
 }
 
 int Position::uncheckedPreviousOffset(const Node* n, int current)
index 7af8977..8e0ee19 100644 (file)
@@ -45,7 +45,7 @@ public:
 
     PositionIterator(const Position& pos)
         : m_anchorNode(pos.anchorNode())
-        , m_nodeAfterPositionInAnchor(m_anchorNode->childNode(pos.deprecatedEditingOffset()))
+        , m_nodeAfterPositionInAnchor(m_anchorNode->traverseToChildAt(pos.deprecatedEditingOffset()))
         , m_offsetInAnchor(m_nodeAfterPositionInAnchor ? 0 : pos.deprecatedEditingOffset())
     {
     }
index dca8763..1dc2c92 100644 (file)
@@ -1056,7 +1056,7 @@ void Range::insertNode(PassRefPtr<Node> prpNewNode, ExceptionCode& ec)
         container = m_start.container();
         RefPtr<Node> firstInsertedChild = newNodeType == Node::DOCUMENT_FRAGMENT_NODE ? newNode->firstChild() : newNode;
         RefPtr<Node> lastInsertedChild = newNodeType == Node::DOCUMENT_FRAGMENT_NODE ? newNode->lastChild() : newNode;
-        RefPtr<Node> childAfterInsertedContent = container->childNode(m_start.offset());
+        RefPtr<Node> childAfterInsertedContent = container->traverseToChildAt(m_start.offset());
         container->insertBefore(newNode.release(), childAfterInsertedContent.get(), ec);
         if (ec)
             return;
@@ -1171,7 +1171,7 @@ Node* Range::checkNodeWOffset(Node* n, int offset, ExceptionCode& ec) const
         case Node::XPATH_NAMESPACE_NODE: {
             if (!offset)
                 return 0;
-            Node* childBefore = n->childNode(offset - 1);
+            Node* childBefore = n->traverseToChildAt(offset - 1);
             if (!childBefore)
                 ec = INDEX_SIZE_ERR;
             return childBefore;
@@ -1568,7 +1568,7 @@ Node* Range::firstNode() const
         return 0;
     if (m_start.container()->offsetInCharacters())
         return m_start.container();
-    if (Node* child = m_start.container()->childNode(m_start.offset()))
+    if (Node* child = m_start.container()->traverseToChildAt(m_start.offset()))
         return child;
     if (!m_start.offset())
         return m_start.container();
@@ -1586,7 +1586,7 @@ Node* Range::pastLastNode() const
         return 0;
     if (m_end.container()->offsetInCharacters())
         return NodeTraversal::nextSkippingChildren(m_end.container());
-    if (Node* child = m_end.container()->childNode(m_end.offset()))
+    if (Node* child = m_end.container()->traverseToChildAt(m_end.offset()))
         return child;
     return NodeTraversal::nextSkippingChildren(m_end.container());
 }
index 80921d2..784fa45 100644 (file)
@@ -121,7 +121,7 @@ inline void RangeBoundaryPoint::set(PassRefPtr<Node> container, int offset, Node
 {
     ASSERT(container);
     ASSERT(offset >= 0);
-    ASSERT(childBefore == (offset ? container->childNode(offset - 1) : 0));
+    ASSERT(childBefore == (offset ? container->traverseToChildAt(offset - 1) : 0));
     m_containerNode = container;
     m_offsetInContainer = offset;
     m_childBeforeBoundary = childBefore;
index a1f5776..5548705 100644 (file)
@@ -114,7 +114,7 @@ void BreakBlockquoteCommand::doApply()
         } else if (pos.deprecatedEditingOffset() > 0)
             splitTextNode(textNode, pos.deprecatedEditingOffset());
     } else if (pos.deprecatedEditingOffset() > 0) {
-        Node* childAtOffset = startNode->childNode(pos.deprecatedEditingOffset());
+        Node* childAtOffset = startNode->traverseToChildAt(pos.deprecatedEditingOffset());
         startNode = childAtOffset ? childAtOffset : NodeTraversal::next(startNode);
         ASSERT(startNode);
     }
index 9b48b2d..1d8a7fb 100644 (file)
@@ -396,7 +396,7 @@ void CompositeEditCommand::appendNode(PassRefPtr<Node> node, PassRefPtr<Containe
 void CompositeEditCommand::removeChildrenInRange(PassRefPtr<Node> node, unsigned from, unsigned to)
 {
     Vector<RefPtr<Node>> children;
-    Node* child = node->childNode(from);
+    Node* child = node->traverseToChildAt(from);
     for (unsigned i = from; child && i < to; i++, child = child->nextSibling())
         children.append(child);
 
index 362619d..f8a644a 100644 (file)
@@ -507,7 +507,7 @@ void DeleteSelectionCommand::handleGeneralDelete()
                 deleteTextFromNode(text, startOffset, text->length() - startOffset);
                 node = NodeTraversal::next(node.get());
             } else {
-                node = startNode->childNode(startOffset);
+                node = startNode->traverseToChildAt(startOffset);
             }
         } else if (startNode == m_upstreamEnd.deprecatedNode() && startNode->isTextNode()) {
             Text* text = toText(m_upstreamEnd.deprecatedNode());
index 67cc86c..7fb7503 100644 (file)
@@ -267,7 +267,7 @@ void InsertParagraphSeparatorCommand::doApply()
             refNode = startBlock->firstChild();
         }
         else if (insertionPosition.deprecatedNode() == startBlock && nestNewBlock) {
-            refNode = startBlock->childNode(insertionPosition.deprecatedEditingOffset());
+            refNode = startBlock->traverseToChildAt(insertionPosition.deprecatedEditingOffset());
             ASSERT(refNode); // must be true or we'd be in the end of block case
         } else
             refNode = insertionPosition.deprecatedNode();
index e9763bc..d8c2513 100644 (file)
@@ -193,7 +193,7 @@ static unsigned depthCrossingShadowBoundaries(Node& node)
 static Node* nextInPreOrderCrossingShadowBoundaries(Node& rangeEndContainer, int rangeEndOffset)
 {
     if (rangeEndOffset >= 0 && !rangeEndContainer.offsetInCharacters()) {
-        if (Node* next = rangeEndContainer.childNode(rangeEndOffset))
+        if (Node* next = rangeEndContainer.traverseToChildAt(rangeEndOffset))
             return next;
     }
     for (Node* node = &rangeEndContainer; node; node = node->parentOrShadowHostNode()) {
@@ -1111,7 +1111,7 @@ Node* TextIterator::node() const
     if (node->offsetInCharacters())
         return node;
     
-    return node->childNode(textRange->startOffset());
+    return node->traverseToChildAt(textRange->startOffset());
 }
 
 // --------
@@ -1147,13 +1147,13 @@ SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Range& ra
 
     if (!startNode->offsetInCharacters()) {
         if (startOffset >= 0 && startOffset < static_cast<int>(startNode->countChildNodes())) {
-            startNode = startNode->childNode(startOffset);
+            startNode = startNode->traverseToChildAt(startOffset);
             startOffset = 0;
         }
     }
     if (!endNode->offsetInCharacters()) {
         if (endOffset > 0 && endOffset <= static_cast<int>(endNode->countChildNodes())) {
-            endNode = endNode->childNode(endOffset - 1);
+            endNode = endNode->traverseToChildAt(endOffset - 1);
             endOffset = lastOffsetInNode(endNode);
         }
     }
index 64ce390..ed000fa 100644 (file)
@@ -1013,7 +1013,7 @@ VisiblePosition nextLinePosition(const VisiblePosition& visiblePosition, int lin
 
     if (!root) {
         // FIXME: We need do the same in previousLinePosition.
-        Node* child = node->childNode(p.deprecatedEditingOffset());
+        Node* child = node->traverseToChildAt(p.deprecatedEditingOffset());
         node = child ? child : node->lastDescendant();
         Position position = nextRootInlineBoxCandidatePosition(node, visiblePosition, editableType);
         if (position.isNotNull()) {
index 518e4fa..8bb7496 100644 (file)
@@ -2569,7 +2569,7 @@ NSAttributedString *editingAttributedStringFromRange(Range& range)
         int endOffset = currentTextRange->endOffset();
         
         if (startContainer == endContainer && (startOffset == endOffset - 1)) {
-            Node* node = startContainer->childNode(startOffset);
+            Node* node = startContainer->traverseToChildAt(startOffset);
             if (node && node->hasTagName(imgTag)) {
                 NSFileWrapper* fileWrapper = fileWrapperForElement(toElement(node));
                 NSTextAttachment* attachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper];
index 3f2fa9a..672e5be 100644 (file)
@@ -377,10 +377,11 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
     }
 
     // 3. Insert missing nodes.
-    for (size_t i = 0; i < newMap.size(); ++i) {
+    Node* node = parentNode->firstChild();
+    for (unsigned i = 0; node && i < newMap.size(); ++i, node = node->nextSibling()) {
         if (newMap[i].first || merges.contains(newList[i].get()))
             continue;
-        if (!insertBeforeAndMarkAsUsed(parentNode, newList[i].get(), parentNode->childNode(i), ec))
+        if (!insertBeforeAndMarkAsUsed(parentNode, newList[i].get(), node, ec))
             return false;
     }
 
@@ -389,7 +390,7 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
         if (!oldMap[i].first)
             continue;
         RefPtr<Node> node = oldMap[i].first->m_node;
-        Node* anchorNode = parentNode->childNode(oldMap[i].second);
+        Node* anchorNode = parentNode->traverseToChildAt(oldMap[i].second);
         if (node.get() == anchorNode)
             continue;
         if (node->hasTagName(bodyTag) || node->hasTagName(headTag))