Bug 1188802 - only rebuild local webfont rules when needed. r=heycam

This commit is contained in:
John Daggett 2016-02-05 16:46:27 +09:00
parent 374f21e4e2
commit ae14fdcda2
3 changed files with 12 additions and 3 deletions

View File

@ -784,6 +784,7 @@ gfxUserFontEntry::GetUserFontSets(nsTArray<gfxUserFontSet*>& 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();
}
}

View File

@ -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;

View File

@ -789,8 +789,11 @@ FontFaceSet::UpdateRules(const nsTArray<nsFontFaceRuleContainer>& aRules)
CheckLoadingFinished();
}
// local rules have been rebuilt, so clear the flag
// 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();