Bug 897342 - Don't try to adjust text for textLength="" when there is no opportunity to do so. r=jwatt
authorCameron McCormack <cam@mcc.id.au>
Wed, 24 Jul 2013 21:47:07 +1000
changeset 152104 8a3e8b6c04ebba6b6b70c16dd67dacf1b984e265
parent 152103 d06db659283dc4cce0b9cf588329321ed37f06de
child 152105 20b11f54203cb96254a08321ac9c97bde1443ee2
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs897342
milestone25.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 897342 - Don't try to adjust text for textLength="" when there is no opportunity to do so. r=jwatt
layout/svg/crashtests/897342-1.svg
layout/svg/crashtests/crashtests.list
layout/svg/nsSVGTextFrame2.cpp
new file mode 100644
--- /dev/null
+++ b/layout/svg/crashtests/897342-1.svg
@@ -0,0 +1,1 @@
+<svg xmlns="http://www.w3.org/2000/svg"><text textLength="50" lengthAdjust="spacingAndGlyphs">&#x200D;</text></svg>
--- a/layout/svg/crashtests/crashtests.list
+++ b/layout/svg/crashtests/crashtests.list
@@ -168,8 +168,9 @@ load 876831-1.svg
 load 877029-1.svg
 load 880925-1.svg
 load 881031-1.svg
 load 885608-1.svg
 load 890782-1.svg
 load 890783-1.svg
 load 893510-1.svg
 load 895311-1.svg
+load 897342-1.svg
--- a/layout/svg/nsSVGTextFrame2.cpp
+++ b/layout/svg/nsSVGTextFrame2.cpp
@@ -4815,29 +4815,33 @@ nsSVGTextFrame2::DoGlyphPositioning()
     float actualTextLength =
       static_cast<float>(presContext->AppUnitsToGfxUnits(frameWidth) * factor);
 
     nsRefPtr<SVGAnimatedEnumeration> lengthAdjustEnum = element->LengthAdjust();
     uint16_t lengthAdjust = lengthAdjustEnum->AnimVal();
     switch (lengthAdjust) {
       case SVG_LENGTHADJUST_SPACINGANDGLYPHS:
         // Scale the glyphs and their positions.
-        mLengthAdjustScaleFactor = expectedTextLength / actualTextLength;
+        if (actualTextLength > 0) {
+          mLengthAdjustScaleFactor = expectedTextLength / actualTextLength;
+        }
         break;
 
       default:
         MOZ_ASSERT(lengthAdjust == SVG_LENGTHADJUST_SPACING);
         // Just add space between each glyph.
         int32_t adjustableSpaces = 0;
         for (uint32_t i = 1; i < mPositions.Length(); i++) {
           if (!mPositions[i].mUnaddressable) {
             adjustableSpaces++;
           }
         }
-        adjustment = (expectedTextLength - actualTextLength) / adjustableSpaces;
+        if (adjustableSpaces) {
+          adjustment = (expectedTextLength - actualTextLength) / adjustableSpaces;
+        }
         break;
     }
   }
 
   // Fill in any unspecified character positions based on the positions recorded
   // in charPositions, and also add in the dx/dy values.
   if (!deltas.IsEmpty()) {
     mPositions[0].mPosition += deltas[0];