|
| 1 | +/* |
| 2 | + * Copyright (c) 2025, Johannes Gustafsson <johannesgu@outlook.com> |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: BSD-2-Clause |
| 5 | + */ |
| 6 | + |
| 7 | +#include <LibJS/Runtime/Realm.h> |
| 8 | +#include <LibWeb/Bindings/Intrinsics.h> |
| 9 | +#include <LibWeb/Bindings/PlatformObject.h> |
| 10 | +#include <LibWeb/Bindings/XPathEvaluatorPrototype.h> |
| 11 | +#include <LibWeb/WebIDL/ExceptionOr.h> |
| 12 | + |
| 13 | +#include "XPathEvaluator.h" |
| 14 | +#include "XPathExpression.h" |
| 15 | +#include "XPathResult.h" |
| 16 | + |
| 17 | +namespace Web::XPath { |
| 18 | + |
| 19 | +GC_DEFINE_ALLOCATOR(XPathEvaluator); |
| 20 | + |
| 21 | +XPathEvaluator::XPathEvaluator(JS::Realm& realm) |
| 22 | + : Web::Bindings::PlatformObject(realm) |
| 23 | +{ |
| 24 | +} |
| 25 | + |
| 26 | +XPathEvaluator::~XPathEvaluator() = default; |
| 27 | + |
| 28 | +WebIDL::ExceptionOr<GC::Ref<XPathEvaluator>> XPathEvaluator::construct_impl(JS::Realm& realm) |
| 29 | +{ |
| 30 | + return realm.create<XPathEvaluator>(realm); |
| 31 | +} |
| 32 | + |
| 33 | +void XPathEvaluator::initialize(JS::Realm& realm) |
| 34 | +{ |
| 35 | + WEB_SET_PROTOTYPE_FOR_INTERFACE(XPathEvaluator); |
| 36 | + Base::initialize(realm); |
| 37 | +} |
| 38 | + |
| 39 | +WebIDL::ExceptionOr<GC::Ref<XPathExpression>> XPathEvaluator::create_expression(String const& expression, GC::Ptr<XPathNSResolver> resolver) |
| 40 | +{ |
| 41 | + auto& realm = this->realm(); |
| 42 | + return realm.create<XPathExpression>(realm, expression, resolver); |
| 43 | +} |
| 44 | + |
| 45 | +WebIDL::ExceptionOr<GC::Ref<XPathResult>> XPathEvaluator::evaluate(String const&, DOM::Node const&, GC::Ptr<XPathNSResolver>, WebIDL::UnsignedShort, GC::Ptr<XPathResult>) |
| 46 | +{ |
| 47 | + auto& realm = this->realm(); |
| 48 | + return realm.create<XPathResult>(realm); |
| 49 | +} |
| 50 | + |
| 51 | +GC::Ref<DOM::Node> XPathEvaluator::create_ns_resolver(GC::Ref<DOM::Node> node_resolver) |
| 52 | +{ |
| 53 | + return node_resolver; |
| 54 | +} |
| 55 | + |
| 56 | +} |
0 commit comments