SVGElement.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/DOM/Document.h>
  8. #include <LibWeb/DOM/Element.h>
  9. namespace Web::SVG {
  10. class SVGElement : public DOM::Element {
  11. WEB_PLATFORM_OBJECT(SVGElement, DOM::Element);
  12. public:
  13. virtual bool requires_svg_container() const override { return true; }
  14. virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
  15. virtual void children_changed() override;
  16. virtual void inserted() override;
  17. virtual void removed_from(Node*) override;
  18. HTML::DOMStringMap* dataset() { return m_dataset.ptr(); }
  19. HTML::DOMStringMap const* dataset() const { return m_dataset.ptr(); }
  20. void focus();
  21. void blur();
  22. protected:
  23. SVGElement(DOM::Document&, DOM::QualifiedName);
  24. virtual void initialize(JS::Realm&) override;
  25. virtual void visit_edges(Cell::Visitor&) override;
  26. void update_use_elements_that_reference_this();
  27. void remove_from_use_element_that_reference_this();
  28. JS::GCPtr<HTML::DOMStringMap> m_dataset;
  29. private:
  30. virtual bool is_svg_element() const final { return true; }
  31. };
  32. }
  33. namespace Web::DOM {
  34. template<>
  35. inline bool Node::fast_is<SVG::SVGElement>() const { return is_svg_element(); }
  36. }