diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp index 0885d3e5472c..56d291e85db3 100644 --- a/gfx/src/nsDeviceContext.cpp +++ b/gfx/src/nsDeviceContext.cpp @@ -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(mFontMetrics[i]); - if (fm->Font().Equals(aFont)) { + nsIThebesFontMetrics* tfm = static_cast(fm); + if (fm->Font().Equals(aFont) && tfm->GetUserFontSet() == aUserFontSet) { nsCOMPtr 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; } diff --git a/gfx/src/thebes/nsIThebesFontMetrics.h b/gfx/src/thebes/nsIThebesFontMetrics.h index 14e506fdb057..7ad66eaebd57 100644 --- a/gfx/src/thebes/nsIThebesFontMetrics.h +++ b/gfx/src/thebes/nsIThebesFontMetrics.h @@ -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 */ diff --git a/gfx/src/thebes/nsThebesFontMetrics.cpp b/gfx/src/thebes/nsThebesFontMetrics.cpp index edb74ea95afc..ce6a494eeebf 100644 --- a/gfx/src/thebes/nsThebesFontMetrics.cpp +++ b/gfx/src/thebes/nsThebesFontMetrics.cpp @@ -494,3 +494,9 @@ nsThebesFontMetrics::GetRightToLeftText() { return mIsRightToLeft; } + +/* virtual */ gfxUserFontSet* +nsThebesFontMetrics::GetUserFontSet() +{ + return mFontGroup->GetUserFontSet(); +} diff --git a/gfx/src/thebes/nsThebesFontMetrics.h b/gfx/src/thebes/nsThebesFontMetrics.h index 900a5c4c051f..89a84361affd 100644 --- a/gfx/src/thebes/nsThebesFontMetrics.h +++ b/gfx/src/thebes/nsThebesFontMetrics.h @@ -141,6 +141,8 @@ public: virtual void SetTextRunRTL(PRBool aIsRTL) { mTextRunRTL = aIsRTL; } virtual gfxFontGroup* GetThebesFontGroup() { return mFontGroup; } + + virtual gfxUserFontSet* GetUserFontSet(); PRBool GetRightToLeftTextRunMode() { return mTextRunRTL; diff --git a/gfx/thebes/public/gfxAtsuiFonts.h b/gfx/thebes/public/gfxAtsuiFonts.h index ebaff6f56de9..a18913720ead 100644 --- a/gfx/thebes/public/gfxAtsuiFonts.h +++ b/gfx/thebes/public/gfxAtsuiFonts.h @@ -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(static_cast(mFonts[aFontIndex])); } diff --git a/gfx/thebes/public/gfxFT2Fonts.h b/gfx/thebes/public/gfxFT2Fonts.h index 28227d247431..239d29ec55cf 100644 --- a/gfx/thebes/public/gfxFT2Fonts.h +++ b/gfx/thebes/public/gfxFT2Fonts.h @@ -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 (static_cast (mFonts[i])); } diff --git a/gfx/thebes/public/gfxFont.h b/gfx/thebes/public/gfxFont.h index cdb4a6ebcdad..d43bff4bc936 100644 --- a/gfx/thebes/public/gfxFont.h +++ b/gfx/thebes/public/gfxFont.h @@ -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(mFonts[i]); } virtual PRUint32 FontListLength() const { diff --git a/gfx/thebes/public/gfxOS2Fonts.h b/gfx/thebes/public/gfxOS2Fonts.h index 85fb9e24d201..415d6f114f9f 100644 --- a/gfx/thebes/public/gfxOS2Fonts.h +++ b/gfx/thebes/public/gfxOS2Fonts.h @@ -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]); diff --git a/gfx/thebes/src/gfxPangoFonts.cpp b/gfx/thebes/src/gfxPangoFonts.cpp index e6109da906e9..fcc676397c81 100644 --- a/gfx/thebes/src/gfxPangoFonts.cpp +++ b/gfx/thebes/src/gfxPangoFonts.cpp @@ -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]) { diff --git a/gfx/thebes/src/gfxWindowsFonts.cpp b/gfx/thebes/src/gfxWindowsFonts.cpp index cdf8090dba96..9d2c8e17b3f0 100644 --- a/gfx/thebes/src/gfxWindowsFonts.cpp +++ b/gfx/thebes/src/gfxWindowsFonts.cpp @@ -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 font = gfxWindowsFont::GetOrMakeFont(mFontEntries[i], &mStyle); diff --git a/layout/reftests/font-face/reftest.list b/layout/reftests/font-face/reftest.list index 92cdc7ef54a2..4d313cbe0dc1 100644 --- a/layout/reftests/font-face/reftest.list +++ b/layout/reftests/font-face/reftest.list @@ -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