Bug 548608 - update SupportsLangGroup in Windows font list code for nsIAtom-based language codes. r=roc
authorJonathan Kew <jfkthame@gmail.com>
Thu, 25 Feb 2010 15:02:54 -0800
changeset 38716 c2ed18018054dd89e598d6a3afbf7ca5f1447ce5
parent 38715 e0b27f47922930e045bf7252acde6de8757b4a09
child 38717 2cc3e6d170ebe56e9dd15d03de16a4ddf6e92f30
push id11818
push userjkew@mozilla.com
push dateThu, 25 Feb 2010 23:05:20 +0000
treeherderautoland@c2ed18018054 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs548608
milestone1.9.3a2pre
Bug 548608 - update SupportsLangGroup in Windows font list code for nsIAtom-based language codes. r=roc
gfx/thebes/src/gfxAtomList.h
gfx/thebes/src/gfxGDIFontList.h
--- a/gfx/thebes/src/gfxAtomList.h
+++ b/gfx/thebes/src/gfxAtomList.h
@@ -82,8 +82,12 @@ GFX_ATOM(x_gujr, "x-gujr")
 GFX_ATOM(x_guru, "x-guru")
 GFX_ATOM(x_khmr, "x-khmr")
 GFX_ATOM(x_mlym, "x-mlym")
 GFX_ATOM(x_orya, "x-orya")
 GFX_ATOM(x_telu, "x-telu")
 GFX_ATOM(x_knda, "x-knda")
 GFX_ATOM(x_sinh, "x-sinh")
 
+// used in gfxGDIFontList.h
+GFX_ATOM(ko_xxx, "ko-xxx")
+GFX_ATOM(x_central_euro, "x-central-euro")
+GFX_ATOM(x_symbol, "x-symbol")
--- a/gfx/thebes/src/gfxGDIFontList.h
+++ b/gfx/thebes/src/gfxGDIFontList.h
@@ -38,16 +38,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef GFX_GDIFONTLIST_H
 #define GFX_GDIFONTLIST_H
 
 #include "gfxWindowsPlatform.h"
 #include "gfxPlatformFontList.h"
+#include "gfxAtoms.h"
 
 #include <windows.h>
 
 class AutoDC // get the global device context, and auto-release it on destruction
 {
 public:
     AutoDC() {
         mDC = ::GetDC(NULL);
@@ -169,19 +170,20 @@ public:
                 mFontType == GFX_FONT_TYPE_TT_OPENTYPE);
     }
 
     PRBool IsCrappyFont() const {
         /* return if it is a bitmap not a unicode font */
         return (!mUnicodeFont || IsSymbolFont() || IsType1());
     }
 
-    PRBool MatchesGenericFamily(const nsACString& aGeneric) const {
-        if (aGeneric.IsEmpty())
+    virtual PRBool MatchesGenericFamily(const nsACString& aGeneric) const {
+        if (aGeneric.IsEmpty()) {
             return PR_TRUE;
+        }
 
         // Japanese 'Mincho' fonts do not belong to FF_MODERN even if
         // they are fixed pitch because they have variable stroke width.
         if (mWindowsFamily == FF_ROMAN && mWindowsPitch & FIXED_PITCH) {
             return aGeneric.EqualsLiteral("monospace");
         }
 
         // Japanese 'Gothic' fonts do not belong to FF_SWISS even if
@@ -204,66 +206,68 @@ public:
             return aGeneric.EqualsLiteral("cursive");
         case FF_DECORATIVE:
             return aGeneric.EqualsLiteral("fantasy");
         }
 
         return PR_FALSE;
     }
 
-    PRBool SupportsLangGroup(const nsACString& aLangGroup) const {
-        if (aLangGroup.IsEmpty())
+    virtual PRBool SupportsLangGroup(nsIAtom* aLangGroup) const {
+        if (!aLangGroup) {
             return PR_TRUE;
+        }
 
         PRInt16 bit = -1;
 
         /* map our langgroup names in to Windows charset bits */
-        if (aLangGroup.EqualsLiteral("x-western")) {
+        if (aLangGroup == gfxAtoms::x_western) {
             bit = ANSI_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("ja")) {
+        } else if (aLangGroup == gfxAtoms::ja) {
             bit = SHIFTJIS_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("ko")) {
+        } else if (aLangGroup == gfxAtoms::ko) {
             bit = HANGEUL_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("ko-XXX")) {
+        } else if (aLangGroup == gfxAtoms::ko_xxx) {
             bit = JOHAB_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("zh-CN")) {
+        } else if (aLangGroup == gfxAtoms::zh_cn) {
             bit = GB2312_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("zh-TW")) {
+        } else if (aLangGroup == gfxAtoms::zh_tw) {
             bit = CHINESEBIG5_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("el")) {
+        } else if (aLangGroup == gfxAtoms::el) {
             bit = GREEK_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("tr")) {
+        } else if (aLangGroup == gfxAtoms::tr) {
             bit = TURKISH_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("he")) {
+        } else if (aLangGroup == gfxAtoms::he) {
             bit = HEBREW_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("ar")) {
+        } else if (aLangGroup == gfxAtoms::ar) {
             bit = ARABIC_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("x-baltic")) {
+        } else if (aLangGroup == gfxAtoms::x_baltic) {
             bit = BALTIC_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("x-cyrillic")) {
+        } else if (aLangGroup == gfxAtoms::x_cyrillic) {
             bit = RUSSIAN_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("th")) {
+        } else if (aLangGroup == gfxAtoms::th) {
             bit = THAI_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("x-central-euro")) {
+        } else if (aLangGroup == gfxAtoms::x_central_euro) {
             bit = EASTEUROPE_CHARSET;
-        } else if (aLangGroup.EqualsLiteral("x-symbol")) {
+        } else if (aLangGroup == gfxAtoms::x_symbol) {
             bit = SYMBOL_CHARSET;
         }
 
-        if (bit != -1)
+        if (bit != -1) {
             return mCharset.test(bit);
+        }
 
         return PR_FALSE;
     }
 
-    PRBool SupportsRange(PRUint8 range) {
+    virtual PRBool SupportsRange(PRUint8 range) {
         return mUnicodeRanges.test(range);
     }
 
-    PRBool TestCharacterMap(PRUint32 aCh);
+    virtual PRBool TestCharacterMap(PRUint32 aCh);
 
     // create a font entry for a font with a given name
     static GDIFontEntry* CreateFontEntry(const nsAString& aName, 
                                       gfxWindowsFontType aFontType, 
                                       PRBool aItalic, PRUint16 aWeight, 
                                       gfxUserFontData* aUserFontData);
 
     // create a font entry for a font referenced by its fullname