ladybird/Userland/Libraries/LibWeb/HTML/DOMParser.h
Andreas Kling 6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00

41 lines
1,008 B
C++

/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefCounted.h>
#include <AK/Weakable.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparser
class DOMParser final
: public RefCounted<DOMParser>
, public Weakable<DOMParser>
, public Bindings::Wrappable {
public:
using WrapperType = Bindings::DOMParserWrapper;
static DOM::ExceptionOr<NonnullRefPtr<DOMParser>> create_with_global_object(HTML::Window& window)
{
return adopt_ref(*new DOMParser(window));
}
virtual ~DOMParser() override;
JS::NonnullGCPtr<DOM::Document> parse_from_string(String const&, Bindings::DOMParserSupportedType type);
private:
explicit DOMParser(HTML::Window&);
JS::Handle<HTML::Window> m_window;
};
}