diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index a1acf253188..97f940817b2 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -784,6 +784,7 @@ gfxUserFontEntry::GetUserFontSets(nsTArray& aResult) gfxUserFontSet::gfxUserFontSet() : mFontFamilies(4), mLocalRulesUsed(false), + mRebuildLocalRules(false), mDownloadCount(0), mDownloadSize(0) { @@ -958,6 +959,7 @@ void gfxUserFontSet::RebuildLocalRules() { if (mLocalRulesUsed) { + mRebuildLocalRules = true; DoRebuildUserFontSet(); } } diff --git a/gfx/thebes/gfxUserFontSet.h b/gfx/thebes/gfxUserFontSet.h index eb4720a5f36..88caa6ff442 100644 --- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -526,6 +526,9 @@ protected: // true when local names have been looked up, false otherwise bool mLocalRulesUsed; + // true when rules using local names need to be redone + bool mRebuildLocalRules; + // performance stats uint32_t mDownloadCount; uint64_t mDownloadSize; diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 6a18c330dd6..9d07a8ce277 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -789,8 +789,11 @@ FontFaceSet::UpdateRules(const nsTArray& aRules) CheckLoadingFinished(); } - // local rules have been rebuilt, so clear the flag - mUserFontSet->mLocalRulesUsed = false; + // if local rules needed to be rebuilt, they have been rebuilt at this point + if (mUserFontSet->mRebuildLocalRules) { + mUserFontSet->mLocalRulesUsed = false; + mUserFontSet->mRebuildLocalRules = false; + } if (LOG_ENABLED() && !mRuleFaces.IsEmpty()) { LOG(("userfonts (%p) userfont rules update (%s) rule count: %d", @@ -875,7 +878,8 @@ FontFaceSet::InsertRuleFontFace(FontFace* aFontFace, SheetType aSheetType, // if local rules were used, don't use the old font entry // for rules containing src local usage - if (mUserFontSet->mLocalRulesUsed) { + if (mUserFontSet->mLocalRulesUsed && + mUserFontSet->mRebuildLocalRules) { nsCSSValue val; aFontFace->GetDesc(eCSSFontDesc_Src, val); nsCSSUnit unit = val.GetUnit();