Truly independent web browser
LibWeb: Reflect the textLength attribute of SVGTextContentElement
Andreas Klinga3cca9199f66
diff --git a/Libraries/LibWeb/SVG/SVGTextContentElement.h b/Libraries/LibWeb/SVG/SVGTextContentElement.hindex 987377d2976..19f0635c69d 100644--- a/Libraries/LibWeb/SVG/SVGTextContentElement.h+++ b/Libraries/LibWeb/SVG/SVGTextContentElement.h@@ -9,6 +9,7 @@#include <LibWeb/Geometry/DOMPoint.h>#include <LibWeb/Geometry/DOMRect.h>#include <LibWeb/Layout/LayoutRustFFI.h>+#include <LibWeb/SVG/AttributeNames.h>#include <LibWeb/SVG/AttributeParsing.h>#include <LibWeb/SVG/SVGGraphicsElement.h>#include <LibWeb/WebIDL/ExceptionOr.h>@@ -27,6 +28,12 @@ public:GC::Ref<SVGAnimatedEnumeration> length_adjust();+ // https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__textLength+ // The initial value of the ‘textLength’ content attribute is defined to equal the user-agent's calculated length+ // for the element.+ // FIXME: Use the calculated length of the element as the initial value, rather than 0.+ REFLECT_ANIMATED_LENGTH_ATTRIBUTE_WITH_GETTER(textLength, text_length, Horizontal, SVGLengthValue::number(0));+WebIDL::ExceptionOr<WebIDL::Long> get_number_of_chars();WebIDL::ExceptionOr<float> get_computed_text_length();WebIDL::ExceptionOr<float> get_sub_string_length(WebIDL::UnsignedLong charnum, WebIDL::UnsignedLong nchars);diff --git a/Libraries/LibWeb/SVG/SVGTextContentElement.idl b/Libraries/LibWeb/SVG/SVGTextContentElement.idlindex 7afa1434dcf..c0e1c5996fd 100644--- a/Libraries/LibWeb/SVG/SVGTextContentElement.idl+++ b/Libraries/LibWeb/SVG/SVGTextContentElement.idl@@ -7,7 +7,7 @@ interface SVGTextContentElement : SVGGraphicsElement {const unsigned short LENGTHADJUST_SPACING = 1;const unsigned short LENGTHADJUST_SPACINGANDGLYPHS = 2;- [FIXME, SameObject] readonly attribute SVGAnimatedLength textLength;+ [SameObject] readonly attribute SVGAnimatedLength textLength;[SameObject] readonly attribute SVGAnimatedEnumeration lengthAdjust;long getNumberOfChars();diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txtindex 0b78220f32f..3a1ba2b7e6f 100644--- a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt@@ -2,8 +2,8 @@ Harness status: OKFound 1780 tests-1582 Pass-198 Fail+1586 Pass+194 FailPass idl_test setupPass idl_test validationPass Partial interface Document: original interface defined@@ -1104,7 +1104,7 @@ Pass SVGTextContentElement interface: constant LENGTHADJUST_SPACING on interfacePass SVGTextContentElement interface: constant LENGTHADJUST_SPACING on interface prototype objectPass SVGTextContentElement interface: constant LENGTHADJUST_SPACINGANDGLYPHS on interface objectPass SVGTextContentElement interface: constant LENGTHADJUST_SPACINGANDGLYPHS on interface prototype object-Fail SVGTextContentElement interface: attribute textLength+Pass SVGTextContentElement interface: attribute textLengthPass SVGTextContentElement interface: attribute lengthAdjustPass SVGTextContentElement interface: operation getNumberOfChars()Pass SVGTextContentElement interface: operation getComputedTextLength()@@ -1142,7 +1142,7 @@ Pass SVGTextPositioningElement interface: objects.text must inherit property "roPass SVGTextContentElement interface: objects.text must inherit property "LENGTHADJUST_UNKNOWN" with the proper typePass SVGTextContentElement interface: objects.text must inherit property "LENGTHADJUST_SPACING" with the proper typePass SVGTextContentElement interface: objects.text must inherit property "LENGTHADJUST_SPACINGANDGLYPHS" with the proper type-Fail SVGTextContentElement interface: objects.text must inherit property "textLength" with the proper type+Pass SVGTextContentElement interface: objects.text must inherit property "textLength" with the proper typePass SVGTextContentElement interface: objects.text must inherit property "lengthAdjust" with the proper typePass SVGTextContentElement interface: objects.text must inherit property "getNumberOfChars()" with the proper typePass SVGTextContentElement interface: objects.text must inherit property "getComputedTextLength()" with the proper type@@ -1188,7 +1188,7 @@ Pass SVGTextPositioningElement interface: objects.tspan must inherit property "rPass SVGTextContentElement interface: objects.tspan must inherit property "LENGTHADJUST_UNKNOWN" with the proper typePass SVGTextContentElement interface: objects.tspan must inherit property "LENGTHADJUST_SPACING" with the proper typePass SVGTextContentElement interface: objects.tspan must inherit property "LENGTHADJUST_SPACINGANDGLYPHS" with the proper type-Fail SVGTextContentElement interface: objects.tspan must inherit property "textLength" with the proper type+Pass SVGTextContentElement interface: objects.tspan must inherit property "textLength" with the proper typePass SVGTextContentElement interface: objects.tspan must inherit property "lengthAdjust" with the proper typePass SVGTextContentElement interface: objects.tspan must inherit property "getNumberOfChars()" with the proper typePass SVGTextContentElement interface: objects.tspan must inherit property "getComputedTextLength()" with the proper type@@ -1255,7 +1255,7 @@ Pass SVGTextPathElement interface: objects.textPath must inherit property "href"Pass SVGTextContentElement interface: objects.textPath must inherit property "LENGTHADJUST_UNKNOWN" with the proper typePass SVGTextContentElement interface: objects.textPath must inherit property "LENGTHADJUST_SPACING" with the proper typePass SVGTextContentElement interface: objects.textPath must inherit property "LENGTHADJUST_SPACINGANDGLYPHS" with the proper type-Fail SVGTextContentElement interface: objects.textPath must inherit property "textLength" with the proper type+Pass SVGTextContentElement interface: objects.textPath must inherit property "textLength" with the proper typePass SVGTextContentElement interface: objects.textPath must inherit property "lengthAdjust" with the proper typePass SVGTextContentElement interface: objects.textPath must inherit property "getNumberOfChars()" with the proper typePass SVGTextContentElement interface: objects.textPath must inherit property "getComputedTextLength()" with the proper typediff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGAnimatedLength-initial-values.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGAnimatedLength-initial-values.txtindex ea272a12363..21c418af098 100644--- a/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGAnimatedLength-initial-values.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGAnimatedLength-initial-values.txt@@ -2,8 +2,7 @@ Harness status: OKFound 130 tests-128 Pass-2 Fail+130 PassPass SVGAnimatedLength, initial values, SVGCircleElement.prototype.cx (remove)Pass SVGAnimatedLength, initial values, SVGCircleElement.prototype.cx (invalid value)Pass SVGAnimatedLength, initial values, SVGCircleElement.prototype.cy (remove)@@ -122,8 +121,8 @@ Pass SVGAnimatedLength, initial values, SVGSVGElement.prototype.width (remove)Pass SVGAnimatedLength, initial values, SVGSVGElement.prototype.width (invalid value)Pass SVGAnimatedLength, initial values, SVGSVGElement.prototype.height (remove)Pass SVGAnimatedLength, initial values, SVGSVGElement.prototype.height (invalid value)-Fail SVGAnimatedLength, initial values, SVGTextContentElement.prototype.textLength (remove)-Fail SVGAnimatedLength, initial values, SVGTextContentElement.prototype.textLength (invalid value)+Pass SVGAnimatedLength, initial values, SVGTextContentElement.prototype.textLength (remove)+Pass SVGAnimatedLength, initial values, SVGTextContentElement.prototype.textLength (invalid value)Pass SVGAnimatedLength, initial values, SVGTextPathElement.prototype.startOffset (remove)Pass SVGAnimatedLength, initial values, SVGTextPathElement.prototype.startOffset (invalid value)Pass SVGAnimatedLength, initial values, SVGUseElement.prototype.x (remove)