bug 393632. cache cjk resolved font list as well. r=elif

This commit is contained in:
pavlov@pavlov.net 2007-08-24 17:00:41 -07:00
Родитель 1a0a46a143
Коммит c6ab64680a
2 изменённых файлов: 57 добавлений и 49 удалений

Просмотреть файл

@ -1344,6 +1344,7 @@ private:
return -1;
}
// this function appends to the array passed in.
void GetPrefFonts(const char *aLangGroup, nsTArray<nsRefPtr<FontEntry> >& array) {
NS_ASSERTION(aLangGroup, "aLangGroup is null");
gfxWindowsPlatform *platform = gfxWindowsPlatform::GetPlatform();
@ -1361,7 +1362,10 @@ private:
array.AppendElements(fonts);
}
// this function assigns to the array passed in.
void GetCJKPrefFonts(nsTArray<nsRefPtr<FontEntry> >& array) {
gfxWindowsPlatform *platform = gfxWindowsPlatform::GetPlatform();
if (!platform->GetPrefFontEntries("x-internal-cjk", &array)) {
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (!prefs)
return;
@ -1413,6 +1417,9 @@ private:
GetPrefFonts(CJK_LANG_ZH_CN, array);
GetPrefFonts(CJK_LANG_ZH_HK, array);
GetPrefFonts(CJK_LANG_ZH_TW, array);
platform->SetPrefFontEntries("x-internal-cjk", array);
}
}
void GenerateAlternativeString() {
@ -1456,8 +1463,6 @@ private:
GOFFSET *mOffsets;
int *mAdvances;
nsTArray< nsRefPtr<gfxWindowsFont> > mFonts;
nsRefPtr<gfxWindowsFont> mCurrentFont;
PRPackedBool mFontSelected;

Просмотреть файл

@ -70,6 +70,8 @@
int PR_CALLBACK
gfxWindowsPlatform::PrefChangedCallback(const char *aPrefName, void *closure)
{
// XXX this could be made to only clear out the cache for the prefs that were changed
// but it probably isn't that big a deal.
gfxWindowsPlatform *plat = static_cast<gfxWindowsPlatform *>(closure);
plat->mPrefFonts.Clear();
return 0;
@ -87,6 +89,7 @@ gfxWindowsPlatform::gfxWindowsPlatform()
nsCOMPtr<nsIPref> pref = do_GetService(NS_PREF_CONTRACTID);
pref->RegisterCallback("font.", PrefChangedCallback, this);
pref->RegisterCallback("font.name-list.", PrefChangedCallback, this);
pref->RegisterCallback("intl.accept_languages", PrefChangedCallback, this);
// don't bother unregistering. We'll get shutdown after the pref service
}