Bug 678222 - Fix build with clang and c++0x; r=roc
Change AppUnitsPerDevPixel to return a PRUint32. It should never return
negative values and it is used in initializer lists that expect unsigned
values, which is not valid c++0x.
I have also change the member variables to be unsigned and converted
a sentinel value to use 0 instead of -1. UINT32_MAX should work fine too
if you like it better.
--- a/gfx/src/nsDeviceContext.h
+++ b/gfx/src/nsDeviceContext.h
@@ -110,17 +110,17 @@ public:
*/
static PRInt32 AppUnitsPerCSSPixel() { return 60; }
/**
* Gets the number of app units in one device pixel; this number
* is usually a factor of AppUnitsPerCSSPixel(), although that is
* not guaranteed.
*/
- PRInt32 AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
+ PRUint32 AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
/**
* Convert device pixels which is used for gfx/thebes to nearest
* (rounded) app units
*/
nscoord GfxUnitsToAppUnits(gfxFloat aGfxUnits) const
{ return nscoord(NS_round(aGfxUnits * AppUnitsPerDevPixel())); }
@@ -306,17 +306,17 @@ protected:
void ComputeFullAreaUsingScreen(nsRect *outRect);
void FindScreen(nsIScreen **outScreen);
void CalcPrintingSize();
void UpdateScaledAppUnits();
nscoord mWidth;
nscoord mHeight;
PRUint32 mDepth;
- PRInt32 mAppUnitsPerDevPixel;
+ PRUint32 mAppUnitsPerDevPixel;
PRInt32 mAppUnitsPerDevNotScaledPixel;
PRInt32 mAppUnitsPerPhysicalInch;
float mPixelScale;
float mPrintingScale;
nsFontCache* mFontCache;
nsCOMPtr<nsIWidget> mWidget;
nsCOMPtr<nsIScreenManager> mScreenManager;
--- a/gfx/src/nsFontMetrics.cpp
+++ b/gfx/src/nsFontMetrics.cpp
@@ -93,32 +93,32 @@ public:
Spacing* aSpacing) {
NS_ERROR("This shouldn't be called because we never enable spacing");
}
};
} // anon namespace
nsFontMetrics::nsFontMetrics()
- : mDeviceContext(nsnull), mP2A(-1), mTextRunRTL(PR_FALSE)
+ : mDeviceContext(nsnull), mP2A(0), mTextRunRTL(PR_FALSE)
{
}
nsFontMetrics::~nsFontMetrics()
{
if (mDeviceContext)
mDeviceContext->FontMetricsDeleted(this);
}
nsresult
nsFontMetrics::Init(const nsFont& aFont, nsIAtom* aLanguage,
nsDeviceContext *aContext,
gfxUserFontSet *aUserFontSet)
{
- NS_ABORT_IF_FALSE(mP2A == -1, "already initialized");
+ NS_ABORT_IF_FALSE(mP2A == 0, "already initialized");
mFont = aFont;
mLanguage = aLanguage;
mDeviceContext = aContext;
mP2A = mDeviceContext->AppUnitsPerDevPixel();
gfxFontStyle style(aFont.style,
aFont.weight,
--- a/gfx/src/nsFontMetrics.h
+++ b/gfx/src/nsFontMetrics.h
@@ -222,22 +222,22 @@ public:
nsRenderingContext *aContext);
void SetTextRunRTL(PRBool aIsRTL) { mTextRunRTL = aIsRTL; }
PRBool GetTextRunRTL() { return mTextRunRTL; }
gfxFontGroup* GetThebesFontGroup() { return mFontGroup; }
gfxUserFontSet* GetUserFontSet() { return mFontGroup->GetUserFontSet(); }
- PRInt32 AppUnitsPerDevPixel() { return mP2A; }
+ PRUint32 AppUnitsPerDevPixel() { return mP2A; }
protected:
const gfxFont::Metrics& GetMetrics() const;
nsFont mFont;
nsRefPtr<gfxFontGroup> mFontGroup;
nsCOMPtr<nsIAtom> mLanguage;
nsDeviceContext *mDeviceContext;
- PRInt32 mP2A;
+ PRUint32 mP2A;
PRPackedBool mTextRunRTL;
};
#endif /* NSFONTMETRICS__H__ */
--- a/gfx/src/nsRenderingContext.h
+++ b/gfx/src/nsRenderingContext.h
@@ -65,17 +65,17 @@ public:
NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
void Init(nsDeviceContext* aContext, gfxASurface* aThebesSurface);
void Init(nsDeviceContext* aContext, gfxContext* aThebesContext);
// These accessors will never return null.
gfxContext *ThebesContext() { return mThebes; }
nsDeviceContext *DeviceContext() { return mDeviceContext; }
- PRInt32 AppUnitsPerDevPixel() { return mP2A; }
+ PRUint32 AppUnitsPerDevPixel() { return mP2A; }
// Graphics state
void PushState(void);
void PopState(void);
void IntersectClip(const nsRect& aRect);
void SetClip(const nsIntRegion& aRegion);
void SetLineStyle(nsLineStyle aLineStyle);
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -587,17 +587,17 @@ public:
float GetFullZoom() { return mFullZoom; }
void SetFullZoom(float aZoom);
nscoord GetAutoQualityMinFontSize() {
return DevPixelsToAppUnits(mAutoQualityMinFontSizePixelsPref);
}
static PRInt32 AppUnitsPerCSSPixel() { return nsDeviceContext::AppUnitsPerCSSPixel(); }
- PRInt32 AppUnitsPerDevPixel() const { return mDeviceContext->AppUnitsPerDevPixel(); }
+ PRUint32 AppUnitsPerDevPixel() const { return mDeviceContext->AppUnitsPerDevPixel(); }
static PRInt32 AppUnitsPerCSSInch() { return nsDeviceContext::AppUnitsPerCSSInch(); }
static nscoord CSSPixelsToAppUnits(PRInt32 aPixels)
{ return NSIntPixelsToAppUnits(aPixels,
nsDeviceContext::AppUnitsPerCSSPixel()); }
static nscoord CSSPixelsToAppUnits(float aPixels)
{ return NSFloatPixelsToAppUnits(aPixels,
--- a/view/src/nsViewManager.h
+++ b/view/src/nsViewManager.h
@@ -248,17 +248,17 @@ public: // NOT in nsIViewManager, so pri
nsEventStatus HandleEvent(nsView* aView, nsGUIEvent* aEvent);
PRBool IsRefreshEnabled() { return RootViewManager()->mUpdateBatchCnt == 0; }
// Call this when you need to let the viewmanager know that it now has
// pending updates.
void PostPendingUpdate() { RootViewManager()->mHasPendingUpdates = PR_TRUE; }
- PRInt32 AppUnitsPerDevPixel() const
+ PRUint32 AppUnitsPerDevPixel() const
{
return mContext->AppUnitsPerDevPixel();
}
private:
nsRefPtr<nsDeviceContext> mContext;
nsIViewObserver *mObserver;
--- a/xpfe/appshell/src/nsXULWindow.cpp
+++ b/xpfe/appshell/src/nsXULWindow.cpp
@@ -2078,17 +2078,17 @@ NS_IMETHODIMP nsXULWindow::SetXULBrowser
mXULBrowserWindow = aXULBrowserWindow;
return NS_OK;
}
//*****************************************************************************
// nsXULWindow: Accessors
//*****************************************************************************
-PRInt32 nsXULWindow::AppUnitsPerDevPixel()
+PRUint32 nsXULWindow::AppUnitsPerDevPixel()
{
if (mWindow && mWindow->GetDeviceContext()) {
mAppPerDev = mWindow->GetDeviceContext()->AppUnitsPerDevPixel();
} else {
NS_ERROR("nsXULWindow::AppUnitsPerDevPixel called with no window "
"or no dev context");
}
return mAppPerDev;
--- a/xpfe/appshell/src/nsXULWindow.h
+++ b/xpfe/appshell/src/nsXULWindow.h
@@ -142,17 +142,17 @@ protected:
void EnableParent(PRBool aEnable);
PRBool ConstrainToZLevel(PRBool aImmediate, nsWindowZ *aPlacement,
nsIWidget *aReqBelow, nsIWidget **aActualBelow);
void PlaceWindowLayersBehind(PRUint32 aLowLevel, PRUint32 aHighLevel,
nsIXULWindow *aBehind);
void SetContentScrollbarVisibility(PRBool aVisible);
PRBool GetContentScrollbarVisibility();
void PersistentAttributesDirty(PRUint32 aDirtyFlags);
- PRInt32 AppUnitsPerDevPixel();
+ PRUint32 AppUnitsPerDevPixel();
nsChromeTreeOwner* mChromeTreeOwner;
nsContentTreeOwner* mContentTreeOwner;
nsContentTreeOwner* mPrimaryContentTreeOwner;
nsCOMPtr<nsIWidget> mWindow;
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIDOMWindow> mDOMWindow;
nsCOMPtr<nsIWeakReference> mParentWindow;