DOMImplementation.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #pragma once
  8. #include <LibJS/Heap/GCPtr.h>
  9. #include <LibWeb/Bindings/PlatformObject.h>
  10. #include <LibWeb/DOM/Document.h>
  11. namespace Web::DOM {
  12. class DOMImplementation final : public Bindings::PlatformObject {
  13. WEB_PLATFORM_OBJECT(DOMImplementation, Bindings::PlatformObject);
  14. public:
  15. static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMImplementation>> create(Document&);
  16. virtual ~DOMImplementation();
  17. WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_document(DeprecatedString const&, DeprecatedString const&, JS::GCPtr<DocumentType>) const;
  18. JS::NonnullGCPtr<Document> create_html_document(DeprecatedString const& title) const;
  19. WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> create_document_type(DeprecatedString const& qualified_name, DeprecatedString const& public_id, DeprecatedString const& system_id);
  20. // https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
  21. bool has_feature() const { return true; }
  22. private:
  23. explicit DOMImplementation(Document&);
  24. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  25. virtual void visit_edges(Cell::Visitor&) override;
  26. Document& document() { return m_document; }
  27. Document const& document() const { return m_document; }
  28. JS::NonnullGCPtr<Document> m_document;
  29. };
  30. }