Bug 1162850 - Don't stop looking for style sheet load finishes after the FontFaceSet gets a DOMContentLoaded. r=jdaggett
authorCameron McCormack <cam@mcc.id.au>
Wed, 13 May 2015 15:06:52 +1000
changeset 243637 3cfde06d952aafa82f9ba248e1b5493f2aa5900e
parent 243636 33a09170386b045838d52218e1c9b13856b4b7cc
child 243638 87c080e0543b24fbd8632034b7fb1554a3a7deed
push id28744
push userkwierso@gmail.com
push dateWed, 13 May 2015 18:12:16 +0000
treeherdermozilla-central@324c3423deaf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs1162850
milestone41.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 1162850 - Don't stop looking for style sheet load finishes after the FontFaceSet gets a DOMContentLoaded. r=jdaggett
layout/style/FontFaceSet.cpp
layout/style/FontFaceSet.h
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -131,25 +131,32 @@ JSObject*
 FontFaceSet::WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto)
 {
   return FontFaceSetBinding::Wrap(aContext, this, aGivenProto);
 }
 
 void
 FontFaceSet::Disconnect()
 {
+  RemoveDOMContentLoadedListener();
+
+  if (mDocument && mDocument->CSSLoader()) {
+    // We're null checking CSSLoader() since FontFaceSet::Disconnect() might be
+    // being called during unlink, at which time the loader amy already have
+    // been unlinked from the document.
+    mDocument->CSSLoader()->RemoveObserver(this);
+  }
+}
+
+void
+FontFaceSet::RemoveDOMContentLoadedListener()
+{
   if (mDocument) {
     mDocument->RemoveSystemEventListener(NS_LITERAL_STRING("DOMContentLoaded"),
                                          this, false);
-    // We're null checking CSSLoader() since FontFaceSet::Disconnect() might be
-    // being called during unlink, at which time the loader amy already have
-    // been unlinked from the document.
-    if (mDocument->CSSLoader()) {
-      mDocument->CSSLoader()->RemoveObserver(this);
-    }
   }
 }
 
 already_AddRefed<Promise>
 FontFaceSet::Load(const nsAString& aFont,
                   const nsAString& aText,
                   ErrorResult& aRv)
 {
@@ -1552,17 +1559,17 @@ FontFaceSet::HandleEvent(nsIDOMEvent* aE
 {
   nsString type;
   aEvent->GetType(type);
 
   if (!type.EqualsLiteral("DOMContentLoaded")) {
     return NS_ERROR_FAILURE;
   }
 
-  Disconnect();
+  RemoveDOMContentLoadedListener();
   CheckLoadingFinished();
 
   return NS_OK;
 }
 
 /* static */ bool
 FontFaceSet::PrefEnabled()
 {
--- a/layout/style/FontFaceSet.h
+++ b/layout/style/FontFaceSet.h
@@ -192,16 +192,18 @@ private:
    */
   bool HasAvailableFontFace(FontFace* aFontFace);
 
   /**
    * Removes any listeners and observers.
    */
   void Disconnect();
 
+  void RemoveDOMContentLoadedListener();
+
   /**
    * Returns whether there might be any pending font loads, which should cause
    * the mReady Promise not to be resolved yet.
    */
   bool MightHavePendingFontLoads();
 
   /**
    * Checks to see whether it is time to replace mReady and dispatch a