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(); |