Bug 1144450 - Part 3: Replace uses of mDispatchedLoadingEvent with mStatus, as they're equivalent. r=jdaggett
authorCameron McCormack <cam@mcc.id.au>
Tue, 24 Mar 2015 19:34:32 +1100
changeset 265552 8530a96751c6b43aed6783b8936b31dce36fed31
parent 265551 f2c86fe2f8e92ef8cd19a0e224b259d0927785fd
child 265553 fabd2ae326921bddf114f4f5f025b43525128c44
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs1144450
milestone39.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 1144450 - Part 3: Replace uses of mDispatchedLoadingEvent with mStatus, as they're equivalent. r=jdaggett
layout/style/FontFaceSet.cpp
layout/style/FontFaceSet.h
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -72,17 +72,16 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEvent
 
 FontFaceSet::FontFaceSet(nsPIDOMWindow* aWindow, nsPresContext* aPresContext)
   : DOMEventTargetHelper(aWindow)
   , mPresContext(aPresContext)
   , mDocument(aPresContext->Document())
   , mStatus(FontFaceSetLoadStatus::Loaded)
   , mNonRuleFacesDirty(false)
   , mReadyIsResolved(true)
-  , mDispatchedLoadingEvent(false)
   , mHasLoadingFontFaces(false)
   , mHasLoadingFontFacesIsDirty(false)
 {
   MOZ_COUNT_CTOR(FontFaceSet);
 
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aWindow);
 
   // If the pref is not set, don't create the Promise (which the page wouldn't
@@ -1335,23 +1334,26 @@ FontFaceSet::DidRefresh()
 
 void
 FontFaceSet::CheckLoadingStarted()
 {
   if (!HasLoadingFontFaces()) {
     return;
   }
 
-  if (!mDispatchedLoadingEvent) {
-    mStatus = FontFaceSetLoadStatus::Loading;
-    mDispatchedLoadingEvent = true;
-    (new AsyncEventDispatcher(this, NS_LITERAL_STRING("loading"),
-                              false))->RunDOMEventWhenSafe();
+  if (mStatus == FontFaceSetLoadStatus::Loading) {
+    // We have already dispatched a loading event and replaced mReady
+    // with a fresh, unresolved promise.
+    return;
   }
 
+  mStatus = FontFaceSetLoadStatus::Loading;
+  (new AsyncEventDispatcher(this, NS_LITERAL_STRING("loading"),
+                            false))->RunDOMEventWhenSafe();
+
   if (mReadyIsResolved && PrefEnabled()) {
     nsRefPtr<Promise> ready;
     if (GetParentObject()) {
       ErrorResult rv;
       ready = Promise::Create(GetParentObject(), rv);
     }
 
     if (ready) {
@@ -1430,17 +1432,16 @@ FontFaceSet::CheckLoadingFinished()
   }
 
   if (MightHavePendingFontLoads()) {
     // We're not finished loading yet.
     return;
   }
 
   mStatus = FontFaceSetLoadStatus::Loaded;
-  mDispatchedLoadingEvent = false;
   if (mReady) {
     mReady->MaybeResolve(this);
     mReadyIsResolved = true;
   }
 
   // Now dispatch the loadingdone/loadingerror events.
   nsTArray<FontFace*> loaded;
   nsTArray<FontFace*> failed;
--- a/layout/style/FontFaceSet.h
+++ b/layout/style/FontFaceSet.h
@@ -309,20 +309,16 @@ private:
   mozilla::dom::FontFaceSetLoadStatus mStatus;
 
   // Whether mNonRuleFaces has changed since last time UpdateRules ran.
   bool mNonRuleFacesDirty;
 
   // Whether we have called MaybeResolve() on mReady.
   bool mReadyIsResolved;
 
-  // Whether we have already dispatched loading events for the current set
-  // of loading FontFaces.
-  bool mDispatchedLoadingEvent;
-
   // Whether any FontFace objects in mRuleFaces or mNonRuleFaces are
   // loading.  Only valid when mHasLoadingFontFacesIsDirty is false.  Don't use
   // this variable directly; call the HasLoadingFontFaces method instead.
   bool mHasLoadingFontFaces;
 
   // This variable is only valid when mLoadingDirty is false.
   bool mHasLoadingFontFacesIsDirty;
 };