SVGUseElement.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2023, Preston Taylor <95388976+PrestonLTaylor@users.noreply.github.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGfx/Path.h>
  8. #include <LibWeb/DOM/DocumentObserver.h>
  9. #include <LibWeb/SVG/SVGAnimatedLength.h>
  10. #include <LibWeb/SVG/SVGGraphicsElement.h>
  11. namespace Web::SVG {
  12. class SVGUseElement final : public SVGGraphicsElement {
  13. WEB_PLATFORM_OBJECT(SVGUseElement, SVGGraphicsElement);
  14. public:
  15. virtual ~SVGUseElement() override = default;
  16. virtual void attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  17. virtual void inserted() override;
  18. void svg_element_changed(SVGElement&);
  19. void svg_element_removed(SVGElement&);
  20. JS::NonnullGCPtr<SVGAnimatedLength> x() const;
  21. JS::NonnullGCPtr<SVGAnimatedLength> y() const;
  22. JS::NonnullGCPtr<SVGAnimatedLength> width() const;
  23. JS::NonnullGCPtr<SVGAnimatedLength> height() const;
  24. JS::GCPtr<SVGElement> instance_root() const;
  25. JS::GCPtr<SVGElement> animated_instance_root() const;
  26. private:
  27. SVGUseElement(DOM::Document&, DOM::QualifiedName);
  28. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  29. virtual void visit_edges(Cell::Visitor&) override;
  30. virtual bool is_svg_use_element() const override { return true; }
  31. Optional<StringView> parse_id_from_href(DeprecatedString const& href);
  32. JS::GCPtr<DOM::Element> referenced_element();
  33. void clone_element_tree_as_our_shadow_tree(Element* to_clone) const;
  34. bool is_valid_reference_element(Element* reference_element) const;
  35. Optional<float> m_x;
  36. Optional<float> m_y;
  37. Optional<StringView> m_referenced_id;
  38. JS::GCPtr<DOM::DocumentObserver> m_document_observer;
  39. };
  40. }
  41. namespace Web::DOM {
  42. template<>
  43. inline bool Node::fast_is<SVG::SVGUseElement>() const { return is_svg_use_element(); }
  44. }