Bug 1043163. Avoid negative widths and heights due to overflow. r=mats

--HG--
extra : rebase_source : 62db3ad669f7a965672ea6bbab1b932c4a07040f
This commit is contained in:
Robert O'Callahan 2014-08-06 17:19:23 +12:00
parent 9479fff06b
commit 28409a4a31
3 changed files with 18 additions and 12 deletions

View File

@ -244,10 +244,11 @@ nsRect::ScaleToNearestPixels(float aXScale, float aYScale,
nsIntRect rect;
rect.x = NSToIntRoundUp(NSAppUnitsToDoublePixels(x, aAppUnitsPerPixel) * aXScale);
rect.y = NSToIntRoundUp(NSAppUnitsToDoublePixels(y, aAppUnitsPerPixel) * aYScale);
rect.width = NSToIntRoundUp(NSAppUnitsToDoublePixels(XMost(),
aAppUnitsPerPixel) * aXScale) - rect.x;
rect.height = NSToIntRoundUp(NSAppUnitsToDoublePixels(YMost(),
aAppUnitsPerPixel) * aYScale) - rect.y;
// Avoid negative widths and heights due to overflow
rect.width = std::max(0, NSToIntRoundUp(NSAppUnitsToDoublePixels(XMost(),
aAppUnitsPerPixel) * aXScale) - rect.x);
rect.height = std::max(0, NSToIntRoundUp(NSAppUnitsToDoublePixels(YMost(),
aAppUnitsPerPixel) * aYScale) - rect.y);
return rect;
}
@ -259,10 +260,11 @@ nsRect::ScaleToOutsidePixels(float aXScale, float aYScale,
nsIntRect rect;
rect.x = NSToIntFloor(NSAppUnitsToFloatPixels(x, float(aAppUnitsPerPixel)) * aXScale);
rect.y = NSToIntFloor(NSAppUnitsToFloatPixels(y, float(aAppUnitsPerPixel)) * aYScale);
rect.width = NSToIntCeil(NSAppUnitsToFloatPixels(XMost(),
float(aAppUnitsPerPixel)) * aXScale) - rect.x;
rect.height = NSToIntCeil(NSAppUnitsToFloatPixels(YMost(),
float(aAppUnitsPerPixel)) * aYScale) - rect.y;
// Avoid negative widths and heights due to overflow
rect.width = std::max(0, NSToIntCeil(NSAppUnitsToFloatPixels(XMost(),
float(aAppUnitsPerPixel)) * aXScale) - rect.x);
rect.height = std::max(0, NSToIntCeil(NSAppUnitsToFloatPixels(YMost(),
float(aAppUnitsPerPixel)) * aYScale) - rect.y);
return rect;
}
@ -274,10 +276,11 @@ nsRect::ScaleToInsidePixels(float aXScale, float aYScale,
nsIntRect rect;
rect.x = NSToIntCeil(NSAppUnitsToFloatPixels(x, float(aAppUnitsPerPixel)) * aXScale);
rect.y = NSToIntCeil(NSAppUnitsToFloatPixels(y, float(aAppUnitsPerPixel)) * aYScale);
rect.width = NSToIntFloor(NSAppUnitsToFloatPixels(XMost(),
float(aAppUnitsPerPixel)) * aXScale) - rect.x;
rect.height = NSToIntFloor(NSAppUnitsToFloatPixels(YMost(),
float(aAppUnitsPerPixel)) * aYScale) - rect.y;
// Avoid negative widths and heights due to overflow
rect.width = std::max(0, NSToIntFloor(NSAppUnitsToFloatPixels(XMost(),
float(aAppUnitsPerPixel)) * aXScale) - rect.x);
rect.height = std::max(0, NSToIntFloor(NSAppUnitsToFloatPixels(YMost(),
float(aAppUnitsPerPixel)) * aYScale) - rect.y);
return rect;
}

View File

@ -0,0 +1,2 @@
<!DOCTYPE HTML>
<html style="mask: url(#none);"><canvas style="transform: scaleY(-118055395520340);"></canvas></html>

View File

@ -439,3 +439,4 @@ load 935765-1.html
load 942690.html
load 973390-1.html
load 1001237.html
load 1043163-1.html