diff --git a/mozilla/content/base/src/nsStyleContext.cpp b/mozilla/content/base/src/nsStyleContext.cpp index cd3514441f9..a520fa357f4 100644 --- a/mozilla/content/base/src/nsStyleContext.cpp +++ b/mozilla/content/base/src/nsStyleContext.cpp @@ -245,9 +245,9 @@ void nsStyleSpacing::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) } static const nscoord kBorderWidths[3] = - { NS_POINTS_TO_TWIPS_INT(1), - NS_POINTS_TO_TWIPS_INT(3), - NS_POINTS_TO_TWIPS_INT(5) }; + { NSIntPointsToTwips(1), + NSIntPointsToTwips(3), + NSIntPointsToTwips(5) }; void nsStyleSpacing::CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const { diff --git a/mozilla/content/events/src/nsDOMEvent.cpp b/mozilla/content/events/src/nsDOMEvent.cpp index 97e38f75804..81bb727b7be 100644 --- a/mozilla/content/events/src/nsDOMEvent.cpp +++ b/mozilla/content/events/src/nsDOMEvent.cpp @@ -128,7 +128,7 @@ NS_METHOD nsDOMEvent::SetScreenY(PRInt32 aScreenY) NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX) { - *aClientX = NS_TO_INT_ROUND(mEvent->point.x * mPresContext->GetTwipsToPixels()); + *aClientX = NSTwipsToIntPixels(mEvent->point.x, mPresContext->GetTwipsToPixels()); return NS_OK; } @@ -139,7 +139,7 @@ NS_METHOD nsDOMEvent::SetClientX(PRInt32 aClientX) NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY) { - *aClientY = NS_TO_INT_ROUND(mEvent->point.y * mPresContext->GetTwipsToPixels()); + *aClientY = NSTwipsToIntPixels(mEvent->point.y, mPresContext->GetTwipsToPixels()); return NS_OK; } diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index cf1b6c98d79..d7d83c3e9f2 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -1158,7 +1158,7 @@ HTMLContentSink::ScrollToRef() #if 0 nsIPresContext* cx = shell->GetPresContext(); float t2p = cx->GetTwipsToPixels(); -printf("x=%d y=%d\n", nscoord(x * t2p), nscoord(y * t2p)); +printf("x=%d y=%d\n", NSTwipsToIntPixels(x, t2p), NSTwipsToIntPixels(y, t2p)); NS_RELEASE(cx); #endif sview->SetScrollPreference(mOriginalScrollPreference); diff --git a/mozilla/content/html/style/src/nsCSSDeclaration.cpp b/mozilla/content/html/style/src/nsCSSDeclaration.cpp index 38f4f48d504..9043f5df4c3 100644 --- a/mozilla/content/html/style/src/nsCSSDeclaration.cpp +++ b/mozilla/content/html/style/src/nsCSSDeclaration.cpp @@ -322,29 +322,29 @@ nscoord nsCSSValue::GetLengthTwips(void) const if (IsFixedLengthUnit()) { switch (mUnit) { case eCSSUnit_Inch: - return (nscoord)NS_INCHES_TO_TWIPS(mValue.mFloat); + return NS_INCHES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Foot: - return (nscoord)NS_FEET_TO_TWIPS(mValue.mFloat); + return NS_FEET_TO_TWIPS(mValue.mFloat); case eCSSUnit_Mile: - return (nscoord)NS_MILES_TO_TWIPS(mValue.mFloat); + return NS_MILES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Millimeter: - return (nscoord)NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); + return NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Centimeter: - return (nscoord)NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); + return NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Meter: - return (nscoord)NS_METERS_TO_TWIPS(mValue.mFloat); + return NS_METERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Kilometer: - return (nscoord)NS_KILOMETERS_TO_TWIPS(mValue.mFloat); + return NS_KILOMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Point: - return (nscoord)NS_POINTS_TO_TWIPS_FLOAT(mValue.mFloat); + return NSFloatPointsToTwips(mValue.mFloat); case eCSSUnit_Pica: - return (nscoord)NS_PICAS_TO_TWIPS(mValue.mFloat); + return NS_PICAS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Didot: - return (nscoord)NS_DIDOTS_TO_TWIPS(mValue.mFloat); + return NS_DIDOTS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Cicero: - return (nscoord)NS_CICEROS_TO_TWIPS(mValue.mFloat); + return NS_CICEROS_TO_TWIPS(mValue.mFloat); } } return 0; diff --git a/mozilla/content/html/style/src/nsCSSStruct.cpp b/mozilla/content/html/style/src/nsCSSStruct.cpp index 38f4f48d504..9043f5df4c3 100644 --- a/mozilla/content/html/style/src/nsCSSStruct.cpp +++ b/mozilla/content/html/style/src/nsCSSStruct.cpp @@ -322,29 +322,29 @@ nscoord nsCSSValue::GetLengthTwips(void) const if (IsFixedLengthUnit()) { switch (mUnit) { case eCSSUnit_Inch: - return (nscoord)NS_INCHES_TO_TWIPS(mValue.mFloat); + return NS_INCHES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Foot: - return (nscoord)NS_FEET_TO_TWIPS(mValue.mFloat); + return NS_FEET_TO_TWIPS(mValue.mFloat); case eCSSUnit_Mile: - return (nscoord)NS_MILES_TO_TWIPS(mValue.mFloat); + return NS_MILES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Millimeter: - return (nscoord)NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); + return NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Centimeter: - return (nscoord)NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); + return NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Meter: - return (nscoord)NS_METERS_TO_TWIPS(mValue.mFloat); + return NS_METERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Kilometer: - return (nscoord)NS_KILOMETERS_TO_TWIPS(mValue.mFloat); + return NS_KILOMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Point: - return (nscoord)NS_POINTS_TO_TWIPS_FLOAT(mValue.mFloat); + return NSFloatPointsToTwips(mValue.mFloat); case eCSSUnit_Pica: - return (nscoord)NS_PICAS_TO_TWIPS(mValue.mFloat); + return NS_PICAS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Didot: - return (nscoord)NS_DIDOTS_TO_TWIPS(mValue.mFloat); + return NS_DIDOTS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Cicero: - return (nscoord)NS_CICEROS_TO_TWIPS(mValue.mFloat); + return NS_CICEROS_TO_TWIPS(mValue.mFloat); } } return 0; diff --git a/mozilla/content/html/style/src/nsCSSStyleRule.cpp b/mozilla/content/html/style/src/nsCSSStyleRule.cpp index 7eb2e08fd41..3e2b6f680c0 100644 --- a/mozilla/content/html/style/src/nsCSSStyleRule.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleRule.cpp @@ -438,7 +438,7 @@ nscoord CSSStyleRuleImpl::CalcLength(const nsCSSValue& aValue, return ((aFont->mFont.size / 3) * 2); // XXX HACK! case eCSSUnit_Pixel: - return (nscoord)(aPresContext->GetPixelsToTwips() * aValue.GetFloatValue()); + return NSFloatPixelsToTwips(aValue.GetFloatValue(), aPresContext->GetPixelsToTwips()); } return 0; } diff --git a/mozilla/content/html/style/src/nsStyleUtil.cpp b/mozilla/content/html/style/src/nsStyleUtil.cpp index 50e443f4b25..1ab34d8949a 100644 --- a/mozilla/content/html/style/src/nsStyleUtil.cpp +++ b/mozilla/content/html/style/src/nsStyleUtil.cpp @@ -48,7 +48,7 @@ float nsStyleUtil::GetScalingFactor(PRInt32 aScaler) scale *= mult; } - return scale; + return (float)scale; } /* diff --git a/mozilla/content/shared/src/nsStyleUtil.cpp b/mozilla/content/shared/src/nsStyleUtil.cpp index 50e443f4b25..1ab34d8949a 100644 --- a/mozilla/content/shared/src/nsStyleUtil.cpp +++ b/mozilla/content/shared/src/nsStyleUtil.cpp @@ -48,7 +48,7 @@ float nsStyleUtil::GetScalingFactor(PRInt32 aScaler) scale *= mult; } - return scale; + return (float)scale; } /* diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp index eee1a17dc5d..2d041319d8a 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp @@ -109,7 +109,7 @@ nsresult nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget) { mTwipsToPixels = (((float)::XDisplayWidth(XtDisplay((Widget)mNativeWidget), DefaultScreen(XtDisplay((Widget)mNativeWidget)))) / ((float)::XDisplayWidthMM(XtDisplay((Widget)mNativeWidget),DefaultScreen(XtDisplay((Widget)mNativeWidget)) )) * 25.4) / - NS_POINTS_TO_TWIPS_FLOAT(72.0f); + (float)NSIntPointsToTwips(72); mPixelsToTwips = 1.0f / mTwipsToPixels; }*/ diff --git a/mozilla/gfx/src/mac/nsFontMetricsMac.cpp b/mozilla/gfx/src/mac/nsFontMetricsMac.cpp index 62b4a799b01..59d14a31f7b 100644 --- a/mozilla/gfx/src/mac/nsFontMetricsMac.cpp +++ b/mozilla/gfx/src/mac/nsFontMetricsMac.cpp @@ -54,7 +54,7 @@ nsresult nsFontMetricsMac :: Init(const nsFont& aFont, nsIDeviceContext* aCX) int numnames = 0; char altitalicization = 0; XFontStruct *fonts; - PRInt32 dpi = NS_TO_INT_ROUND(aCX->GetTwipsToDevUnits() * 1440); + PRInt32 dpi = NSToIntRound(aCX->GetTwipsToDevUnits() * 1440); Display *dpy = XtDisplay((Widget)aCX->GetNativeWidget()); if (nsnull == wildstring) @@ -166,7 +166,7 @@ nsresult nsFontMetricsMac :: Init(const nsFont& aFont, nsIDeviceContext* aCX) /*char * nsFontMetricsMac::PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired) { int idx; - PRInt32 desiredpix = NS_TO_INT_ROUND(mContext->GetAppUnitsToDevUnits() * desired); + PRInt32 desiredpix = NSToIntRound(mContext->GetAppUnitsToDevUnits() * desired); XFontStruct *curfont; PRInt32 closestmin = -1, minidx; diff --git a/mozilla/gfx/src/mac/nsRenderingContextMac.cpp b/mozilla/gfx/src/mac/nsRenderingContextMac.cpp index 9e6625997f6..84e23309c13 100644 --- a/mozilla/gfx/src/mac/nsRenderingContextMac.cpp +++ b/mozilla/gfx/src/mac/nsRenderingContextMac.cpp @@ -752,8 +752,8 @@ void nsRenderingContextMac :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, ns ::XDrawArc(mRenderingSurface->display, mRenderingSurface->drawable, mRenderingSurface->gc, - x,y,w,h, NS_TO_INT_ROUND(aStartAngle * 64.0f), - NS_TO_INT_ROUND(aEndAngle * 64.0f)); + x,y,w,h, NSToIntRound(aStartAngle * 64.0f), + NSToIntRound(aEndAngle * 64.0f)); } void nsRenderingContextMac :: FillArc(const nsRect& aRect, @@ -777,8 +777,8 @@ void nsRenderingContextMac :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, ns ::XFillArc(mRenderingSurface->display, mRenderingSurface->drawable, mRenderingSurface->gc, - x,y,w,h, NS_TO_INT_ROUND(aStartAngle * 64.0f), - NS_TO_INT_ROUND(aEndAngle * 64.0f)); + x,y,w,h, NSToIntRound(aStartAngle * 64.0f), + NSToIntRound(aEndAngle * 64.0f)); } void nsRenderingContextMac :: DrawString(const char *aString, PRUint32 aLength, @@ -875,8 +875,8 @@ void nsRenderingContextMac :: DrawString(const nsString& aString, void nsRenderingContextMac :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) { nscoord width,height; - width = NS_TO_INT_ROUND(mP2T * aImage->GetWidth()); - height = NS_TO_INT_ROUND(mP2T * aImage->GetHeight()); + width = NSToCoordRound(mP2T * aImage->GetWidth()); + height = NSToCoordRound(mP2T * aImage->GetHeight()); this->DrawImage(aImage,aX,aY,width,height);8? } diff --git a/mozilla/gfx/src/motif/nsDeviceContextUnix.cpp b/mozilla/gfx/src/motif/nsDeviceContextUnix.cpp index 6a2effcccb6..332b4abdc73 100644 --- a/mozilla/gfx/src/motif/nsDeviceContextUnix.cpp +++ b/mozilla/gfx/src/motif/nsDeviceContextUnix.cpp @@ -106,7 +106,7 @@ nsresult nsDeviceContextUnix :: Init(nsNativeWidget aNativeWidget) { mTwipsToPixels = (((float)::XDisplayWidth(XtDisplay((Widget)mNativeWidget), DefaultScreen(XtDisplay((Widget)mNativeWidget)))) / ((float)::XDisplayWidthMM(XtDisplay((Widget)mNativeWidget),DefaultScreen(XtDisplay((Widget)mNativeWidget)) )) * 25.4) / - NS_POINTS_TO_TWIPS_FLOAT(72.0f); + (float)NSIntPointsToTwips(72); mPixelsToTwips = 1.0f / mTwipsToPixels; } diff --git a/mozilla/gfx/src/motif/nsFontMetricsUnix.cpp b/mozilla/gfx/src/motif/nsFontMetricsUnix.cpp index f5d8796d373..3db54a0edaf 100644 --- a/mozilla/gfx/src/motif/nsFontMetricsUnix.cpp +++ b/mozilla/gfx/src/motif/nsFontMetricsUnix.cpp @@ -63,7 +63,7 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX) int numnames = 0; char altitalicization = 0; XFontStruct *fonts; - PRInt32 dpi = NS_TO_INT_ROUND(aCX->GetTwipsToDevUnits() * 1440); + PRInt32 dpi = NSToIntRound(aCX->GetTwipsToDevUnits() * 1440); Display *dpy = XtDisplay((Widget)aCX->GetNativeWidget()); if (nsnull == wildstring) @@ -175,7 +175,7 @@ nsresult nsFontMetricsUnix :: Init(const nsFont& aFont, nsIDeviceContext* aCX) char * nsFontMetricsUnix::PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired) { int idx; - PRInt32 desiredpix = NS_TO_INT_ROUND(mContext->GetAppUnitsToDevUnits() * desired); + PRInt32 desiredpix = NSToIntRound(mContext->GetAppUnitsToDevUnits() * desired); XFontStruct *curfont; PRInt32 closestmin = -1, minidx; diff --git a/mozilla/gfx/src/motif/nsRenderingContextUnix.cpp b/mozilla/gfx/src/motif/nsRenderingContextUnix.cpp index 88c161413c6..2b674d40d6e 100644 --- a/mozilla/gfx/src/motif/nsRenderingContextUnix.cpp +++ b/mozilla/gfx/src/motif/nsRenderingContextUnix.cpp @@ -899,8 +899,8 @@ void nsRenderingContextUnix :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, n ::XDrawArc(mRenderingSurface->display, mRenderingSurface->drawable, mRenderingSurface->gc, - x,y,w,h, NS_TO_INT_ROUND(aStartAngle * 64.0f), - NS_TO_INT_ROUND(aEndAngle * 64.0f)); + x,y,w,h, NSToIntRound(aStartAngle * 64.0f), + NSToIntRound(aEndAngle * 64.0f)); } void nsRenderingContextUnix :: FillArc(const nsRect& aRect, @@ -924,8 +924,8 @@ void nsRenderingContextUnix :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, n ::XFillArc(mRenderingSurface->display, mRenderingSurface->drawable, mRenderingSurface->gc, - x,y,w,h, NS_TO_INT_ROUND(aStartAngle * 64.0f), - NS_TO_INT_ROUND(aEndAngle * 64.0f)); + x,y,w,h, NSToIntRound(aStartAngle * 64.0f), + NSToIntRound(aEndAngle * 64.0f)); } void nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength, @@ -1022,8 +1022,8 @@ void nsRenderingContextUnix :: DrawString(const nsString& aString, void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) { nscoord width,height; - width = NS_TO_INT_ROUND(mP2T * aImage->GetWidth()); - height = NS_TO_INT_ROUND(mP2T * aImage->GetHeight()); + width = NSToCoordRound(mP2T * aImage->GetWidth()); + height = NSToCoordRound(mP2T * aImage->GetHeight()); this->DrawImage(aImage,aX,aY,width,height); } diff --git a/mozilla/gfx/src/nsRect.cpp b/mozilla/gfx/src/nsRect.cpp index 06867b7a55b..313d3aaa3e2 100644 --- a/mozilla/gfx/src/nsRect.cpp +++ b/mozilla/gfx/src/nsRect.cpp @@ -152,6 +152,30 @@ void nsRect::Deflate(const nsMargin &aMargin) height -= aMargin.top + aMargin.bottom; } +// scale the rect but round to smallest containing rect +nsRect& nsRect::ScaleRoundOut(const float aScale) +{ + nscoord right = NSToCoordCeil(float(x + width) * aScale); + nscoord bottom = NSToCoordCeil(float(y + height) * aScale); + x = NSToCoordFloor(float(x) * aScale); + y = NSToCoordFloor(float(y) * aScale); + width = (right - x); + height = (bottom - y); + return *this; +} + +// scale the rect but round to largest contained rect +nsRect& nsRect::ScaleRoundIn(const float aScale) +{ + nscoord right = NSToCoordFloor(float(x + width) * aScale); + nscoord bottom = NSToCoordFloor(float(y + height) * aScale); + x = NSToCoordCeil(float(x) * aScale); + y = NSToCoordCeil(float(y) * aScale); + width = (right - x); + height = (bottom - y); + return *this; +} + // Diagnostics FILE* operator<<(FILE* out, const nsRect& rect) @@ -160,13 +184,13 @@ FILE* operator<<(FILE* out, const nsRect& rect) // Output the coordinates in fractional points so they're easier to read tmp.Append("{"); - tmp.Append(NS_TWIPS_TO_POINTS_FLOAT(rect.x)); + tmp.Append(NSTwipsToFloatPoints(rect.x)); tmp.Append(", "); - tmp.Append(NS_TWIPS_TO_POINTS_FLOAT(rect.y)); + tmp.Append(NSTwipsToFloatPoints(rect.y)); tmp.Append(", "); - tmp.Append(NS_TWIPS_TO_POINTS_FLOAT(rect.width)); + tmp.Append(NSTwipsToFloatPoints(rect.width)); tmp.Append(", "); - tmp.Append(NS_TWIPS_TO_POINTS_FLOAT(rect.height)); + tmp.Append(NSTwipsToFloatPoints(rect.height)); tmp.Append("}"); fputs(tmp, out); return out; diff --git a/mozilla/gfx/src/nsRect.h b/mozilla/gfx/src/nsRect.h index 05b214a6f49..ee6beadc6f2 100644 --- a/mozilla/gfx/src/nsRect.h +++ b/mozilla/gfx/src/nsRect.h @@ -112,12 +112,15 @@ struct NS_GFX nsRect { nsRect& operator+=(const nsPoint& aPoint) {x += aPoint.x; y += aPoint.y; return *this;} nsRect& operator-=(const nsPoint& aPoint) {x -= aPoint.x; y -= aPoint.y; return *this;} - nsRect& operator*=(const float aScale) {x = NS_TO_INT_ROUND(x * aScale); - y = NS_TO_INT_ROUND(y * aScale); - width = NS_TO_INT_ROUND(width * aScale); - height = NS_TO_INT_ROUND(height * aScale); + nsRect& operator*=(const float aScale) {x = NSToCoordRound(x * aScale); + y = NSToCoordRound(y * aScale); + width = NSToCoordRound(width * aScale); + height = NSToCoordRound(height * aScale); return *this;} + nsRect& ScaleRoundOut(const float aScale); + nsRect& ScaleRoundIn(const float aScale); + // Helper methods for computing the extents nscoord XMost() const {return x + width;} nscoord YMost() const {return y + height;} diff --git a/mozilla/gfx/src/nsTransform2D.cpp b/mozilla/gfx/src/nsTransform2D.cpp index 59633af4fac..4682f1b2205 100644 --- a/mozilla/gfx/src/nsTransform2D.cpp +++ b/mozilla/gfx/src/nsTransform2D.cpp @@ -279,8 +279,8 @@ void nsTransform2D :: TransformNoXLateCoord(nscoord *ptX, nscoord *ptY) break; case MG_2DSCALE: - *ptX = NS_TO_INT_ROUND(*ptX * m00); - *ptY = NS_TO_INT_ROUND(*ptY * m11); + *ptX = NSToCoordRound(*ptX * m00); + *ptY = NSToCoordRound(*ptY * m11); break; default: @@ -288,8 +288,8 @@ void nsTransform2D :: TransformNoXLateCoord(nscoord *ptX, nscoord *ptY) x = (float)*ptX; y = (float)*ptY; - *ptX = NS_TO_INT_ROUND(x * m00 + y * m10); - *ptY = NS_TO_INT_ROUND(x * m01 + y * m11); + *ptX = NSToCoordRound(x * m00 + y * m10); + *ptY = NSToCoordRound(x * m01 + y * m11); break; } @@ -350,27 +350,27 @@ void nsTransform2D :: TransformCoord(nscoord *ptX, nscoord *ptY) break; case MG_2DTRANSLATION: - *ptX += NS_TO_INT_ROUND(m20); - *ptY += NS_TO_INT_ROUND(m21); + *ptX += NSToCoordRound(m20); + *ptY += NSToCoordRound(m21); break; case MG_2DSCALE: - *ptX = NS_TO_INT_ROUND(*ptX * m00); - *ptY = NS_TO_INT_ROUND(*ptY * m11); + *ptX = NSToCoordRound(*ptX * m00); + *ptY = NSToCoordRound(*ptY * m11); break; case MG_2DGENERAL: x = (float)*ptX; y = (float)*ptY; - *ptX = NS_TO_INT_ROUND(x * m00 + y * m10); - *ptY = NS_TO_INT_ROUND(x * m01 + y * m11); + *ptX = NSToCoordRound(x * m00 + y * m10); + *ptY = NSToCoordRound(x * m01 + y * m11); break; case MG_2DSCALE | MG_2DTRANSLATION: - *ptX = NS_TO_INT_ROUND(*ptX * m00 + m20); - *ptY = NS_TO_INT_ROUND(*ptY * m11 + m21); + *ptX = NSToCoordRound(*ptX * m00 + m20); + *ptY = NSToCoordRound(*ptY * m11 + m21); break; default: @@ -378,8 +378,8 @@ void nsTransform2D :: TransformCoord(nscoord *ptX, nscoord *ptY) x = (float)*ptX; y = (float)*ptY; - *ptX = NS_TO_INT_ROUND(x * m00 + y * m10 + m20); - *ptY = NS_TO_INT_ROUND(x * m01 + y * m11 + m21); + *ptX = NSToCoordRound(x * m00 + y * m10 + m20); + *ptY = NSToCoordRound(x * m01 + y * m11 + m21); break; } @@ -456,37 +456,37 @@ void nsTransform2D :: TransformCoord(nscoord *aX, nscoord *aY, nscoord *aWidth, break; case MG_2DTRANSLATION: - *aX += NS_TO_INT_ROUND(m20); - *aY += NS_TO_INT_ROUND(m21); + *aX += NSToCoordRound(m20); + *aY += NSToCoordRound(m21); break; case MG_2DSCALE: - *aX = NS_TO_INT_ROUND(*aX * m00); - *aY = NS_TO_INT_ROUND(*aY * m11); - *aWidth = NS_TO_INT_ROUND(*aWidth * m00); - *aHeight = NS_TO_INT_ROUND(*aHeight * m11); + *aX = NSToCoordRound(*aX * m00); + *aY = NSToCoordRound(*aY * m11); + *aWidth = NSToCoordRound(*aWidth * m00); + *aHeight = NSToCoordRound(*aHeight * m11); break; case MG_2DGENERAL: x = (float)*aX; y = (float)*aY; - *aX = NS_TO_INT_ROUND(x * m00 + y * m10); - *aY = NS_TO_INT_ROUND(x * m01 + y * m11); + *aX = NSToCoordRound(x * m00 + y * m10); + *aY = NSToCoordRound(x * m01 + y * m11); x = (float)*aWidth; y = (float)*aHeight; - *aHeight = NS_TO_INT_ROUND(x * m00 + y * m10); - *aHeight = NS_TO_INT_ROUND(x * m01 + y * m11); + *aHeight = NSToCoordRound(x * m00 + y * m10); + *aHeight = NSToCoordRound(x * m01 + y * m11); break; case MG_2DSCALE | MG_2DTRANSLATION: - *aX = NS_TO_INT_ROUND(*aX * m00 + m20); - *aY = NS_TO_INT_ROUND(*aY * m11 + m21); - *aWidth = NS_TO_INT_ROUND(*aWidth * m00); - *aHeight = NS_TO_INT_ROUND(*aHeight * m11); + *aX = NSToCoordRound(*aX * m00 + m20); + *aY = NSToCoordRound(*aY * m11 + m21); + *aWidth = NSToCoordRound(*aWidth * m00); + *aHeight = NSToCoordRound(*aHeight * m11); break; default: @@ -494,14 +494,14 @@ void nsTransform2D :: TransformCoord(nscoord *aX, nscoord *aY, nscoord *aWidth, x = (float)*aX; y = (float)*aY; - *aX = NS_TO_INT_ROUND(x * m00 + y * m10 + m20); - *aY = NS_TO_INT_ROUND(x * m01 + y * m11 + m21); + *aX = NSToCoordRound(x * m00 + y * m10 + m20); + *aY = NSToCoordRound(x * m01 + y * m11 + m21); x = (float)*aWidth; y = (float)*aHeight; - *aWidth = NS_TO_INT_ROUND(x * m00 + y * m10); - *aHeight = NS_TO_INT_ROUND(x * m01 + y * m11); + *aWidth = NSToCoordRound(x * m00 + y * m10); + *aHeight = NSToCoordRound(x * m01 + y * m11); break; } diff --git a/mozilla/gfx/src/nsTransform2D.h b/mozilla/gfx/src/nsTransform2D.h index 523158a1ab0..145d8fbe957 100644 --- a/mozilla/gfx/src/nsTransform2D.h +++ b/mozilla/gfx/src/nsTransform2D.h @@ -98,7 +98,7 @@ public: **/ void GetTranslation(float *ptX, float *ptY) { *ptX = m20; *ptY = m21; } - void GetTranslationCoord(nscoord *ptX, nscoord *ptY) { *ptX = NS_TO_INT_ROUND(m20); *ptY = NS_TO_INT_ROUND(m21); } + void GetTranslationCoord(nscoord *ptX, nscoord *ptY) { *ptX = NSToCoordRound(m20); *ptY = NSToCoordRound(m21); } /** * get the X translation portion of this transform @@ -109,7 +109,7 @@ public: **/ float GetXTranslation(void) { return m20; } - nscoord GetXTranslationCoord(void) { return NS_TO_INT_ROUND(m20); } + nscoord GetXTranslationCoord(void) { return NSToCoordRound(m20); } /** * get the Y translation portion of this transform @@ -120,7 +120,7 @@ public: **/ float GetYTranslation(void) { return m21; } - nscoord GetYTranslationCoord(void) { return NS_TO_INT_ROUND(m21); } + nscoord GetYTranslationCoord(void) { return NSToCoordRound(m21); } /** * set this matrix and type from another Transform2D diff --git a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp index aa3747b7de5..9e1f0b71cd2 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp @@ -24,7 +24,7 @@ nsDeviceContextWin :: nsDeviceContextWin() { HDC hdc = ::GetDC(NULL); - mTwipsToPixels = ((float)::GetDeviceCaps(hdc, LOGPIXELSX)) / NS_POINTS_TO_TWIPS_FLOAT(72.0f); + mTwipsToPixels = ((float)::GetDeviceCaps(hdc, LOGPIXELSX)) / (float)NSIntPointsToTwips(72); // XXX shouldn't be LOGPIXELSY ?? mPixelsToTwips = 1.0f / mTwipsToPixels; ::ReleaseDC(NULL, hdc); diff --git a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp index a5b4bb4d1f8..4a33eeb30cb 100644 --- a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp +++ b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp @@ -162,9 +162,9 @@ void nsFontMetricsWin::RealizeFont(nsIDeviceContext *aContext) float app2dev = aContext->GetAppUnitsToDevUnits(); float app2twip = app2dev * aContext->GetDevUnitsToTwips(); - float rounded = NS_POINTS_TO_TWIPS_FLOAT(NS_TWIPS_TO_POINTS_INT(mFont->size * app2twip)) / app2twip; + float rounded = ((float)NSIntPointsToTwips(NSTwipsToFloorIntPoints(nscoord(mFont->size * app2twip)))) / app2twip; // round font size off to floor point size to be windows compatible -// logFont.lfHeight = - NS_TO_INT_ROUND(rounded * app2dev); // this is proper (windows) rounding +// logFont.lfHeight = - NSToIntRound(rounded * app2dev); // this is proper (windows) rounding logFont.lfHeight = - LONG(rounded * app2dev); // this floor rounding is to make ours compatible with Nav 4.0 strncpy(logFont.lfFaceName, MapFamilyToFont(mFont->name), diff --git a/mozilla/gfx/src/windows/nsRenderingContextWin.cpp b/mozilla/gfx/src/windows/nsRenderingContextWin.cpp index c9f381d4465..b1092506f9a 100644 --- a/mozilla/gfx/src/windows/nsRenderingContextWin.cpp +++ b/mozilla/gfx/src/windows/nsRenderingContextWin.cpp @@ -954,8 +954,8 @@ void nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY nscoord width, height; - width = NS_TO_INT_ROUND(mP2T * aImage->GetWidth()); - height = NS_TO_INT_ROUND(mP2T * aImage->GetHeight()); + width = NSToCoordRound(mP2T * aImage->GetWidth()); + height = NSToCoordRound(mP2T * aImage->GetHeight()); this->DrawImage(aImage, aX, aY, width, height); } diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index 55a04c0543d..1987d833978 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -693,8 +693,8 @@ void nsCSSRendering::PaintBackground(nsIPresContext& aPresContext, // Convert image dimensions into nscoord's float p2t = aPresContext.GetPixelsToTwips(); - nscoord tileWidth = nscoord(p2t * imageSize.width); - nscoord tileHeight = nscoord(p2t * imageSize.height); + nscoord tileWidth = NSIntPixelsToTwips(imageSize.width, p2t); + nscoord tileHeight = NSIntPixelsToTwips(imageSize.height, p2t); PRIntn repeat = aColor.mBackgroundRepeat; PRIntn xcount, ycount; diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index 556a9a6e367..e6cd53a78a9 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -36,12 +36,12 @@ nsPresContext::nsPresContext() NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, - NS_POINTS_TO_TWIPS_INT(12)), + NSIntPointsToTwips(12)), mDefaultFixedFont("Courier", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, - NS_POINTS_TO_TWIPS_INT(10)) + NSIntPointsToTwips(10)) { NS_INIT_REFCNT(); mShell = nsnull; @@ -138,13 +138,13 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs) mDefaultFont.name = prefChar; } if (NS_OK == mPrefs->GetIntPref("intl.font2.win.prop_size", &prefInt)) { - mDefaultFont.size = NS_POINTS_TO_TWIPS_INT(prefInt); + mDefaultFont.size = NSIntPointsToTwips(prefInt); } if (NS_OK == mPrefs->GetCharPref("intl.font2.win.fixed_font", &(prefChar[0]), &charSize)) { mDefaultFixedFont.name = prefChar; } if (NS_OK == mPrefs->GetIntPref("intl.font2.win.fixed_size", &prefInt)) { - mDefaultFixedFont.size = NS_POINTS_TO_TWIPS_INT(prefInt); + mDefaultFixedFont.size = NSIntPointsToTwips(prefInt); } } diff --git a/mozilla/layout/base/src/nsFrameImageLoader.cpp b/mozilla/layout/base/src/nsFrameImageLoader.cpp index 8112888778f..bcbebcffd85 100644 --- a/mozilla/layout/base/src/nsFrameImageLoader.cpp +++ b/mozilla/layout/base/src/nsFrameImageLoader.cpp @@ -202,10 +202,10 @@ nsFrameImageLoader::Notify(nsIImageRequest *aImageRequest, // Convert the rect from pixels to twips p2t = mPresContext->GetPixelsToTwips(); changeRect = (const nsRect*)aParam3; - damageRect.x = nscoord(p2t * changeRect->x); - damageRect.y = nscoord(p2t * changeRect->y); - damageRect.width = nscoord(p2t * changeRect->width); - damageRect.height = nscoord(p2t * changeRect->height); + damageRect.x = NSIntPixelsToTwips(changeRect->x, p2t); + damageRect.y = NSIntPixelsToTwips(changeRect->y, p2t); + damageRect.width = NSIntPixelsToTwips(changeRect->width, p2t); + damageRect.height = NSIntPixelsToTwips(changeRect->height, p2t); DamageRepairFrame(&damageRect); break; diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index 556a9a6e367..e6cd53a78a9 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -36,12 +36,12 @@ nsPresContext::nsPresContext() NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, - NS_POINTS_TO_TWIPS_INT(12)), + NSIntPointsToTwips(12)), mDefaultFixedFont("Courier", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, - NS_POINTS_TO_TWIPS_INT(10)) + NSIntPointsToTwips(10)) { NS_INIT_REFCNT(); mShell = nsnull; @@ -138,13 +138,13 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext, nsIPref* aPrefs) mDefaultFont.name = prefChar; } if (NS_OK == mPrefs->GetIntPref("intl.font2.win.prop_size", &prefInt)) { - mDefaultFont.size = NS_POINTS_TO_TWIPS_INT(prefInt); + mDefaultFont.size = NSIntPointsToTwips(prefInt); } if (NS_OK == mPrefs->GetCharPref("intl.font2.win.fixed_font", &(prefChar[0]), &charSize)) { mDefaultFixedFont.name = prefChar; } if (NS_OK == mPrefs->GetIntPref("intl.font2.win.fixed_size", &prefInt)) { - mDefaultFixedFont.size = NS_POINTS_TO_TWIPS_INT(prefInt); + mDefaultFixedFont.size = NSIntPointsToTwips(prefInt); } } diff --git a/mozilla/layout/base/src/nsPresShell.cpp b/mozilla/layout/base/src/nsPresShell.cpp index f111809f3c2..93cc02ff278 100644 --- a/mozilla/layout/base/src/nsPresShell.cpp +++ b/mozilla/layout/base/src/nsPresShell.cpp @@ -1041,7 +1041,6 @@ PresShell::VerifyIncrementalReflow() // Create a new presentation shell to view the document rv = mDocument->CreateShell(cx, vm, ss, &sh); NS_ASSERTION(NS_OK == rv, "failed to create presentation shell"); - float p2t = cx->GetPixelsToTwips(); sh->ResizeReflow(r.width, r.height); // Now that the document has been reflowed, use its frame tree to diff --git a/mozilla/layout/base/src/nsPrintPreviewContext.cpp b/mozilla/layout/base/src/nsPrintPreviewContext.cpp index c50e6828314..0ed1467b0d5 100644 --- a/mozilla/layout/base/src/nsPrintPreviewContext.cpp +++ b/mozilla/layout/base/src/nsPrintPreviewContext.cpp @@ -55,7 +55,7 @@ nscoord PrintPreviewContext::GetPageWidth() #else // For testing purposes make the page width smaller than the visible // area - nscoord sbar = NS_TO_INT_ROUND(mDeviceContext->GetScrollBarWidth()); + nscoord sbar = NSToCoordRound(mDeviceContext->GetScrollBarWidth()); return mVisibleArea.width - sbar - 2*100; #endif } diff --git a/mozilla/layout/base/src/nsStyleContext.cpp b/mozilla/layout/base/src/nsStyleContext.cpp index cd3514441f9..a520fa357f4 100644 --- a/mozilla/layout/base/src/nsStyleContext.cpp +++ b/mozilla/layout/base/src/nsStyleContext.cpp @@ -245,9 +245,9 @@ void nsStyleSpacing::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) } static const nscoord kBorderWidths[3] = - { NS_POINTS_TO_TWIPS_INT(1), - NS_POINTS_TO_TWIPS_INT(3), - NS_POINTS_TO_TWIPS_INT(5) }; + { NSIntPointsToTwips(1), + NSIntPointsToTwips(3), + NSIntPointsToTwips(5) }; void nsStyleSpacing::CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const { diff --git a/mozilla/layout/events/src/nsDOMEvent.cpp b/mozilla/layout/events/src/nsDOMEvent.cpp index 97e38f75804..81bb727b7be 100644 --- a/mozilla/layout/events/src/nsDOMEvent.cpp +++ b/mozilla/layout/events/src/nsDOMEvent.cpp @@ -128,7 +128,7 @@ NS_METHOD nsDOMEvent::SetScreenY(PRInt32 aScreenY) NS_METHOD nsDOMEvent::GetClientX(PRInt32* aClientX) { - *aClientX = NS_TO_INT_ROUND(mEvent->point.x * mPresContext->GetTwipsToPixels()); + *aClientX = NSTwipsToIntPixels(mEvent->point.x, mPresContext->GetTwipsToPixels()); return NS_OK; } @@ -139,7 +139,7 @@ NS_METHOD nsDOMEvent::SetClientX(PRInt32 aClientX) NS_METHOD nsDOMEvent::GetClientY(PRInt32* aClientY) { - *aClientY = NS_TO_INT_ROUND(mEvent->point.y * mPresContext->GetTwipsToPixels()); + *aClientY = NSTwipsToIntPixels(mEvent->point.y, mPresContext->GetTwipsToPixels()); return NS_OK; } diff --git a/mozilla/layout/generic/nsImageMap.cpp b/mozilla/layout/generic/nsImageMap.cpp index 2122aa7f02b..a568255000d 100644 --- a/mozilla/layout/generic/nsImageMap.cpp +++ b/mozilla/layout/generic/nsImageMap.cpp @@ -25,9 +25,6 @@ #include "nsXIFConverter.h" #include "nsISizeOfHandler.h" -#undef SCALE -#define SCALE(a,b) nscoord((a) * (b)) - class Area { public: Area(const nsString& aBaseURL, const nsString& aHREF, @@ -455,10 +452,10 @@ void RectArea::Draw(nsIPresContext& aCX, nsIRenderingContext& aRC) { if (mNumCoords >= 4) { float p2t = aCX.GetPixelsToTwips(); - nscoord x1 = SCALE(p2t, mCoords[0]); - nscoord y1 = SCALE(p2t, mCoords[1]); - nscoord x2 = SCALE(p2t, mCoords[2]); - nscoord y2 = SCALE(p2t, mCoords[3]); + nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t); + nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t); + nscoord x2 = NSIntPixelsToTwips(mCoords[2], p2t); + nscoord y2 = NSIntPixelsToTwips(mCoords[3], p2t); if ((x1 > x2)|| (y1 > y2)) { return; } @@ -563,11 +560,11 @@ void PolyArea::Draw(nsIPresContext& aCX, nsIRenderingContext& aRC) { if (mNumCoords >= 6) { float p2t = aCX.GetPixelsToTwips(); - nscoord x0 = SCALE(p2t, mCoords[0]); - nscoord y0 = SCALE(p2t, mCoords[1]); + nscoord x0 = NSIntPixelsToTwips(mCoords[0], p2t); + nscoord y0 = NSIntPixelsToTwips(mCoords[1], p2t); for (PRInt32 i = 2; i < mNumCoords; i += 2) { - nscoord x1 = SCALE(p2t, mCoords[i]); - nscoord y1 = SCALE(p2t, mCoords[i+1]); + nscoord x1 = NSIntPixelsToTwips(mCoords[i], p2t); + nscoord y1 = NSIntPixelsToTwips(mCoords[i+1], p2t); aRC.DrawLine(x0, y0, x1, y1); x0 = x1; y0 = y1; @@ -631,9 +628,9 @@ void CircleArea::Draw(nsIPresContext& aCX, nsIRenderingContext& aRC) { if (mNumCoords >= 3) { float p2t = aCX.GetPixelsToTwips(); - nscoord x1 = SCALE(p2t, mCoords[0]); - nscoord y1 = SCALE(p2t, mCoords[1]); - nscoord radius = SCALE(p2t, mCoords[2]); + nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t); + nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t); + nscoord radius = NSIntPixelsToTwips(mCoords[2], p2t); if (radius < 0) { return; } diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 69813cdfa07..311c9d0fcdd 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -163,7 +163,7 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, } else { float p2t = aPresContext->GetPixelsToTwips(); - aMetrics.width = nscoord(p2t * EMBED_DEF_DIM); + aMetrics.width = NSIntPixelsToTwips(EMBED_DEF_DIM, p2t); } } if (!haveHeight) { @@ -172,7 +172,7 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, } else { float p2t = aPresContext->GetPixelsToTwips(); - aMetrics.height = nscoord(p2t * EMBED_DEF_DIM); + aMetrics.height = NSIntPixelsToTwips(EMBED_DEF_DIM, p2t); } } aMetrics.ascent = aMetrics.height; @@ -293,7 +293,7 @@ nsObjectFrame::Paint(nsIPresContext& aPresContext, aRenderingContext.SetColor(NS_RGB(0, 0, 0)); aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height); float p2t = aPresContext.GetPixelsToTwips(); - nscoord px3 = nscoord(3 * p2t); + nscoord px3 = NSIntPixelsToTwips(3, p2t); nsAutoString tmp; nsIAtom* atom = mContent->GetTag(); if (nsnull != atom) { diff --git a/mozilla/layout/generic/nsPlaceholderFrame.cpp b/mozilla/layout/generic/nsPlaceholderFrame.cpp index a9e1dd65266..c1b62f4ee1b 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.cpp +++ b/mozilla/layout/generic/nsPlaceholderFrame.cpp @@ -161,10 +161,10 @@ nsPlaceholderFrame::Paint(nsIPresContext& aPresContext, if (nsIFrame::GetShowFrameBorders()) { float p2t = aPresContext.GetPixelsToTwips(); aRenderingContext.SetColor(NS_RGB(0, 255, 255)); - nscoord x = nscoord(-5 * p2t); - aRenderingContext.FillRect(x, 0, nscoord(13 * p2t), nscoord(3 * p2t)); - nscoord y = nscoord(-10 * p2t); - aRenderingContext.FillRect(0, y, nscoord(3 * p2t), nscoord(10 * p2t)); + nscoord x = NSIntPixelsToTwips(-5, p2t); + aRenderingContext.FillRect(x, 0, NSIntPixelsToTwips(13, p2t), NSIntPixelsToTwips(3, p2t)); + nscoord y = NSIntPixelsToTwips(-10, p2t); + aRenderingContext.FillRect(0, y, NSIntPixelsToTwips(3, p2t), NSIntPixelsToTwips(10, p2t)); } return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsBRPart.cpp b/mozilla/layout/html/base/src/nsBRPart.cpp index e563a3df75d..69405b5c056 100644 --- a/mozilla/layout/html/base/src/nsBRPart.cpp +++ b/mozilla/layout/html/base/src/nsBRPart.cpp @@ -83,7 +83,7 @@ BRFrame::Paint(nsIPresContext& aPresContext, if (nsIFrame::GetShowFrameBorders()) { float p2t = aPresContext.GetPixelsToTwips(); aRenderingContext.SetColor(NS_RGB(0, 255, 255)); - aRenderingContext.FillRect(0, 0, nscoord(5 * p2t), mRect.height); + aRenderingContext.FillRect(0, 0, NSIntPixelsToTwips(5, p2t), mRect.height); } return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsBodyFrame.cpp b/mozilla/layout/html/base/src/nsBodyFrame.cpp index f6380f308b0..f7b3f0cb4e3 100644 --- a/mozilla/layout/html/base/src/nsBodyFrame.cpp +++ b/mozilla/layout/html/base/src/nsBodyFrame.cpp @@ -384,7 +384,7 @@ nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext, aBorderPadding.right; if (! aPresContext->IsPaginated()) { nsIDeviceContext* dc = aPresContext->GetDeviceContext(); - result.width -= NS_TO_INT_ROUND(dc->GetScrollBarWidth()); + result.width -= NSToCoordRound(dc->GetScrollBarWidth()); NS_RELEASE(dc); } } diff --git a/mozilla/layout/html/base/src/nsHRPart.cpp b/mozilla/layout/html/base/src/nsHRPart.cpp index 98801558d5e..c4e52f95051 100644 --- a/mozilla/layout/html/base/src/nsHRPart.cpp +++ b/mozilla/layout/html/base/src/nsHRPart.cpp @@ -113,7 +113,7 @@ HRuleFrame::Paint(nsIPresContext& aPresContext, } float p2t = aPresContext.GetPixelsToTwips(); - nscoord thickness = nscoord(p2t * ((HRulePart*)mContent)->GetThickness()); + nscoord thickness = NSIntPixelsToTwips(((HRulePart*)mContent)->GetThickness(), p2t); // Get style data const nsStyleSpacing* spacing = (const nsStyleSpacing*) @@ -188,8 +188,8 @@ HRuleFrame::Paint(nsIPresContext& aPresContext, if (!noShadeAttribute && ((printing && bevel) || !printing)) { // Lines render inclusively on the both the starting and ending // coordinate, so reduce the end coordinates by one pixel. - nscoord x1 = nscoord(x0 + width - p2t); - nscoord y1 = nscoord(y0 + height - p2t); + nscoord x1 = nscoord(x0 + width - NSIntPixelsToTwips(1, p2t)); + nscoord y1 = nscoord(y0 + height - NSIntPixelsToTwips(1, p2t)); // Draw bottom and right lines aRenderingContext.SetColor (colors[1]); @@ -205,7 +205,7 @@ HRuleFrame::Paint(nsIPresContext& aPresContext, // draw half-circles on the end points. aRenderingContext.SetColor (colors[0]); nscoord diameter = height; - if ((diameter > width) || (diameter < nscoord(p2t * 3))) { + if ((diameter > width) || (diameter < NSIntPixelsToTwips(3, p2t))) { // The half-circles on the ends of the rule aren't going to // look right so don't bother drawing them. aRenderingContext.FillRect(x0, y0, width, height); @@ -238,7 +238,7 @@ HRuleFrame::Reflow(nsIPresContext& aPresContext, // HR's do not impact the max-element-size, otherwise tables behave // badly. This makes sense they are springy. if (nsnull != aDesiredSize.maxElementSize) { - nscoord onePixel = nscoord(aPresContext.GetPixelsToTwips()); + nscoord onePixel = NSIntPixelsToTwips(1, aPresContext.GetPixelsToTwips()); aDesiredSize.maxElementSize->width = onePixel; aDesiredSize.maxElementSize->height = onePixel; } @@ -278,11 +278,11 @@ HRuleFrame::GetDesiredSize(nsIPresContext* aPresContext, // Get the thickness of the rule (this is not css's height property) float p2t = aPresContext->GetPixelsToTwips(); - nscoord thickness = nscoord(p2t * ((HRulePart*)mContent)->GetThickness()); + nscoord thickness = NSIntPixelsToTwips(((HRulePart*)mContent)->GetThickness(), p2t); // Compute height of "line" that hrule will layout within. Use the // default font to do this. - lineHeight = thickness + nscoord(p2t * 2); + lineHeight = thickness + NSIntPixelsToTwips(2, p2t); const nsFont& defaultFont = aPresContext->GetDefaultFont(); nsIFontMetrics* fm = aPresContext->GetMetricsFor(defaultFont); nscoord defaultLineHeight = fm->GetHeight(); @@ -414,7 +414,7 @@ HRulePart::MapAttributesInto(nsIStyleContext* aContext, aContext->GetMutableStyleData(eStyleStruct_Position); GetAttribute(nsHTMLAtoms::width, value); if (value.GetUnit() == eHTMLUnit_Pixel) { - nscoord twips = nscoord(p2t * value.GetPixelValue()); + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); pos->mWidth.SetCoordValue(twips); } else if (value.GetUnit() == eHTMLUnit_Percent) { diff --git a/mozilla/layout/html/base/src/nsHTMLBullet.cpp b/mozilla/layout/html/base/src/nsHTMLBullet.cpp index 5e28cda6d36..e146a389b23 100644 --- a/mozilla/layout/html/base/src/nsHTMLBullet.cpp +++ b/mozilla/layout/html/base/src/nsHTMLBullet.cpp @@ -557,12 +557,12 @@ BulletFrame::GetDesiredSize(nsIPresContext* aCX, case NS_STYLE_LIST_STYLE_BASIC: case NS_STYLE_LIST_STYLE_SQUARE: t2p = aCX->GetTwipsToPixels(); - bulletSize = nscoord(t2p * .8 * (fm->GetMaxAscent() / 2)); + bulletSize = NSTwipsToIntPixels((nscoord)NSToIntRound(0.8f * (float(fm->GetMaxAscent()) / 2.0f)), t2p); if (bulletSize < 1) { bulletSize = MIN_BULLET_SIZE; } p2t = aCX->GetPixelsToTwips(); - bulletSize = nscoord(p2t * bulletSize); + bulletSize = NSIntPixelsToTwips(bulletSize, p2t); mPadding.bottom = (fm->GetMaxAscent() / 8); if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == myList->mListStylePosition) { mPadding.right = bulletSize / 2; diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.cpp b/mozilla/layout/html/base/src/nsHTMLContainer.cpp index a5f5421941a..54d3af3e37c 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainer.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainer.cpp @@ -616,13 +616,13 @@ void nsHTMLContainer::MapAttributesInto(nsIStyleContext* aContext, GetAttribute(nsHTMLAtoms::pointSize, value); if (value.GetUnit() == eHTMLUnit_Integer) { // XXX should probably sanitize value - font->mFont.size = parentFont->mFont.size + NS_POINTS_TO_TWIPS_INT(value.GetIntValue()); - font->mFixedFont.size = parentFont->mFixedFont.size + NS_POINTS_TO_TWIPS_INT(value.GetIntValue()); + font->mFont.size = parentFont->mFont.size + NSIntPointsToTwips(value.GetIntValue()); + font->mFixedFont.size = parentFont->mFixedFont.size + NSIntPointsToTwips(value.GetIntValue()); font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT; } else if (value.GetUnit() == eHTMLUnit_Enumerated) { - font->mFont.size = NS_POINTS_TO_TWIPS_INT(value.GetIntValue()); - font->mFixedFont.size = NS_POINTS_TO_TWIPS_INT(value.GetIntValue()); + font->mFont.size = NSIntPointsToTwips(value.GetIntValue()); + font->mFixedFont.size = NSIntPointsToTwips(value.GetIntValue()); font->mFlags |= NS_STYLE_FONT_SIZE_EXPLICIT; } else { diff --git a/mozilla/layout/html/base/src/nsHTMLImage.cpp b/mozilla/layout/html/base/src/nsHTMLImage.cpp index 18180f6bab2..5fe1437094e 100644 --- a/mozilla/layout/html/base/src/nsHTMLImage.cpp +++ b/mozilla/layout/html/base/src/nsHTMLImage.cpp @@ -316,14 +316,14 @@ nsHTMLImageLoader::GetDesiredSize(nsIPresContext* aPresContext, // from width. aDesiredSize.width = styleSize.width; aDesiredSize.height = - nscoord(styleSize.width * imageHeight / imageWidth); + (nscoord)NSToIntRound(styleSize.width * imageHeight / imageWidth); } else { // We have a height and an auto width. Compute width from // height. aDesiredSize.height = styleSize.height; aDesiredSize.width = - nscoord(styleSize.height * imageWidth / imageHeight); + (nscoord)NSToIntRound(styleSize.height * imageWidth / imageHeight); } } else { @@ -346,8 +346,8 @@ nsHTMLImageLoader::GetDesiredSize(nsIPresContext* aPresContext, float p2t = aPresContext->GetPixelsToTwips(); nsSize imageSize; mImageLoader->GetSize(imageSize); - aDesiredSize.width = nscoord(imageSize.width * p2t); - aDesiredSize.height = nscoord(imageSize.height * p2t); + aDesiredSize.width = NSIntPixelsToTwips(imageSize.width, p2t); + aDesiredSize.height = NSIntPixelsToTwips(imageSize.height, p2t); } } } @@ -595,14 +595,14 @@ ImageFrame::Paint(nsIPresContext& aPresContext, nsRect inner; GetInnerArea(&aPresContext, inner); - nscoord p2t = (nscoord)aPresContext.GetPixelsToTwips(); - nsRecessedBorder recessedBorder(p2t); + float p2t = aPresContext.GetPixelsToTwips(); + nsRecessedBorder recessedBorder(NSIntPixelsToTwips(1, p2t)); nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, inner, inner, recessedBorder, 0); - inner.Deflate(p2t, p2t); + inner.Deflate(NSIntPixelsToTwips(1, p2t), NSIntPixelsToTwips(1, p2t)); // Leave a 8 pixel left/right padding, and a 5 pixel top/bottom padding - inner.Deflate(8 * p2t, 5 * p2t); + inner.Deflate(NSIntPixelsToTwips(8, p2t), NSIntPixelsToTwips(5, p2t)); // If there's room, then display the alt-text if (!inner.IsEmpty()) { @@ -618,8 +618,8 @@ ImageFrame::Paint(nsIPresContext& aPresContext, GetInnerArea(&aPresContext, inner); if (mImageLoader.GetLoadImageFailed()) { float p2t = aPresContext.GetPixelsToTwips(); - inner.width = nscoord(p2t * image->GetWidth()); - inner.height = nscoord(p2t * image->GetHeight()); + inner.width = NSIntPixelsToTwips(image->GetWidth(), p2t); + inner.height = NSIntPixelsToTwips(image->GetHeight(), p2t); } aRenderingContext.DrawImage(image, inner); @@ -745,8 +745,8 @@ ImageFrame::HandleEvent(nsIPresContext& aPresContext, // the image's borders. nsRect inner; GetInnerArea(&aPresContext, inner); - nscoord x = nscoord(t2p * (aEvent->point.x - inner.x)); - nscoord y = nscoord(t2p * (aEvent->point.y - inner.y)); + PRInt32 x = NSTwipsToIntPixels((aEvent->point.x - inner.x), t2p); + PRInt32 y = NSTwipsToIntPixels((aEvent->point.y - inner.y), t2p); nsresult r = map->IsInside(x, y, docURL, absURL, target, altText, &suppress); NS_IF_RELEASE(docURL); @@ -771,8 +771,8 @@ ImageFrame::HandleEvent(nsIPresContext& aPresContext, // Note: We don't subtract out the border/padding here to remain // compatible with navigator. [ick] - nscoord x = nscoord(t2p * aEvent->point.x); - nscoord y = nscoord(t2p * aEvent->point.y); + PRInt32 x = NSTwipsToIntPixels(aEvent->point.x, t2p); + PRInt32 y = NSTwipsToIntPixels(aEvent->point.y, t2p); char cbuf[50]; PR_snprintf(cbuf, sizeof(cbuf), "?%d,%d", x, y); absURL.Append(cbuf); @@ -819,8 +819,8 @@ ImageFrame::GetCursorAndContentAt(nsIPresContext& aPresContext, GetInnerArea(&aPresContext, inner); aCursor = NS_STYLE_CURSOR_DEFAULT; float t2p = aPresContext.GetTwipsToPixels(); - nscoord x = nscoord(t2p * (aPoint.x - inner.x)); - nscoord y = nscoord(t2p * (aPoint.y - inner.y)); + PRInt32 x = NSTwipsToIntPixels((aPoint.x - inner.x), t2p); + PRInt32 y = NSTwipsToIntPixels((aPoint.y - inner.y), t2p); if (NS_OK == map->IsInside(x, y)) { aCursor = NS_STYLE_CURSOR_HAND; } @@ -1023,7 +1023,7 @@ nsHTMLImage::MapAttributesInto(nsIStyleContext* aContext, nsStyleSpacing* spacing = (nsStyleSpacing*) aContext->GetMutableStyleData(eStyleStruct_Spacing); float p2t = aPresContext->GetPixelsToTwips(); - nsStyleCoord three(nscoord(p2t*3)); + nsStyleCoord three(NSIntPixelsToTwips(3, p2t)); switch (align) { case NS_STYLE_TEXT_ALIGN_LEFT: display->mFloats = NS_STYLE_FLOAT_LEFT; diff --git a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp index 05c66f71b10..1e0e80fcdbf 100644 --- a/mozilla/layout/html/base/src/nsHTMLTagContent.cpp +++ b/mozilla/layout/html/base/src/nsHTMLTagContent.cpp @@ -1309,7 +1309,7 @@ nsHTMLTagContent::MapImagePropertiesInto(nsIStyleContext* aContext, // width: value GetAttribute(nsHTMLAtoms::width, value); if (value.GetUnit() == eHTMLUnit_Pixel) { - nscoord twips = nscoord(p2t * value.GetPixelValue()); + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); pos->mWidth.SetCoordValue(twips); } else if (value.GetUnit() == eHTMLUnit_Percent) { @@ -1319,7 +1319,7 @@ nsHTMLTagContent::MapImagePropertiesInto(nsIStyleContext* aContext, // height: value GetAttribute(nsHTMLAtoms::height, value); if (value.GetUnit() == eHTMLUnit_Pixel) { - nscoord twips = nscoord(p2t * value.GetPixelValue()); + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); pos->mHeight.SetCoordValue(twips); } else if (value.GetUnit() == eHTMLUnit_Percent) { @@ -1329,7 +1329,7 @@ nsHTMLTagContent::MapImagePropertiesInto(nsIStyleContext* aContext, // hspace: value GetAttribute(nsHTMLAtoms::hspace, value); if (value.GetUnit() == eHTMLUnit_Pixel) { - nscoord twips = nscoord(p2t * value.GetPixelValue()); + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); spacing->mMargin.SetRight(nsStyleCoord(twips)); } else if (value.GetUnit() == eHTMLUnit_Percent) { @@ -1340,7 +1340,7 @@ nsHTMLTagContent::MapImagePropertiesInto(nsIStyleContext* aContext, // vspace: value GetAttribute(nsHTMLAtoms::vspace, value); if (value.GetUnit() == eHTMLUnit_Pixel) { - nscoord twips = nscoord(p2t * value.GetPixelValue()); + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); spacing->mMargin.SetBottom(nsStyleCoord(twips)); } else if (value.GetUnit() == eHTMLUnit_Percent) { @@ -1370,7 +1370,7 @@ nsHTMLTagContent::MapImageBorderInto(nsIStyleContext* aContext, } float p2t = aPresContext->GetPixelsToTwips(); - nscoord twips = nscoord(p2t * value.GetPixelValue()); + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); // Fixup border-padding sums: subtract out the old size and then // add in the new size. diff --git a/mozilla/layout/html/base/src/nsImageMap.cpp b/mozilla/layout/html/base/src/nsImageMap.cpp index 2122aa7f02b..a568255000d 100644 --- a/mozilla/layout/html/base/src/nsImageMap.cpp +++ b/mozilla/layout/html/base/src/nsImageMap.cpp @@ -25,9 +25,6 @@ #include "nsXIFConverter.h" #include "nsISizeOfHandler.h" -#undef SCALE -#define SCALE(a,b) nscoord((a) * (b)) - class Area { public: Area(const nsString& aBaseURL, const nsString& aHREF, @@ -455,10 +452,10 @@ void RectArea::Draw(nsIPresContext& aCX, nsIRenderingContext& aRC) { if (mNumCoords >= 4) { float p2t = aCX.GetPixelsToTwips(); - nscoord x1 = SCALE(p2t, mCoords[0]); - nscoord y1 = SCALE(p2t, mCoords[1]); - nscoord x2 = SCALE(p2t, mCoords[2]); - nscoord y2 = SCALE(p2t, mCoords[3]); + nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t); + nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t); + nscoord x2 = NSIntPixelsToTwips(mCoords[2], p2t); + nscoord y2 = NSIntPixelsToTwips(mCoords[3], p2t); if ((x1 > x2)|| (y1 > y2)) { return; } @@ -563,11 +560,11 @@ void PolyArea::Draw(nsIPresContext& aCX, nsIRenderingContext& aRC) { if (mNumCoords >= 6) { float p2t = aCX.GetPixelsToTwips(); - nscoord x0 = SCALE(p2t, mCoords[0]); - nscoord y0 = SCALE(p2t, mCoords[1]); + nscoord x0 = NSIntPixelsToTwips(mCoords[0], p2t); + nscoord y0 = NSIntPixelsToTwips(mCoords[1], p2t); for (PRInt32 i = 2; i < mNumCoords; i += 2) { - nscoord x1 = SCALE(p2t, mCoords[i]); - nscoord y1 = SCALE(p2t, mCoords[i+1]); + nscoord x1 = NSIntPixelsToTwips(mCoords[i], p2t); + nscoord y1 = NSIntPixelsToTwips(mCoords[i+1], p2t); aRC.DrawLine(x0, y0, x1, y1); x0 = x1; y0 = y1; @@ -631,9 +628,9 @@ void CircleArea::Draw(nsIPresContext& aCX, nsIRenderingContext& aRC) { if (mNumCoords >= 3) { float p2t = aCX.GetPixelsToTwips(); - nscoord x1 = SCALE(p2t, mCoords[0]); - nscoord y1 = SCALE(p2t, mCoords[1]); - nscoord radius = SCALE(p2t, mCoords[2]); + nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t); + nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t); + nscoord radius = NSIntPixelsToTwips(mCoords[2], p2t); if (radius < 0) { return; } diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 69813cdfa07..311c9d0fcdd 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -163,7 +163,7 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, } else { float p2t = aPresContext->GetPixelsToTwips(); - aMetrics.width = nscoord(p2t * EMBED_DEF_DIM); + aMetrics.width = NSIntPixelsToTwips(EMBED_DEF_DIM, p2t); } } if (!haveHeight) { @@ -172,7 +172,7 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, } else { float p2t = aPresContext->GetPixelsToTwips(); - aMetrics.height = nscoord(p2t * EMBED_DEF_DIM); + aMetrics.height = NSIntPixelsToTwips(EMBED_DEF_DIM, p2t); } } aMetrics.ascent = aMetrics.height; @@ -293,7 +293,7 @@ nsObjectFrame::Paint(nsIPresContext& aPresContext, aRenderingContext.SetColor(NS_RGB(0, 0, 0)); aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height); float p2t = aPresContext.GetPixelsToTwips(); - nscoord px3 = nscoord(3 * p2t); + nscoord px3 = NSIntPixelsToTwips(3, p2t); nsAutoString tmp; nsIAtom* atom = mContent->GetTag(); if (nsnull != atom) { diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp index a9e1dd65266..c1b62f4ee1b 100644 --- a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp +++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp @@ -161,10 +161,10 @@ nsPlaceholderFrame::Paint(nsIPresContext& aPresContext, if (nsIFrame::GetShowFrameBorders()) { float p2t = aPresContext.GetPixelsToTwips(); aRenderingContext.SetColor(NS_RGB(0, 255, 255)); - nscoord x = nscoord(-5 * p2t); - aRenderingContext.FillRect(x, 0, nscoord(13 * p2t), nscoord(3 * p2t)); - nscoord y = nscoord(-10 * p2t); - aRenderingContext.FillRect(0, y, nscoord(3 * p2t), nscoord(10 * p2t)); + nscoord x = NSIntPixelsToTwips(-5, p2t); + aRenderingContext.FillRect(x, 0, NSIntPixelsToTwips(13, p2t), NSIntPixelsToTwips(3, p2t)); + nscoord y = NSIntPixelsToTwips(-10, p2t); + aRenderingContext.FillRect(0, y, NSIntPixelsToTwips(3, p2t), NSIntPixelsToTwips(10, p2t)); } return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsRootPart.cpp b/mozilla/layout/html/base/src/nsRootPart.cpp index 0f32dae158b..d8329378084 100644 --- a/mozilla/layout/html/base/src/nsRootPart.cpp +++ b/mozilla/layout/html/base/src/nsRootPart.cpp @@ -356,7 +356,7 @@ NS_METHOD RootContentFrame::Reflow(nsIPresContext& aPresContext, aPresContext.GetPageHeight()); nsIDeviceContext *dx = aPresContext.GetDeviceContext(); PRInt32 extra = aReflowState.maxSize.width - PAGE_SPACING_TWIPS*2 - - pageSize.width - NS_TO_INT_ROUND(dx->GetScrollBarWidth()); + pageSize.width - NSToCoordRound(dx->GetScrollBarWidth()); NS_RELEASE(dx); // Note: nscoord is an unsigned type so don't combine these diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 5656e238817..62a5c82e12d 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -167,8 +167,8 @@ nsScrollBodyFrame::Reflow(nsIPresContext& aPresContext, // Place and size the page. If the page is narrower than our // max width then center it horizontally nsIDeviceContext *dx = aPresContext.GetDeviceContext(); - PRInt32 extra = aReflowState.maxSize.width - kidSize.width - - NS_TO_INT_ROUND(dx->GetScrollBarWidth()); + nscoord extra = aReflowState.maxSize.width - kidSize.width - + NSToCoordRound(dx->GetScrollBarWidth()); NS_RELEASE(dx); nscoord x = extra > 0 ? extra / 2 : 0; @@ -380,7 +380,7 @@ nsScrollInnerFrame::Reflow(nsIPresContext& aPresContext, nsSize maxSize; nsIDeviceContext* dc = aPresContext.GetDeviceContext(); maxSize.width = aReflowState.maxSize.width - - NS_TO_INT_ROUND(dc->GetScrollBarWidth()); + NSToCoordRound(dc->GetScrollBarWidth()); NS_RELEASE(dc); maxSize.height = NS_UNCONSTRAINEDSIZE; diff --git a/mozilla/layout/html/base/src/nsSpacerPart.cpp b/mozilla/layout/html/base/src/nsSpacerPart.cpp index e7f5cb8ef54..11fbe57211a 100644 --- a/mozilla/layout/html/base/src/nsSpacerPart.cpp +++ b/mozilla/layout/html/base/src/nsSpacerPart.cpp @@ -141,21 +141,21 @@ SpacerFrame::InlineReflow(nsCSSLineLayout& aLineLayout, switch (type) { case TYPE_WORD: if (0 != width) { - aMetrics.width = nscoord(width * p2t); + aMetrics.width = NSIntPixelsToTwips(width, p2t); } break; case TYPE_LINE: if (0 != width) { rv = NS_INLINE_LINE_BREAK_AFTER(0); - aMetrics.height = nscoord(width * p2t); + aMetrics.height = NSIntPixelsToTwips(width, p2t); aMetrics.ascent = aMetrics.height; } break; case TYPE_IMAGE: - aMetrics.width = nscoord(width * p2t); - aMetrics.height = nscoord(height * p2t); + aMetrics.width = NSIntPixelsToTwips(width, p2t); + aMetrics.height = NSIntPixelsToTwips(height, p2t); aMetrics.ascent = aMetrics.height; break; } diff --git a/mozilla/layout/html/base/src/nsTextContent.cpp b/mozilla/layout/html/base/src/nsTextContent.cpp index 001342aee77..5ab77d64c32 100644 --- a/mozilla/layout/html/base/src/nsTextContent.cpp +++ b/mozilla/layout/html/base/src/nsTextContent.cpp @@ -514,7 +514,7 @@ NS_METHOD TextFrame::Paint(nsIPresContext& aPresContext, #if XXX if (font->mThreeD) { - nscoord onePixel = nscoord(1.0f * aPresContext.GetPixelsToTwips()); + nscoord onePixel = NSIntPixelsToTwips(1, aPresContext.GetPixelsToTwips()); aRenderingContext.SetColor(color->mBackgroundColor); PaintRegularText(aPresContext, aRenderingContext, aDirtyRect, onePixel, onePixel); } diff --git a/mozilla/layout/html/content/src/nsObjectContent.cpp b/mozilla/layout/html/content/src/nsObjectContent.cpp index 2c13647a2dc..ca9fd1bf73b 100644 --- a/mozilla/layout/html/content/src/nsObjectContent.cpp +++ b/mozilla/layout/html/content/src/nsObjectContent.cpp @@ -101,7 +101,7 @@ nsObjectContent::MapAttributesInto(nsIStyleContext* aContext, nsStyleSpacing* spacing = (nsStyleSpacing*) aContext->GetMutableStyleData(eStyleStruct_Spacing); float p2t = aPresContext->GetPixelsToTwips(); - nsStyleCoord three(nscoord(p2t*3)); + nsStyleCoord three(NSIntPixelsToTwips(3, p2t)); switch (align) { case NS_STYLE_TEXT_ALIGN_LEFT: display->mFloats = NS_STYLE_FLOAT_LEFT; diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index cf1b6c98d79..d7d83c3e9f2 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -1158,7 +1158,7 @@ HTMLContentSink::ScrollToRef() #if 0 nsIPresContext* cx = shell->GetPresContext(); float t2p = cx->GetTwipsToPixels(); -printf("x=%d y=%d\n", nscoord(x * t2p), nscoord(y * t2p)); +printf("x=%d y=%d\n", NSTwipsToIntPixels(x, t2p), NSTwipsToIntPixels(y, t2p)); NS_RELEASE(cx); #endif sview->SetScrollPreference(mOriginalScrollPreference); diff --git a/mozilla/layout/html/document/src/nsHTMLFrame.cpp b/mozilla/layout/html/document/src/nsHTMLFrame.cpp index b462b7b65c3..384a3757896 100644 --- a/mozilla/layout/html/document/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/document/src/nsHTMLFrame.cpp @@ -257,10 +257,10 @@ nsHTMLFrameOuterFrame::GetDesiredSize(nsIPresContext* aPresContext, // XXX this needs to be changed from (200,200) to a better default for inline frames if (0 == (ss & NS_SIZE_HAS_WIDTH)) { - size.width = (nscoord)(200.0 * p2t + 0.5); + size.width = NSIntPixelsToTwips(200, p2t); } if (0 == (ss & NS_SIZE_HAS_HEIGHT)) { - size.height = (nscoord)(200 * p2t + 0.5); + size.height = NSIntPixelsToTwips(200, p2t); } aDesiredSize.width = size.width; @@ -550,8 +550,8 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext, nsIWidget* widget = view->GetWidget(); NS_RELEASE(view); - nsRect webBounds(0, 0, NS_TO_INT_ROUND(aSize.width * t2p), - NS_TO_INT_ROUND(aSize.height * t2p)); + nsRect webBounds(0, 0, NSToCoordRound(aSize.width * t2p), + NSToCoordRound(aSize.height * t2p)); mWebShell->Init(widget->GetNativeData(NS_NATIVE_WIDGET), webBounds, content->GetScrolling()); @@ -613,8 +613,8 @@ nsHTMLFrameInnerFrame::Reflow(nsIPresContext& aPresContext, float t2p = aPresContext.GetTwipsToPixels(); nsRect subBounds; mWebShell->GetBounds(subBounds); - subBounds.width = NS_TO_INT_ROUND(aDesiredSize.width * t2p); - subBounds.height = NS_TO_INT_ROUND(aDesiredSize.height * t2p); + subBounds.width = NSToCoordRound(aDesiredSize.width * t2p); + subBounds.height = NSToCoordRound(aDesiredSize.height * t2p); mWebShell->SetBounds(subBounds); aStatus = NS_FRAME_COMPLETE; diff --git a/mozilla/layout/html/document/src/nsHTMLFrameset.cpp b/mozilla/layout/html/document/src/nsHTMLFrameset.cpp index e4e18ad138c..a90ecd77d5e 100644 --- a/mozilla/layout/html/document/src/nsHTMLFrameset.cpp +++ b/mozilla/layout/html/document/src/nsHTMLFrameset.cpp @@ -163,7 +163,7 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsIPresContext* aPresContext, nscoord // Now that we know the size we are laying out in, turn fixed // pixel dimensions into percents. // XXX maybe use UnitConverter for proper rounding? MMP - aValues[i] = (nscoord) NS_TO_INT_ROUND(100 * p2t * aSpecs[i].mValue / aSize); + aValues[i] = NSToCoordRound(100 * p2t * aSpecs[i].mValue / aSize); if (aValues[i] < 1) aValues[i] = 1; pixel += aValues[i]; break; @@ -288,7 +288,7 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsIPresContext* aPresContext, nscoord PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsIPresContext* aPresContext) { float p2t = aPresContext->GetPixelsToTwips(); - return NS_TO_INT_ROUND(p2t * 6); + return NSIntPixelsToTwips(6, p2t); } PRIntn @@ -859,10 +859,10 @@ nsHTMLFramesetBorderFrame::Paint(nsIPresContext& aPresContext, aRenderingContext.SetColor (color); aRenderingContext.DrawLine (x0, y0, x1, y1); if (mVertical) { - x0 += nscoord(p2t + 0.5); + x0 += NSIntPixelsToTwips(1, p2t); x1 = x0; } else { - y0 += nscoord(p2t + 0.5); + y0 += NSIntPixelsToTwips(1, p2t); y1 = y0; } } @@ -894,8 +894,8 @@ NS_METHOD nsHTMLFramesetBorderFrame::HandleEvent(nsIPresContext& aPresContext, aEventStatus = nsEventStatus_eConsumeNoDefault; } if (eMouseDown == mLastMouseState) { - //((nsInput*)mContent)->SetClickPoint(NS_TO_INT_ROUND(conv * aEvent->point.x), - // NS_TO_INT_ROUND(conv * aEvent->point.y)); + //((nsInput*)mContent)->SetClickPoint(NSToCoordRound(conv * aEvent->point.x), + // NSToCoordRound(conv * aEvent->point.y)); //MouseClicked(&aPresContext); mLastMouseState = eMouseDrag; } @@ -904,8 +904,8 @@ NS_METHOD nsHTMLFramesetBorderFrame::HandleEvent(nsIPresContext& aPresContext, break; case NS_MOUSE_LEFT_BUTTON_UP: if (eMouseDrag == mLastMouseState) { - //((nsInput*)mContent)->SetClickPoint(NS_TO_INT_ROUND(conv * aEvent->point.x), - // NS_TO_INT_ROUND(conv * aEvent->point.y)); + //((nsInput*)mContent)->SetClickPoint(NSToCoordRound(conv * aEvent->point.x), + // NSToCoordRound(conv * aEvent->point.y)); //MouseClicked(&aPresContext); } mLastMouseState = eMouseUp; diff --git a/mozilla/layout/html/forms/src/nsInputButton.cpp b/mozilla/layout/html/forms/src/nsInputButton.cpp index 2f597ec07c2..652594a23ac 100644 --- a/mozilla/layout/html/forms/src/nsInputButton.cpp +++ b/mozilla/layout/html/forms/src/nsInputButton.cpp @@ -124,8 +124,8 @@ public: nsButtonType GetButtonType() const; nsButtonTagType GetButtonTagType() const; - virtual PRInt32 GetVerticalBorderWidth(float aPixToTwip) const; - virtual PRInt32 GetHorizontalBorderWidth(float aPixToTwip) const; + virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const; + virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const; virtual nscoord GetVerticalInsidePadding(float aPixToTwip, nscoord aInnerHeight) const; virtual nscoord GetHorizontalInsidePadding(float aPixToTwip, @@ -360,12 +360,12 @@ nsInputButtonFrame::GetButtonTagType() const return button->GetButtonTagType(); } -PRInt32 nsInputButtonFrame::GetVerticalBorderWidth(float aPixToTwip) const +nscoord nsInputButtonFrame::GetVerticalBorderWidth(float aPixToTwip) const { - return (int)(4 * aPixToTwip + 0.5); + return NSIntPixelsToTwips(4, aPixToTwip); } -PRInt32 nsInputButtonFrame::GetHorizontalBorderWidth(float aPixToTwip) const +nscoord nsInputButtonFrame::GetHorizontalBorderWidth(float aPixToTwip) const { return GetVerticalBorderWidth(aPixToTwip); } @@ -373,12 +373,12 @@ PRInt32 nsInputButtonFrame::GetHorizontalBorderWidth(float aPixToTwip) const nscoord nsInputButtonFrame::GetVerticalInsidePadding(float aPixToTwip, nscoord aInnerHeight) const { - //return (int)(4 * aPixToTwip + 0.5); + //return NSIntPixelsToTwips(4, aPixToTwip); #ifdef XP_PC - return (nscoord)(aInnerHeight * .25 + 0.5); + return (nscoord)NSToIntRound((float)aInnerHeight * 0.25f); #endif #ifdef XP_UNIX - return (nscoord)(aInnerHeight * .50 + 0.5); + return (nscoord)NSToIntRound((float)aInnerHeight * 0.50f); #endif } @@ -388,16 +388,16 @@ nscoord nsInputButtonFrame::GetHorizontalInsidePadding(float aPixToTwip, { #ifdef XP_PC if (kBackwardMode == GetMode()) { - return (nscoord)((aInnerWidth * .25) + 0.5); + return (nscoord)NSToIntRound(float(aInnerWidth) * 0.25f); } else { - return (nscoord)(10 * aPixToTwip + 0.5)+8; + return NSIntPixelsToTwips(10, aPixToTwip) + 8; } #endif #ifdef XP_UNIX if (kBackwardMode == GetMode()) { - return (nscoord)(aInnerWidth * .5 + 0.5); + return (nscoord)NSToIntRound(float(aInnerWidth) * 0.5f); } else { - return (nscoord)(20 * aPixToTwip + 0.5); + return NSIntPixelsToTwips(20, aPixToTwip); } #endif } diff --git a/mozilla/layout/html/forms/src/nsInputCheckbox.cpp b/mozilla/layout/html/forms/src/nsInputCheckbox.cpp index 94ceff8b1dc..8a33ffe2232 100644 --- a/mozilla/layout/html/forms/src/nsInputCheckbox.cpp +++ b/mozilla/layout/html/forms/src/nsInputCheckbox.cpp @@ -84,12 +84,12 @@ nsInputCheckboxFrame::GetDesiredSize(nsIPresContext* aPresContext, { float p2t = aPresContext->GetPixelsToTwips(); #ifdef XP_PC - aDesiredWidgetSize.width = (int)(12 * p2t); - aDesiredWidgetSize.height = (int)(12 * p2t); + aDesiredWidgetSize.width = NSIntPixelsToTwips(12, p2t); + aDesiredWidgetSize.height = NSIntPixelsToTwips(12, p2t); #endif #ifdef XP_PC - aDesiredWidgetSize.width = (int)(20 * p2t); - aDesiredWidgetSize.height = (int)(20 * p2t); + aDesiredWidgetSize.width = NSIntPixelsToTwips(20, p2t); + aDesiredWidgetSize.height = NSIntPixelsToTwips(20, p2t); #endif aDesiredLayoutSize.width = aDesiredWidgetSize.width; aDesiredLayoutSize.height = aDesiredWidgetSize.height; @@ -158,7 +158,7 @@ void nsInputCheckbox::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { float p2t = aPresContext->GetPixelsToTwips(); - nscoord pad = (int)(3 * p2t + 0.5); + nscoord pad = NSIntPixelsToTwips(3, p2t); // add left and right padding around the radio button via css nsStyleSpacing* spacing = (nsStyleSpacing*) aContext->GetMutableStyleData(eStyleStruct_Spacing); @@ -167,7 +167,7 @@ void nsInputCheckbox::MapAttributesInto(nsIStyleContext* aContext, spacing->mMargin.SetLeft(left); } if (eStyleUnit_Null == spacing->mMargin.GetRightUnit()) { - nsStyleCoord right((int)(5 * p2t + 0.5)); + nsStyleCoord right(NSIntPixelsToTwips(5, p2t)); spacing->mMargin.SetRight(right); } // add bottom padding if backward mode diff --git a/mozilla/layout/html/forms/src/nsInputFrame.cpp b/mozilla/layout/html/forms/src/nsInputFrame.cpp index f0bb098dca6..9a784a2ac80 100644 --- a/mozilla/layout/html/forms/src/nsInputFrame.cpp +++ b/mozilla/layout/html/forms/src/nsInputFrame.cpp @@ -78,17 +78,17 @@ nsFormRenderingMode nsInputFrame::GetMode() const } } -PRInt32 nsInputFrame::GetScrollbarWidth(float aPixToTwip) +nscoord nsInputFrame::GetScrollbarWidth(float aPixToTwip) { - return (PRInt32)((19 * aPixToTwip) + 0.5); // XXX this is windows + return NSIntPixelsToTwips(19, aPixToTwip); // XXX this is windows } -PRInt32 nsInputFrame::GetVerticalBorderWidth(float aPixToTwip) const +nscoord nsInputFrame::GetVerticalBorderWidth(float aPixToTwip) const { - return (int)(3 * aPixToTwip + 0.5); + return NSIntPixelsToTwips(3, aPixToTwip); } -PRInt32 nsInputFrame::GetHorizontalBorderWidth(float aPixToTwip) const +nscoord nsInputFrame::GetHorizontalBorderWidth(float aPixToTwip) const { return GetVerticalBorderWidth(aPixToTwip); } @@ -96,7 +96,7 @@ PRInt32 nsInputFrame::GetHorizontalBorderWidth(float aPixToTwip) const nscoord nsInputFrame::GetVerticalInsidePadding(float aPixToTwip, nscoord aInnerHeight) const { - return (nscoord)(3 * aPixToTwip + 0.5); + return NSIntPixelsToTwips(3, aPixToTwip); } nscoord nsInputFrame::GetHorizontalInsidePadding(float aPixToTwip, @@ -398,9 +398,9 @@ NS_METHOD nsInputFrame::HandleEvent(nsIPresContext& aPresContext, widget->SetFocus(); NS_RELEASE(widget); NS_RELEASE(view); */ - float conv = aPresContext.GetTwipsToPixels(); - ((nsInput*)mContent)->SetClickPoint(NS_TO_INT_ROUND(conv * aEvent->point.x), - NS_TO_INT_ROUND(conv * aEvent->point.y)); + float t2p = aPresContext.GetTwipsToPixels(); + ((nsInput*)mContent)->SetClickPoint(NSTwipsToIntPixels(aEvent->point.x, t2p), + NSTwipsToIntPixels(aEvent->point.y, t2p)); MouseClicked(&aPresContext); //return PR_FALSE; } @@ -495,7 +495,7 @@ nsInputFrame::CalculateSize (nsIPresContext* aPresContext, nsInputFrame* aFrame, // determine the width if (eContentAttr_HasValue == colStatus) { // col attr will provide width if (aSpec.mColSizeAttrInPixels) { - aBounds.width = (int) (((float)colAttr.GetPixelValue()) * p2t); + aBounds.width = NSIntPixelsToTwips(colAttr.GetPixelValue(), p2t); } else { PRInt32 col = ((colAttr.GetUnit() == eHTMLUnit_Pixel) ? colAttr.GetPixelValue() : colAttr.GetIntValue()); diff --git a/mozilla/layout/html/forms/src/nsInputFrame.h b/mozilla/layout/html/forms/src/nsInputFrame.h index 7818553cb08..ced82b2ff31 100644 --- a/mozilla/layout/html/forms/src/nsInputFrame.h +++ b/mozilla/layout/html/forms/src/nsInputFrame.h @@ -171,9 +171,9 @@ public: // XXX similar functionality needs to be added to widget library and these // need to change to use it. - static PRInt32 GetScrollbarWidth(float aPixToTwip); - virtual PRInt32 GetVerticalBorderWidth(float aPixToTwip) const; - virtual PRInt32 GetHorizontalBorderWidth(float aPixToTwip) const; + static nscoord GetScrollbarWidth(float aPixToTwip); + virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const; + virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const; virtual nscoord GetVerticalInsidePadding(float aPixToTwip, nscoord aInnerHeight) const; virtual nscoord GetHorizontalInsidePadding(float aPixToTwip, diff --git a/mozilla/layout/html/forms/src/nsInputRadio.cpp b/mozilla/layout/html/forms/src/nsInputRadio.cpp index 0f4ae98d6ac..4ba5ef5f2c0 100644 --- a/mozilla/layout/html/forms/src/nsInputRadio.cpp +++ b/mozilla/layout/html/forms/src/nsInputRadio.cpp @@ -87,8 +87,8 @@ nsInputRadioFrame::GetDesiredSize(nsIPresContext* aPresContext, nsSize& aDesiredWidgetSize) { float p2t = aPresContext->GetPixelsToTwips(); - aDesiredWidgetSize.width = (int)(12 * p2t); - aDesiredWidgetSize.height = (int)(12 * p2t); + aDesiredWidgetSize.width = NSIntPixelsToTwips(12, p2t); + aDesiredWidgetSize.height = NSIntPixelsToTwips(12, p2t); aDesiredLayoutSize.width = aDesiredWidgetSize.width; aDesiredLayoutSize.height = aDesiredWidgetSize.height; aDesiredLayoutSize.ascent = aDesiredLayoutSize.height; @@ -139,7 +139,7 @@ void nsInputRadio::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { float p2t = aPresContext->GetPixelsToTwips(); - nscoord pad = (int)(3 * p2t + 0.5); + nscoord pad = NSIntPixelsToTwips(3, p2t); // add left and right padding around the radio button via css nsStyleSpacing* spacing = (nsStyleSpacing*) aContext->GetMutableStyleData(eStyleStruct_Spacing); @@ -148,7 +148,7 @@ void nsInputRadio::MapAttributesInto(nsIStyleContext* aContext, spacing->mMargin.SetLeft(left); } if (eStyleUnit_Null == spacing->mMargin.GetRightUnit()) { - nsStyleCoord right((int)(5 * p2t + 0.5)); + nsStyleCoord right(NSIntPixelsToTwips(5, p2t)); spacing->mMargin.SetRight(right); } // add bottom padding if backward mode diff --git a/mozilla/layout/html/forms/src/nsInputText.cpp b/mozilla/layout/html/forms/src/nsInputText.cpp index 1102246a9cb..5b50d1dd392 100644 --- a/mozilla/layout/html/forms/src/nsInputText.cpp +++ b/mozilla/layout/html/forms/src/nsInputText.cpp @@ -49,8 +49,8 @@ public: virtual const nsIID& GetIID(); - virtual PRInt32 GetVerticalBorderWidth(float aPixToTwip) const; - virtual PRInt32 GetHorizontalBorderWidth(float aPixToTwip) const; + virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const; + virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const; virtual nscoord GetVerticalInsidePadding(float aPixToTwip, nscoord aInnerHeight) const; virtual nscoord GetHorizontalInsidePadding(float aPixToTwip, @@ -78,12 +78,12 @@ nsInputTextFrame::~nsInputTextFrame() { } -PRInt32 nsInputTextFrame::GetVerticalBorderWidth(float aPixToTwip) const +nscoord nsInputTextFrame::GetVerticalBorderWidth(float aPixToTwip) const { - return (int)(4 * aPixToTwip + 0.5); + return NSIntPixelsToTwips(4, aPixToTwip); } -PRInt32 nsInputTextFrame::GetHorizontalBorderWidth(float aPixToTwip) const +nscoord nsInputTextFrame::GetHorizontalBorderWidth(float aPixToTwip) const { return GetVerticalBorderWidth(aPixToTwip); } @@ -96,13 +96,13 @@ nscoord nsInputTextFrame::GetVerticalInsidePadding(float aPixToTwip, nsAutoString type; ((nsInput*)mContent)->GetType(type); if (type.EqualsIgnoreCase("textarea")) { - return (nscoord)((aInnerHeight * .40) + 0.5); + return (nscoord)NSToIntRound(float(aInnerHeight) * 0.40f); } else { - return (nscoord)((aInnerHeight * .25) + 0.5); + return (nscoord)NSToIntRound(float(aInnerHeight) * 0.25f); } #endif #ifdef XP_UNIX - return (nscoord)(10 * aPixToTwip + 0.5); // XXX this is probably wrong + return NSIntPixelsToTwips(10, aPixToTwip); // XXX this is probably wrong #endif } @@ -119,7 +119,7 @@ nscoord nsInputTextFrame::GetHorizontalInsidePadding(float aPixToTwip, } else { padding = (nscoord)(55 * aCharWidth / 100); } - nscoord min = (nscoord)((3 * aPixToTwip) + 0.5); + nscoord min = NSIntPixelsToTwips(3, aPixToTwip); if (padding > min) { return padding; } else { @@ -127,7 +127,7 @@ nscoord nsInputTextFrame::GetHorizontalInsidePadding(float aPixToTwip, } #endif #ifdef XP_UNIX - return (nscoord)(6 * aPixToTwip + 0.5); // XXX this is probably wrong + return NSIntPixelsToTwips(6, aPixToTwip); // XXX this is probably wrong #endif } @@ -210,7 +210,7 @@ nsInputTextFrame::GetDesiredSize(nsIPresContext* aPresContext, if (kInputText_Area == textType) { float p2t = aPresContext->GetPixelsToTwips(); - PRInt32 scrollbarWidth = GetScrollbarWidth(p2t); + nscoord scrollbarWidth = GetScrollbarWidth(p2t); if (!heightExplicit) { size.height += scrollbarWidth; diff --git a/mozilla/layout/html/forms/src/nsSelect.cpp b/mozilla/layout/html/forms/src/nsSelect.cpp index 383a7ae1e9d..db141413e12 100644 --- a/mozilla/layout/html/forms/src/nsSelect.cpp +++ b/mozilla/layout/html/forms/src/nsSelect.cpp @@ -60,8 +60,8 @@ public: virtual const nsIID& GetIID(); - virtual PRInt32 GetVerticalBorderWidth(float aPixToTwip) const; - virtual PRInt32 GetHorizontalBorderWidth(float aPixToTwip) const; + virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const; + virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const; virtual nscoord GetVerticalInsidePadding(float aPixToTwip, nscoord aInnerHeight) const; virtual nscoord GetHorizontalInsidePadding(float aPixToTwip, @@ -163,12 +163,12 @@ nsSelectFrame::~nsSelectFrame() } -PRInt32 nsSelectFrame::GetVerticalBorderWidth(float aPixToTwip) const +nscoord nsSelectFrame::GetVerticalBorderWidth(float aPixToTwip) const { - return (int)(1 * aPixToTwip + 0.5); + return NSIntPixelsToTwips(1, aPixToTwip); } -PRInt32 nsSelectFrame::GetHorizontalBorderWidth(float aPixToTwip) const +nscoord nsSelectFrame::GetHorizontalBorderWidth(float aPixToTwip) const { return GetVerticalBorderWidth(aPixToTwip); } @@ -177,10 +177,10 @@ nscoord nsSelectFrame::GetVerticalInsidePadding(float aPixToTwip, nscoord aInnerHeight) const { #ifdef XP_PC - return (nscoord)((aInnerHeight * .15) + 0.5); + return (nscoord)NSToIntRound(float(aInnerHeight) * 0.15f); #endif #ifdef XP_UNIX - return (nscoord)(1 * aPixToTwip + 0.5); // XXX this is probably wrong + return NSIntPixelsToTwips(1, aPixToTwip); // XXX this is probably wrong #endif } @@ -189,8 +189,8 @@ PRInt32 nsSelectFrame::GetHorizontalInsidePadding(float aPixToTwip, nscoord aCharWidth) const { #ifdef XP_PC - nscoord padding = (nscoord)((aCharWidth * .40) + 0.5); - nscoord min = (nscoord)((3 * aPixToTwip) + 0.5); + nscoord padding = (nscoord)NSToIntRound(float(aCharWidth) * 0.40f); + nscoord min = NSIntPixelsToTwips(3, aPixToTwip); if (padding > min) { return padding; } else { @@ -198,7 +198,7 @@ PRInt32 nsSelectFrame::GetHorizontalInsidePadding(float aPixToTwip, } #endif #ifdef XP_UNIX - return (nscoord)(7 * aPixToTwip + 0.5); // XXX this is probably wrong + return NSIntPixelsToTwips(7, aPixToTwip); // XXX this is probably wrong #endif } @@ -303,7 +303,7 @@ nsSelectFrame::GetWidgetInitData(nsIPresContext& aPresContext) if (select->mIsComboBox) { nsComboBoxInitData* initData = new nsComboBoxInitData(); float twipToPix = aPresContext.GetTwipsToPixels(); - initData->mDropDownHeight = NS_TO_INT_ROUND(mWidgetSize.height * twipToPix); + initData->mDropDownHeight = NSTwipsToIntPixels(mWidgetSize.height, twipToPix); return initData; } else { diff --git a/mozilla/layout/html/style/src/nsCSSDeclaration.cpp b/mozilla/layout/html/style/src/nsCSSDeclaration.cpp index 38f4f48d504..9043f5df4c3 100644 --- a/mozilla/layout/html/style/src/nsCSSDeclaration.cpp +++ b/mozilla/layout/html/style/src/nsCSSDeclaration.cpp @@ -322,29 +322,29 @@ nscoord nsCSSValue::GetLengthTwips(void) const if (IsFixedLengthUnit()) { switch (mUnit) { case eCSSUnit_Inch: - return (nscoord)NS_INCHES_TO_TWIPS(mValue.mFloat); + return NS_INCHES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Foot: - return (nscoord)NS_FEET_TO_TWIPS(mValue.mFloat); + return NS_FEET_TO_TWIPS(mValue.mFloat); case eCSSUnit_Mile: - return (nscoord)NS_MILES_TO_TWIPS(mValue.mFloat); + return NS_MILES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Millimeter: - return (nscoord)NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); + return NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Centimeter: - return (nscoord)NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); + return NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Meter: - return (nscoord)NS_METERS_TO_TWIPS(mValue.mFloat); + return NS_METERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Kilometer: - return (nscoord)NS_KILOMETERS_TO_TWIPS(mValue.mFloat); + return NS_KILOMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Point: - return (nscoord)NS_POINTS_TO_TWIPS_FLOAT(mValue.mFloat); + return NSFloatPointsToTwips(mValue.mFloat); case eCSSUnit_Pica: - return (nscoord)NS_PICAS_TO_TWIPS(mValue.mFloat); + return NS_PICAS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Didot: - return (nscoord)NS_DIDOTS_TO_TWIPS(mValue.mFloat); + return NS_DIDOTS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Cicero: - return (nscoord)NS_CICEROS_TO_TWIPS(mValue.mFloat); + return NS_CICEROS_TO_TWIPS(mValue.mFloat); } } return 0; diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index 55a04c0543d..1987d833978 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -693,8 +693,8 @@ void nsCSSRendering::PaintBackground(nsIPresContext& aPresContext, // Convert image dimensions into nscoord's float p2t = aPresContext.GetPixelsToTwips(); - nscoord tileWidth = nscoord(p2t * imageSize.width); - nscoord tileHeight = nscoord(p2t * imageSize.height); + nscoord tileWidth = NSIntPixelsToTwips(imageSize.width, p2t); + nscoord tileHeight = NSIntPixelsToTwips(imageSize.height, p2t); PRIntn repeat = aColor.mBackgroundRepeat; PRIntn xcount, ycount; diff --git a/mozilla/layout/html/style/src/nsCSSStyleRule.cpp b/mozilla/layout/html/style/src/nsCSSStyleRule.cpp index 7eb2e08fd41..3e2b6f680c0 100644 --- a/mozilla/layout/html/style/src/nsCSSStyleRule.cpp +++ b/mozilla/layout/html/style/src/nsCSSStyleRule.cpp @@ -438,7 +438,7 @@ nscoord CSSStyleRuleImpl::CalcLength(const nsCSSValue& aValue, return ((aFont->mFont.size / 3) * 2); // XXX HACK! case eCSSUnit_Pixel: - return (nscoord)(aPresContext->GetPixelsToTwips() * aValue.GetFloatValue()); + return NSFloatPixelsToTwips(aValue.GetFloatValue(), aPresContext->GetPixelsToTwips()); } return 0; } diff --git a/mozilla/layout/html/style/src/nsStyleUtil.cpp b/mozilla/layout/html/style/src/nsStyleUtil.cpp index 50e443f4b25..1ab34d8949a 100644 --- a/mozilla/layout/html/style/src/nsStyleUtil.cpp +++ b/mozilla/layout/html/style/src/nsStyleUtil.cpp @@ -48,7 +48,7 @@ float nsStyleUtil::GetScalingFactor(PRInt32 aScaler) scale *= mult; } - return scale; + return (float)scale; } /* diff --git a/mozilla/layout/html/table/src/nsTableCell.cpp b/mozilla/layout/html/table/src/nsTableCell.cpp index 6ddf06d655f..81dee9edc77 100644 --- a/mozilla/layout/html/table/src/nsTableCell.cpp +++ b/mozilla/layout/html/table/src/nsTableCell.cpp @@ -336,7 +336,7 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext, aContext->GetMutableStyleData(eStyleStruct_Position); GetAttribute(nsHTMLAtoms::width, widthValue); if (widthValue.GetUnit() == eHTMLUnit_Pixel) { - nscoord twips = nscoord(p2t * widthValue.GetPixelValue()); + nscoord twips = NSIntPixelsToTwips(widthValue.GetPixelValue(), p2t); pos->mWidth.SetCoordValue(twips); } else if (widthValue.GetUnit() == eHTMLUnit_Percent) { @@ -346,7 +346,7 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext, // height: pixel GetAttribute(nsHTMLAtoms::height, value); if (value.GetUnit() == eHTMLUnit_Pixel) { - nscoord twips = nscoord(p2t * value.GetPixelValue()); + nscoord twips = NSIntPixelsToTwips(value.GetPixelValue(), p2t); pos->mHeight.SetCoordValue(twips); } diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index ae226212813..45247adb7a7 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -362,7 +362,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext, grandChild->ChildCount(childCount); if (0!=childCount) { - nscoord one = ((nscoord)(NS_INT_PIXELS_TO_TWIPS(1, aPresContext.GetPixelsToTwips()))); + nscoord one = ((nscoord)(NSIntPixelsToTwips(1, aPresContext.GetPixelsToTwips()))); cellWidth = 1; if (gsDebug) printf ("setting cellWidth=1 because it was 0 but there's some content\n"); @@ -502,8 +502,6 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) nscoord spacing = 0; nscoord border = 1; - float p2t = aPresContext->GetPixelsToTwips(); - nsTableFrame* tableFrame = GetTableFrame(); tableFrame->GetGeometricParent((nsIFrame *&)tableFrame); // get the outer frame NS_ASSERTION(tableFrame,"Table Must not be null"); @@ -539,7 +537,7 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) if (0!=borderWidth.GetCoordValue()) { // in HTML, cell borders are always 1 pixel by default - border = (nscoord)(1*(aPresContext->GetPixelsToTwips())); + border = NSIntPixelsToTwips(1, aPresContext->GetPixelsToTwips()); MapHTMLBorderStyle(aPresContext, *spacingData, border); } } @@ -1063,10 +1061,10 @@ void nsTableCellFrame::List(FILE* out, PRInt32 aIndent) const */ for (indent = aIndent; --indent >= 0; ) fputs(" ", out); fprintf(out,"Margin -- Top: %d Left: %d Bottom: %d Right: %d \n", - NS_TWIPS_TO_POINTS_INT(mMargin.top), - NS_TWIPS_TO_POINTS_INT(mMargin.left), - NS_TWIPS_TO_POINTS_INT(mMargin.bottom), - NS_TWIPS_TO_POINTS_INT(mMargin.right)); + NSTwipsToIntPoints(mMargin.top), + NSTwipsToIntPoints(mMargin.left), + NSTwipsToIntPoints(mMargin.bottom), + NSTwipsToIntPoints(mMargin.right)); for (indent = aIndent; --indent >= 0; ) fputs(" ", out); @@ -1080,10 +1078,10 @@ void nsTableCellFrame::List(FILE* out, PRInt32 aIndent) const fprintf(out,"Border -- Top: %d Left: %d Bottom: %d Right: %d \n", - NS_TWIPS_TO_POINTS_INT(top), - NS_TWIPS_TO_POINTS_INT(left), - NS_TWIPS_TO_POINTS_INT(bottom), - NS_TWIPS_TO_POINTS_INT(right)); + NSTwipsToIntPoints(top), + NSTwipsToIntPoints(left), + NSTwipsToIntPoints(bottom), + NSTwipsToIntPoints(right)); diff --git a/mozilla/layout/html/table/src/nsTableCol.cpp b/mozilla/layout/html/table/src/nsTableCol.cpp index 9b966c09a43..e881e424cd7 100644 --- a/mozilla/layout/html/table/src/nsTableCol.cpp +++ b/mozilla/layout/html/table/src/nsTableCol.cpp @@ -146,7 +146,7 @@ void nsTableCol::MapAttributesInto(nsIStyleContext* aContext, case eHTMLUnit_Pixel: p2t = aPresContext->GetPixelsToTwips(); - position->mWidth.SetCoordValue(nscoord(p2t * (float)value.GetPixelValue())); + position->mWidth.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t)); break; } } diff --git a/mozilla/layout/html/table/src/nsTableColGroup.cpp b/mozilla/layout/html/table/src/nsTableColGroup.cpp index 4be6ed4eeb5..f7ad092e9ea 100644 --- a/mozilla/layout/html/table/src/nsTableColGroup.cpp +++ b/mozilla/layout/html/table/src/nsTableColGroup.cpp @@ -321,7 +321,7 @@ void nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext, case eHTMLUnit_Pixel: p2t = aPresContext->GetPixelsToTwips(); - position->mWidth.SetCoordValue(nscoord(p2t * (float)value.GetPixelValue())); + position->mWidth.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t)); break; } } diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 820d17f6d71..4c16f63c6c3 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -899,10 +899,10 @@ void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent) nsMargin margin; cellFrame->GetMargin(margin); fprintf(out,"Margin -- Top: %d Left: %d Bottom: %d Right: %d \n", - NS_TWIPS_TO_POINTS_INT(margin.top), - NS_TWIPS_TO_POINTS_INT(margin.left), - NS_TWIPS_TO_POINTS_INT(margin.bottom), - NS_TWIPS_TO_POINTS_INT(margin.right)); + NSTwipsToIntPoints(margin.top), + NSTwipsToIntPoints(margin.left), + NSTwipsToIntPoints(margin.bottom), + NSTwipsToIntPoints(margin.right)); for (rowIndent = aIndent+2; --rowIndent >= 0; ) fputs(" ", out); @@ -914,10 +914,10 @@ void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent) right = (mBorderFrame[NS_SIDE_RIGHT] ? cellFrame->GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_RIGHT], NS_SIDE_RIGHT) : 0); fprintf(out,"Border -- Top: %d Left: %d Bottom: %d Right: %d \n", - NS_TWIPS_TO_POINTS_INT(top), - NS_TWIPS_TO_POINTS_INT(left), - NS_TWIPS_TO_POINTS_INT(bottom), - NS_TWIPS_TO_POINTS_INT(right)); + NSTwipsToIntPoints(top), + NSTwipsToIntPoints(left), + NSTwipsToIntPoints(bottom), + NSTwipsToIntPoints(right)); */ } } @@ -2906,7 +2906,7 @@ void nsTableFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) PRInt32 intValue = 0; if (ConvertToPixelValue(border_value,1,intValue)) - border = nscoord(p2t*(float)intValue); + border = NSIntPixelsToTwips(intValue, p2t); } MapHTMLBorderStyle(*spacingData,border); } diff --git a/mozilla/layout/html/table/src/nsTablePart.cpp b/mozilla/layout/html/table/src/nsTablePart.cpp index b8d12be4c52..f86de8dcacb 100644 --- a/mozilla/layout/html/table/src/nsTablePart.cpp +++ b/mozilla/layout/html/table/src/nsTablePart.cpp @@ -678,7 +678,7 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext, break; case eHTMLUnit_Pixel: - position->mWidth.SetCoordValue(nscoord(p2t * (float)value.GetPixelValue())); + position->mWidth.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t)); break; } } @@ -707,7 +707,7 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext, GetAttribute(nsHTMLAtoms::cellpadding, value); if (value.GetUnit() != eHTMLUnit_Null) { tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table); - tableStyle->mCellPadding.SetCoordValue((nscoord)(p2t*(float)(value.GetPixelValue()))); + tableStyle->mCellPadding.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t)); } // cellspacing (reuses tableStyle if already resolved) @@ -715,13 +715,13 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext, if (value.GetUnit() != eHTMLUnit_Null) { if (nsnull==tableStyle) tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table); - tableStyle->mCellSpacing.SetCoordValue((nscoord)(p2t*(float)(value.GetPixelValue()))); + tableStyle->mCellSpacing.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t)); } else { // XXX: remove me as soon as we get this from the style sheet if (nsnull==tableStyle) tableStyle = (nsStyleTable*)aContext->GetMutableStyleData(eStyleStruct_Table); - tableStyle->mCellSpacing.SetCoordValue((nscoord)(p2t*(float)2)); + tableStyle->mCellSpacing.SetCoordValue(NSIntPixelsToTwips(2, p2t)); } // cols @@ -757,14 +757,14 @@ void nsTablePart::GetTableBorder(nsIHTMLContent* aContent, float p2t = aPresContext->GetPixelsToTwips(); nsStyleCoord twips; if (value.GetUnit() == eHTMLUnit_Empty) { - twips.SetCoordValue(nscoord(NS_INT_PIXELS_TO_TWIPS(1, p2t))); + twips.SetCoordValue(NSIntPixelsToTwips(1, p2t)); } else { - twips.SetCoordValue(nscoord(NS_INT_PIXELS_TO_TWIPS(value.GetPixelValue(), p2t))); + twips.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t)); } #if 0 - nsStyleCoord two(nscoord(NS_INT_PIXELS_TO_TWIPS(2,p2t))); + nsStyleCoord two(NSIntPixelsToTwips(2, p2t)); spacing->mPadding.SetTop(two); spacing->mPadding.SetRight(two); diff --git a/mozilla/layout/style/nsCSSDeclaration.cpp b/mozilla/layout/style/nsCSSDeclaration.cpp index 38f4f48d504..9043f5df4c3 100644 --- a/mozilla/layout/style/nsCSSDeclaration.cpp +++ b/mozilla/layout/style/nsCSSDeclaration.cpp @@ -322,29 +322,29 @@ nscoord nsCSSValue::GetLengthTwips(void) const if (IsFixedLengthUnit()) { switch (mUnit) { case eCSSUnit_Inch: - return (nscoord)NS_INCHES_TO_TWIPS(mValue.mFloat); + return NS_INCHES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Foot: - return (nscoord)NS_FEET_TO_TWIPS(mValue.mFloat); + return NS_FEET_TO_TWIPS(mValue.mFloat); case eCSSUnit_Mile: - return (nscoord)NS_MILES_TO_TWIPS(mValue.mFloat); + return NS_MILES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Millimeter: - return (nscoord)NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); + return NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Centimeter: - return (nscoord)NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); + return NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Meter: - return (nscoord)NS_METERS_TO_TWIPS(mValue.mFloat); + return NS_METERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Kilometer: - return (nscoord)NS_KILOMETERS_TO_TWIPS(mValue.mFloat); + return NS_KILOMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Point: - return (nscoord)NS_POINTS_TO_TWIPS_FLOAT(mValue.mFloat); + return NSFloatPointsToTwips(mValue.mFloat); case eCSSUnit_Pica: - return (nscoord)NS_PICAS_TO_TWIPS(mValue.mFloat); + return NS_PICAS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Didot: - return (nscoord)NS_DIDOTS_TO_TWIPS(mValue.mFloat); + return NS_DIDOTS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Cicero: - return (nscoord)NS_CICEROS_TO_TWIPS(mValue.mFloat); + return NS_CICEROS_TO_TWIPS(mValue.mFloat); } } return 0; diff --git a/mozilla/layout/style/nsCSSStruct.cpp b/mozilla/layout/style/nsCSSStruct.cpp index 38f4f48d504..9043f5df4c3 100644 --- a/mozilla/layout/style/nsCSSStruct.cpp +++ b/mozilla/layout/style/nsCSSStruct.cpp @@ -322,29 +322,29 @@ nscoord nsCSSValue::GetLengthTwips(void) const if (IsFixedLengthUnit()) { switch (mUnit) { case eCSSUnit_Inch: - return (nscoord)NS_INCHES_TO_TWIPS(mValue.mFloat); + return NS_INCHES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Foot: - return (nscoord)NS_FEET_TO_TWIPS(mValue.mFloat); + return NS_FEET_TO_TWIPS(mValue.mFloat); case eCSSUnit_Mile: - return (nscoord)NS_MILES_TO_TWIPS(mValue.mFloat); + return NS_MILES_TO_TWIPS(mValue.mFloat); case eCSSUnit_Millimeter: - return (nscoord)NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); + return NS_MILLIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Centimeter: - return (nscoord)NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); + return NS_CENTIMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Meter: - return (nscoord)NS_METERS_TO_TWIPS(mValue.mFloat); + return NS_METERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Kilometer: - return (nscoord)NS_KILOMETERS_TO_TWIPS(mValue.mFloat); + return NS_KILOMETERS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Point: - return (nscoord)NS_POINTS_TO_TWIPS_FLOAT(mValue.mFloat); + return NSFloatPointsToTwips(mValue.mFloat); case eCSSUnit_Pica: - return (nscoord)NS_PICAS_TO_TWIPS(mValue.mFloat); + return NS_PICAS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Didot: - return (nscoord)NS_DIDOTS_TO_TWIPS(mValue.mFloat); + return NS_DIDOTS_TO_TWIPS(mValue.mFloat); case eCSSUnit_Cicero: - return (nscoord)NS_CICEROS_TO_TWIPS(mValue.mFloat); + return NS_CICEROS_TO_TWIPS(mValue.mFloat); } } return 0; diff --git a/mozilla/layout/style/nsCSSStyleRule.cpp b/mozilla/layout/style/nsCSSStyleRule.cpp index 7eb2e08fd41..3e2b6f680c0 100644 --- a/mozilla/layout/style/nsCSSStyleRule.cpp +++ b/mozilla/layout/style/nsCSSStyleRule.cpp @@ -438,7 +438,7 @@ nscoord CSSStyleRuleImpl::CalcLength(const nsCSSValue& aValue, return ((aFont->mFont.size / 3) * 2); // XXX HACK! case eCSSUnit_Pixel: - return (nscoord)(aPresContext->GetPixelsToTwips() * aValue.GetFloatValue()); + return NSFloatPixelsToTwips(aValue.GetFloatValue(), aPresContext->GetPixelsToTwips()); } return 0; } diff --git a/mozilla/layout/style/nsStyleContext.cpp b/mozilla/layout/style/nsStyleContext.cpp index cd3514441f9..a520fa357f4 100644 --- a/mozilla/layout/style/nsStyleContext.cpp +++ b/mozilla/layout/style/nsStyleContext.cpp @@ -245,9 +245,9 @@ void nsStyleSpacing::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) } static const nscoord kBorderWidths[3] = - { NS_POINTS_TO_TWIPS_INT(1), - NS_POINTS_TO_TWIPS_INT(3), - NS_POINTS_TO_TWIPS_INT(5) }; + { NSIntPointsToTwips(1), + NSIntPointsToTwips(3), + NSIntPointsToTwips(5) }; void nsStyleSpacing::CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const { diff --git a/mozilla/layout/style/nsStyleUtil.cpp b/mozilla/layout/style/nsStyleUtil.cpp index 50e443f4b25..1ab34d8949a 100644 --- a/mozilla/layout/style/nsStyleUtil.cpp +++ b/mozilla/layout/style/nsStyleUtil.cpp @@ -48,7 +48,7 @@ float nsStyleUtil::GetScalingFactor(PRInt32 aScaler) scale *= mult; } - return scale; + return (float)scale; } /* diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index ae226212813..45247adb7a7 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -362,7 +362,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext, grandChild->ChildCount(childCount); if (0!=childCount) { - nscoord one = ((nscoord)(NS_INT_PIXELS_TO_TWIPS(1, aPresContext.GetPixelsToTwips()))); + nscoord one = ((nscoord)(NSIntPixelsToTwips(1, aPresContext.GetPixelsToTwips()))); cellWidth = 1; if (gsDebug) printf ("setting cellWidth=1 because it was 0 but there's some content\n"); @@ -502,8 +502,6 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) nscoord spacing = 0; nscoord border = 1; - float p2t = aPresContext->GetPixelsToTwips(); - nsTableFrame* tableFrame = GetTableFrame(); tableFrame->GetGeometricParent((nsIFrame *&)tableFrame); // get the outer frame NS_ASSERTION(tableFrame,"Table Must not be null"); @@ -539,7 +537,7 @@ void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) if (0!=borderWidth.GetCoordValue()) { // in HTML, cell borders are always 1 pixel by default - border = (nscoord)(1*(aPresContext->GetPixelsToTwips())); + border = NSIntPixelsToTwips(1, aPresContext->GetPixelsToTwips()); MapHTMLBorderStyle(aPresContext, *spacingData, border); } } @@ -1063,10 +1061,10 @@ void nsTableCellFrame::List(FILE* out, PRInt32 aIndent) const */ for (indent = aIndent; --indent >= 0; ) fputs(" ", out); fprintf(out,"Margin -- Top: %d Left: %d Bottom: %d Right: %d \n", - NS_TWIPS_TO_POINTS_INT(mMargin.top), - NS_TWIPS_TO_POINTS_INT(mMargin.left), - NS_TWIPS_TO_POINTS_INT(mMargin.bottom), - NS_TWIPS_TO_POINTS_INT(mMargin.right)); + NSTwipsToIntPoints(mMargin.top), + NSTwipsToIntPoints(mMargin.left), + NSTwipsToIntPoints(mMargin.bottom), + NSTwipsToIntPoints(mMargin.right)); for (indent = aIndent; --indent >= 0; ) fputs(" ", out); @@ -1080,10 +1078,10 @@ void nsTableCellFrame::List(FILE* out, PRInt32 aIndent) const fprintf(out,"Border -- Top: %d Left: %d Bottom: %d Right: %d \n", - NS_TWIPS_TO_POINTS_INT(top), - NS_TWIPS_TO_POINTS_INT(left), - NS_TWIPS_TO_POINTS_INT(bottom), - NS_TWIPS_TO_POINTS_INT(right)); + NSTwipsToIntPoints(top), + NSTwipsToIntPoints(left), + NSTwipsToIntPoints(bottom), + NSTwipsToIntPoints(right)); diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 820d17f6d71..4c16f63c6c3 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -899,10 +899,10 @@ void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent) nsMargin margin; cellFrame->GetMargin(margin); fprintf(out,"Margin -- Top: %d Left: %d Bottom: %d Right: %d \n", - NS_TWIPS_TO_POINTS_INT(margin.top), - NS_TWIPS_TO_POINTS_INT(margin.left), - NS_TWIPS_TO_POINTS_INT(margin.bottom), - NS_TWIPS_TO_POINTS_INT(margin.right)); + NSTwipsToIntPoints(margin.top), + NSTwipsToIntPoints(margin.left), + NSTwipsToIntPoints(margin.bottom), + NSTwipsToIntPoints(margin.right)); for (rowIndent = aIndent+2; --rowIndent >= 0; ) fputs(" ", out); @@ -914,10 +914,10 @@ void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent) right = (mBorderFrame[NS_SIDE_RIGHT] ? cellFrame->GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_RIGHT], NS_SIDE_RIGHT) : 0); fprintf(out,"Border -- Top: %d Left: %d Bottom: %d Right: %d \n", - NS_TWIPS_TO_POINTS_INT(top), - NS_TWIPS_TO_POINTS_INT(left), - NS_TWIPS_TO_POINTS_INT(bottom), - NS_TWIPS_TO_POINTS_INT(right)); + NSTwipsToIntPoints(top), + NSTwipsToIntPoints(left), + NSTwipsToIntPoints(bottom), + NSTwipsToIntPoints(right)); */ } } @@ -2906,7 +2906,7 @@ void nsTableFrame::MapBorderMarginPadding(nsIPresContext* aPresContext) PRInt32 intValue = 0; if (ConvertToPixelValue(border_value,1,intValue)) - border = nscoord(p2t*(float)intValue); + border = NSIntPixelsToTwips(intValue, p2t); } MapHTMLBorderStyle(*spacingData,border); } diff --git a/mozilla/view/src/nsScrollingView.cpp b/mozilla/view/src/nsScrollingView.cpp index 19f4cfd4186..5b93148ba97 100644 --- a/mozilla/view/src/nsScrollingView.cpp +++ b/mozilla/view/src/nsScrollingView.cpp @@ -33,6 +33,9 @@ static NS_DEFINE_IID(kIScrollbarIID, NS_ISCROLLBAR_IID); static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID); static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID); +#define NS_TO_INT_ROUND(x) ((PRInt32)floor((x) + 0.5)) +#define NS_POINTS_TO_TWIPS_INT(x) ((PRInt32)(20 * (x))) + class ScrollBarView : public nsView { public: diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp index f091cd6d53f..fdf5c6d148c 100644 --- a/mozilla/view/src/nsView.cpp +++ b/mozilla/view/src/nsView.cpp @@ -85,8 +85,8 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent) NS_RELEASE(scrollView); - if ((width == NS_TO_INT_ROUND(sizex * t2p)) && - (height == NS_TO_INT_ROUND(sizey * t2p))) + if ((width == NSTwipsToIntPixels(sizex, t2p)) && + (height == NSTwipsToIntPixels(sizey, t2p))) { NS_IF_RELEASE(rootView); NS_RELEASE(presContext); @@ -95,8 +95,8 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent) } } - vm->SetWindowDimensions(NS_TO_INT_ROUND(width * p2t), - NS_TO_INT_ROUND(height * p2t)); + vm->SetWindowDimensions(NSIntPixelsToTwips(width, p2t), + NSIntPixelsToTwips(height, p2t)); result = nsEventStatus_eConsumeNoDefault; } @@ -143,15 +143,15 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent) // pass on to view somewhere else to deal with - aEvent->point.x = NS_TO_INT_ROUND(aEvent->point.x * cx->GetPixelsToTwips()); - aEvent->point.y = NS_TO_INT_ROUND(aEvent->point.y * cx->GetPixelsToTwips()); + aEvent->point.x = NSIntPixelsToTwips(aEvent->point.x, cx->GetPixelsToTwips()); + aEvent->point.y = NSIntPixelsToTwips(aEvent->point.y, cx->GetPixelsToTwips()); result = view->HandleEvent(aEvent, NS_VIEW_FLAG_CHECK_CHILDREN | NS_VIEW_FLAG_CHECK_PARENT | NS_VIEW_FLAG_CHECK_SIBLINGS); - aEvent->point.x = NS_TO_INT_ROUND(aEvent->point.x * cx->GetTwipsToPixels()); - aEvent->point.y = NS_TO_INT_ROUND(aEvent->point.y * cx->GetTwipsToPixels()); + aEvent->point.x = NSTwipsToIntPixels(aEvent->point.x, cx->GetTwipsToPixels()); + aEvent->point.y = NSTwipsToIntPixels(aEvent->point.y, cx->GetTwipsToPixels()); NS_RELEASE(cx); NS_RELEASE(vm); @@ -726,8 +726,8 @@ void nsView :: SetPosition(nscoord x, nscoord y) pwidget = GetOffsetFromWidget(&parx, &pary); NS_IF_RELEASE(pwidget); - mWindow->Move(NS_TO_INT_ROUND((x + parx + offx) * scale), - NS_TO_INT_ROUND((y + pary + offy) * scale)); + mWindow->Move(NSTwipsToIntPixels((x + parx + offx), scale), + NSTwipsToIntPixels((y + pary + offy), scale)); NS_RELEASE(px); } @@ -770,7 +770,7 @@ void nsView :: SetDimensions(nscoord width, nscoord height) nsIPresContext *px = mViewManager->GetPresContext(); float t2p = px->GetTwipsToPixels(); - mWindow->Resize(NS_TO_INT_ROUND(t2p * width), NS_TO_INT_ROUND(t2p * height), + mWindow->Resize(NSTwipsToIntPixels(width, t2p), NSTwipsToIntPixels(height, t2p), PR_TRUE); NS_RELEASE(px); diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index 267d158c6bc..3afd67adc01 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -324,15 +324,15 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI GetWindowOffsets(&xoff, &yoff); - region->Offset(NS_TO_INT_ROUND(-xoff * scale), NS_TO_INT_ROUND(-yoff * scale)); + region->Offset(NSTwipsToIntPixels(-xoff, scale), NSTwipsToIntPixels(-yoff, scale)); // localcx->SetClipRegion(*region, nsClipCombine_kIntersect); localcx->SetClipRegion(*region, nsClipCombine_kReplace); - region->Offset(NS_TO_INT_ROUND(xoff * scale), NS_TO_INT_ROUND(yoff * scale)); + region->Offset(NSTwipsToIntPixels(xoff, scale), NSTwipsToIntPixels(yoff, scale)); nsRect trect; region->GetBoundingBox(&trect.x, &trect.y, &trect.width, &trect.height); - trect *= mContext->GetPixelsToTwips(); + trect.ScaleRoundOut(mContext->GetPixelsToTwips()); aView->Paint(*localcx, trect, 0); @@ -439,7 +439,7 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsR { nsRect pixrect = trect; - pixrect *= mContext->GetTwipsToPixels(); + pixrect.ScaleRoundIn(mContext->GetTwipsToPixels()); mDirtyRegion->Subtract(pixrect.x, pixrect.y, pixrect.width, pixrect.height); } @@ -553,7 +553,7 @@ void nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 a rrect = mDirtyRect; #else mDirtyRegion->GetBoundingBox(&rrect.x, &rrect.y, &rrect.width, &rrect.height); - rrect *= mContext->GetPixelsToTwips(); + rrect.ScaleRoundOut(mContext->GetPixelsToTwips()); #endif rrect.IntersectRect(rrect, vrect); @@ -1040,7 +1040,7 @@ void nsViewManager :: AddRectToDirtyRegion(nsRect &aRect) nsRect trect = aRect; - trect *= mContext->GetTwipsToPixels(); + trect.ScaleRoundOut(mContext->GetTwipsToPixels()); mDirtyRegion->Union(trect.x, trect.y, trect.width, trect.height); } diff --git a/mozilla/webshell/src/nsDocumentViewer.cpp b/mozilla/webshell/src/nsDocumentViewer.cpp index a8ca5bfbd62..2a2d619bd9c 100644 --- a/mozilla/webshell/src/nsDocumentViewer.cpp +++ b/mozilla/webshell/src/nsDocumentViewer.cpp @@ -349,8 +349,8 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent, mWindow->GetBounds(bounds); width = bounds.width; height = bounds.height; - width = NS_TO_INT_ROUND(width * mPresContext->GetPixelsToTwips()); - height = NS_TO_INT_ROUND(height * mPresContext->GetPixelsToTwips()); + width = NSIntPixelsToTwips(width, mPresContext->GetPixelsToTwips()); + height = NSIntPixelsToTwips(height, mPresContext->GetPixelsToTwips()); mViewManager->DisableRefresh(); mViewManager->SetWindowDimensions(width, height); diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index f899f7d1bae..097b16bd25e 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -535,7 +535,7 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) float t2d = dc->GetTwipsToDevUnits(); nsFont font(TOOL_BAR_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, - nscoord(t2d * NS_POINTS_TO_TWIPS_INT(TOOL_BAR_FONT_SIZE))); + nscoord(t2d * NSIntPointsToTwips(TOOL_BAR_FONT_SIZE))); NS_RELEASE(dc); // Create and place back button @@ -601,7 +601,7 @@ nsBrowserWindow::CreateStatusBar(PRInt32 aWidth) float t2d = dc->GetTwipsToDevUnits(); nsFont font(STATUS_BAR_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL, 0, - nscoord(t2d * NS_POINTS_TO_TWIPS_INT(STATUS_BAR_FONT_SIZE))); + nscoord(t2d * NSIntPointsToTwips(STATUS_BAR_FONT_SIZE))); NS_RELEASE(dc); nsRect r(0, 0, aWidth, THROBBER_HEIGHT); diff --git a/mozilla/widget/src/mac/nsDeviceContextMac.cpp b/mozilla/widget/src/mac/nsDeviceContextMac.cpp index eee1a17dc5d..2d041319d8a 100644 --- a/mozilla/widget/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/widget/src/mac/nsDeviceContextMac.cpp @@ -109,7 +109,7 @@ nsresult nsDeviceContextMac :: Init(nsNativeWidget aNativeWidget) { mTwipsToPixels = (((float)::XDisplayWidth(XtDisplay((Widget)mNativeWidget), DefaultScreen(XtDisplay((Widget)mNativeWidget)))) / ((float)::XDisplayWidthMM(XtDisplay((Widget)mNativeWidget),DefaultScreen(XtDisplay((Widget)mNativeWidget)) )) * 25.4) / - NS_POINTS_TO_TWIPS_FLOAT(72.0f); + (float)NSIntPointsToTwips(72); mPixelsToTwips = 1.0f / mTwipsToPixels; }*/ diff --git a/mozilla/widget/src/windows/nsScrollbar.cpp b/mozilla/widget/src/windows/nsScrollbar.cpp index 4f735f414c3..6c83c2cc21f 100644 --- a/mozilla/widget/src/windows/nsScrollbar.cpp +++ b/mozilla/widget/src/windows/nsScrollbar.cpp @@ -30,7 +30,7 @@ nsScrollbar::nsScrollbar(nsISupports *aOuter, PRBool aIsVertical) : nsWindow(aOuter) { mPositionFlag = (aIsVertical) ? SBS_VERT : SBS_HORZ; - mScaleFactor = 1.0; + mScaleFactor = 1.0f; mLineIncrement = 0; mBackground = ::GetSysColor(COLOR_SCROLLBAR); mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground)); @@ -75,9 +75,9 @@ nsresult nsScrollbar::QueryObject(const nsIID& aIID, void** aInstancePtr) void nsScrollbar::SetMaxRange(PRUint32 aEndRange) { if (aEndRange > 32767) - mScaleFactor = aEndRange / 32767.0; + mScaleFactor = aEndRange / 32767.0f; if (mWnd) { - VERIFY(::SetScrollRange(mWnd, SB_CTL, 0, NS_TO_INT_ROUND(aEndRange / mScaleFactor), TRUE)); + VERIFY(::SetScrollRange(mWnd, SB_CTL, 0, NSToIntRound(aEndRange / mScaleFactor), TRUE)); } } @@ -94,7 +94,7 @@ PRUint32 nsScrollbar::GetMaxRange() VERIFY(::GetScrollRange(mWnd, SB_CTL, &startRange, &endRange)); } - return (PRUint32)NS_TO_INT_ROUND(endRange * mScaleFactor); + return (PRUint32)NSToIntRound(endRange * mScaleFactor); } @@ -105,7 +105,7 @@ PRUint32 nsScrollbar::GetMaxRange() //------------------------------------------------------------------------- void nsScrollbar::SetPosition(PRUint32 aPos) { - ::SetScrollPos(mWnd, SB_CTL, NS_TO_INT_ROUND(aPos / mScaleFactor), TRUE); + ::SetScrollPos(mWnd, SB_CTL, NSToIntRound(aPos / mScaleFactor), TRUE); } @@ -116,7 +116,7 @@ void nsScrollbar::SetPosition(PRUint32 aPos) //------------------------------------------------------------------------- PRUint32 nsScrollbar::GetPosition() { - return (PRUint32)NS_TO_INT_ROUND(::GetScrollPos(mWnd, SB_CTL) * mScaleFactor); + return (PRUint32)NSToIntRound(::GetScrollPos(mWnd, SB_CTL) * mScaleFactor); } @@ -131,7 +131,7 @@ void nsScrollbar::SetThumbSize(PRUint32 aSize) SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_PAGE; - si.nPage = NS_TO_INT_ROUND(aSize / mScaleFactor); + si.nPage = NSToIntRound(aSize / mScaleFactor); ::SetScrollInfo(mWnd, SB_CTL, &si, TRUE); } } @@ -149,7 +149,7 @@ PRUint32 nsScrollbar::GetThumbSize() si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_PAGE; VERIFY(::GetScrollInfo(mWnd, SB_CTL, &si)); - return (PRUint32)NS_TO_INT_ROUND(si.nPage * mScaleFactor); + return (PRUint32)NSToIntRound(si.nPage * mScaleFactor); } return 0; @@ -163,7 +163,7 @@ PRUint32 nsScrollbar::GetThumbSize() //------------------------------------------------------------------------- void nsScrollbar::SetLineIncrement(PRUint32 aSize) { - mLineIncrement = NS_TO_INT_ROUND(aSize / mScaleFactor); + mLineIncrement = NSToIntRound(aSize / mScaleFactor); } @@ -174,7 +174,7 @@ void nsScrollbar::SetLineIncrement(PRUint32 aSize) //------------------------------------------------------------------------- PRUint32 nsScrollbar::GetLineIncrement() { - return (PRUint32)NS_TO_INT_ROUND(mLineIncrement * mScaleFactor); + return (PRUint32)NSToIntRound(mLineIncrement * mScaleFactor); } @@ -187,20 +187,20 @@ void nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, PRUint32 aPosition, PRUint32 aLineIncrement) { if (aMaxRange > 32767) - mScaleFactor = aMaxRange / 32767.0; + mScaleFactor = aMaxRange / 32767.0f; if (mWnd) { SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE; - si.nPage = NS_TO_INT_ROUND(aThumbSize / mScaleFactor); - si.nPos = NS_TO_INT_ROUND(aPosition / mScaleFactor); + si.nPage = NSToIntRound(aThumbSize / mScaleFactor); + si.nPos = NSToIntRound(aPosition / mScaleFactor); si.nMin = 0; - si.nMax = NS_TO_INT_ROUND(aMaxRange / mScaleFactor); + si.nMax = NSToIntRound(aMaxRange / mScaleFactor); ::SetScrollInfo(mWnd, SB_CTL, &si, TRUE); } - mLineIncrement = NS_TO_INT_ROUND(aLineIncrement / mScaleFactor); + mLineIncrement = NSToIntRound(aLineIncrement / mScaleFactor); } @@ -257,10 +257,10 @@ PRBool nsScrollbar::OnScroll(UINT scrollCode, int cPos) event.point.x = cpos.x; event.point.y = cpos.y; event.time = ::GetMessageTime(); - event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor); + event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NS_TO_INT_ROUND(event.position / mScaleFactor); + newPosition = NSToIntRound(event.position / mScaleFactor); } ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); @@ -291,10 +291,10 @@ PRBool nsScrollbar::OnScroll(UINT scrollCode, int cPos) event.point.x = cpos.x; event.point.y = cpos.y; event.time = ::GetMessageTime(); - event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor); + event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NS_TO_INT_ROUND(event.position / mScaleFactor); + newPosition = NSToIntRound(event.position / mScaleFactor); } ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); @@ -330,11 +330,11 @@ PRBool nsScrollbar::OnScroll(UINT scrollCode, int cPos) event.point.x = cpos.x; event.point.y = cpos.y; event.time = ::GetMessageTime(); - event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor);; + event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor);; result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NS_TO_INT_ROUND(event.position / mScaleFactor); + newPosition = NSToIntRound(event.position / mScaleFactor); } ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); @@ -369,10 +369,10 @@ PRBool nsScrollbar::OnScroll(UINT scrollCode, int cPos) event.point.x = cpos.x; event.point.y = cpos.y; event.time = ::GetMessageTime(); - event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor); + event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NS_TO_INT_ROUND(event.position / mScaleFactor); + newPosition = NSToIntRound(event.position / mScaleFactor); } ::SetScrollPos(mWnd, SB_CTL, newPosition - 10, TRUE); @@ -401,10 +401,10 @@ PRBool nsScrollbar::OnScroll(UINT scrollCode, int cPos) event.point.x = cpos.x; event.point.y = cpos.y; event.time = ::GetMessageTime(); - event.position = (PRUint32)NS_TO_INT_ROUND(newPosition * mScaleFactor); + event.position = (PRUint32)NSToIntRound(newPosition * mScaleFactor); result = ConvertStatus((*mEventCallback)(&event)); - newPosition = NS_TO_INT_ROUND(event.position * mScaleFactor); + newPosition = NSToIntRound(event.position * mScaleFactor); } ::SetScrollPos(mWnd, SB_CTL, newPosition, TRUE); diff --git a/mozilla/widget/src/windows/nsScrollbar.h b/mozilla/widget/src/windows/nsScrollbar.h index 894030c3bca..a76ae56732f 100644 --- a/mozilla/widget/src/windows/nsScrollbar.h +++ b/mozilla/widget/src/windows/nsScrollbar.h @@ -72,7 +72,7 @@ protected: private: DWORD mPositionFlag; int mLineIncrement; - double mScaleFactor; + float mScaleFactor; }; #endif // nsButton_h__