diff --git a/layout/base/Units.h b/layout/base/Units.h index cae5ce4ada77..5aaaed8bd38a 100644 --- a/layout/base/Units.h +++ b/layout/base/Units.h @@ -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()))); } }; diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 979776472d8d..be8728cc5968 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -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)