bug 842514 - consistently use signed types for appUnitsPerDevPixel variables. r=roc
authorJonathan Kew <jkew@mozilla.com>
Tue, 19 Feb 2013 21:46:27 +0000
changeset 133580 27652a4eddb470d29d1850e02be5d73727385803
parent 133579 408ad90d68dcc3b4968fc92d7e54861f2ff9369b
child 133581 a104642698a0a40b2f7e0bba316c28d63b00939c
push id336
push userakeybl@mozilla.com
push dateMon, 17 Jun 2013 22:53:19 +0000
treeherdermozilla-release@574a39cdf657 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs842514
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 842514 - consistently use signed types for appUnitsPerDevPixel variables. r=roc
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/CanvasRenderingContext2D.h
gfx/src/nsDeviceContext.cpp
gfx/src/nsDeviceContext.h
gfx/src/nsFontMetrics.h
gfx/src/nsRenderingContext.h
gfx/thebes/gfxDWriteShaper.cpp
gfx/thebes/gfxGDIShaper.cpp
layout/base/nsCaret.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
layout/generic/nsGfxScrollFrame.cpp
layout/svg/nsSVGUtils.cpp
view/public/nsViewManager.h
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -2295,17 +2295,17 @@ struct NS_STACK_CLASS CanvasBidiProcesso
       // old code was:
       //   point.x += width * mAppUnitsPerDevPixel;
       // TODO: restore this if/when we move to fractional coords
       // throughout the text layout process
     }
 
     uint32_t numRuns;
     const gfxTextRun::GlyphRun *runs = mTextRun->GetGlyphRuns(&numRuns);
-    const uint32_t appUnitsPerDevUnit = mAppUnitsPerDevPixel;
+    const int32_t appUnitsPerDevUnit = mAppUnitsPerDevPixel;
     const double devUnitsPerAppUnit = 1.0/double(appUnitsPerDevUnit);
     Point baselineOrigin =
       Point(point.x * devUnitsPerAppUnit, point.y * devUnitsPerAppUnit);
 
     float advanceSum = 0;
 
     mCtx->EnsureTarget();
     for (uint32_t c = 0; c < numRuns; c++) {
@@ -2419,17 +2419,17 @@ struct NS_STACK_CLASS CanvasBidiProcesso
 
   // position of the left side of the string, alphabetic baseline
   gfxPoint mPt;
 
   // current font
   gfxFontGroup* mFontgrp;
 
   // dev pixel conversion factor
-  uint32_t mAppUnitsPerDevPixel;
+  int32_t mAppUnitsPerDevPixel;
 
   // operation (fill or stroke)
   CanvasRenderingContext2D::TextDrawOperation mOp;
 
   // context state
   ContextState *mState;
 
   // union of bounding boxes of all runs, needed for shadows
--- a/content/canvas/src/CanvasRenderingContext2D.h
+++ b/content/canvas/src/CanvasRenderingContext2D.h
@@ -474,20 +474,20 @@ public:
   // this rect is in mTarget's current user space
   void RedrawUser(const gfxRect &r);
 
   // nsISupports interface + CC
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(CanvasRenderingContext2D)
 
-  enum CanvasMultiGetterType {
-    CMG_STYLE_STRING = 0,
-    CMG_STYLE_PATTERN = 1,
-    CMG_STYLE_GRADIENT = 2
+  enum CanvasMultiGetterType {
+    CMG_STYLE_STRING = 0,
+    CMG_STYLE_PATTERN = 1,
+    CMG_STYLE_GRADIENT = 2
   };
 
   enum Style {
     STYLE_STROKE = 0,
     STYLE_FILL,
     STYLE_MAX
   };
 
@@ -897,21 +897,21 @@ protected:
   inline ContextState& CurrentState() {
     return mStyleStack[mStyleStack.Length() - 1];
   }
 
   friend class CanvasGeneralPattern;
   friend class AdjustedTarget;
 
   // other helpers
-  void GetAppUnitsValues(uint32_t *perDevPixel, uint32_t *perCSSPixel)
+  void GetAppUnitsValues(int32_t *perDevPixel, int32_t *perCSSPixel)
   {
     // If we don't have a canvas element, we just return something generic.
-    uint32_t devPixel = 60;
-    uint32_t cssPixel = 60;
+    int32_t devPixel = 60;
+    int32_t cssPixel = 60;
 
     nsIPresShell *ps = GetPresShell();
     nsPresContext *pc;
 
     if (!ps) goto FINISH;
     pc = ps->GetPresContext();
     if (!pc) goto FINISH;
     devPixel = pc->AppUnitsPerDevPixel();
--- a/gfx/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -724,17 +724,17 @@ bool nsDeviceContext::CheckDPIChange() {
 
 bool
 nsDeviceContext::SetPixelScale(float aScale)
 {
     if (aScale <= 0) {
         NS_NOTREACHED("Invalid pixel scale value");
         return false;
     }
-    uint32_t oldAppUnitsPerDevPixel = mAppUnitsPerDevPixel;
+    int32_t oldAppUnitsPerDevPixel = mAppUnitsPerDevPixel;
     mPixelScale = aScale;
     UpdateScaledAppUnits();
     return oldAppUnitsPerDevPixel != mAppUnitsPerDevPixel;
 }
 
 void
 nsDeviceContext::UpdateScaledAppUnits()
 {
--- a/gfx/src/nsDeviceContext.h
+++ b/gfx/src/nsDeviceContext.h
@@ -53,17 +53,17 @@ public:
      */
     static int32_t 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.
      */
-    uint32_t AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
+    int32_t 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())); }
 
@@ -238,17 +238,17 @@ protected:
     void ComputeFullAreaUsingScreen(nsRect *outRect);
     void FindScreen(nsIScreen **outScreen);
     void CalcPrintingSize();
     void UpdateScaledAppUnits();
 
     nscoord  mWidth;
     nscoord  mHeight;
     uint32_t mDepth;
-    uint32_t  mAppUnitsPerDevPixel;
+    int32_t  mAppUnitsPerDevPixel;
     int32_t  mAppUnitsPerDevNotScaledPixel;
     int32_t  mAppUnitsPerPhysicalInch;
     float    mPixelScale;
     float    mPrintingScale;
 
     nsFontCache*                   mFontCache;
     nsCOMPtr<nsIWidget>            mWidget;
     nsCOMPtr<nsIScreenManager>     mScreenManager;
--- a/gfx/src/nsFontMetrics.h
+++ b/gfx/src/nsFontMetrics.h
@@ -195,22 +195,22 @@ public:
                                                     nsRenderingContext *aContext);
 
     void SetTextRunRTL(bool aIsRTL) { mTextRunRTL = aIsRTL; }
     bool GetTextRunRTL() { return mTextRunRTL; }
 
     gfxFontGroup* GetThebesFontGroup() { return mFontGroup; }
     gfxUserFontSet* GetUserFontSet() { return mFontGroup->GetUserFontSet(); }
 
-    uint32_t AppUnitsPerDevPixel() { return mP2A; }
+    int32_t AppUnitsPerDevPixel() { return mP2A; }
 
 protected:
     const gfxFont::Metrics& GetMetrics() const;
 
     nsFont mFont;
     nsRefPtr<gfxFontGroup> mFontGroup;
     nsCOMPtr<nsIAtom> mLanguage;
     nsDeviceContext *mDeviceContext;
-    uint32_t mP2A;
+    int32_t mP2A;
     bool mTextRunRTL;
 };
 
 #endif /* NSFONTMETRICS__H__ */
--- a/gfx/src/nsRenderingContext.h
+++ b/gfx/src/nsRenderingContext.h
@@ -36,17 +36,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; }
-    uint32_t AppUnitsPerDevPixel() { return NSToIntRound(mP2A); }
+    int32_t AppUnitsPerDevPixel() { return NSToIntRound(mP2A); }
 
     // Graphics state
 
     void PushState(void);
     void PopState(void);
     void IntersectClip(const nsRect& aRect);
     void SetClip(const nsIntRegion& aRegion);
     void SetLineStyle(nsLineStyle aLineStyle);
--- a/gfx/thebes/gfxDWriteShaper.cpp
+++ b/gfx/thebes/gfxDWriteShaper.cpp
@@ -49,17 +49,17 @@ gfxDWriteShaper::ShapeText(gfxContext   
     TextAnalysis::Run *runHead;
     hr = analysis.GenerateResults(analyzer, &runHead);
 
     if (FAILED(hr)) {
         NS_WARNING("Analyzer failed to generate results.");
         return false;
     }
 
-    uint32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
+    int32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
 
     UINT32 maxGlyphs = 0;
 trymoreglyphs:
     if ((UINT32_MAX - 3 * length / 2 + 16) < maxGlyphs) {
         // This isn't going to work, we're going to cross the UINT32 upper
         // limit. Give up.
         NS_WARNING("Shaper needs to generate more than 2^32 glyphs?!");
         return false;
--- a/gfx/thebes/gfxGDIShaper.cpp
+++ b/gfx/thebes/gfxGDIShaper.cpp
@@ -59,17 +59,17 @@ gfxGDIShaper::ShapeText(gfxContext      
         return false;
     }
 
     gfxTextRun::CompressedGlyph g;
     gfxTextRun::CompressedGlyph *charGlyphs =
         aShapedText->GetCharacterGlyphs();
     uint32_t i;
     int32_t lastWidth = 0;
-    uint32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
+    int32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
     for (i = 0; i < length; ++i) {
         uint32_t offset = aOffset + i;
         int32_t advancePixels = partialWidthArray[i] - lastWidth;
         lastWidth = partialWidthArray[i];
         int32_t advanceAppUnits = advancePixels * appUnitsPerDevPixel;
         WCHAR glyph = glyphs[i];
         NS_ASSERTION(!gfxFontGroup::IsInvalidChar(aText[i]),
                      "Invalid character detected!");
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -214,17 +214,17 @@ nsCaret::Metrics nsCaret::ComputeMetrics
   if (DrawCJKCaret(aFrame, aOffset)) {
     caretWidth += nsPresContext::CSSPixelsToAppUnits(1);
   }
   nscoord bidiIndicatorSize = nsPresContext::CSSPixelsToAppUnits(kMinBidiIndicatorPixels);
   bidiIndicatorSize = std::max(caretWidth, bidiIndicatorSize);
 
   // Round them to device pixels. Always round down, except that anything
   // between 0 and 1 goes up to 1 so we don't let the caret disappear.
-  uint32_t tpp = aFrame->PresContext()->AppUnitsPerDevPixel();
+  int32_t tpp = aFrame->PresContext()->AppUnitsPerDevPixel();
   Metrics result;
   result.mCaretWidth = NS_ROUND_BORDER_TO_PIXELS(caretWidth, tpp);
   result.mBidiIndicatorSize = NS_ROUND_BORDER_TO_PIXELS(bidiIndicatorSize, tpp);
   return result;
 }
 
 //-----------------------------------------------------------------------------
 void nsCaret::Terminate()
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1655,17 +1655,17 @@ nsPresContext::UIResolutionChangedSubdoc
 }
 
 void
 nsPresContext::UIResolutionChangedInternal()
 {
   mPendingUIResolutionChanged = false;
 
   mDeviceContext->CheckDPIChange();
-  if (uint32_t(mCurAppUnitsPerDevPixel) != AppUnitsPerDevPixel()) {
+  if (mCurAppUnitsPerDevPixel != AppUnitsPerDevPixel()) {
     AppUnitsPerDevPixelChanged();
   }
 
   mDocument->EnumerateSubDocuments(UIResolutionChangedSubdocumentCallback,
                                    nullptr);
 }
 
 void
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -546,17 +546,17 @@ public:
    * If |aChanged| is non-null, then aChanged is filled in with whether
    * the return value has changed since either:
    *  a. the last time the function was called with non-null aChanged, or
    *  b. the first time the function was called.
    */
   float ScreenWidthInchesForFontInflation(bool* aChanged = nullptr);
 
   static int32_t AppUnitsPerCSSPixel() { return nsDeviceContext::AppUnitsPerCSSPixel(); }
-  uint32_t AppUnitsPerDevPixel() const  { return mDeviceContext->AppUnitsPerDevPixel(); }
+  int32_t AppUnitsPerDevPixel() const  { return mDeviceContext->AppUnitsPerDevPixel(); }
   static int32_t AppUnitsPerCSSInch() { return nsDeviceContext::AppUnitsPerCSSInch(); }
 
   static nscoord CSSPixelsToAppUnits(int32_t aPixels)
   { return NSIntPixelsToAppUnits(aPixels,
                                  nsDeviceContext::AppUnitsPerCSSPixel()); }
 
   static nscoord CSSPixelsToAppUnits(float aPixels)
   { return NSFloatPixelsToAppUnits(aPixels,
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2328,17 +2328,17 @@ nsGfxScrollFrameInner::GetLineScrollAmou
   nsLayoutUtils::GetFontMetricsForFrame(mOuter, getter_AddRefs(fm),
     nsLayoutUtils::FontSizeInflationFor(mOuter));
   NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit");
   static nscoord sMinLineScrollAmountInPixels = -1;
   if (sMinLineScrollAmountInPixels < 0) {
     Preferences::AddIntVarCache(&sMinLineScrollAmountInPixels,
                                 "mousewheel.min_line_scroll_amount", 1);
   }
-  uint32_t appUnitsPerDevPixel = mOuter->PresContext()->AppUnitsPerDevPixel();
+  int32_t appUnitsPerDevPixel = mOuter->PresContext()->AppUnitsPerDevPixel();
   nscoord minScrollAmountInAppUnits =
     std::max(1, sMinLineScrollAmountInPixels) * appUnitsPerDevPixel;
   nscoord horizontalAmount = fm ? fm->AveCharWidth() : 0;
   nscoord verticalAmount = fm ? fm->MaxHeight() : 0;
   return nsSize(std::max(horizontalAmount, minScrollAmountInAppUnits),
                 std::max(verticalAmount, minScrollAmountInAppUnits));
 }
 
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -795,17 +795,17 @@ nsSVGUtils::PaintFrameWithEffects(nsRend
     // SVG doesn't maintain bounds/overflow rects.
     nsRect overflowRect = aFrame->GetVisualOverflowRectRelativeToSelf();
     if (aFrame->IsFrameOfType(nsIFrame::eSVGGeometry) ||
         aFrame->IsSVGText()) {
       // Unlike containers, leaf frames do not include GetPosition() in
       // GetCanvasTM().
       overflowRect = overflowRect + aFrame->GetPosition();
     }
-    uint32_t appUnitsPerDevPx = aFrame->PresContext()->AppUnitsPerDevPixel();
+    int32_t appUnitsPerDevPx = aFrame->PresContext()->AppUnitsPerDevPixel();
     gfxMatrix tm = GetCanvasTM(aFrame, nsISVGChildFrame::FOR_PAINTING);
     if (aFrame->IsFrameOfType(nsIFrame::eSVG | nsIFrame::eSVGContainer)) {
       gfxMatrix childrenOnlyTM;
       if (static_cast<nsSVGContainerFrame*>(aFrame)->
             HasChildrenOnlyTransform(&childrenOnlyTM)) {
         // Undo the children-only transform:
         tm = childrenOnlyTM.Invert() * tm;
       }
--- a/view/public/nsViewManager.h
+++ b/view/public/nsViewManager.h
@@ -309,17 +309,17 @@ public:
    */
   void ProcessPendingUpdates();
 
   /**
    * Just update widget geometry without flushing the dirty region
    */
   void UpdateWidgetGeometry();
 
-  uint32_t AppUnitsPerDevPixel() const
+  int32_t AppUnitsPerDevPixel() const
   {
     return mContext->AppUnitsPerDevPixel();
   }
 
 private:
   static uint32_t gLastUserEventTime;
 
   /* Update the cached RootViewManager pointer on this view manager. */