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

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

Issue 167013002: Port SiblingTraversalStrategies to ElementTraversal API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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/css/SiblingTraversalStrategies.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ElementTraversal.h
diff --git a/Source/core/dom/ElementTraversal.h b/Source/core/dom/ElementTraversal.h
index 4235e80d45b0ab0f15809a3a2ba5a98f57dc1c13..1adba4498ceb50733935bdafff16afc0665ad229 100644
--- a/Source/core/dom/ElementTraversal.h
+++ b/Source/core/dom/ElementTraversal.h
@@ -56,7 +56,8 @@ Element* nextIncludingPseudoSkippingChildren(const Node&, const Node* stayWithin
// Utility function to traverse only the element and pseudo-element siblings of a node.
Element* pseudoAwarePreviousSibling(const Node&);
-// Next sibling.
+// Previous / Next sibling.
+Element* previousSibling(const Node&);
Element* nextSibling(const Node&);
template <class NodeType>
@@ -147,6 +148,14 @@ inline Element* pseudoAwarePreviousSibling(const Node& current)
return toElement(node);
}
+inline Element* previousSibling(const Node& current)
+{
+ Node* node = current.previousSibling();
+ while (node && !node->isElementNode())
+ node = node->previousSibling();
+ return toElement(node);
+}
+
inline Element* nextSibling(const Node& current)
{
Node* node = current.nextSibling();
« no previous file with comments | « Source/core/css/SiblingTraversalStrategies.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698