bug 424398. fix crash when installing new fonts while loading pages. r=vlad a=beltzner

This commit is contained in:
pavlov@pavlov.net 2008-03-21 14:22:29 -07:00
Родитель b4338a64a7
Коммит 986ecb504f
2 изменённых файлов: 10 добавлений и 8 удалений

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

@ -79,15 +79,15 @@ class FontEntry
public: public:
THEBES_INLINE_DECL_REFCOUNTING(FontEntry) THEBES_INLINE_DECL_REFCOUNTING(FontEntry)
FontEntry(FontFamily *aFontFamily) : FontEntry(const nsString& aFaceName) :
mFamily(aFontFamily), mUnicodeFont(PR_FALSE), mSymbolFont(PR_FALSE), mFaceName(aFaceName), mUnicodeFont(PR_FALSE), mSymbolFont(PR_FALSE),
mTrueType(PR_FALSE), mIsType1(PR_FALSE), mTrueType(PR_FALSE), mIsType1(PR_FALSE),
mIsBadUnderlineFont(PR_FALSE), mForceGDI(PR_FALSE), mCharset(0), mUnicodeRanges(0) mIsBadUnderlineFont(PR_FALSE), mForceGDI(PR_FALSE), mCharset(0), mUnicodeRanges(0)
{ {
} }
FontEntry(const FontEntry& aFontEntry) : FontEntry(const FontEntry& aFontEntry) :
mFamily(aFontEntry.mFamily), mFaceName(aFontEntry.mFaceName),
mWindowsFamily(aFontEntry.mWindowsFamily), mWindowsFamily(aFontEntry.mWindowsFamily),
mWindowsPitch(aFontEntry.mWindowsPitch), mWindowsPitch(aFontEntry.mWindowsPitch),
mUnicodeFont(aFontEntry.mUnicodeFont), mUnicodeFont(aFontEntry.mUnicodeFont),
@ -104,7 +104,7 @@ public:
} }
const nsString& GetName() const { const nsString& GetName() const {
return mFamily->mName; return mFaceName;
} }
PRBool IsCrappyFont() const { PRBool IsCrappyFont() const {
@ -199,8 +199,7 @@ public:
// whether this font family is in "bad" underline offset blacklist. // whether this font family is in "bad" underline offset blacklist.
PRBool IsBadUnderlineFont() { return mIsBadUnderlineFont != 0; } PRBool IsBadUnderlineFont() { return mIsBadUnderlineFont != 0; }
/* needs to be a weak pointer to avoid a cycle */ nsString mFaceName;
FontFamily *mFamily;
PRUint8 mWindowsFamily; PRUint8 mWindowsFamily;
PRUint8 mWindowsPitch; PRUint8 mWindowsPitch;

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

@ -137,7 +137,7 @@ gfxWindowsPlatform::FontEnumProc(const ENUMLOGFONTEXW *lpelfe,
} }
} }
fe = new FontEntry(ff); fe = new FontEntry(ff->mName);
/* don't append it until the end in case of error */ /* don't append it until the end in case of error */
fe->mItalic = (logFont.lfItalic == 0xFF); fe->mItalic = (logFont.lfItalic == 0xFF);
@ -363,6 +363,9 @@ BuildKeyNameFromFontName(nsAString &aName)
nsresult nsresult
gfxWindowsPlatform::UpdateFontList() gfxWindowsPlatform::UpdateFontList()
{ {
gfxFontCache *fc = gfxFontCache::GetCache();
if (fc)
fc->AgeAllGenerations();
mFonts.Clear(); mFonts.Clear();
mFontAliases.Clear(); mFontAliases.Clear();
mNonExistingFonts.Clear(); mNonExistingFonts.Clear();
@ -693,7 +696,7 @@ gfxWindowsPlatform::FindFontEntry(FontFamily *aFontFamily, const gfxFontStyle *a
for (PRUint32 j = 0; j < 2; j++) { for (PRUint32 j = 0; j < 2; j++) {
PRBool matchesSomething = PR_FALSE; PRBool matchesSomething = PR_FALSE;
// build up an array of weights that match the italicness we're looking for // build up an array of weights that match the italicness we're looking for
for (PRInt32 i = 0; i < aFontFamily->mVariations.Length(); i++) { for (PRUint32 i = 0; i < aFontFamily->mVariations.Length(); i++) {
nsRefPtr<FontEntry> fe = aFontFamily->mVariations[i]; nsRefPtr<FontEntry> fe = aFontFamily->mVariations[i];
const PRUint8 weight = (fe->mWeight / 100); const PRUint8 weight = (fe->mWeight / 100);
if (fe->mItalic == italic) { if (fe->mItalic == italic) {