From 6aa36c0f9994a0f13d695682237eed682b5aed09 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Wed, 24 Aug 2016 13:42:57 -0400 Subject: [PATCH] Bug 1321885 - Add CSSPixel::FromAppUnits(nscoord) and CSSPixel::ToAppUnits(CSSCoord). r=kats MozReview-Commit-ID: 8V9gjVf35bC --HG-- extra : rebase_source : 7fc17e00fddbdbe4856c08a78729e8467a1f9571 --- layout/base/Units.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/layout/base/Units.h b/layout/base/Units.h index d363860b12e9..7db686ea15a3 100644 --- a/layout/base/Units.h +++ b/layout/base/Units.h @@ -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())));