Bug 711653: In SVG lighting calculations, when input surface is 1px wide, use a normal vector that points straight out of the page. r=dholbert a=lsblakk
--- a/content/svg/content/src/nsSVGFilters.cpp
+++ b/content/svg/content/src/nsSVGFilters.cpp
@@ -4692,16 +4692,25 @@ GenerateNormal(float *N, const PRUint8 *
{ { 2.0 / 3.0, 1.0 / 3.0, 2.0 / 3.0 },
{ 1.0 / 2.0, 1.0 / 4.0, 1.0 / 2.0 },
{ 2.0 / 3.0, 1.0 / 3.0, 2.0 / 3.0 } };
static const float FACTORy[3][3] =
{ { 2.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0 },
{ 1.0 / 3.0, 1.0 / 4.0, 1.0 / 3.0 },
{ 2.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0 } };
+ // degenerate cases
+ if (surfaceWidth == 1 || surfaceHeight == 1) {
+ // just return a unit vector pointing towards the viewer
+ N[0] = 0;
+ N[1] = 0;
+ N[2] = 255;
+ return;
+ }
+
PRInt8 xflag, yflag;
if (x == 0) {
xflag = 0;
} else if (x == surfaceWidth - 1) {
xflag = 2;
} else {
xflag = 1;
}