From 0da57ac99e421356434bf7fd00a31c02645c804e Mon Sep 17 00:00:00 2001 From: "jminta%gmail.com" Date: Mon, 21 May 2007 02:18:05 +0000 Subject: [PATCH] Bug 377717 Remove 'decorations' and 'variant' from gfxFontStyle, r=pavlov git-svn-id: svn://10.0.0.236/trunk@226695 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/thebes/nsSystemFontsBeOS.cpp | 9 +++------ mozilla/gfx/src/thebes/nsSystemFontsGTK2.cpp | 13 ++++--------- mozilla/gfx/src/thebes/nsSystemFontsMac.cpp | 3 --- mozilla/gfx/src/thebes/nsSystemFontsOS2.cpp | 2 -- mozilla/gfx/src/thebes/nsSystemFontsWin.cpp | 14 -------------- .../gfx/src/thebes/nsThebesDeviceContext.cpp | 9 ++++----- mozilla/gfx/src/thebes/nsThebesFontMetrics.cpp | 7 +++---- mozilla/gfx/thebes/public/gfxFont.h | 18 +----------------- mozilla/gfx/thebes/src/gfxFont.cpp | 13 ++++++------- .../gfx/thebes/test/gfxFontSelectionTests.h | 4 ---- mozilla/gfx/thebes/test/gfxTextRunPerfTest.cpp | 2 -- .../layout/svg/base/src/nsSVGGlyphFrame.cpp | 8 +++----- 12 files changed, 24 insertions(+), 78 deletions(-) diff --git a/mozilla/gfx/src/thebes/nsSystemFontsBeOS.cpp b/mozilla/gfx/src/thebes/nsSystemFontsBeOS.cpp index 03c19aff3eb..3b62bdf150d 100644 --- a/mozilla/gfx/src/thebes/nsSystemFontsBeOS.cpp +++ b/mozilla/gfx/src/thebes/nsSystemFontsBeOS.cpp @@ -52,16 +52,13 @@ nsSystemFontsBeOS::nsSystemFontsBeOS() : mDefaultFontName(NS_LITERAL_STRING("sans-serif")) , mMenuFontName(NS_LITERAL_STRING("sans-serif")) , mCaptionFontName(NS_LITERAL_STRING("sans-serif")) - , mDefaultFontStyle(FONT_STYLE_NORMAL, FONT_VARIANT_NORMAL, - FONT_WEIGHT_NORMAL, FONT_DECORATION_NONE, + , mDefaultFontStyle(FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, DEFAULT_PIXEL_FONT_SIZE, NS_LITERAL_CSTRING(""), 0.0f, PR_TRUE, PR_FALSE) - , mMenuFontStyle(FONT_STYLE_NORMAL, FONT_VARIANT_NORMAL, - FONT_WEIGHT_NORMAL, FONT_DECORATION_NONE, + , mMenuFontStyle(FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, DEFAULT_PIXEL_FONT_SIZE, NS_LITERAL_CSTRING(""), 0.0f, PR_TRUE, PR_FALSE) - , mCaptionFontStyle(FONT_STYLE_NORMAL, FONT_VARIANT_NORMAL, - FONT_WEIGHT_NORMAL, FONT_DECORATION_NONE, + , mCaptionFontStyle(FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, DEFAULT_PIXEL_FONT_SIZE, NS_LITERAL_CSTRING(""), 0.0f, PR_TRUE, PR_FALSE) { diff --git a/mozilla/gfx/src/thebes/nsSystemFontsGTK2.cpp b/mozilla/gfx/src/thebes/nsSystemFontsGTK2.cpp index 802bd921cd2..ab8bbdbb388 100644 --- a/mozilla/gfx/src/thebes/nsSystemFontsGTK2.cpp +++ b/mozilla/gfx/src/thebes/nsSystemFontsGTK2.cpp @@ -121,20 +121,16 @@ nsSystemFontsGTK2::nsSystemFontsGTK2() , mButtonFontName(NS_LITERAL_STRING("sans-serif")) , mFieldFontName(NS_LITERAL_STRING("sans-serif")) , mMenuFontName(NS_LITERAL_STRING("sans-serif")) - , mDefaultFontStyle(FONT_STYLE_NORMAL, FONT_VARIANT_NORMAL, - FONT_WEIGHT_NORMAL, FONT_DECORATION_NONE, + , mDefaultFontStyle(FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, DEFAULT_PIXEL_FONT_SIZE, NS_LITERAL_CSTRING(""), 0.0f, PR_TRUE, PR_FALSE) - , mButtonFontStyle(FONT_STYLE_NORMAL, FONT_VARIANT_NORMAL, - FONT_WEIGHT_NORMAL, FONT_DECORATION_NONE, + , mButtonFontStyle(FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, DEFAULT_PIXEL_FONT_SIZE, NS_LITERAL_CSTRING(""), 0.0f, PR_TRUE, PR_FALSE) - , mFieldFontStyle(FONT_STYLE_NORMAL, FONT_VARIANT_NORMAL, - FONT_WEIGHT_NORMAL, FONT_DECORATION_NONE, + , mFieldFontStyle(FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, DEFAULT_PIXEL_FONT_SIZE, NS_LITERAL_CSTRING(""), 0.0f, PR_TRUE, PR_FALSE) - , mMenuFontStyle(FONT_STYLE_NORMAL, FONT_VARIANT_NORMAL, - FONT_WEIGHT_NORMAL, FONT_DECORATION_NONE, + , mMenuFontStyle(FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, DEFAULT_PIXEL_FONT_SIZE, NS_LITERAL_CSTRING(""), 0.0f, PR_TRUE, PR_FALSE) { @@ -217,7 +213,6 @@ nsSystemFontsGTK2::GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName, GtkSettings *settings = gtk_widget_get_settings(aWidget); aFontStyle->style = FONT_STYLE_NORMAL; - aFontStyle->decorations = FONT_DECORATION_NONE; gchar *fontname; g_object_get(settings, "gtk-font-name", &fontname, NULL); diff --git a/mozilla/gfx/src/thebes/nsSystemFontsMac.cpp b/mozilla/gfx/src/thebes/nsSystemFontsMac.cpp index e42229b9546..7c34881a1b2 100644 --- a/mozilla/gfx/src/thebes/nsSystemFontsMac.cpp +++ b/mozilla/gfx/src/thebes/nsSystemFontsMac.cpp @@ -116,7 +116,6 @@ nsSystemFontsMac::GetSystemFont(nsSystemFontID aID, nsString *aFontName, { aFontStyle->style = FONT_STYLE_NORMAL; aFontStyle->weight = FONT_WEIGHT_NORMAL; - aFontStyle->decorations = FONT_DECORATION_NONE; aFontName->AssignLiteral("sans-serif"); aFontStyle->size = 14; @@ -183,8 +182,6 @@ nsSystemFontsMac::GetSystemFont(nsSystemFontID aID, nsString *aFontName, aFontStyle->weight = FONT_WEIGHT_BOLD; if (fontStyle & italic) aFontStyle->style = FONT_STYLE_ITALIC; - if (fontStyle & underline) - aFontStyle->decorations = FONT_DECORATION_UNDERLINE; aFontStyle->systemFont = PR_TRUE; diff --git a/mozilla/gfx/src/thebes/nsSystemFontsOS2.cpp b/mozilla/gfx/src/thebes/nsSystemFontsOS2.cpp index cb80d54a390..355c3d10f90 100644 --- a/mozilla/gfx/src/thebes/nsSystemFontsOS2.cpp +++ b/mozilla/gfx/src/thebes/nsSystemFontsOS2.cpp @@ -189,9 +189,7 @@ nsresult nsSystemFontsOS2::GetSystemFontInfo(nsSystemFontID aID, nsString* aFont // As in old gfx/src/os2 set the styles to the defaults aFontStyle->style = FONT_STYLE_NORMAL; - aFontStyle->variant = FONT_VARIANT_NORMAL; aFontStyle->weight = FONT_WEIGHT_NORMAL; - aFontStyle->decorations = FONT_DECORATION_NONE; aFontStyle->size = gfxFloat(pointSize); aFontStyle->systemFont = PR_TRUE; diff --git a/mozilla/gfx/src/thebes/nsSystemFontsWin.cpp b/mozilla/gfx/src/thebes/nsSystemFontsWin.cpp index bce4e62fd39..f53f06ae102 100644 --- a/mozilla/gfx/src/thebes/nsSystemFontsWin.cpp +++ b/mozilla/gfx/src/thebes/nsSystemFontsWin.cpp @@ -66,24 +66,10 @@ nsresult nsSystemFontsWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONT* ptrLogF } // XXX What about oblique? - aFontStyle->variant = FONT_VARIANT_NORMAL; - // Do Weight aFontStyle->weight = (ptrLogFont->lfWeight == FW_BOLD ? FONT_WEIGHT_BOLD : FONT_WEIGHT_NORMAL); - // Do decorations - aFontStyle->decorations = FONT_DECORATION_NONE; - if (ptrLogFont->lfUnderline) - { - aFontStyle->decorations |= FONT_DECORATION_UNDERLINE; - } - if (ptrLogFont->lfStrikeOut) - { - aFontStyle->decorations |= FONT_DECORATION_STRIKEOUT; - } - - // XXX mPixelScale is currently hardcoded to 1 in thebes gfx... float mPixelScale = 1.0f; // Do Point Size diff --git a/mozilla/gfx/src/thebes/nsThebesDeviceContext.cpp b/mozilla/gfx/src/thebes/nsThebesDeviceContext.cpp index a16fd9c8aaf..3454262e88c 100644 --- a/mozilla/gfx/src/thebes/nsThebesDeviceContext.cpp +++ b/mozilla/gfx/src/thebes/nsThebesDeviceContext.cpp @@ -399,9 +399,8 @@ nsThebesDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const } nsString fontName; - gfxFontStyle fontStyle(NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL, - FONT_WEIGHT_NORMAL, FONT_DECORATION_NONE, - 16.0f, NS_LITERAL_CSTRING(""), 0.0f, PR_TRUE, + gfxFontStyle fontStyle(NS_FONT_STYLE_NORMAL, FONT_WEIGHT_NORMAL, 16.0f, + NS_LITERAL_CSTRING(""), 0.0f, PR_TRUE, PR_FALSE); nsresult rv = gSystemFonts->GetSystemFont(aID, &fontName, &fontStyle); NS_ENSURE_SUCCESS(rv, rv); @@ -409,10 +408,10 @@ nsThebesDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const aFont->name = fontName; aFont->style = fontStyle.style; aFont->systemFont = fontStyle.systemFont; - aFont->variant = fontStyle.variant; + aFont->variant = NS_FONT_VARIANT_NORMAL; aFont->familyNameQuirks = fontStyle.familyNameQuirks; aFont->weight = fontStyle.weight; - aFont->decorations = fontStyle.decorations; + aFont->decorations = NS_FONT_DECORATION_NONE; aFont->size = NSFloatPixelsToAppUnits(fontStyle.size, AppUnitsPerDevPixel()); //aFont->langGroup = fontStyle.langGroup; aFont->sizeAdjust = fontStyle.sizeAdjust; diff --git a/mozilla/gfx/src/thebes/nsThebesFontMetrics.cpp b/mozilla/gfx/src/thebes/nsThebesFontMetrics.cpp index 1a5c30d25ff..7fecd46f240 100644 --- a/mozilla/gfx/src/thebes/nsThebesFontMetrics.cpp +++ b/mozilla/gfx/src/thebes/nsThebesFontMetrics.cpp @@ -84,10 +84,9 @@ nsThebesFontMetrics::Init(const nsFont& aFont, nsIAtom* aLangGroup, langGroup.Assign(lg); } - mFontStyle = new gfxFontStyle(aFont.style, aFont.variant, - aFont.weight, aFont.decorations, - size, langGroup, aFont.sizeAdjust, - aFont.systemFont, aFont.familyNameQuirks); + mFontStyle = new gfxFontStyle(aFont.style, aFont.weight, size, langGroup, + aFont.sizeAdjust, aFont.systemFont, + aFont.familyNameQuirks); mFontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(aFont.name, mFontStyle); diff --git a/mozilla/gfx/thebes/public/gfxFont.h b/mozilla/gfx/thebes/public/gfxFont.h index 5606e834f30..7d12ab6b003 100644 --- a/mozilla/gfx/thebes/public/gfxFont.h +++ b/mozilla/gfx/thebes/public/gfxFont.h @@ -61,20 +61,11 @@ typedef struct _cairo cairo_t; #define FONT_STYLE_ITALIC 1 #define FONT_STYLE_OBLIQUE 2 -#define FONT_VARIANT_NORMAL 0 -#define FONT_VARIANT_SMALL_CAPS 1 - -#define FONT_DECORATION_NONE 0x0 -#define FONT_DECORATION_UNDERLINE 0x1 -#define FONT_DECORATION_OVERLINE 0x2 -#define FONT_DECORATION_STRIKEOUT 0x4 - #define FONT_WEIGHT_NORMAL 400 #define FONT_WEIGHT_BOLD 700 struct THEBES_API gfxFontStyle { - gfxFontStyle(PRUint8 aStyle, PRUint8 aVariant, - PRUint16 aWeight, PRUint8 aDecoration, gfxFloat aSize, + gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, gfxFloat aSize, const nsACString& aLangGroup, float aSizeAdjust, PRPackedBool aSystemFont, PRPackedBool aFamilyNameQuirks); @@ -88,9 +79,6 @@ struct THEBES_API gfxFontStyle { // sources. PRPackedBool systemFont : 1; - // The variant of the font (normal, small-caps) - PRUint8 variant : 7; - // True if the character set quirks (for treatment of "Symbol", // "Wingdings", etc.) should be applied. PRPackedBool familyNameQuirks : 1; @@ -102,10 +90,6 @@ struct THEBES_API gfxFontStyle { // font being used, since it is two weights lighter than 900. PRUint16 weight; - // The decorations on the font (underline, overline, - // line-through). The decorations can be binary or'd together. - PRUint8 decorations; - // The logical size of the font, in pixels gfxFloat size; diff --git a/mozilla/gfx/thebes/src/gfxFont.cpp b/mozilla/gfx/thebes/src/gfxFont.cpp index ef77c640ab8..66dcd6c582b 100644 --- a/mozilla/gfx/thebes/src/gfxFont.cpp +++ b/mozilla/gfx/thebes/src/gfxFont.cpp @@ -552,14 +552,13 @@ gfxFontGroup::MakeSpaceTextRun(const Parameters *aParams, PRUint32 aFlags) return textRun.forget(); } -gfxFontStyle::gfxFontStyle(PRUint8 aStyle, PRUint8 aVariant, - PRUint16 aWeight, PRUint8 aDecoration, gfxFloat aSize, +gfxFontStyle::gfxFontStyle(PRUint8 aStyle, PRUint16 aWeight, gfxFloat aSize, const nsACString& aLangGroup, float aSizeAdjust, PRPackedBool aSystemFont, PRPackedBool aFamilyNameQuirks) : - style(aStyle), systemFont(aSystemFont), variant(aVariant), + style(aStyle), systemFont(aSystemFont), familyNameQuirks(aFamilyNameQuirks), weight(aWeight), - decorations(aDecoration), size(PR_MIN(aSize, 5000)), langGroup(aLangGroup), sizeAdjust(aSizeAdjust) + size(PR_MIN(aSize, 5000)), langGroup(aLangGroup), sizeAdjust(aSizeAdjust) { if (weight > 900) weight = 900; @@ -573,10 +572,10 @@ gfxFontStyle::gfxFontStyle(PRUint8 aStyle, PRUint8 aVariant, } gfxFontStyle::gfxFontStyle(const gfxFontStyle& aStyle) : - style(aStyle.style), systemFont(aStyle.systemFont), variant(aStyle.variant), + style(aStyle.style), systemFont(aStyle.systemFont), familyNameQuirks(aStyle.familyNameQuirks), weight(aStyle.weight), - decorations(aStyle.decorations), size(aStyle.size), - langGroup(aStyle.langGroup), sizeAdjust(aStyle.sizeAdjust) + size(aStyle.size), langGroup(aStyle.langGroup), + sizeAdjust(aStyle.sizeAdjust) { } diff --git a/mozilla/gfx/thebes/test/gfxFontSelectionTests.h b/mozilla/gfx/thebes/test/gfxFontSelectionTests.h index 5e0d79aa687..af03a39023f 100644 --- a/mozilla/gfx/thebes/test/gfxFontSelectionTests.h +++ b/mozilla/gfx/thebes/test/gfxFontSelectionTests.h @@ -106,18 +106,14 @@ SetupTests() /* some common styles */ gfxFontStyle style_western_normal_16 (FONT_STYLE_NORMAL, - FONT_VARIANT_NORMAL, 400, - FONT_DECORATION_NONE, 16.0, nsDependentCString("x-western"), 0.0, PR_FALSE, PR_FALSE); gfxFontStyle style_western_bold_16 (FONT_STYLE_NORMAL, - FONT_VARIANT_NORMAL, 700, - FONT_DECORATION_NONE, 16.0, nsDependentCString("x-western"), 0.0, diff --git a/mozilla/gfx/thebes/test/gfxTextRunPerfTest.cpp b/mozilla/gfx/thebes/test/gfxTextRunPerfTest.cpp index 100c40df6a3..9620906998f 100644 --- a/mozilla/gfx/thebes/test/gfxTextRunPerfTest.cpp +++ b/mozilla/gfx/thebes/test/gfxTextRunPerfTest.cpp @@ -90,9 +90,7 @@ void RunTest (TestEntry *test, gfxContext *ctx) { if (!lastFamilies || strcmp(lastFamilies, test->mFamilies)) { gfxFontStyle style_western_normal_16 (FONT_STYLE_NORMAL, - FONT_VARIANT_NORMAL, 400, - FONT_DECORATION_NONE, 16.0, nsDependentCString("x-western"), 0.0, diff --git a/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp b/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp index ea8debf6b5d..1c29fc377ee 100644 --- a/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGGlyphFrame.cpp @@ -140,11 +140,9 @@ nsSVGGlyphFrame::DidSetStyleContext() langGroup.Assign(lg); } - // XXX decorations are ignored by gfxFontStyle - still need to implement - mFontStyle = new gfxFontStyle(font.style, font.variant, - font.weight, font.decorations, - size, langGroup, font.sizeAdjust, - font.systemFont, font.familyNameQuirks); + mFontStyle = new gfxFontStyle(font.style, font.weight, size, langGroup, + font.sizeAdjust, font.systemFont, + font.familyNameQuirks); if (mFontStyle) { mFontGroup =