Bug 1481905 - When canceling a user font load, make sure to not leave mUserFontLoadState as LOADING. r=jfkthame
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 10 Aug 2018 16:08:12 +0200
changeset 431160 49daf4d2dee7
parent 431159 935abf820aeb
child 431161 6b10b850fddb
push id34429
push usercbrindusan@mozilla.com
push dateSun, 12 Aug 2018 21:49:33 +0000
treeherdermozilla-central@83d0673bbca4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1481905
milestone63.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 1481905 - When canceling a user font load, make sure to not leave mUserFontLoadState as LOADING. r=jfkthame Since that's what we use to kick off new loads, should they be needed. Differential Revision: https://phabricator.services.mozilla.com/D3111
gfx/thebes/gfxUserFontSet.h
layout/style/nsFontFaceLoader.cpp
--- a/gfx/thebes/gfxUserFontSet.h
+++ b/gfx/thebes/gfxUserFontSet.h
@@ -584,16 +584,23 @@ public:
 
     gfxFont* CreateFontInstance(const gfxFontStyle* aFontStyle) override;
 
     gfxFontEntry* GetPlatformFontEntry() const { return mPlatformFontEntry; }
 
     // is the font loading or loaded, or did it fail?
     UserFontLoadState LoadState() const { return mUserFontLoadState; }
 
+    void LoadCanceled()
+    {
+      mUserFontLoadState = STATUS_NOT_LOADED;
+      mFontDataLoadingState = NOT_LOADING;
+      mLoader = nullptr;
+    }
+
     // whether to wait before using fallback font or not
     bool WaitForUserFont() const {
         return (mUserFontLoadState == STATUS_LOAD_PENDING ||
                 mUserFontLoadState == STATUS_LOADING) &&
                mFontDataLoadingState < LOADING_SLOWLY;
     }
 
     // for userfonts, cmap is used to store the unicode range data
--- a/layout/style/nsFontFaceLoader.cpp
+++ b/layout/style/nsFontFaceLoader.cpp
@@ -320,18 +320,17 @@ nsFontFaceLoader::OnStopRequest(nsIReque
 {
   MOZ_ASSERT(NS_IsMainThread());
   return NS_OK;
 }
 
 void
 nsFontFaceLoader::Cancel()
 {
-  mUserFontEntry->mFontDataLoadingState = gfxUserFontEntry::NOT_LOADING;
-  mUserFontEntry->mLoader = nullptr;
+  mUserFontEntry->LoadCanceled();
   mFontFaceSet = nullptr;
   if (mLoadTimer) {
     mLoadTimer->Cancel();
     mLoadTimer = nullptr;
   }
   mChannel->Cancel(NS_BINDING_ABORTED);
 }