summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/TreeNode.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-29 00:24:35 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-29 00:39:51 +0200
commit9177eea8fe2f6eb36a36422bfc2adbe3ad8785a5 (patch)
tree525ae0005b95b797693cd0d5cd7cda399335a4a2 /Libraries/LibWeb/TreeNode.h
parent706fc3d1aa4647e2c7c2a454cbca4e8646097f0e (diff)
downloadserenity-9177eea8fe2f6eb36a36422bfc2adbe3ad8785a5.zip
LibWeb: Add LayoutRange::normalized()
We use this to ensure that we're always working with a selection where the start() is before the end() in document order. That simplifies all the logic around this.
Diffstat (limited to 'Libraries/LibWeb/TreeNode.h')
-rw-r--r--Libraries/LibWeb/TreeNode.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Libraries/LibWeb/TreeNode.h b/Libraries/LibWeb/TreeNode.h
index 65fc2f5134..347d917f0d 100644
--- a/Libraries/LibWeb/TreeNode.h
+++ b/Libraries/LibWeb/TreeNode.h
@@ -136,6 +136,17 @@ public:
return const_cast<TreeNode*>(this)->next_in_pre_order();
}
+ bool is_before(const T& other) const
+ {
+ if (this == &other)
+ return false;
+ for (auto* node = this; node; node = node->next_in_pre_order()) {
+ if (node == &other)
+ return true;
+ }
+ return false;
+ }
+
template<typename Callback>
IterationDecision for_each_in_subtree(Callback callback) const
{