SVGTextContentElement.cpp 617 B

123456789101112131415161718192021222324
  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. }
  14. // https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getNumberOfChars
  15. int SVGTextContentElement::get_number_of_chars() const
  16. {
  17. return AK::utf8_to_utf16(child_text_content()).size();
  18. }
  19. }