summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/dom/node_traversal.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/dom/node_traversal.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/dom/node_traversal.cc32
1 files changed, 10 insertions, 22 deletions
diff --git a/chromium/third_party/blink/renderer/core/dom/node_traversal.cc b/chromium/third_party/blink/renderer/core/dom/node_traversal.cc
index d45ad20f352..90ca86e0607 100644
--- a/chromium/third_party/blink/renderer/core/dom/node_traversal.cc
+++ b/chromium/third_party/blink/renderer/core/dom/node_traversal.cc
@@ -47,14 +47,10 @@ Node* NodeTraversal::NextIncludingPseudo(const Node& current,
const Node* stay_within) {
if (Node* next = current.PseudoAwareFirstChild())
return next;
- if (current == stay_within)
- return nullptr;
- if (Node* next = current.PseudoAwareNextSibling())
- return next;
- for (Node& parent : AncestorsOf(current)) {
- if (parent == stay_within)
+ for (Node& node : InclusiveAncestorsOf(current)) {
+ if (node == stay_within)
return nullptr;
- if (Node* next = parent.PseudoAwareNextSibling())
+ if (Node* next = node.PseudoAwareNextSibling())
return next;
}
return nullptr;
@@ -63,14 +59,10 @@ Node* NodeTraversal::NextIncludingPseudo(const Node& current,
Node* NodeTraversal::NextIncludingPseudoSkippingChildren(
const Node& current,
const Node* stay_within) {
- if (current == stay_within)
- return nullptr;
- if (Node* next = current.PseudoAwareNextSibling())
- return next;
- for (Node& parent : AncestorsOf(current)) {
- if (parent == stay_within)
+ for (Node& node : InclusiveAncestorsOf(current)) {
+ if (node == stay_within)
return nullptr;
- if (Node* next = parent.PseudoAwareNextSibling())
+ if (Node* next = node.PseudoAwareNextSibling())
return next;
}
return nullptr;
@@ -138,15 +130,11 @@ Node* NodeTraversal::PreviousAbsoluteSiblingIncludingPseudo(
Node* NodeTraversal::PreviousAbsoluteSibling(const Node& current,
const Node* stay_within) {
- if (current == stay_within)
- return nullptr;
- if (current.previousSibling())
- return current.previousSibling();
- for (Node& parent : AncestorsOf(current)) {
- if (parent == stay_within)
+ for (Node& node : InclusiveAncestorsOf(current)) {
+ if (node == stay_within)
return nullptr;
- if (parent.previousSibling())
- return parent.previousSibling();
+ if (Node* prev = node.previousSibling())
+ return prev;
}
return nullptr;
}