DocumentFragment.h 1005 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/FlyString.h>
  8. #include <LibWeb/DOM/Element.h>
  9. #include <LibWeb/DOM/NonElementParentNode.h>
  10. #include <LibWeb/DOM/ParentNode.h>
  11. namespace Web::DOM {
  12. class DocumentFragment
  13. : public ParentNode
  14. , public NonElementParentNode<DocumentFragment> {
  15. public:
  16. using WrapperType = Bindings::DocumentFragmentWrapper;
  17. static NonnullRefPtr<DocumentFragment> create_with_global_object(Bindings::WindowObject& window);
  18. explicit DocumentFragment(Document& document);
  19. virtual ~DocumentFragment() override = default;
  20. virtual FlyString node_name() const override { return "#document-fragment"; }
  21. Element* host() { return m_host; }
  22. Element const* host() const { return m_host; }
  23. void set_host(Element* host) { m_host = host; }
  24. private:
  25. // https://dom.spec.whatwg.org/#concept-documentfragment-host
  26. WeakPtr<Element> m_host;
  27. };
  28. }