Bug 1321885 - Add CSSPixel::FromAppUnits(nscoord) and CSSPixel::ToAppUnits(CSSCoord). r=kats

MozReview-Commit-ID: 8V9gjVf35bC

--HG--
extra : rebase_source : 7fc17e00fddbdbe4856c08a78729e8467a1f9571
This commit is contained in:
Botond Ballo 2016-08-24 13:42:57 -04:00
parent 71a6962e97
commit 6aa36c0f99

View File

@ -194,6 +194,10 @@ struct CSSPixel {
// Conversions from app units
static CSSCoord FromAppUnits(nscoord aCoord) {
return NSAppUnitsToFloatPixels(aCoord, float(AppUnitsPerCSSPixel()));
}
static CSSPoint FromAppUnits(const nsPoint& aPoint) {
return CSSPoint(NSAppUnitsToFloatPixels(aPoint.x, float(AppUnitsPerCSSPixel())),
NSAppUnitsToFloatPixels(aPoint.y, float(AppUnitsPerCSSPixel())));
@ -238,6 +242,10 @@ struct CSSPixel {
// Conversions to app units
static nscoord ToAppUnits(CSSCoord aCoord) {
return NSToCoordRoundWithClamp(aCoord * float(AppUnitsPerCSSPixel()));
}
static nsPoint ToAppUnits(const CSSPoint& aPoint) {
return nsPoint(NSToCoordRoundWithClamp(aPoint.x * float(AppUnitsPerCSSPixel())),
NSToCoordRoundWithClamp(aPoint.y * float(AppUnitsPerCSSPixel())));