Bug 1288255 - Clear hyphen width cache when user fonts update. r?jfkthame
MozReview-Commit-ID: 66zUQIFafdh
--- a/gfx/thebes/gfxFontconfigFonts.cpp
+++ b/gfx/thebes/gfxFontconfigFonts.cpp
@@ -1465,20 +1465,18 @@ void
gfxPangoFontGroup::UpdateUserFonts()
{
uint64_t newGeneration = GetGeneration();
if (newGeneration == mCurrGeneration)
return;
mFonts[0] = FamilyFace();
mFontSets.Clear();
- mCachedEllipsisTextRun = nullptr;
- mUnderlineOffset = UNDERLINE_OFFSET_NOT_SET;
+ ClearCachedData();
mCurrGeneration = newGeneration;
- mSkipDrawing = false;
}
already_AddRefed<gfxFcFontSet>
gfxPangoFontGroup::MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor,
nsAutoRef<FcPattern> *aMatchPattern)
{
const char *lang = pango_language_to_string(aLang);
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -3072,26 +3072,22 @@ gfxFontGroup::GetRebuildGeneration()
// note: gfxPangoFontGroup overrides UpdateUserFonts, such that
// BuildFontList is never used
void
gfxFontGroup::UpdateUserFonts()
{
if (mCurrGeneration < GetRebuildGeneration()) {
// fonts in userfont set changed, need to redo the fontlist
mFonts.Clear();
- mUnderlineOffset = UNDERLINE_OFFSET_NOT_SET;
- mSkipDrawing = false;
+ ClearCachedData();
BuildFontList();
mCurrGeneration = GetGeneration();
- mCachedEllipsisTextRun = nullptr;
} else if (mCurrGeneration != GetGeneration()) {
// load state change occurred, verify load state and validity of fonts
- mSkipDrawing = false;
- mUnderlineOffset = UNDERLINE_OFFSET_NOT_SET;
- mCachedEllipsisTextRun = nullptr;
+ ClearCachedData();
uint32_t len = mFonts.Length();
for (uint32_t i = 0; i < len; i++) {
FamilyFace& ff = mFonts[i];
if (ff.Font() || !ff.IsUserFontContainer()) {
continue;
}
ff.CheckState(mSkipDrawing);
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -896,16 +896,24 @@ public:
uint64_t GetRebuildGeneration();
// used when logging text performance
gfxTextPerfMetrics *GetTextPerfMetrics() { return mTextPerf; }
// This will call UpdateUserFonts() if the user font set is changed.
void SetUserFontSet(gfxUserFontSet *aUserFontSet);
+ void ClearCachedData()
+ {
+ mUnderlineOffset = UNDERLINE_OFFSET_NOT_SET;
+ mSkipDrawing = false;
+ mHyphenWidth = -1;
+ mCachedEllipsisTextRun = nullptr;
+ }
+
// If there is a user font set, check to see whether the font list or any
// caches need updating.
virtual void UpdateUserFonts();
// search for a specific userfont in the list of fonts
bool ContainsUserFont(const gfxUserFontEntry* aUserFont);
bool ShouldSkipDrawing() const {