From 5c0cb5339d7b749ca67027b8811d2ed2c2a5cd2c Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Tue, 20 Mar 2007 08:58:53 +0000 Subject: [PATCH] Bug 374567. Make GetDevUnitsPerAppUnit return a PRUint32. r=pavlov --- gfx/thebes/public/gfxFont.h | 4 ++-- gfx/thebes/src/gfxAtsuiFonts.cpp | 4 +--- gfx/thebes/src/gfxFont.cpp | 8 ++++---- gfx/thebes/src/gfxPangoFonts.cpp | 8 ++++---- gfx/thebes/src/gfxWindowsFonts.cpp | 2 +- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/gfx/thebes/public/gfxFont.h b/gfx/thebes/public/gfxFont.h index 6cc177d4621..9fb9e46f754 100644 --- a/gfx/thebes/public/gfxFont.h +++ b/gfx/thebes/public/gfxFont.h @@ -693,7 +693,7 @@ public: void *GetUserData() const { return mUserData; } PRUint32 GetFlags() const { return mFlags; } const gfxSkipChars& GetSkipChars() const { return mSkipChars; } - float GetAppUnitsPerDevUnit() { return mAppUnitsPerDevUnit; } + PRUint32 GetAppUnitsPerDevUnit() const { return mAppUnitsPerDevUnit; } // The caller is responsible for initializing our glyphs after construction. // Initially all glyphs are such that GetCharacterGlyphs()[i].IsMissing() is true. @@ -965,7 +965,7 @@ private: gfxSkipChars mSkipChars; // This is actually an integer, but we keep it in float form to reduce // the conversions required - float mAppUnitsPerDevUnit; + PRUint32 mAppUnitsPerDevUnit; PRUint32 mFlags; PRUint32 mCharacterCount; }; diff --git a/gfx/thebes/src/gfxAtsuiFonts.cpp b/gfx/thebes/src/gfxAtsuiFonts.cpp index 8168d898ec6..dd86ebc1e7e 100644 --- a/gfx/thebes/src/gfxAtsuiFonts.cpp +++ b/gfx/thebes/src/gfxAtsuiFonts.cpp @@ -619,9 +619,7 @@ PostLayoutCallback(ATSULineRef aLine, gfxTextRun *aRun, if (numGlyphs == 0) return; - PRUint32 appUnitsPerDevUnit = PRUint32(aRun->GetAppUnitsPerDevUnit()); - NS_ASSERTION(appUnitsPerDevUnit == aRun->GetAppUnitsPerDevUnit(), - "Textrun's appunits per devunit is weird..."); + PRUint32 appUnitsPerDevUnit = aRun->GetAppUnitsPerDevUnit(); // ATSUI seems to have a bug where trailing whitespace in a run, // even after we've forced the direction with LRO/RLO/PDF, does not diff --git a/gfx/thebes/src/gfxFont.cpp b/gfx/thebes/src/gfxFont.cpp index 6fdafe3043c..e422cd7d166 100644 --- a/gfx/thebes/src/gfxFont.cpp +++ b/gfx/thebes/src/gfxFont.cpp @@ -76,8 +76,8 @@ gfxFont::Draw(gfxTextRun *aTextRun, PRUint32 aStart, PRUint32 aEnd, return; const gfxTextRun::CompressedGlyph *charGlyphs = aTextRun->GetCharacterGlyphs(); - double appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit(); - double devUnitsPerAppUnit = 1/appUnitsPerDevUnit; + const PRUint32 appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit(); + const double devUnitsPerAppUnit = 1.0/double(appUnitsPerDevUnit); PRBool isRTL = aTextRun->IsRightToLeft(); double direction = aTextRun->GetDirection(); nsAutoTArray glyphBuffer; @@ -195,7 +195,7 @@ gfxFont::Measure(gfxTextRun *aTextRun, RunMetrics metrics; const gfxFont::Metrics& fontMetrics = GetMetrics(); metrics.mAdvanceWidth = floatAdvance; - gfxFloat appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit(); + const PRUint32 appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit(); metrics.mAscent = fontMetrics.maxAscent*appUnitsPerDevUnit; metrics.mDescent = fontMetrics.maxDescent*appUnitsPerDevUnit; metrics.mBoundingBox = @@ -426,7 +426,7 @@ gfxFontGroup::GetSpecialStringTextRun(SpecialString aString, gfxTextRunFactory::Parameters params = { nsnull, nsnull, nsnull, nsnull, nsnull, 0, - PRUint32(aTemplate->GetAppUnitsPerDevUnit()), TEXT_IS_PERSISTENT + aTemplate->GetAppUnitsPerDevUnit(), TEXT_IS_PERSISTENT }; gfxTextRun* textRun; diff --git a/gfx/thebes/src/gfxPangoFonts.cpp b/gfx/thebes/src/gfxPangoFonts.cpp index 53991fff2d2..6ecbef37778 100644 --- a/gfx/thebes/src/gfxPangoFonts.cpp +++ b/gfx/thebes/src/gfxPangoFonts.cpp @@ -739,13 +739,13 @@ gfxPangoFontGroup::InitTextRun(gfxTextRun *aTextRun, const gchar *aUTF8Text, static gfxTextRun::Metrics GetPangoMetrics(PangoGlyphString *aGlyphs, PangoFont *aPangoFont, - gfxFloat aPixelsToUnits, PRUint32 aClusterCount) + PRUint32 aPixelsToUnits, PRUint32 aClusterCount) { PangoRectangle inkRect; PangoRectangle logicalRect; pango_glyph_string_extents(aGlyphs, aPangoFont, &inkRect, &logicalRect); - gfxFloat scale = aPixelsToUnits/PANGO_SCALE; + gfxFloat scale = gfxFloat(aPixelsToUnits)/PANGO_SCALE; gfxTextRun::Metrics metrics; NS_ASSERTION(logicalRect.x == 0, "Weird logical rect..."); @@ -959,7 +959,7 @@ gfxPangoFontGroup::SetGlyphs(gfxTextRun* aTextRun, PRInt32 direction = aTextRun->IsRightToLeft() ? -1 : 1; gfxTextRun::CompressedGlyph g; nsAutoTArray detailedGlyphs; - PRUint32 appUnitsPerDevUnit = PRUint32(aTextRun->GetAppUnitsPerDevUnit()); + const PRUint32 appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit(); while (index < aUTF8Length) { if (utf16Offset >= textRunLength) { @@ -1069,7 +1069,7 @@ gfxPangoFontGroup::CreateGlyphRunsXft(gfxTextRun *aTextRun, XftFont *xfont = font->GetXftFont(); PRUint32 utf16Offset = 0; gfxTextRun::CompressedGlyph g; - PRUint32 appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit(); + const PRUint32 appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit(); while (p < aUTF8 + aUTF8Length) { gunichar ch = g_utf8_get_char(p); diff --git a/gfx/thebes/src/gfxWindowsFonts.cpp b/gfx/thebes/src/gfxWindowsFonts.cpp index 294cbfdf788..72d10c19321 100644 --- a/gfx/thebes/src/gfxWindowsFonts.cpp +++ b/gfx/thebes/src/gfxWindowsFonts.cpp @@ -1150,7 +1150,7 @@ public: PRUint32 offset = 0; nsAutoTArray detailedGlyphs; gfxTextRun::CompressedGlyph g; - PRUint32 appUnitsPerDevUnit = PRUint32(aRun->GetAppUnitsPerDevUnit()); + const PRUint32 appUnitsPerDevUnit = aRun->GetAppUnitsPerDevUnit(); while (offset < mLength) { PRUint32 runOffset = offsetInRun + offset; if (offset > 0 && mClusters[offset] == mClusters[offset - 1]) {