Check that the user font set matches before returning an entry from the font cache. (Bug 457821) r=jdaggett sr=roc a=blocking1.9.1+

This commit is contained in:
L. David Baron 2008-11-25 13:27:54 -08:00
Родитель 72a6a28162
Коммит 29208d6cc4
11 изменённых файлов: 66 добавлений и 3 удалений

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

@ -51,6 +51,7 @@
#include "nsCRT.h"
#include "nsIRenderingContext.h"
#include "gfxUserFontSet.h"
#include "nsIThebesFontMetrics.h"
NS_IMPL_ISUPPORTS3(DeviceContextImpl, nsIDeviceContext, nsIObserver, nsISupportsWeakReference)
@ -482,7 +483,8 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
PRInt32 n = mFontMetrics.Count() - 1;
for (PRInt32 i = n; i >= 0; --i) {
fm = static_cast<nsIFontMetrics*>(mFontMetrics[i]);
if (fm->Font().Equals(aFont)) {
nsIThebesFontMetrics* tfm = static_cast<nsIThebesFontMetrics*>(fm);
if (fm->Font().Equals(aFont) && tfm->GetUserFontSet() == aUserFontSet) {
nsCOMPtr<nsIAtom> langGroup;
fm->GetLangGroup(getter_AddRefs(langGroup));
if (aLangGroup == langGroup.get()) {
@ -490,6 +492,7 @@ nsFontCache::GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
// promote it to the end of the cache
mFontMetrics.MoveElement(i, n);
}
tfm->GetThebesFontGroup()->UpdateFontList();
NS_ADDREF(aMetrics = fm);
return NS_OK;
}

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

@ -116,6 +116,10 @@ public:
virtual PRInt32 GetMaxStringLength() = 0;
virtual gfxFontGroup* GetThebesFontGroup() = 0;
// Needs to be virtual and at this level so that its caller in gkgfx can
// avoid linking against thebes.
virtual gfxUserFontSet* GetUserFontSet() = 0;
};
#endif /* __nsIThebesFontMetrics_h */

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

@ -494,3 +494,9 @@ nsThebesFontMetrics::GetRightToLeftText()
{
return mIsRightToLeft;
}
/* virtual */ gfxUserFontSet*
nsThebesFontMetrics::GetUserFontSet()
{
return mFontGroup->GetUserFontSet();
}

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

@ -141,6 +141,8 @@ public:
virtual void SetTextRunRTL(PRBool aIsRTL) { mTextRunRTL = aIsRTL; }
virtual gfxFontGroup* GetThebesFontGroup() { return mFontGroup; }
virtual gfxUserFontSet* GetUserFontSet();
PRBool GetRightToLeftTextRunMode() {
return mTextRunRTL;

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

@ -133,6 +133,14 @@ public:
PRBool aWrapped, gfxTextRun *aTextRun);
gfxAtsuiFont* GetFontAt(PRInt32 aFontIndex) {
// If it turns out to be hard for all clients that cache font
// groups to call UpdateFontList at appropriate times, we could
// instead consider just calling UpdateFontList from someplace
// more central (such as here).
NS_ASSERTION(!mUserFontSet || mCurrGeneration == GetGeneration(),
"Whoever was caching this font group should have "
"called UpdateFontList on it");
return static_cast<gfxAtsuiFont*>(static_cast<gfxFont*>(mFonts[aFontIndex]));
}

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

@ -132,6 +132,14 @@ public: // new functions
virtual ~gfxFT2FontGroup ();
inline gfxFT2Font *GetFontAt (PRInt32 i) {
// If it turns out to be hard for all clients that cache font
// groups to call UpdateFontList at appropriate times, we could
// instead consider just calling UpdateFontList from someplace
// more central (such as here).
NS_ASSERTION(!mUserFontSet || mCurrGeneration == GetGeneration(),
"Whoever was caching this font group should have "
"called UpdateFontList on it");
return static_cast <gfxFT2Font *>(static_cast <gfxFont *>(mFonts[i]));
}

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

@ -1523,6 +1523,14 @@ public:
virtual ~gfxFontGroup();
virtual gfxFont *GetFontAt(PRInt32 i) {
// If it turns out to be hard for all clients that cache font
// groups to call UpdateFontList at appropriate times, we could
// instead consider just calling UpdateFontList from someplace
// more central (such as here).
NS_ASSERTION(!mUserFontSet || mCurrGeneration == GetGeneration(),
"Whoever was caching this font group should have "
"called UpdateFontList on it");
return static_cast<gfxFont*>(mFonts[i]);
}
virtual PRUint32 FontListLength() const {

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

@ -107,6 +107,14 @@ public:
const Parameters* aParams, PRUint32 aFlags);
gfxOS2Font *GetFontAt(PRInt32 i) {
// If it turns out to be hard for all clients that cache font
// groups to call UpdateFontList at appropriate times, we could
// instead consider just calling UpdateFontList from someplace
// more central (such as here).
NS_ASSERTION(!mUserFontSet || mCurrGeneration == GetGeneration(),
"Whoever was caching this font group should have "
"called UpdateFontList on it");
#ifdef DEBUG_thebes_2
printf("gfxOS2FontGroup[%#x]::GetFontAt(%d), %#x, %#x\n",
(unsigned)this, i, (unsigned)&mFonts, (unsigned)&mFonts[i]);

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

@ -1401,6 +1401,14 @@ gfxPangoFontGroup::GetBasePangoFont()
gfxFont *
gfxPangoFontGroup::GetFontAt(PRInt32 i) {
// If it turns out to be hard for all clients that cache font
// groups to call UpdateFontList at appropriate times, we could
// instead consider just calling UpdateFontList from someplace
// more central (such as here).
NS_ASSERTION(!mUserFontSet || mCurrGeneration == GetGeneration(),
"Whoever was caching this font group should have "
"called UpdateFontList on it");
NS_PRECONDITION(i == 0, "Only have one font");
if (!mFonts[0]) {

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

@ -889,6 +889,14 @@ gfxWindowsFontGroup::~gfxWindowsFontGroup()
gfxWindowsFont *
gfxWindowsFontGroup::GetFontAt(PRInt32 i)
{
// If it turns out to be hard for all clients that cache font
// groups to call UpdateFontList at appropriate times, we could
// instead consider just calling UpdateFontList from someplace
// more central (such as here).
NS_ASSERTION(!mUserFontSet || mCurrGeneration == GetGeneration(),
"Whoever was caching this font group should have "
"called UpdateFontList on it");
if (!mFonts[i]) {
nsRefPtr<gfxWindowsFont> font =
gfxWindowsFont::GetOrMakeFont(mFontEntries[i], &mStyle);

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

@ -12,7 +12,7 @@ fails HTTP(..) == name-override-1.html name-override-1-ref.html
HTTP(..) == multiple-descriptor-1.html multiple-descriptor-1-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) != multiple-descriptor-1.html multiple-descriptor-1-notref.html
fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) == src-list-1.html src-list-1-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") random-if(MOZ_WIDGET_TOOLKIT=="cocoa") random-if(MOZ_WIDGET_TOOLKIT=="windows") HTTP(..) == src-list-2.html src-list-2-ref.html # random probably fixed by the font cache patch on bug 457821
fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) == src-list-2.html src-list-2-ref.html
fails HTTP(..) == src-list-format-1.html src-list-format-1-ref.html
fails HTTP(..) == src-list-format-2.html src-list-format-2-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) == src-list-format-3.html src-list-format-3-ref.html
@ -26,7 +26,7 @@ fails HTTP(..) == order-2.html order-2-ref.html
fails HTTP(..) == order-3.html order-3-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") random-if(MOZ_WIDGET_TOOLKIT=="windows") HTTP(..) == multiple-in-family-1.html multiple-in-family-1-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") random-if(MOZ_WIDGET_TOOLKIT=="windows") HTTP(..) != multiple-in-family-1.html multiple-in-family-1-notref.html
random-if(MOZ_WIDGET_TOOLKIT=="windows") random-if(MOZ_WIDGET_TOOLKIT=="cocoa") HTTP(..) == prop-order-over-rule-order-1a.html prop-order-over-rule-order-2a.html # randomness on cocoa should be fixed by the font cache patch on bug 457821
random-if(MOZ_WIDGET_TOOLKIT=="windows") HTTP(..) == prop-order-over-rule-order-1a.html prop-order-over-rule-order-2a.html
random-if(MOZ_WIDGET_TOOLKIT=="windows") HTTP(..) == prop-order-over-rule-order-1b.html prop-order-over-rule-order-2b.html
random-if(MOZ_WIDGET_TOOLKIT=="windows") fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) != prop-order-over-rule-order-1a.html prop-order-over-rule-order-1b.html
fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") HTTP(..) == cross-iframe-1.html cross-iframe-1-ref.html