ElementInternals.h 995 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2024, the Ladybird developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/WeakPtr.h>
  8. #include <LibGC/Ptr.h>
  9. #include <LibWeb/Bindings/PlatformObject.h>
  10. #include <LibWeb/Forward.h>
  11. namespace Web::HTML {
  12. // https://html.spec.whatwg.org/multipage/custom-elements.html#elementinternals
  13. class ElementInternals final : public Bindings::PlatformObject {
  14. WEB_PLATFORM_OBJECT(ElementInternals, Bindings::PlatformObject);
  15. GC_DECLARE_ALLOCATOR(ElementInternals);
  16. public:
  17. static GC::Ref<ElementInternals> create(JS::Realm&, HTMLElement& target_element);
  18. GC::Ptr<DOM::ShadowRoot> shadow_root() const;
  19. private:
  20. explicit ElementInternals(JS::Realm&, HTMLElement& target_element);
  21. virtual void initialize(JS::Realm&) override;
  22. virtual void visit_edges(JS::Cell::Visitor& visitor) override;
  23. // https://html.spec.whatwg.org/multipage/custom-elements.html#internals-target
  24. GC::Ref<HTMLElement> m_target_element;
  25. };
  26. }