SVGStyleElement.cpp 1.6 KB

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