Bug 504698. Force Cleartype rendering of content on XP based on pref (follow-on). r=jkew

This commit is contained in:
John Daggett 2010-06-09 09:33:13 +09:00
Родитель 8adc0c8eec
Коммит a771fdd41d
13 изменённых файлов: 63 добавлений и 27 удалений

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

@ -168,7 +168,7 @@ public:
mName(aName), mItalic(PR_FALSE), mFixedPitch(PR_FALSE), mName(aName), mItalic(PR_FALSE), mFixedPitch(PR_FALSE),
mIsProxy(PR_FALSE), mIsValid(PR_TRUE), mIsProxy(PR_FALSE), mIsValid(PR_TRUE),
mIsBadUnderlineFont(PR_FALSE), mIsUserFont(PR_FALSE), mIsBadUnderlineFont(PR_FALSE), mIsUserFont(PR_FALSE),
mStandardFace(aIsStandardFace), mIsLocalUserFont(PR_FALSE), mStandardFace(aIsStandardFace),
mSymbolFont(PR_FALSE), mSymbolFont(PR_FALSE),
mWeight(500), mStretch(NS_FONT_STRETCH_NORMAL), mWeight(500), mStretch(NS_FONT_STRETCH_NORMAL),
mCmapInitialized(PR_FALSE), mCmapInitialized(PR_FALSE),
@ -186,6 +186,7 @@ public:
PRInt16 Stretch() const { return mStretch; } PRInt16 Stretch() const { return mStretch; }
PRBool IsUserFont() const { return mIsUserFont; } PRBool IsUserFont() const { return mIsUserFont; }
PRBool IsLocalUserFont() const { return mIsLocalUserFont; }
PRBool IsFixedPitch() const { return mFixedPitch; } PRBool IsFixedPitch() const { return mFixedPitch; }
PRBool IsItalic() const { return mItalic; } PRBool IsItalic() const { return mItalic; }
PRBool IsBold() const { return mWeight >= 600; } // bold == weights 600 and above PRBool IsBold() const { return mWeight >= 600; } // bold == weights 600 and above
@ -226,6 +227,7 @@ public:
PRPackedBool mIsValid : 1; PRPackedBool mIsValid : 1;
PRPackedBool mIsBadUnderlineFont : 1; PRPackedBool mIsBadUnderlineFont : 1;
PRPackedBool mIsUserFont : 1; PRPackedBool mIsUserFont : 1;
PRPackedBool mIsLocalUserFont : 1;
PRPackedBool mStandardFace : 1; PRPackedBool mStandardFace : 1;
PRPackedBool mSymbolFont : 1; PRPackedBool mSymbolFont : 1;
@ -250,6 +252,7 @@ protected:
mIsProxy(PR_FALSE), mIsValid(PR_TRUE), mIsProxy(PR_FALSE), mIsValid(PR_TRUE),
mIsBadUnderlineFont(PR_FALSE), mIsBadUnderlineFont(PR_FALSE),
mIsUserFont(PR_FALSE), mIsUserFont(PR_FALSE),
mIsLocalUserFont(PR_FALSE),
mStandardFace(PR_FALSE), mStandardFace(PR_FALSE),
mSymbolFont(PR_FALSE), mSymbolFont(PR_FALSE),
mWeight(500), mStretch(NS_FONT_STRETCH_NORMAL), mWeight(500), mStretch(NS_FONT_STRETCH_NORMAL),
@ -482,6 +485,14 @@ public:
// font; we just delete it. // font; we just delete it.
virtual void NotifyExpired(gfxFont *aFont); virtual void NotifyExpired(gfxFont *aFont);
// Cleans out the hashtable and removes expired fonts waiting for cleanup.
// Other gfxFont objects may be still in use but they will be pushed
// into the expiration queues and removed.
void Flush() {
mFonts.Clear();
AgeAllGenerations();
}
protected: protected:
void DestroyFont(gfxFont *aFont); void DestroyFont(gfxFont *aFont);

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

@ -99,6 +99,8 @@ public:
*/ */
static void RemoveTextRun(gfxTextRun *aTextRun); static void RemoveTextRun(gfxTextRun *aTextRun);
static void Flush();
protected: protected:
friend class gfxPlatform; friend class gfxPlatform;

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

@ -129,6 +129,7 @@ public:
mStretch = aStretch; mStretch = aStretch;
mItalic = aItalic; mItalic = aItalic;
mIsUserFont = PR_TRUE; mIsUserFont = PR_TRUE;
mIsLocalUserFont = PR_TRUE;
} }
/** /**

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

@ -167,6 +167,7 @@ gfxFontEntry::FindOrMakeFont(const gfxFontStyle *aStyle, PRBool aNeedsBold)
{ {
// the font entry name is the psname, not the family name // the font entry name is the psname, not the family name
nsRefPtr<gfxFont> font = gfxFontCache::GetCache()->Lookup(Name(), aStyle); nsRefPtr<gfxFont> font = gfxFontCache::GetCache()->Lookup(Name(), aStyle);
if (!font) { if (!font) {
gfxFont *newFont = CreateFontInstance(aStyle, aNeedsBold); gfxFont *newFont = CreateFontInstance(aStyle, aNeedsBold);
if (!newFont) if (!newFont)

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

@ -199,15 +199,7 @@ GDIFontEntry::GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontT
mForceGDI = PR_TRUE; mForceGDI = PR_TRUE;
mIsUserFont = aUserFontData != nsnull; mIsUserFont = aUserFontData != nsnull;
PRBool isXP = (gfxWindowsPlatform::WindowsOSVersion() InitLogFont(aFaceName, aFontType);
< gfxWindowsPlatform::kWindowsVista);
PRBool useClearType = isXP &&
(gfxWindowsPlatform::GetPlatform()->UseClearTypeAlways() ||
(mIsUserFont &&
gfxWindowsPlatform::GetPlatform()->UseClearTypeForDownloadableFonts()));
InitLogFont(aFaceName, aFontType, useClearType);
} }
nsresult nsresult
@ -241,9 +233,9 @@ GDIFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle, PRBool aNeedsBo
PRBool isXP = (gfxWindowsPlatform::WindowsOSVersion() PRBool isXP = (gfxWindowsPlatform::WindowsOSVersion()
< gfxWindowsPlatform::kWindowsVista); < gfxWindowsPlatform::kWindowsVista);
PRBool useClearType = isXP && PRBool useClearType = isXP && !aFontStyle->systemFont &&
(gfxWindowsPlatform::GetPlatform()->UseClearTypeAlways() || (gfxWindowsPlatform::GetPlatform()->UseClearTypeAlways() ||
(mIsUserFont && (mIsUserFont && !mIsLocalUserFont &&
gfxWindowsPlatform::GetPlatform()->UseClearTypeForDownloadableFonts())); gfxWindowsPlatform::GetPlatform()->UseClearTypeForDownloadableFonts()));
return new gfxGDIFont(this, aFontStyle, aNeedsBold, return new gfxGDIFont(this, aFontStyle, aNeedsBold,
@ -287,6 +279,7 @@ GDIFontEntry::FillLogFont(LOGFONTW *aLogFont, PRBool aItalic,
// do fake italic for us in that case. // do fake italic for us in that case.
aLogFont->lfItalic = aItalic; aLogFont->lfItalic = aItalic;
aLogFont->lfWeight = aWeight; aLogFont->lfWeight = aWeight;
aLogFont->lfQuality = (aUseCleartype ? CLEARTYPE_QUALITY : DEFAULT_QUALITY);
} }
PRBool PRBool
@ -356,8 +349,7 @@ GDIFontEntry::TestCharacterMap(PRUint32 aCh)
void void
GDIFontEntry::InitLogFont(const nsAString& aName, GDIFontEntry::InitLogFont(const nsAString& aName,
gfxWindowsFontType aFontType, gfxWindowsFontType aFontType)
PRBool aUseCleartype)
{ {
#define CLIP_TURNOFF_FONTASSOCIATION 0x40 #define CLIP_TURNOFF_FONTASSOCIATION 0x40
@ -372,7 +364,7 @@ GDIFontEntry::InitLogFont(const nsAString& aName,
mLogFont.lfCharSet = DEFAULT_CHARSET; mLogFont.lfCharSet = DEFAULT_CHARSET;
mLogFont.lfOutPrecision = FontTypeToOutPrecision(aFontType); mLogFont.lfOutPrecision = FontTypeToOutPrecision(aFontType);
mLogFont.lfClipPrecision = CLIP_TURNOFF_FONTASSOCIATION; mLogFont.lfClipPrecision = CLIP_TURNOFF_FONTASSOCIATION;
mLogFont.lfQuality = (aUseCleartype ? CLEARTYPE_QUALITY : DEFAULT_QUALITY); mLogFont.lfQuality = DEFAULT_QUALITY;
mLogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; mLogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
// always force lfItalic if we want it. Font selection code will // always force lfItalic if we want it. Font selection code will
// do its best to give us an italic font entry, but if no face exists // do its best to give us an italic font entry, but if no face exists
@ -693,6 +685,7 @@ gfxGDIFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
return nsnull; return nsnull;
fe->mIsUserFont = PR_TRUE; fe->mIsUserFont = PR_TRUE;
fe->mIsLocalUserFont = PR_TRUE;
return fe; return fe;
} }

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

@ -300,8 +300,7 @@ protected:
GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType, GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType,
PRBool aItalic, PRUint16 aWeight, gfxUserFontData *aUserFontData); PRBool aItalic, PRUint16 aWeight, gfxUserFontData *aUserFontData);
void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType, void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType);
PRBool aUseCleartype);
virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle, PRBool aNeedsBold); virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle, PRBool aNeedsBold);

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

@ -289,6 +289,7 @@ public:
mPatterns.AppendElement(); mPatterns.AppendElement();
mPatterns[i].own(pattern); mPatterns[i].own(pattern);
} }
mIsLocalUserFont = PR_TRUE;
} }
}; };

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

@ -138,3 +138,4 @@ gfxTextRunCache::Shutdown()
delete gTextRunCache; delete gTextRunCache;
gTextRunCache = nsnull; gTextRunCache = nsnull;
} }

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

@ -122,6 +122,13 @@ public:
*/ */
void RemoveTextRun(gfxTextRun *aTextRun); void RemoveTextRun(gfxTextRun *aTextRun);
void Flush() {
mCache.Clear();
#ifdef DEBUG
mGeneration++;
#endif
}
#ifdef DEBUG #ifdef DEBUG
PRUint32 mGeneration; PRUint32 mGeneration;
void Dump(); void Dump();
@ -1010,3 +1017,11 @@ gfxTextRunWordCache::RemoveTextRun(gfxTextRun *aTextRun)
return; return;
gTextRunWordCache->RemoveTextRun(aTextRun); gTextRunWordCache->RemoveTextRun(aTextRun);
} }
void
gfxTextRunWordCache::Flush()
{
if (!gTextRunWordCache)
return;
gTextRunWordCache->Flush();
}

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

@ -42,6 +42,7 @@
#include "gfxImageSurface.h" #include "gfxImageSurface.h"
#include "gfxWindowsSurface.h" #include "gfxWindowsSurface.h"
#include "gfxTextRunWordCache.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
@ -492,7 +493,7 @@ gfxWindowsPlatform::InitDisplayCaps()
void void
gfxWindowsPlatform::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref) gfxWindowsPlatform::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref)
{ {
PRBool clearFontCache = PR_TRUE; PRBool clearTextFontCaches = PR_TRUE;
gfxPlatform::FontsPrefsChanged(aPrefBranch, aPref); gfxPlatform::FontsPrefsChanged(aPrefBranch, aPref);
@ -504,12 +505,14 @@ gfxWindowsPlatform::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aP
} else if (!strcmp(GFX_USE_CLEARTYPE_ALWAYS, aPref)) { } else if (!strcmp(GFX_USE_CLEARTYPE_ALWAYS, aPref)) {
mUseClearTypeAlways = UNINITIALIZED_VALUE; mUseClearTypeAlways = UNINITIALIZED_VALUE;
} else { } else {
clearFontCache = PR_FALSE; clearTextFontCaches = PR_FALSE;
} }
if (clearFontCache) { if (clearTextFontCaches) {
gfxFontCache *fc = gfxFontCache::GetCache(); gfxFontCache *fc = gfxFontCache::GetCache();
if (fc) if (fc) {
fc->AgeAllGenerations(); fc->Flush();
}
gfxTextRunWordCache::Flush();
} }
} }

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

@ -308,6 +308,9 @@ nsPresContext::~nsPresContext()
delete mBidiUtils; delete mBidiUtils;
#endif // IBMBIDI #endif // IBMBIDI
nsContentUtils::UnregisterPrefCallback("gfx.font_rendering.",
nsPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("layout.css.dpi", nsContentUtils::UnregisterPrefCallback("layout.css.dpi",
nsPresContext::PrefChangedCallback, nsPresContext::PrefChangedCallback,
this); this);
@ -806,6 +809,10 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
// Changes to bidi.numeral also needs to empty the text run cache. // Changes to bidi.numeral also needs to empty the text run cache.
// This is handled in gfxTextRunWordCache.cpp. // This is handled in gfxTextRunWordCache.cpp.
} }
if (StringBeginsWith(prefName, NS_LITERAL_CSTRING("gfx.font_rendering."))) {
// Changes to font_rendering prefs need to trigger a reflow
mPrefChangePendingNeedsReflow = PR_TRUE;
}
// we use a zero-delay timer to coalesce multiple pref updates // we use a zero-delay timer to coalesce multiple pref updates
if (!mPrefChangedTimer) if (!mPrefChangedTimer)
{ {
@ -915,6 +922,8 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
nsContentUtils::RegisterPrefCallback("bidi.", PrefChangedCallback, nsContentUtils::RegisterPrefCallback("bidi.", PrefChangedCallback,
this); this);
#endif #endif
nsContentUtils::RegisterPrefCallback("gfx.font_rendering.", PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("layout.css.dpi", nsContentUtils::RegisterPrefCallback("layout.css.dpi",
nsPresContext::PrefChangedCallback, nsPresContext::PrefChangedCallback,
this); this);

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

@ -1,5 +1,5 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html lang="en">
<head> <head>
<title>Bug 533251 crashtest</title> <title>Bug 533251 crashtest</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

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

@ -27,15 +27,15 @@ HTTP(..) == src-list-format-6.html src-list-format-3-ref.html
# assumes AAT fonts are only supported on MacOS # assumes AAT fonts are only supported on MacOS
random-if(MOZ_WIDGET_TOOLKIT=="cocoa") HTTP(..) == src-list-format-7.html src-list-format-2-ref.html random-if(MOZ_WIDGET_TOOLKIT=="cocoa") HTTP(..) == src-list-format-7.html src-list-format-2-ref.html
random-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP(..) == src-list-format-7.html src-list-format-3-ref.html random-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP(..) == src-list-format-7.html src-list-format-3-ref.html
random-if(MOZ_WIDGET_TOOLKIT=="windows") == src-list-local-full.html src-list-local-full-ref.html # bug 504698 == src-list-local-full.html src-list-local-full-ref.html
random-if(MOZ_WIDGET_TOOLKIT=="windows") == src-list-local-full-quotes.html src-list-local-full-ref.html # bug 504698 == src-list-local-full-quotes.html src-list-local-full-ref.html
HTTP(..) == src-list-local-fallback.html src-list-local-fallback-ref.html HTTP(..) == src-list-local-fallback.html src-list-local-fallback-ref.html
# localized full fontnames should *not* match, only English ones (need locale-invariant key) # localized full fontnames should *not* match, only English ones (need locale-invariant key)
skip HTTP(..) == src-list-local-localized.html src-list-local-localized-ref.html # 486787, 486497 skip HTTP(..) == src-list-local-localized.html src-list-local-localized-ref.html # 486787, 486497
# Postscript name lookup only supported on MacOS/Windows currently # Postscript name lookup only supported on MacOS/Windows currently
random-if(MOZ_WIDGET_TOOLKIT=="windows") random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == src-list-local-ps.html src-list-local-full-ref.html # bug 504698 random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == src-list-local-ps.html src-list-local-full-ref.html
# Mac-specific test of 100 weight faces # Mac-specific test of 100 weight faces
random-if(MOZ_WIDGET_TOOLKIT!="cocoa") == helveticaneue-ultra.html helveticaneue-ultra-ref.html random-if(MOZ_WIDGET_TOOLKIT!="cocoa") == helveticaneue-ultra.html helveticaneue-ultra-ref.html
@ -85,7 +85,7 @@ HTTP(..) == ex-unit-1-dynamic.html ex-unit-1-ref.html
# random-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP(..) == src-format-arabic.html src-format-arabic-aat-ref.html # random-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP(..) == src-format-arabic.html src-format-arabic-aat-ref.html
# random-if(MOZ_WIDGET_TOOLKIT=="cocoa") HTTP(..) == src-format-arabic.html src-format-arabic-ot-ref.html # random-if(MOZ_WIDGET_TOOLKIT=="cocoa") HTTP(..) == src-format-arabic.html src-format-arabic-ot-ref.html
random-if(MOZ_WIDGET_TOOLKIT=="windows") == local-1.html local-1-ref.html # bug 504698 == local-1.html local-1-ref.html
HTTP(..) == synthetic-weight-style.html synthetic-weight-style-ref.html HTTP(..) == synthetic-weight-style.html synthetic-weight-style-ref.html
random-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) == synthetic-variations.html synthetic-variations-ref.html # bug 419962 random-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) == synthetic-variations.html synthetic-variations-ref.html # bug 419962