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

This commit is contained in:
tor%cs.brown.edu 2005-10-02 19:26:51 +00:00
Родитель 5a7c8549b3
Коммит 2583a3b7b8
2 изменённых файлов: 34 добавлений и 2 удалений

Просмотреть файл

@ -668,18 +668,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;
return NS_ERROR_OUT_OF_MEMORY;
}
if (totalLength == 0.0f) {
nsMemory::Free(*arr);
*count = 0;
*arr = nsnull;
}
}
return NS_OK;

Просмотреть файл

@ -647,18 +647,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;
return NS_ERROR_OUT_OF_MEMORY;
}
if (totalLength == 0.0f) {
nsMemory::Free(*arr);
*count = 0;
*arr = nsnull;
}
}
return NS_OK;