Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(828)

Unified Diff: Source/core/dom/Position.cpp

Issue 425223005: Move Node/ContainerNode's traverseToChildAt() to NodeTraversal (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/NodeTraversal.h ('k') | Source/core/dom/PositionIterator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Position.cpp
diff --git a/Source/core/dom/Position.cpp b/Source/core/dom/Position.cpp
index ecf514ff8acc5801451d8afd4e02965cfd0570c7..dfa220226f7867b5e3060a0726a81279dea888f2 100644
--- a/Source/core/dom/Position.cpp
+++ b/Source/core/dom/Position.cpp
@@ -234,7 +234,7 @@ Node* Position::computeNodeBeforePosition() const
case PositionIsAfterChildren:
return m_anchorNode->lastChild();
case PositionIsOffsetInAnchor:
- return m_anchorNode->traverseToChildAt(m_offset - 1); // -1 converts to traverseToChildAt((unsigned)-1) and returns null.
+ return m_offset ? NodeTraversal::childAt(*m_anchorNode, m_offset - 1) : 0;
case PositionIsBeforeAnchor:
return m_anchorNode->previousSibling();
case PositionIsAfterAnchor:
@@ -255,7 +255,7 @@ Node* Position::computeNodeAfterPosition() const
case PositionIsAfterChildren:
return 0;
case PositionIsOffsetInAnchor:
- return m_anchorNode->traverseToChildAt(m_offset);
+ return NodeTraversal::childAt(*m_anchorNode, m_offset);
case PositionIsBeforeAnchor:
return m_anchorNode.get();
case PositionIsAfterAnchor:
@@ -303,7 +303,7 @@ Position Position::previous(PositionMoveType moveType) const
ASSERT(offset >= 0);
if (offset > 0) {
- if (Node* child = node->traverseToChildAt(offset - 1))
+ if (Node* child = NodeTraversal::childAt(*node, offset - 1))
return lastPositionInOrAfterNode(child);
// There are two reasons child might be 0:
@@ -338,7 +338,7 @@ Position Position::next(PositionMoveType moveType) const
// FIXME: Negative offsets shouldn't be allowed. We should catch this earlier.
ASSERT(offset >= 0);
- if (Node* child = node->traverseToChildAt(offset))
+ if (Node* child = NodeTraversal::childAt(*node, offset))
return firstPositionInOrBeforeNode(child);
if (!node->hasChildren() && offset < lastOffsetForEditing(node)) {
« no previous file with comments | « Source/core/dom/NodeTraversal.h ('k') | Source/core/dom/PositionIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698