2011-03-27 Rob Buis <rwlbuis@gmail.com>
authorrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Mar 2011 11:16:44 +0000 (11:16 +0000)
committerrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Mar 2011 11:16:44 +0000 (11:16 +0000)
        Reviewed by Nikolas Zimmermann.

        Text on path positioning at zero startOffset
        https://bugs.webkit.org/show_bug.cgi?id=56245

        Since for length 0 no previous point is set, choose epsilon
        length to get normal at starting point of the path.

        Test: svg/text/text-path-middle-align.svg

        * platform/graphics/Path.cpp:
        (WebCore::Path::normalAngleAtLength):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82061 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.txt [new file with mode: 0644]
LayoutTests/svg/text/text-path-middle-align.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Path.cpp

index 97eb538..c2db2e7 100644 (file)
@@ -1,3 +1,15 @@
+2011-03-27  Rob Buis  <rwlbuis@gmail.com>
+
+        Reviewed by Nikolas Zimmermann.
+
+        Text on path positioning at zero startOffset
+        https://bugs.webkit.org/show_bug.cgi?id=56245
+
+        * platform/mac/svg/text/text-path-middle-align-expected.checksum: Added.
+        * platform/mac/svg/text/text-path-middle-align-expected.png: Added.
+        * platform/mac/svg/text/text-path-middle-align-expected.txt: Added.
+        * svg/text/text-path-middle-align.svg: Added.
+
 2011-03-26  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.checksum b/LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.checksum
new file mode 100644 (file)
index 0000000..da67102
--- /dev/null
@@ -0,0 +1 @@
+fb362be38fb6ad990ebfdb886a1d4589
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.png b/LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.png
new file mode 100644 (file)
index 0000000..999e232
Binary files /dev/null and b/LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.txt b/LayoutTests/platform/mac/svg/text/text-path-middle-align-expected.txt
new file mode 100644 (file)
index 0000000..bb8359b
--- /dev/null
@@ -0,0 +1,10 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (149,127) size 202x224
+    RenderSVGPath {path} at (149,149) size 202x202 [stroke={[type=SOLID] [color=#000000]}] [data="M 250 150 C 305.228 150 350 194.772 350 250 C 350 305.228 305.228 350 250 350 C 194.772 350 150 305.228 150 250 C 150 194.772 194.772 150 250 150"]
+    RenderSVGText {text} at (239,127) size 22x30 contains 1 chunk(s)
+      RenderSVGTextPath {textPath} at (0,0) size 22x30
+        RenderSVGInlineText {#text} at (0,0) size 22x30
+          chunk 1 (middle anchor) text run 1 at (250.00,150.00) startOffset 0 endOffset 1 width 21.00: "M"
+      RenderSVGInlineText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/svg/text/text-path-middle-align.svg b/LayoutTests/svg/text/text-path-middle-align.svg
new file mode 100644 (file)
index 0000000..6c2cbea
--- /dev/null
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+  <path id="circle" d="M250 150C305.228 150 350 194.772 350 250C350 305.228 305.228 350 250 350C194.772 350 150 305.228 150 250C150 194.772 194.772 150 250 150" fill="none" stroke="black"/>
+  <text>
+    <textPath xlink:href="#circle" startOffset="0%" font-size="18pt" fill="red" text-anchor="middle">M</textPath>
+  </text>
+</svg>
index 8d3d14a..548a92c 100644 (file)
@@ -1,3 +1,18 @@
+2011-03-27  Rob Buis  <rwlbuis@gmail.com>
+
+        Reviewed by Nikolas Zimmermann.
+
+        Text on path positioning at zero startOffset
+        https://bugs.webkit.org/show_bug.cgi?id=56245
+
+        Since for length 0 no previous point is set, choose epsilon
+        length to get normal at starting point of the path.
+
+        Test: svg/text/text-path-middle-align.svg
+
+        * platform/graphics/Path.cpp:
+        (WebCore::Path::normalAngleAtLength):
+
 2011-03-27  Ben Taylor  <bentaylor.solx86@gmail.com>
 
         Reviewed by Oliver Hunt.
index d501716..f7aedbe 100644 (file)
@@ -102,7 +102,7 @@ FloatPoint Path::pointAtLength(float length, bool& ok) const
 float Path::normalAngleAtLength(float length, bool& ok) const
 {
     PathTraversalState traversalState(PathTraversalState::TraversalNormalAngleAtLength);
-    traversalState.m_desiredLength = length;
+    traversalState.m_desiredLength = length ? length : std::numeric_limits<float>::epsilon();
     apply(&traversalState, pathLengthApplierFunction);
     ok = traversalState.m_success;
     return traversalState.m_normalAngle;