Bug 1154150 - Only create a FontFaceSet if we find @font-face rules. r=jdaggett
authorCameron McCormack <cam@mcc.id.au>
Sat, 09 May 2015 14:47:09 +1000
changeset 243088 acfe0afcedee4ec594b72ced81c4bc545be51c62
parent 243087 22d300d1944542fa9d6e566ac7720776ffd6d59a
child 243089 c2315e5bc62d3abdac22abef69bbef48395ffa12
push id59593
push usercmccormack@mozilla.com
push dateSat, 09 May 2015 05:02:39 +0000
treeherdermozilla-inbound@c2315e5bc62d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs1154150
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1154150 - Only create a FontFaceSet if we find @font-face rules. r=jdaggett
layout/base/nsPresContext.cpp
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2105,20 +2105,24 @@ nsPresContext::FlushUserFontSet()
 
   if (mFontFaceSetDirty) {
     if (gfxPlatform::GetPlatform()->DownloadableFontsEnabled()) {
       nsTArray<nsFontFaceRuleContainer> rules;
       if (!mShell->StyleSet()->AppendFontFaceRules(rules)) {
         return;
       }
 
-      if (!mFontFaceSet) {
+      bool changed = false;
+
+      if (!mFontFaceSet && !rules.IsEmpty()) {
         mFontFaceSet = new FontFaceSet(mDocument->GetInnerWindow(), this);
       }
-      bool changed = mFontFaceSet->UpdateRules(rules);
+      if (mFontFaceSet) {
+        changed = mFontFaceSet->UpdateRules(rules);
+      }
 
       // We need to enqueue a style change reflow (for later) to
       // reflect that we're modifying @font-face rules.  (However,
       // without a reflow, nothing will happen to start any downloads
       // that are needed.)
       if (changed) {
         UserFontSetUpdated();
       }