LibWeb: Implement XPath functionality using libxml2

This commit is contained in:
Johannes Gustafsson 2025-09-29 22:09:51 +02:00 committed by Jelle Raaijmakers
parent f04b866cb0
commit 0ea519c539
Notes: github-actions[bot] 2025-10-03 11:17:39 +00:00
8 changed files with 277 additions and 6 deletions

View file

@ -36,6 +36,34 @@ void XPathResult::visit_edges(Cell::Visitor& visitor)
XPathResult::~XPathResult() = default;
void XPathResult::set_number(WebIDL::Double number_value)
{
m_result_type = NUMBER_TYPE;
m_number_value = number_value;
}
void XPathResult::set_string(String string_value)
{
m_result_type = STRING_TYPE;
m_string_value = move(string_value);
}
void XPathResult::set_boolean(bool boolean_value)
{
m_result_type = BOOLEAN_TYPE;
m_boolean_value = boolean_value;
}
void XPathResult::set_node_set(Vector<GC::Ptr<DOM::Node>> node_set, unsigned short type)
{
if (type >= XPathResult::UNORDERED_NODE_ITERATOR_TYPE && type <= XPathResult::FIRST_ORDERED_NODE_TYPE)
m_result_type = type;
else
m_result_type = UNORDERED_NODE_ITERATOR_TYPE; // Default if the caller does not explicity ask for anything else
m_node_set = move(node_set);
m_node_set_iter = m_node_set.begin();
}
GC::Ptr<DOM::Node> XPathResult::iterate_next()
{
if (m_node_set_iter == m_node_set.end())