From 329262d54f789509d5465e79816d4be364dfedb0 Mon Sep 17 00:00:00 2001 From: MacDue Date: Mon, 1 Apr 2024 00:45:54 +0100 Subject: [PATCH] LibWeb: Stub `SVGTextContentElement.getStartPositionOfChar()` --- .../Libraries/LibWeb/SVG/SVGTextContentElement.cpp | 10 ++++++++-- Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h | 6 +++++- .../Libraries/LibWeb/SVG/SVGTextContentElement.idl | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp index 24d4e01688d..c2e746edf2b 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp @@ -51,10 +51,16 @@ ByteString SVGTextContentElement::text_contents() const } // https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getNumberOfChars -WebIDL::ExceptionOr SVGTextContentElement::get_number_of_chars() const +WebIDL::ExceptionOr SVGTextContentElement::get_number_of_chars() const { auto chars = TRY_OR_THROW_OOM(vm(), utf8_to_utf16(text_contents())); - return static_cast(chars.size()); + return static_cast(chars.size()); +} + +JS::NonnullGCPtr SVGTextContentElement::get_start_position_of_char(WebIDL::UnsignedLong charnum) +{ + dbgln("(STUBBED) SVGTextContentElement::get_start_position_of_char(charnum={}). Called on: {}", charnum, debug_description()); + return Geometry::DOMPoint::from_point(vm(), Geometry::DOMPointInit {}); } } diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h index 10ea63a8cb3..2f1eb6ab0f4 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h @@ -6,9 +6,11 @@ #pragma once +#include #include #include #include +#include namespace Web::SVG { @@ -17,12 +19,14 @@ class SVGTextContentElement : public SVGGraphicsElement { WEB_PLATFORM_OBJECT(SVGTextContentElement, SVGGraphicsElement); public: - WebIDL::ExceptionOr get_number_of_chars() const; + WebIDL::ExceptionOr get_number_of_chars() const; Optional text_anchor() const; ByteString text_contents() const; + JS::NonnullGCPtr get_start_position_of_char(WebIDL::UnsignedLong charnum); + protected: SVGTextContentElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.idl b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.idl index fd00990866b..4a8155efb97 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.idl +++ b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.idl @@ -15,7 +15,7 @@ interface SVGTextContentElement : SVGGraphicsElement { long getNumberOfChars(); // FIXME: float getComputedTextLength(); // FIXME: float getSubStringLength(unsigned long charnum, unsigned long nchars); - // FIXME: DOMPoint getStartPositionOfChar(unsigned long charnum); + DOMPoint getStartPositionOfChar(unsigned long charnum); // FIXME: DOMPoint getEndPositionOfChar(unsigned long charnum); // FIXME: DOMRect getExtentOfChar(unsigned long charnum); // FIXME: float getRotationOfChar(unsigned long charnum);