mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
|
|
/*
|
||
|
|
* Copyright (c) 2025, Johannes Gustafsson <johannesgu@outlook.com>
|
||
|
|
*
|
||
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include <LibJS/Runtime/Realm.h>
|
||
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||
|
|
#include <LibWeb/Bindings/XPathExpressionPrototype.h>
|
||
|
|
#include <LibWeb/DOM/Node.h>
|
||
|
|
#include <LibWeb/Forward.h>
|
||
|
|
|
||
|
|
#include "XPathEvaluator.h"
|
||
|
|
#include "XPathExpression.h"
|
||
|
|
#include "XPathResult.h"
|
||
|
|
|
||
|
|
namespace Web::XPath {
|
||
|
|
|
||
|
|
GC_DEFINE_ALLOCATOR(XPathExpression);
|
||
|
|
|
||
|
|
XPathExpression::XPathExpression(JS::Realm& realm, String const& expression, GC::Ptr<XPathNSResolver> resolver)
|
||
|
|
: Web::Bindings::PlatformObject(realm)
|
||
|
|
, m_expression(expression)
|
||
|
|
, m_resolver(resolver)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
void XPathExpression::initialize(JS::Realm& realm)
|
||
|
|
{
|
||
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(XPathExpression);
|
||
|
|
Base::initialize(realm);
|
||
|
|
}
|
||
|
|
|
||
|
|
void XPathExpression::visit_edges(Cell::Visitor& visitor)
|
||
|
|
{
|
||
|
|
Base::visit_edges(visitor);
|
||
|
|
visitor.visit(m_resolver);
|
||
|
|
}
|
||
|
|
|
||
|
|
XPathExpression::~XPathExpression() = default;
|
||
|
|
|
||
|
|
WebIDL::ExceptionOr<GC::Ref<XPathResult>> XPathExpression::evaluate(DOM::Node const&, WebIDL::UnsignedShort, GC::Ptr<XPathResult>)
|
||
|
|
{
|
||
|
|
auto& realm = this->realm();
|
||
|
|
return realm.create<XPathResult>(realm);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|