Bug 1673931 - Avoid including Document.h from header files. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D95046

Depends on D95045
This commit is contained in:
Simon Giesecke
2020-11-23 16:07:43 +00:00
parent ec58955170
commit eae3689379
78 changed files with 620 additions and 365 deletions

View File

@@ -4153,6 +4153,41 @@ bool ScriptLoader::MaybeRemovedDeferRequests() {
return false;
}
DocGroup* ScriptLoader::GetDocGroup() const { return mDocument->GetDocGroup(); }
void ScriptLoader::BeginDeferringScripts() {
mDeferEnabled = true;
if (mDeferCheckpointReached) {
// We already completed a parse and were just waiting for some async
// scripts to load (and were already blocking the load event waiting for
// that to happen), when document.open() happened and now we're doing a
// new parse. We shouldn't block the load event again, but _should_ reset
// mDeferCheckpointReached to false. It'll get set to true again when the
// DeferCheckpointReached call that corresponds to this
// BeginDeferringScripts call happens (on document.close()), since we just
// set mDeferEnabled to true.
mDeferCheckpointReached = false;
} else {
if (mDocument) {
mDocument->BlockOnload();
}
}
}
nsAutoScriptLoaderDisabler::nsAutoScriptLoaderDisabler(Document* aDoc) {
mLoader = aDoc->ScriptLoader();
mWasEnabled = mLoader->GetEnabled();
if (mWasEnabled) {
mLoader->SetEnabled(false);
}
}
nsAutoScriptLoaderDisabler::~nsAutoScriptLoaderDisabler() {
if (mWasEnabled) {
mLoader->SetEnabled(true);
}
}
#undef TRACE_FOR_TEST
#undef TRACE_FOR_TEST_BOOL
#undef TRACE_FOR_TEST_NONE