Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 9cd7d9f

Browse files
committed
bug 842514 - consistently use signed types for appUnitsPerDevPixel variables. r=roc
1 parent b233d5c commit 9cd7d9f

14 files changed

Lines changed: 23 additions & 23 deletions

content/canvas/src/CanvasRenderingContext2D.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,7 +2300,7 @@ struct NS_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcesso
23002300

23012301
uint32_t numRuns;
23022302
const gfxTextRun::GlyphRun *runs = mTextRun->GetGlyphRuns(&numRuns);
2303-
const uint32_t appUnitsPerDevUnit = mAppUnitsPerDevPixel;
2303+
const int32_t appUnitsPerDevUnit = mAppUnitsPerDevPixel;
23042304
const double devUnitsPerAppUnit = 1.0/double(appUnitsPerDevUnit);
23052305
Point baselineOrigin =
23062306
Point(point.x * devUnitsPerAppUnit, point.y * devUnitsPerAppUnit);
@@ -2424,7 +2424,7 @@ struct NS_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcesso
24242424
gfxFontGroup* mFontgrp;
24252425

24262426
// dev pixel conversion factor
2427-
uint32_t mAppUnitsPerDevPixel;
2427+
int32_t mAppUnitsPerDevPixel;
24282428

24292429
// operation (fill or stroke)
24302430
CanvasRenderingContext2D::TextDrawOperation mOp;

content/canvas/src/CanvasRenderingContext2D.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,10 @@ typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
479479

480480
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(CanvasRenderingContext2D)
481481

482-
enum CanvasMultiGetterType {
483-
CMG_STYLE_STRING = 0,
484-
CMG_STYLE_PATTERN = 1,
485-
CMG_STYLE_GRADIENT = 2
482+
enum CanvasMultiGetterType {
483+
CMG_STYLE_STRING = 0,
484+
CMG_STYLE_PATTERN = 1,
485+
CMG_STYLE_GRADIENT = 2
486486
};
487487

488488
enum Style {
@@ -902,11 +902,11 @@ typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
902902
friend class AdjustedTarget;
903903

904904
// other helpers
905-
void GetAppUnitsValues(uint32_t *perDevPixel, uint32_t *perCSSPixel)
905+
void GetAppUnitsValues(int32_t *perDevPixel, int32_t *perCSSPixel)
906906
{
907907
// If we don't have a canvas element, we just return something generic.
908-
uint32_t devPixel = 60;
909-
uint32_t cssPixel = 60;
908+
int32_t devPixel = 60;
909+
int32_t cssPixel = 60;
910910

911911
nsIPresShell *ps = GetPresShell();
912912
nsPresContext *pc;

gfx/src/nsDeviceContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ nsDeviceContext::SetPixelScale(float aScale)
729729
NS_NOTREACHED("Invalid pixel scale value");
730730
return false;
731731
}
732-
uint32_t oldAppUnitsPerDevPixel = mAppUnitsPerDevPixel;
732+
int32_t oldAppUnitsPerDevPixel = mAppUnitsPerDevPixel;
733733
mPixelScale = aScale;
734734
UpdateScaledAppUnits();
735735
return oldAppUnitsPerDevPixel != mAppUnitsPerDevPixel;

gfx/src/nsDeviceContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class nsDeviceContext
5858
* is usually a factor of AppUnitsPerCSSPixel(), although that is
5959
* not guaranteed.
6060
*/
61-
uint32_t AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
61+
int32_t AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
6262

6363
/**
6464
* Convert device pixels which is used for gfx/thebes to nearest
@@ -243,7 +243,7 @@ class nsDeviceContext
243243
nscoord mWidth;
244244
nscoord mHeight;
245245
uint32_t mDepth;
246-
uint32_t mAppUnitsPerDevPixel;
246+
int32_t mAppUnitsPerDevPixel;
247247
int32_t mAppUnitsPerDevNotScaledPixel;
248248
int32_t mAppUnitsPerPhysicalInch;
249249
float mPixelScale;

gfx/src/nsFontMetrics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class nsFontMetrics
200200
gfxFontGroup* GetThebesFontGroup() { return mFontGroup; }
201201
gfxUserFontSet* GetUserFontSet() { return mFontGroup->GetUserFontSet(); }
202202

203-
uint32_t AppUnitsPerDevPixel() { return mP2A; }
203+
int32_t AppUnitsPerDevPixel() { return mP2A; }
204204

205205
protected:
206206
const gfxFont::Metrics& GetMetrics() const;
@@ -209,7 +209,7 @@ class nsFontMetrics
209209
nsRefPtr<gfxFontGroup> mFontGroup;
210210
nsCOMPtr<nsIAtom> mLanguage;
211211
nsDeviceContext *mDeviceContext;
212-
uint32_t mP2A;
212+
int32_t mP2A;
213213
bool mTextRunRTL;
214214
};
215215

gfx/src/nsRenderingContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class nsRenderingContext
4141
// These accessors will never return null.
4242
gfxContext *ThebesContext() { return mThebes; }
4343
nsDeviceContext *DeviceContext() { return mDeviceContext; }
44-
uint32_t AppUnitsPerDevPixel() { return NSToIntRound(mP2A); }
44+
int32_t AppUnitsPerDevPixel() { return NSToIntRound(mP2A); }
4545

4646
// Graphics state
4747

gfx/thebes/gfxDWriteShaper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ gfxDWriteShaper::ShapeText(gfxContext *aContext,
5454
return false;
5555
}
5656

57-
uint32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
57+
int32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
5858

5959
UINT32 maxGlyphs = 0;
6060
trymoreglyphs:

gfx/thebes/gfxGDIShaper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ gfxGDIShaper::ShapeText(gfxContext *aContext,
6464
aShapedText->GetCharacterGlyphs();
6565
uint32_t i;
6666
int32_t lastWidth = 0;
67-
uint32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
67+
int32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
6868
for (i = 0; i < length; ++i) {
6969
uint32_t offset = aOffset + i;
7070
int32_t advancePixels = partialWidthArray[i] - lastWidth;

layout/base/nsCaret.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ nsCaret::Metrics nsCaret::ComputeMetrics(nsIFrame* aFrame, int32_t aOffset, nsco
219219

220220
// Round them to device pixels. Always round down, except that anything
221221
// between 0 and 1 goes up to 1 so we don't let the caret disappear.
222-
uint32_t tpp = aFrame->PresContext()->AppUnitsPerDevPixel();
222+
int32_t tpp = aFrame->PresContext()->AppUnitsPerDevPixel();
223223
Metrics result;
224224
result.mCaretWidth = NS_ROUND_BORDER_TO_PIXELS(caretWidth, tpp);
225225
result.mBidiIndicatorSize = NS_ROUND_BORDER_TO_PIXELS(bidiIndicatorSize, tpp);

layout/base/nsPresContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ nsPresContext::UIResolutionChangedInternal()
16601660
mPendingUIResolutionChanged = false;
16611661

16621662
mDeviceContext->CheckDPIChange();
1663-
if (uint32_t(mCurAppUnitsPerDevPixel) != AppUnitsPerDevPixel()) {
1663+
if (mCurAppUnitsPerDevPixel != AppUnitsPerDevPixel()) {
16641664
AppUnitsPerDevPixelChanged();
16651665
}
16661666

0 commit comments

Comments
 (0)