Bug 729996 - trailing spaces in text not properly ignored. r=dholbert
authorRobert Longson <longsonr@gmail.com>
Fri, 24 Feb 2012 10:20:53 +0000
changeset 87618 c65342fe670463db7ddf9ecf57e4fa2301952a34
parent 87617 83b7b3240e1933d0fcb86688de4712f086222300
child 87622 154d6f29dfb9a454cd1148931c4979433bf1f6a8
push id6430
push userlongsonr@gmail.com
push dateFri, 24 Feb 2012 10:20:59 +0000
treeherdermozilla-inbound@c65342fe6704 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs729996
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 729996 - trailing spaces in text not properly ignored. r=dholbert
layout/reftests/svg/reftest.list
layout/reftests/svg/text-layout-07-ref.svg
layout/reftests/svg/text-layout-07.svg
layout/svg/base/src/nsSVGTextFrame.cpp
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -246,16 +246,17 @@ random-if(winWidget) == text-gradient-02
 fails-if(Android) != text-language-00.xhtml text-language-00-ref.xhtml
 fails-if(Android) random-if(gtk2Widget) != text-language-01.xhtml text-language-01-ref.xhtml # Fails on Linux tryserver due to lack of CJK fonts.
 == text-layout-01.svg text-layout-01-ref.svg
 == text-layout-02.svg text-layout-02-ref.svg
 == text-layout-03.svg text-layout-03-ref.svg
 == text-layout-04.svg text-layout-04-ref.svg
 == text-layout-05.svg text-layout-05-ref.svg
 == text-layout-06.svg text-layout-06-ref.svg
+== text-layout-07.svg text-layout-07-ref.svg
 == text-scale-01.svg text-scale-01-ref.svg
 == text-stroke-scaling-01.svg text-stroke-scaling-01-ref.svg
 == stroke-dasharray-and-pathLength-01.svg pass.svg
 == stroke-dasharray-and-text-01.svg stroke-dasharray-and-text-01-ref.svg 
 == stroke-linecap-square-w-zero-length-segs-01.svg pass.svg
 == stroke-linecap-square-w-zero-length-segs-02.svg pass.svg
 == textPath-01.svg textPath-01-ref.svg
 == textPath-02.svg pass.svg
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/text-layout-07-ref.svg
@@ -0,0 +1,8 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <text transform="translate(0, 31)" font-size="120" text-anchor="middle">
+    <tspan y="122.3" x="273">ABC</tspan></text>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/text-layout-07.svg
@@ -0,0 +1,9 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <text transform="translate(0, 31)" font-size="120" text-anchor="middle">
+    <tspan y="122.3" x="273">ABC</tspan>
+  </text>
+</svg>
--- a/layout/svg/base/src/nsSVGTextFrame.cpp
+++ b/layout/svg/base/src/nsSVGTextFrame.cpp
@@ -320,17 +320,23 @@ nsSVGTextFrame::SetWhitespaceHandling(ns
   // Making sure that we reset earlier frames as they may once
   // have been the last non-whitespace frame.
   aFrame = firstFrame;
   while (aFrame != lastNonWhitespaceFrame) {
     aFrame->SetTrimTrailingWhitespace(false);
     aFrame = aFrame->GetNextGlyphFrame();
   }
 
-  lastNonWhitespaceFrame->SetTrimTrailingWhitespace(true);
+  // We're at the last non-whitespace frame so trim off the end
+  // and make sure we set one of the trim bits so that any
+  // further whitespace is compressed to nothing
+  while (aFrame) {
+    aFrame->SetTrimTrailingWhitespace(true);
+    aFrame = aFrame->GetNextGlyphFrame();
+  }
 }
 
 void
 nsSVGTextFrame::UpdateGlyphPositioning(bool aForceGlobalTransform)
 {
   if ((GetStateBits() & NS_STATE_SVG_REDRAW_SUSPENDED) || !mPositioningDirty)
     return;