HTMLStyleElement.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <LibWeb/HTML/HTMLStyleElement.h>
  8. namespace Web::HTML {
  9. JS_DEFINE_ALLOCATOR(HTMLStyleElement);
  10. HTMLStyleElement::HTMLStyleElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  11. : HTMLElement(document, move(qualified_name))
  12. {
  13. }
  14. HTMLStyleElement::~HTMLStyleElement() = default;
  15. void HTMLStyleElement::initialize(JS::Realm& realm)
  16. {
  17. Base::initialize(realm);
  18. WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLStyleElement);
  19. }
  20. void HTMLStyleElement::visit_edges(Cell::Visitor& visitor)
  21. {
  22. Base::visit_edges(visitor);
  23. visitor.visit(m_style_element_utils.sheet());
  24. }
  25. void HTMLStyleElement::children_changed()
  26. {
  27. m_style_element_utils.update_a_style_block(*this);
  28. Base::children_changed();
  29. }
  30. void HTMLStyleElement::inserted()
  31. {
  32. m_style_element_utils.update_a_style_block(*this);
  33. Base::inserted();
  34. }
  35. void HTMLStyleElement::removed_from(Node* old_parent)
  36. {
  37. m_style_element_utils.update_a_style_block(*this);
  38. Base::removed_from(old_parent);
  39. }
  40. // https://www.w3.org/TR/cssom/#dom-linkstyle-sheet
  41. CSS::CSSStyleSheet* HTMLStyleElement::sheet()
  42. {
  43. // The sheet attribute must return the associated CSS style sheet for the node or null if there is no associated CSS style sheet.
  44. return m_style_element_utils.sheet();
  45. }
  46. // https://www.w3.org/TR/cssom/#dom-linkstyle-sheet
  47. CSS::CSSStyleSheet const* HTMLStyleElement::sheet() const
  48. {
  49. // The sheet attribute must return the associated CSS style sheet for the node or null if there is no associated CSS style sheet.
  50. return m_style_element_utils.sheet();
  51. }
  52. }