Bug 420697: Add svgGlyphFrame check to GetStrokeDashoffset and GetStrokeDashArray, making them match GetStrokeWidth. r+sr=roc a=beltzner
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 14 Nov 2008 10:46:56 -0800
changeset 21697 26eff4ebdfbff822b2ef96a565bdc52ffab92775
parent 21696 e4690fcf6f7c741c62bb7793bc36afd0b81b1c9e
child 21699 5107f51b92aa2c19157e92e3ba8a61a4ac217e22
push id3642
push userdholbert@mozilla.com
push dateFri, 14 Nov 2008 19:53:23 +0000
treeherdermozilla-central@26eff4ebdfbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbeltzner
bugs420697
milestone1.9.1b2pre
Bug 420697: Add svgGlyphFrame check to GetStrokeDashoffset and GetStrokeDashArray, making them match GetStrokeWidth. r+sr=roc a=beltzner
layout/svg/base/src/nsSVGGeometryFrame.cpp
--- a/layout/svg/base/src/nsSVGGeometryFrame.cpp
+++ b/layout/svg/base/src/nsSVGGeometryFrame.cpp
@@ -93,33 +93,36 @@ nsSVGGeometryFrame::GetStrokeWidth()
     nsSVGUtils::CoordToFloat(PresContext(),
                              ctx,
                              GetStyleSVG()->mStrokeWidth);
 }
 
 nsresult
 nsSVGGeometryFrame::GetStrokeDashArray(gfxFloat **aDashes, PRUint32 *aCount)
 {
+  nsSVGElement *ctx = static_cast<nsSVGElement*>
+                                 (GetType() == nsGkAtoms::svgGlyphFrame ?
+                                     mContent->GetParent() : mContent);
   *aDashes = nsnull;
   *aCount = 0;
 
   PRUint32 count = GetStyleSVG()->mStrokeDasharrayLength;
   gfxFloat *dashes = nsnull;
 
   if (count) {
     const nsStyleCoord *dasharray = GetStyleSVG()->mStrokeDasharray;
     nsPresContext *presContext = PresContext();
     gfxFloat totalLength = 0.0f;
 
     dashes = new gfxFloat[count];
     if (dashes) {
       for (PRUint32 i = 0; i < count; i++) {
         dashes[i] =
           nsSVGUtils::CoordToFloat(presContext,
-                                   static_cast<nsSVGElement*>(mContent),
+                                   ctx,
                                    dasharray[i]);
         if (dashes[i] < 0.0f) {
           delete [] dashes;
           return NS_OK;
         }
         totalLength += dashes[i];
       }
     } else {
@@ -136,19 +139,23 @@ nsSVGGeometryFrame::GetStrokeDashArray(g
   }
 
   return NS_OK;
 }
 
 float
 nsSVGGeometryFrame::GetStrokeDashoffset()
 {
+  nsSVGElement *ctx = static_cast<nsSVGElement*>
+                                 (GetType() == nsGkAtoms::svgGlyphFrame ?
+                                     mContent->GetParent() : mContent);
+
   return
     nsSVGUtils::CoordToFloat(PresContext(),
-                             static_cast<nsSVGElement*>(mContent),
+                             ctx,
                              GetStyleSVG()->mStrokeDashoffset);
 }
 
 PRUint16
 nsSVGGeometryFrame::GetClipRule()
 {
   return GetStyleSVG()->mClipRule;
 }