Bug 1338446 Part 2 - Label FontFaceSet::CheckLoadingFinishedAfterDelay. r=heycam

mDocument is always valid because we get mDocument from the argument of
FontFaceSet's constructor, and FontFaceSet is always created in
nsIDocument's methods.

Delay giving checkTask a name until we dispatch it. No need to name it
twice.

MozReview-Commit-ID: 6nKYRcRqvQ0

--HG--
extra : rebase_source : 5d7be9c1bcf41ce6fae9ba37a4013144c23fa832
This commit is contained in:
Ting-Yu Lin 2017-03-09 18:02:01 +08:00
Родитель f0c29bc5fc
Коммит bef3641333
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -104,6 +104,8 @@ FontFaceSet::FontFaceSet(nsPIDOMWindowInner* aWindow, nsIDocument* aDocument)
, mHasLoadingFontFacesIsDirty(false)
, mDelayedLoadCheck(false)
{
MOZ_ASSERT(mDocument, "We should get a valid document from the caller!");
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aWindow);
// If the pref is not set, don't create the Promise (which the page wouldn't
@ -1473,9 +1475,9 @@ FontFaceSet::OnFontFaceStatusChanged(FontFace* aFontFace)
if (!mDelayedLoadCheck) {
mDelayedLoadCheck = true;
nsCOMPtr<nsIRunnable> checkTask =
NewRunnableMethod("FontFaceSet::CheckLoadingFinishedAfterDelay",
this, &FontFaceSet::CheckLoadingFinishedAfterDelay);
NS_DispatchToMainThread(checkTask);
NewRunnableMethod(this, &FontFaceSet::CheckLoadingFinishedAfterDelay);
mDocument->Dispatch("FontFaceSet::CheckLoadingFinishedAfterDelay",
TaskCategory::Other, checkTask.forget());
}
}
}