SVG Text NG: Fix rendering with inconsistent textLength values

    <text textLength="150" x="10" y="100">
    <tspan textLength="300">Scalable Vector</tspan>
    </text>

We placed the first 'S' at a wrong position.

The new behavior is compatible with the legacy layout.

Bug: 1399351
Change-Id: I0c8556f79898d89d94eb88c0f2b65dfb93f5a98d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4087969
Auto-Submit: Kent Tamura <tkent@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1080824}
diff --git a/svg/text/scripted/textlength-inconsistent.svg b/svg/text/scripted/textlength-inconsistent.svg
new file mode 100644
index 0000000..ca899de
--- /dev/null
+++ b/svg/text/scripted/textlength-inconsistent.svg
@@ -0,0 +1,19 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:html="http://www.w3.org/1999/xhtml">
+  <title>Inconsistent two 'textLength' attributes</title>
+  <html:script src="/resources/testharness.js"/>
+  <html:script src="/resources/testharnessreport.js"/>
+  <html:link rel="help" href="https://crbug.com/1399351"/>
+  <g>
+    <text textLength="150" x="10" y="100">
+    <tspan textLength="300">Scalable Vector</tspan>
+    </text>
+  </g>
+  <html:script>
+test(() => {
+  const tspan = document.querySelector('tspan');
+  assert_less_than(tspan.getStartPositionOfChar(0).x,
+                   tspan.getStartPositionOfChar(1).x);
+}, 'The first characters should be on the left of the second character.');
+  </html:script>
+</svg>