diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-29 00:24:35 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-29 00:39:51 +0200 |
commit | 9177eea8fe2f6eb36a36422bfc2adbe3ad8785a5 (patch) | |
tree | 525ae0005b95b797693cd0d5cd7cda399335a4a2 /Libraries/LibWeb/TreeNode.h | |
parent | 706fc3d1aa4647e2c7c2a454cbca4e8646097f0e (diff) | |
download | serenity-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.h | 11 |
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 { |