SVGTextPathElement.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2023, MacDue <macdue@dueutil.tech>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibURL/URL.h>
  7. #include <LibWeb/Bindings/SVGTextPathElementPrototype.h>
  8. #include <LibWeb/Layout/SVGTextPathBox.h>
  9. #include <LibWeb/SVG/AttributeNames.h>
  10. #include <LibWeb/SVG/SVGTextPathElement.h>
  11. namespace Web::SVG {
  12. GC_DEFINE_ALLOCATOR(SVGTextPathElement);
  13. SVGTextPathElement::SVGTextPathElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  14. : SVGTextContentElement(document, move(qualified_name))
  15. {
  16. }
  17. GC::Ptr<SVGGeometryElement const> SVGTextPathElement::path_or_shape() const
  18. {
  19. auto href = get_attribute(AttributeNames::href);
  20. if (!href.has_value())
  21. return {};
  22. auto url = document().url().complete_url(*href);
  23. return try_resolve_url_to<SVGGeometryElement const>(url);
  24. }
  25. void SVGTextPathElement::initialize(JS::Realm& realm)
  26. {
  27. Base::initialize(realm);
  28. WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTextPathElement);
  29. }
  30. void SVGTextPathElement::visit_edges(Cell::Visitor& visitor)
  31. {
  32. Base::visit_edges(visitor);
  33. SVGURIReferenceMixin::visit_edges(visitor);
  34. }
  35. GC::Ptr<Layout::Node> SVGTextPathElement::create_layout_node(CSS::StyleProperties style)
  36. {
  37. return heap().allocate<Layout::SVGTextPathBox>(document(), *this, move(style));
  38. }
  39. };