mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1800641 - Part 8: Add LoadContextBase* parameter to ScriptLoadRequest methods which is going to be moved to LoadedScriptDelegate. r=nbp
Depends on D197845 Differential Revision: https://phabricator.services.mozilla.com/D197846
This commit is contained in:
parent
f135bad3aa
commit
976c794ad0
@ -225,7 +225,8 @@ nsresult ModuleLoader::CompileFetchedModule(
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
if (aRequest->IsTextSource()) {
|
||||
MaybeSourceText maybeSource;
|
||||
nsresult rv = aRequest->GetScriptSource(aCx, &maybeSource);
|
||||
nsresult rv = aRequest->GetScriptSource(aCx, &maybeSource,
|
||||
aRequest->mLoadContext.get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
auto compile = [&](auto& source) {
|
||||
|
@ -321,7 +321,7 @@ nsresult ScriptLoadHandler::EnsureKnownDataType(
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mRequest->mFetchSourceOnly) {
|
||||
mRequest->SetTextSource();
|
||||
mRequest->SetTextSource(mRequest->mLoadContext.get());
|
||||
TRACE_FOR_TEST(mRequest->GetScriptLoadContext()->GetScriptElement(),
|
||||
"scriptloader_load_source");
|
||||
return NS_OK;
|
||||
@ -340,7 +340,7 @@ nsresult ScriptLoadHandler::EnsureKnownDataType(
|
||||
MOZ_ASSERT(altDataType.IsEmpty());
|
||||
}
|
||||
|
||||
mRequest->SetTextSource();
|
||||
mRequest->SetTextSource(mRequest->mLoadContext.get());
|
||||
TRACE_FOR_TEST(mRequest->GetScriptLoadContext()->GetScriptElement(),
|
||||
"scriptloader_load_source");
|
||||
|
||||
|
@ -1384,7 +1384,7 @@ bool ScriptLoader::ProcessInlineScript(nsIScriptElement* aElement,
|
||||
request->GetScriptLoadContext()->mColumnNo =
|
||||
aElement->GetScriptColumnNumber();
|
||||
request->mFetchSourceOnly = true;
|
||||
request->SetTextSource();
|
||||
request->SetTextSource(request->mLoadContext.get());
|
||||
TRACE_FOR_TEST_BOOL(request->GetScriptLoadContext()->GetScriptElement(),
|
||||
"scriptloader_load_source");
|
||||
CollectScriptTelemetry(request);
|
||||
@ -2043,7 +2043,8 @@ nsresult ScriptLoader::CreateOffThreadTask(
|
||||
}
|
||||
|
||||
MaybeSourceText maybeSource;
|
||||
nsresult rv = aRequest->GetScriptSource(aCx, &maybeSource);
|
||||
nsresult rv = aRequest->GetScriptSource(aCx, &maybeSource,
|
||||
aRequest->mLoadContext.get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (ShouldApplyDelazifyStrategy(aRequest)) {
|
||||
@ -2646,7 +2647,8 @@ nsresult ScriptLoader::CompileOrDecodeClassicScript(
|
||||
LOG(("ScriptLoadRequest (%p): Compile And Exec", aRequest));
|
||||
MOZ_ASSERT(aRequest->IsTextSource());
|
||||
MaybeSourceText maybeSource;
|
||||
rv = aRequest->GetScriptSource(aCx, &maybeSource);
|
||||
rv = aRequest->GetScriptSource(aCx, &maybeSource,
|
||||
aRequest->mLoadContext.get());
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
AUTO_PROFILER_MARKER_TEXT("ScriptCompileMainThread", JS,
|
||||
MarkerInnerWindowIdFromJSContext(aCx),
|
||||
|
@ -1225,7 +1225,8 @@ bool WorkerScriptLoader::EvaluateScript(JSContext* aCx,
|
||||
|
||||
// Get the source text.
|
||||
ScriptLoadRequest::MaybeSourceText maybeSource;
|
||||
rv = aRequest->GetScriptSource(aCx, &maybeSource);
|
||||
rv = aRequest->GetScriptSource(aCx, &maybeSource,
|
||||
aRequest->mLoadContext.get());
|
||||
if (NS_FAILED(rv)) {
|
||||
mRv.StealExceptionFromJSContext(aCx);
|
||||
return false;
|
||||
|
@ -557,7 +557,7 @@ nsresult CacheLoadHandler::DataReceivedFromCache(
|
||||
nsresult rv;
|
||||
|
||||
// Set the Source type to "text" for decoding.
|
||||
loadContext->mRequest->SetTextSource();
|
||||
loadContext->mRequest->SetTextSource(loadContext);
|
||||
|
||||
rv = mDecoder->DecodeRawData(loadContext->mRequest, aString, aStringLen,
|
||||
/* aEndOfStream = */ true);
|
||||
|
@ -164,7 +164,7 @@ nsresult NetworkLoadHandler::DataReceivedFromNetwork(nsIStreamLoader* aLoader,
|
||||
Document* parentDoc = mWorkerRef->Private()->GetDocument();
|
||||
|
||||
// Set the Source type to "text" for decoding.
|
||||
loadContext->mRequest->SetTextSource();
|
||||
loadContext->mRequest->SetTextSource(loadContext);
|
||||
|
||||
// Use the regular ScriptDecoder Decoder for this grunt work! Should be just
|
||||
// fine because we're running on the main thread.
|
||||
|
@ -171,7 +171,8 @@ nsresult WorkerModuleLoader::CompileFetchedModule(
|
||||
RefPtr<JS::Stencil> stencil;
|
||||
MOZ_ASSERT(aRequest->IsTextSource());
|
||||
MaybeSourceText maybeSource;
|
||||
nsresult rv = aRequest->GetScriptSource(aCx, &maybeSource);
|
||||
nsresult rv = aRequest->GetScriptSource(aCx, &maybeSource,
|
||||
aRequest->mLoadContext.get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
auto compile = [&](auto& source) {
|
||||
|
@ -209,7 +209,7 @@ NS_IMETHODIMP FetchCompleteRunnable::RunOnWorkletThread() {
|
||||
MOZ_ASSERT(request);
|
||||
|
||||
// Set the Source type to "text" for decoding.
|
||||
request->SetTextSource();
|
||||
request->SetTextSource(request->mLoadContext.get());
|
||||
|
||||
nsresult rv;
|
||||
if (mScriptBuffer) {
|
||||
|
@ -106,7 +106,8 @@ nsresult WorkletModuleLoader::CompileFetchedModule(
|
||||
MOZ_ASSERT(aRequest->IsTextSource());
|
||||
|
||||
MaybeSourceText maybeSource;
|
||||
nsresult rv = aRequest->GetScriptSource(aCx, &maybeSource);
|
||||
nsresult rv = aRequest->GetScriptSource(aCx, &maybeSource,
|
||||
aRequest->mLoadContext.get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
auto compile = [&](auto& source) {
|
||||
|
@ -1301,7 +1301,8 @@ UniquePtr<ImportMap> ModuleLoaderBase::ParseImportMap(
|
||||
|
||||
MOZ_ASSERT(aRequest->IsTextSource());
|
||||
MaybeSourceText maybeSource;
|
||||
nsresult rv = aRequest->GetScriptSource(jsapi.cx(), &maybeSource);
|
||||
nsresult rv = aRequest->GetScriptSource(jsapi.cx(), &maybeSource,
|
||||
aRequest->mLoadContext.get());
|
||||
if (NS_FAILED(rv)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -195,7 +195,8 @@ bool ScriptLoadRequest::IsMarkedForBytecodeEncoding() const {
|
||||
}
|
||||
|
||||
nsresult ScriptLoadRequest::GetScriptSource(JSContext* aCx,
|
||||
MaybeSourceText* aMaybeSource) {
|
||||
MaybeSourceText* aMaybeSource,
|
||||
LoadContextBase* aLoadContext) {
|
||||
// If there's no script text, we try to get it from the element
|
||||
if (HasScriptLoadContext() && GetScriptLoadContext()->mIsInline) {
|
||||
nsAutoString inlineData;
|
||||
|
@ -180,7 +180,7 @@ class ScriptLoadRequest
|
||||
mScriptData.reset();
|
||||
}
|
||||
|
||||
void SetTextSource() {
|
||||
void SetTextSource(LoadContextBase* aMaybeLoadContext) {
|
||||
MOZ_ASSERT(IsUnknownDataType());
|
||||
mDataType = DataType::eTextSource;
|
||||
mScriptData.emplace(VariantType<ScriptTextBuffer<Utf8Unit>>());
|
||||
@ -218,7 +218,8 @@ class ScriptLoadRequest
|
||||
|
||||
// Get source text. On success |aMaybeSource| will contain either UTF-8 or
|
||||
// UTF-16 source; on failure it will remain in its initial state.
|
||||
nsresult GetScriptSource(JSContext* aCx, MaybeSourceText* aMaybeSource);
|
||||
nsresult GetScriptSource(JSContext* aCx, MaybeSourceText* aMaybeSource,
|
||||
LoadContextBase* aLoadContext);
|
||||
|
||||
void ClearScriptText() {
|
||||
MOZ_ASSERT(IsTextSource());
|
||||
|
Loading…
Reference in New Issue
Block a user