Bug 1648095 - Don't defer the same sheet load twice. r=heycam

When we call into LoadSheet when starting pending loads for a given
loader, it may be the case that the original loader may still not care
about the load. However some other loader will, so we can't defer this.

This was also causing our state to get out of sync, because if this
happened, then we'd fail to account for it in other loaders.

Differential Revision: https://phabricator.services.mozilla.com/D81119
This commit is contained in:
Emilio Cobos Álvarez 2020-06-26 01:17:40 +00:00
Родитель 2c0ef5cc73
Коммит 8ae606c7bf
3 изменённых файлов: 10 добавлений и 6 удалений

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

@ -1273,11 +1273,12 @@ nsresult Loader::LoadSheet(SheetLoadData& aLoadData, SheetState aSheetState,
if (mSheets) {
// If we have at least one other load ongoing, then we can defer it until
// all non-pending loads are done.
if (aSheetState == SheetState::NeedsParser && aLoadData.ShouldDefer() &&
if (aSheetState == SheetState::NeedsParser &&
aPendingLoad == PendingLoad::No && aLoadData.ShouldDefer() &&
mOngoingLoadCount > mPendingLoadCount + 1) {
LOG((" Deferring sheet load"));
++mPendingLoadCount;
mSheets->DeferSheetLoad(aLoadData);
mSheets->DeferSheetLoad(key, aLoadData);
return NS_OK;
}

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

@ -230,10 +230,13 @@ size_t SharedStyleSheetCache::SizeOfIncludingThis(
return n;
}
void SharedStyleSheetCache::DeferSheetLoad(SheetLoadData& aData) {
SheetLoadDataHashKey key(aData);
void SharedStyleSheetCache::DeferSheetLoad(const SheetLoadDataHashKey& aKey,
SheetLoadData& aData) {
MOZ_ASSERT(SheetLoadDataHashKey(aData).KeyEquals(aKey));
MOZ_DIAGNOSTIC_ASSERT(!aData.mNext, "Should only defer loads once");
aData.mMustNotify = true;
mPendingDatas.Put(key, RefPtr{&aData});
mPendingDatas.Put(aKey, RefPtr{&aData});
}
void SharedStyleSheetCache::LoadStarted(const SheetLoadDataHashKey& aKey,

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

@ -71,7 +71,7 @@ class SharedStyleSheetCache final : public nsIMemoryReporter {
// Puts the load into the "loading" set.
void LoadStarted(const SheetLoadDataHashKey&, css::SheetLoadData&);
// Puts a load into the "pending" set.
void DeferSheetLoad(css::SheetLoadData&);
void DeferSheetLoad(const SheetLoadDataHashKey&, css::SheetLoadData&);
enum class StartLoads {
Always,