SVGTSpanElement.cpp 945 B

1234567891011121314151617181920212223242526272829303132
  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. SVGTSpanElement::SVGTSpanElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  11. : SVGTextPositioningElement(document, move(qualified_name))
  12. {
  13. }
  14. void SVGTSpanElement::initialize(JS::Realm& realm)
  15. {
  16. Base::initialize(realm);
  17. set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGTSpanElementPrototype>(realm, "SVGTSpanElement"));
  18. }
  19. JS::GCPtr<Layout::Node> SVGTSpanElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
  20. {
  21. // Text must be within an SVG <text> element.
  22. if (shadow_including_first_ancestor_of_type<SVGTextElement>())
  23. return heap().allocate_without_realm<Layout::SVGTextBox>(document(), *this, move(style));
  24. return {};
  25. }
  26. }