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

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

Issue 69003004: Have NodeTraversal::previous*() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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/editing/ApplyStyleCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/NodeTraversal.cpp
diff --git a/Source/core/dom/NodeTraversal.cpp b/Source/core/dom/NodeTraversal.cpp
index 11a9661374ce56e2507effbd7d3278e439d948e0..e07b695893546b0c567a5a79edb4bb4af5fc34df 100644
--- a/Source/core/dom/NodeTraversal.cpp
+++ b/Source/core/dom/NodeTraversal.cpp
@@ -30,16 +30,16 @@
namespace WebCore {
namespace NodeTraversal {
-Node* previousIncludingPseudo(const Node* current, const Node* stayWithin)
+Node* previousIncludingPseudo(const Node& current, const Node* stayWithin)
{
if (current == stayWithin)
return 0;
- if (Node* previous = current->pseudoAwarePreviousSibling()) {
+ if (Node* previous = current.pseudoAwarePreviousSibling()) {
while (previous->pseudoAwareLastChild())
previous = previous->pseudoAwareLastChild();
return previous;
}
- return current->parentNode();
+ return current.parentNode();
}
Node* nextIncludingPseudo(const Node* current, const Node* stayWithin)
@@ -97,30 +97,30 @@ Node* nextAncestorSibling(const Node* current, const Node* stayWithin)
return 0;
}
-Node* previous(const Node* current, const Node* stayWithin)
+Node* previous(const Node& current, const Node* stayWithin)
{
if (current == stayWithin)
return 0;
- if (current->previousSibling()) {
- Node* previous = current->previousSibling();
+ if (current.previousSibling()) {
+ Node* previous = current.previousSibling();
while (previous->lastChild())
previous = previous->lastChild();
return previous;
}
- return current->parentNode();
+ return current.parentNode();
}
-Node* previousSkippingChildren(const Node* current, const Node* stayWithin)
+Node* previousSkippingChildren(const Node& current, const Node* stayWithin)
{
if (current == stayWithin)
return 0;
- if (current->previousSibling())
- return current->previousSibling();
- for (current = current->parentNode(); current; current = current->parentNode()) {
- if (current == stayWithin)
+ if (current.previousSibling())
+ return current.previousSibling();
+ for (Node* parent = current.parentNode(); parent; parent = parent->parentNode()) {
+ if (parent == stayWithin)
return 0;
- if (current->previousSibling())
- return current->previousSibling();
+ if (parent->previousSibling())
+ return parent->previousSibling();
}
return 0;
}
@@ -137,35 +137,35 @@ Node* nextPostOrder(const Node* current, const Node* stayWithin)
return next;
}
-static Node* previousAncestorSiblingPostOrder(const Node* current, const Node* stayWithin)
+static Node* previousAncestorSiblingPostOrder(const Node& current, const Node* stayWithin)
{
- ASSERT(!current->previousSibling());
- for (current = current->parentNode(); current; current = current->parentNode()) {
- if (current == stayWithin)
+ ASSERT(!current.previousSibling());
+ for (Node* parent = current.parentNode(); parent; parent = parent->parentNode()) {
+ if (parent == stayWithin)
return 0;
- if (current->previousSibling())
- return current->previousSibling();
+ if (parent->previousSibling())
+ return parent->previousSibling();
}
return 0;
}
-Node* previousPostOrder(const Node* current, const Node* stayWithin)
+Node* previousPostOrder(const Node& current, const Node* stayWithin)
{
- if (current->lastChild())
- return current->lastChild();
+ if (current.lastChild())
+ return current.lastChild();
if (current == stayWithin)
return 0;
- if (current->previousSibling())
- return current->previousSibling();
+ if (current.previousSibling())
+ return current.previousSibling();
return previousAncestorSiblingPostOrder(current, stayWithin);
}
-Node* previousSkippingChildrenPostOrder(const Node* current, const Node* stayWithin)
+Node* previousSkippingChildrenPostOrder(const Node& current, const Node* stayWithin)
{
if (current == stayWithin)
return 0;
- if (current->previousSibling())
- return current->previousSibling();
+ if (current.previousSibling())
+ return current.previousSibling();
return previousAncestorSiblingPostOrder(current, stayWithin);
}
« no previous file with comments | « Source/core/dom/NodeTraversal.h ('k') | Source/core/editing/ApplyStyleCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698