SVGTextPathElement.cpp 1.2 KB

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