diff --git a/Userland/Libraries/LibWeb/TreeNode.h b/Userland/Libraries/LibWeb/TreeNode.h index 0c548f3cec..2c045e53fd 100644 --- a/Userland/Libraries/LibWeb/TreeNode.h +++ b/Userland/Libraries/LibWeb/TreeNode.h @@ -30,30 +30,6 @@ public: T const* first_child() const { return m_first_child; } T const* last_child() const { return m_last_child; } - size_t child_count() const - { - size_t count = 0; - for (auto* child = first_child(); child; child = child->next_sibling()) - ++count; - return count; - } - - T* child_at_index(int index) - { - int count = 0; - for (auto* child = first_child(); child; child = child->next_sibling()) { - if (count == index) - return child; - ++count; - } - return nullptr; - } - - T const* child_at_index(int index) const - { - return const_cast(this)->child_at_index(index); - } - // https://dom.spec.whatwg.org/#concept-tree-index size_t index() const { @@ -64,21 +40,6 @@ public: return index; } - Optional index_of_child(T const& search_child) - { - VERIFY(search_child.parent() == this); - size_t index = 0; - auto* child = first_child(); - VERIFY(child); - - do { - if (child == &search_child) - return index; - index++; - } while (child && (child = child->next_sibling())); - return {}; - } - template Optional index_of_child(T const& search_child) { @@ -99,10 +60,6 @@ public: bool is_ancestor_of(TreeNode const&) const; bool is_inclusive_ancestor_of(TreeNode const&) const; - bool is_descendant_of(TreeNode const&) const; - bool is_inclusive_descendant_of(TreeNode const&) const; - - bool is_following(TreeNode const&) const; void append_child(JS::NonnullGCPtr node); void prepend_child(JS::NonnullGCPtr node); @@ -166,39 +123,6 @@ public: return const_cast(this)->previous_in_pre_order(); } - bool is_before(T const& 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; - } - - // https://dom.spec.whatwg.org/#concept-tree-preceding (Object A is 'typename U' and Object B is 'this') - template - bool has_preceding_node_of_type_in_tree_order() const - { - for (auto* node = previous_in_pre_order(); node; node = node->previous_in_pre_order()) { - if (is(node)) - return true; - } - return false; - } - - // https://dom.spec.whatwg.org/#concept-tree-following (Object A is 'typename U' and Object B is 'this') - template - bool has_following_node_of_type_in_tree_order() const - { - for (auto* node = next_in_pre_order(); node; node = node->next_in_pre_order()) { - if (is(node)) - return true; - } - return false; - } - template IterationDecision for_each_in_inclusive_subtree(Callback callback) const { @@ -383,12 +307,6 @@ public: return nullptr; } - template - bool has_child_of_type() const - { - return first_child_of_type() != nullptr; - } - template U const* first_ancestor_of_type() const { @@ -405,15 +323,6 @@ public: return nullptr; } - bool is_parent_of(T const& other) const - { - for (auto* child = first_child(); child; child = child->next_sibling()) { - if (&other == child) - return true; - } - return false; - } - ~TreeNode() = default; protected: @@ -528,29 +437,4 @@ inline bool TreeNode::is_inclusive_ancestor_of(TreeNode const& other) cons return &other == this || is_ancestor_of(other); } -template -inline bool TreeNode::is_descendant_of(TreeNode const& other) const -{ - return other.is_ancestor_of(*this); -} - -template -inline bool TreeNode::is_inclusive_descendant_of(TreeNode const& other) const -{ - return other.is_inclusive_ancestor_of(*this); -} - -// https://dom.spec.whatwg.org/#concept-tree-following -template -inline bool TreeNode::is_following(TreeNode const& other) const -{ - // An object A is following an object B if A and B are in the same tree and A comes after B in tree order. - for (auto* node = previous_in_pre_order(); node; node = node->previous_in_pre_order()) { - if (node == &other) - return true; - } - - return false; -} - }