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

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

Issue 425383002: Move highestAncestorOrSelf() from Node 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/Node.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.h
diff --git a/Source/core/dom/NodeTraversal.h b/Source/core/dom/NodeTraversal.h
index c0c9053e0aec733cd7b04df5acb1b7a364564dcb..652d7025e9dbaed598d867f8173237bebbdd0310 100644
--- a/Source/core/dom/NodeTraversal.h
+++ b/Source/core/dom/NodeTraversal.h
@@ -26,6 +26,7 @@
#ifndef NodeTraversal_h
#define NodeTraversal_h
+#include "core/dom/ContainerNode.h"
#include "core/dom/Node.h"
namespace blink {
@@ -67,6 +68,7 @@ public:
static Node* nextAncestorSibling(const Node&);
static Node* nextAncestorSibling(const Node&, const Node* stayWithin);
+ static Node& highestAncestorOrSelf(Node&);
private:
template <class NodeType>
@@ -113,6 +115,14 @@ inline Node* NodeTraversal::nextSkippingChildren(const Node& current, const Node
return nextAncestorSibling(current, stayWithin);
}
+inline Node& NodeTraversal::highestAncestorOrSelf(Node& current)
+{
+ Node* highest = &current;
+ while (highest->parentNode())
+ highest = highest->parentNode();
+ return *highest;
+}
+
} // namespace blink
#endif
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/editing/ApplyStyleCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698