Serenity Operating System
1/*
2 * Copyright (c) 2020, the SerenityOS developers.
3 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8#pragma once
9
10#include <LibJS/Heap/GCPtr.h>
11#include <LibWeb/Bindings/PlatformObject.h>
12#include <LibWeb/DOM/Document.h>
13
14namespace Web::DOM {
15
16class DOMImplementation final : public Bindings::PlatformObject {
17 WEB_PLATFORM_OBJECT(DOMImplementation, Bindings::PlatformObject);
18
19public:
20 static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMImplementation>> create(Document&);
21 virtual ~DOMImplementation();
22
23 WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_document(DeprecatedString const&, DeprecatedString const&, JS::GCPtr<DocumentType>) const;
24 JS::NonnullGCPtr<Document> create_html_document(DeprecatedString const& title) const;
25 WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> create_document_type(DeprecatedString const& qualified_name, DeprecatedString const& public_id, DeprecatedString const& system_id);
26
27 // https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
28 bool has_feature() const { return true; }
29
30private:
31 explicit DOMImplementation(Document&);
32
33 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
34 virtual void visit_edges(Cell::Visitor&) override;
35
36 Document& document() { return m_document; }
37 Document const& document() const { return m_document; }
38
39 Document& m_document;
40};
41
42}