Bug 1154148 - Create a FontFaceSet's UserFontSet eagerly. r=jdaggett
authorCameron McCormack <cam@mcc.id.au>
Sat, 09 May 2015 14:46:49 +1000
changeset 274458 22d300d1944542fa9d6e566ac7720776ffd6d59a
parent 274457 e96956b4da3364e6aaf36e711c61a6edfae093ff
child 274459 acfe0afcedee4ec594b72ced81c4bc545be51c62
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs1154148
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 1154148 - Create a FontFaceSet's UserFontSet eagerly. r=jdaggett
layout/base/nsPresContext.cpp
layout/style/FontFaceSet.cpp
layout/style/FontFaceSet.h
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2108,17 +2108,16 @@ nsPresContext::FlushUserFontSet()
       nsTArray<nsFontFaceRuleContainer> rules;
       if (!mShell->StyleSet()->AppendFontFaceRules(rules)) {
         return;
       }
 
       if (!mFontFaceSet) {
         mFontFaceSet = new FontFaceSet(mDocument->GetInnerWindow(), this);
       }
-      mFontFaceSet->EnsureUserFontSet(this);
       bool 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();
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -102,16 +102,18 @@ FontFaceSet::FontFaceSet(nsPIDOMWindow* 
   }
 
   if (!mDocument->DidFireDOMContentLoaded()) {
     mDocument->AddSystemEventListener(NS_LITERAL_STRING("DOMContentLoaded"),
                                       this, false, false);
   }
 
   mDocument->CSSLoader()->AddObserver(this);
+
+  mUserFontSet = new UserFontSet(this);
 }
 
 FontFaceSet::~FontFaceSet()
 {
   MOZ_COUNT_DTOR(FontFaceSet);
 
   NS_ASSERTION(mLoaders.Count() == 0, "mLoaders should have been emptied");
 
@@ -134,26 +136,16 @@ FontFaceSet::Disconnect()
     // being called during unlink, at which time the loader amy already have
     // been unlinked from the document.
     if (mDocument->CSSLoader()) {
       mDocument->CSSLoader()->RemoveObserver(this);
     }
   }
 }
 
-FontFaceSet::UserFontSet*
-FontFaceSet::EnsureUserFontSet(nsPresContext* aPresContext)
-{
-  if (!mUserFontSet) {
-    mUserFontSet = new UserFontSet(this);
-    mPresContext = aPresContext;
-  }
-  return mUserFontSet;
-}
-
 already_AddRefed<Promise>
 FontFaceSet::Load(const nsAString& aFont,
                   const nsAString& aText,
                   ErrorResult& aRv)
 {
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
   return nullptr;
 }
--- a/layout/style/FontFaceSet.h
+++ b/layout/style/FontFaceSet.h
@@ -92,17 +92,16 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FontFaceSet, DOMEventTargetHelper)
   NS_DECL_NSIDOMEVENTLISTENER
 
   FontFaceSet(nsPIDOMWindow* aWindow, nsPresContext* aPresContext);
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
-  UserFontSet* EnsureUserFontSet(nsPresContext* aPresContext);
   UserFontSet* GetUserFontSet() { return mUserFontSet; }
 
   // Called when this font set is no longer associated with a presentation.
   void DestroyUserFontSet();
 
   // Called by nsFontFaceLoader when the loader has completed normally.
   // It's removed from the mLoaders set.
   void RemoveLoader(nsFontFaceLoader* aLoader);