ShadowRoot.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/DOM/DocumentFragment.h>
  8. namespace Web::DOM {
  9. class ShadowRoot final : public DocumentFragment {
  10. public:
  11. ShadowRoot(Document&, Element&);
  12. bool closed() const { return m_closed; }
  13. bool delegates_focus() const { return m_delegates_focus; }
  14. void set_delegates_focus(bool delegates_focus) { m_delegates_focus = delegates_focus; }
  15. bool available_to_element_internals() const { return m_available_to_element_internals; }
  16. void set_available_to_element_internals(bool available_to_element_internals) { m_available_to_element_internals = available_to_element_internals; }
  17. // ^EventTarget
  18. virtual EventTarget* get_parent(const Event&) override;
  19. // NOTE: This is intended for the JS bindings.
  20. String mode() const { return m_closed ? "closed" : "open"; }
  21. private:
  22. // ^Node
  23. virtual FlyString node_name() const override { return "#shadow-root"; }
  24. virtual RefPtr<Layout::Node> create_layout_node() override;
  25. // NOTE: The specification doesn't seem to specify a default value for closed. Assuming false for now.
  26. bool m_closed { false };
  27. bool m_delegates_focus { false };
  28. bool m_available_to_element_internals { false };
  29. };
  30. }