Bug 1288255 - Clear hyphen width cache when user fonts update. r?jfkthame draft
authorXidorn Quan <xidorn+moz@upsuper.org>
Thu, 18 Aug 2016 11:26:50 +1000
changeset 402332 cdbec87f7ab83c76750f8358724db6aa4fb41d49
parent 402331 4d1dde0e8950ed534ba81f73afd568a9fda8b633
child 528634 a7ef113b2b0f63d46a5c5dd3e244a00ad6470a74
push id26616
push userxquan@mozilla.com
push dateThu, 18 Aug 2016 01:32:23 +0000
reviewersjfkthame
bugs1288255
milestone51.0a1
Bug 1288255 - Clear hyphen width cache when user fonts update. r?jfkthame MozReview-Commit-ID: 66zUQIFafdh
gfx/thebes/gfxFontconfigFonts.cpp
gfx/thebes/gfxTextRun.cpp
gfx/thebes/gfxTextRun.h
--- 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 {