b=893523 clamp CSS pixel to nscoord conversion to nscoord_MIN,MAX r=roc

--HG--
extra : transplant_source : P%87%C2l%86%9AWu%CD%06%E5%22%D3%88/%80a%CE%80p
This commit is contained in:
Karl Tomlinson 2013-08-05 14:58:41 +12:00
parent 6ae7b0b28c
commit bd89481631
2 changed files with 11 additions and 11 deletions

View File

@ -106,20 +106,20 @@ struct CSSPixel {
// Conversions to app units
static nsPoint ToAppUnits(const CSSPoint& aPoint) {
return nsPoint(NSFloatPixelsToAppUnits(aPoint.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSFloatPixelsToAppUnits(aPoint.y, float(nsDeviceContext::AppUnitsPerCSSPixel())));
return nsPoint(NSToCoordRoundWithClamp(aPoint.x * float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSToCoordRoundWithClamp(aPoint.y * float(nsDeviceContext::AppUnitsPerCSSPixel())));
}
static nsPoint ToAppUnits(const CSSIntPoint& aPoint) {
return nsPoint(NSIntPixelsToAppUnits(aPoint.x, nsDeviceContext::AppUnitsPerCSSPixel()),
NSIntPixelsToAppUnits(aPoint.y, nsDeviceContext::AppUnitsPerCSSPixel()));
return nsPoint(NSToCoordRoundWithClamp(float(aPoint.x) * float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSToCoordRoundWithClamp(float(aPoint.y) * float(nsDeviceContext::AppUnitsPerCSSPixel())));
}
static nsRect ToAppUnits(const CSSRect& aRect) {
return nsRect(NSFloatPixelsToAppUnits(aRect.x, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSFloatPixelsToAppUnits(aRect.y, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSFloatPixelsToAppUnits(aRect.width, float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSFloatPixelsToAppUnits(aRect.height, float(nsDeviceContext::AppUnitsPerCSSPixel())));
return nsRect(NSToCoordRoundWithClamp(aRect.x * float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSToCoordRoundWithClamp(aRect.y * float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSToCoordRoundWithClamp(aRect.width * float(nsDeviceContext::AppUnitsPerCSSPixel())),
NSToCoordRoundWithClamp(aRect.height * float(nsDeviceContext::AppUnitsPerCSSPixel())));
}
};

View File

@ -580,11 +580,11 @@ public:
static int32_t AppUnitsPerCSSInch() { return nsDeviceContext::AppUnitsPerCSSInch(); }
static nscoord CSSPixelsToAppUnits(int32_t aPixels)
{ return NSIntPixelsToAppUnits(aPixels,
nsDeviceContext::AppUnitsPerCSSPixel()); }
{ return NSToCoordRoundWithClamp(float(aPixels) *
float(nsDeviceContext::AppUnitsPerCSSPixel())); }
static nscoord CSSPixelsToAppUnits(float aPixels)
{ return NSFloatPixelsToAppUnits(aPixels,
{ return NSToCoordRoundWithClamp(aPixels *
float(nsDeviceContext::AppUnitsPerCSSPixel())); }
static int32_t AppUnitsToIntCSSPixels(nscoord aAppUnits)