SVGTSpanElement.cpp 924 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2023, MacDue <macdue@dueutil.tech>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Layout/SVGTextBox.h>
  7. #include <LibWeb/SVG/SVGTSpanElement.h>
  8. #include <LibWeb/SVG/SVGTextElement.h>
  9. namespace Web::SVG {
  10. JS_DEFINE_ALLOCATOR(SVGTSpanElement);
  11. SVGTSpanElement::SVGTSpanElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  12. : SVGTextPositioningElement(document, move(qualified_name))
  13. {
  14. }
  15. void SVGTSpanElement::initialize(JS::Realm& realm)
  16. {
  17. Base::initialize(realm);
  18. WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTSpanElement);
  19. }
  20. JS::GCPtr<Layout::Node> SVGTSpanElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
  21. {
  22. // Text must be within an SVG <text> element.
  23. if (shadow_including_first_ancestor_of_type<SVGTextElement>())
  24. return heap().allocate_without_realm<Layout::SVGTextBox>(document(), *this, move(style));
  25. return {};
  26. }
  27. }