Bug 310754 - check stroke-dasharray before handoff to renderer. r=jwatt, a=asa

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@181492 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
tor%cs.brown.edu
2005-10-03 20:38:01 +00:00
parent c1605a4632
commit 28bf89bc01
2 changed files with 34 additions and 2 deletions

View File

@@ -659,18 +659,34 @@ nsSVGGlyphFrame::GetStrokeDashArray(float **arr, PRUint32 *count)
{
const nsStyleCoord *dasharray = GetStyleSVG()->mStrokeDasharray;
nsPresContext *presContext = nsSVGGlyphFrameBase::GetPresContext();
float totalLength = 0.0f;
*count = GetStyleSVG()->mStrokeDasharrayLength;
*arr = nsnull;
if (*count) {
*arr = (float *) nsMemory::Alloc(*count * sizeof(float));
if (*arr) {
for (PRUint32 i = 0; i < *count; i++)
for (PRUint32 i = 0; i < *count; i++) {
(*arr)[i] = nsSVGUtils::CoordToFloat(presContext, mContent, dasharray[i]);
if ((*arr)[i] < 0.0f) {
nsMemory::Free(*arr);
*count = 0;
*arr = nsnull;
return NS_OK;
}
totalLength += (*arr)[i];
}
} else {
*count = 0;
*arr = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
if (totalLength == 0.0f) {
nsMemory::Free(*arr);
*count = 0;
}
}
return NS_OK;

View File

@@ -547,18 +547,34 @@ nsSVGPathGeometryFrame::GetStrokeDashArray(float **arr, PRUint32 *count)
{
const nsStyleCoord *dasharray = GetStyleSVG()->mStrokeDasharray;
nsPresContext *presContext = nsSVGPathGeometryFrameBase::GetPresContext();
float totalLength = 0.0f;
*count = GetStyleSVG()->mStrokeDasharrayLength;
*arr = nsnull;
if (*count) {
*arr = (float *) nsMemory::Alloc(*count * sizeof(float));
if (*arr) {
for (PRUint32 i = 0; i < *count; i++)
for (PRUint32 i = 0; i < *count; i++) {
(*arr)[i] = nsSVGUtils::CoordToFloat(presContext, mContent, dasharray[i]);
if ((*arr)[i] < 0.0f) {
nsMemory::Free(*arr);
*count = 0;
*arr = nsnull;
return NS_OK;
}
totalLength += (*arr)[i];
}
} else {
*count = 0;
*arr = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
if (totalLength == 0.0f) {
nsMemory::Free(*arr);
*count = 0;
}
}
return NS_OK;