SVGTextContentElement.cpp 703 B

12345678910111213141516171819202122232425
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/Utf16View.h>
  7. #include <LibWeb/DOM/Document.h>
  8. #include <LibWeb/SVG/SVGTextContentElement.h>
  9. namespace Web::SVG {
  10. SVGTextContentElement::SVGTextContentElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  11. : SVGGraphicsElement(document, move(qualified_name))
  12. {
  13. set_prototype(&Bindings::cached_web_prototype(realm(), "SVGTextContentElement"));
  14. }
  15. // https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getNumberOfChars
  16. int SVGTextContentElement::get_number_of_chars() const
  17. {
  18. return AK::utf8_to_utf16(child_text_content()).size();
  19. }
  20. }