Skip to content

Truly independent web browser

1.1 KB
Raw Blame
/*
 * Copyright (c) 2025, Johannes Gustafsson <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/Forward.h>
#include <LibWebCommon/WebIDL/Types.h>

#include "XPathExpression.h"
#include "XPathNSResolver.h"
#include "XPathResult.h"

namespace Web::XPath {

class XPathEvaluator : public Bindings::GCAllocatedWrappable {
    WEB_WRAPPABLE(XPathEvaluator, Bindings::GCAllocatedWrappable);
    GC_DECLARE_ALLOCATOR(XPathEvaluator);

    explicit XPathEvaluator();
    virtual ~XPathEvaluator() override;

public:
    [[nodiscard]] static GC::Ref<XPathEvaluator> create();

    WebIDL::ExceptionOr<GC::Ref<XPathExpression>> create_expression(Utf16String const& expression, GC::Ptr<XPathNSResolver> resolver = nullptr);
    WebIDL::ExceptionOr<GC::Ref<XPathResult>> evaluate(Utf16String const& expression, DOM::Node const& context_node, GC::Ptr<XPathNSResolver> resolver = nullptr, WebIDL::UnsignedShort type = 0, GC::Ptr<XPathResult> result = nullptr);
    static GC::Ref<DOM::Node> create_ns_resolver(GC::Ref<DOM::Node> node_resolver); // legacy
};

}