mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-03 22:07:30 +09:00
Issue #618 - (async) Split out function to add async request.
This commit is contained in:
parent
ecf9c7cf08
commit
d8c2bc2976
2 changed files with 31 additions and 23 deletions
|
|
@ -1358,17 +1358,14 @@ ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
||||||
request->mJSVersion = version;
|
request->mJSVersion = version;
|
||||||
|
|
||||||
if (aElement->GetScriptAsync()) {
|
if (aElement->GetScriptAsync()) {
|
||||||
request->mInAsyncList = true;
|
AddAsyncRequest(request);
|
||||||
if (request->IsReadyToRun()) {
|
if (request->IsReadyToRun()) {
|
||||||
mLoadedAsyncRequests.AppendElement(request);
|
|
||||||
// The script is available already. Run it ASAP when the event
|
// The script is available already. Run it ASAP when the event
|
||||||
// loop gets a chance to spin.
|
// loop gets a chance to spin.
|
||||||
|
|
||||||
// KVKV TODO: Instead of processing immediately, try off-thread-parsing
|
// KVKV TODO: Instead of processing immediately, try off-thread-parsing
|
||||||
// it and only schedule a pending ProcessRequest if that fails.
|
// it and only schedule a pending ProcessRequest if that fails.
|
||||||
ProcessPendingRequestsAsync();
|
ProcessPendingRequestsAsync();
|
||||||
} else {
|
|
||||||
mLoadingAsyncRequests.AppendElement(request);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1469,8 +1466,7 @@ ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
||||||
modReq->mBaseURL = mDocument->GetDocBaseURI();
|
modReq->mBaseURL = mDocument->GetDocBaseURI();
|
||||||
|
|
||||||
if (aElement->GetScriptAsync()) {
|
if (aElement->GetScriptAsync()) {
|
||||||
modReq->mInAsyncList = true;
|
AddAsyncRequest(modReq);
|
||||||
mLoadingAsyncRequests.AppendElement(modReq);
|
|
||||||
} else {
|
} else {
|
||||||
AddDeferRequest(modReq);
|
AddDeferRequest(modReq);
|
||||||
}
|
}
|
||||||
|
|
@ -2418,23 +2414,6 @@ ScriptLoader::NumberOfProcessors()
|
||||||
return mNumberOfProcessors;
|
return mNumberOfProcessors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ScriptLoader::MaybeMoveToLoadedList(ScriptLoadRequest* aRequest)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(aRequest->IsReadyToRun());
|
|
||||||
|
|
||||||
// If it's async, move it to the loaded list. aRequest->mInAsyncList really
|
|
||||||
// _should_ be in a list, but the consequences if it's not are bad enough we
|
|
||||||
// want to avoid trying to move it if it's not.
|
|
||||||
if (aRequest->mInAsyncList) {
|
|
||||||
MOZ_ASSERT(aRequest->isInList());
|
|
||||||
if (aRequest->isInList()) {
|
|
||||||
RefPtr<ScriptLoadRequest> req = mLoadingAsyncRequests.Steal(aRequest);
|
|
||||||
mLoadedAsyncRequests.AppendElement(req);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
|
ScriptLoader::PrepareLoadedRequest(ScriptLoadRequest* aRequest,
|
||||||
nsIIncrementalStreamLoader* aLoader,
|
nsIIncrementalStreamLoader* aLoader,
|
||||||
|
|
@ -2646,6 +2625,34 @@ ScriptLoader::AddDeferRequest(ScriptLoadRequest* aRequest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ScriptLoader::AddAsyncRequest(ScriptLoadRequest* aRequest)
|
||||||
|
{
|
||||||
|
aRequest->mInAsyncList = true;
|
||||||
|
if (aRequest->IsReadyToRun()) {
|
||||||
|
mLoadedAsyncRequests.AppendElement(aRequest);
|
||||||
|
} else {
|
||||||
|
mLoadingAsyncRequests.AppendElement(aRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ScriptLoader::MaybeMoveToLoadedList(ScriptLoadRequest* aRequest)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aRequest->IsReadyToRun());
|
||||||
|
|
||||||
|
// If it's async, move it to the loaded list. aRequest->mInAsyncList really
|
||||||
|
// _should_ be in a list, but the consequences if it's not are bad enough we
|
||||||
|
// want to avoid trying to move it if it's not.
|
||||||
|
if (aRequest->mInAsyncList) {
|
||||||
|
MOZ_ASSERT(aRequest->isInList());
|
||||||
|
if (aRequest->isInList()) {
|
||||||
|
RefPtr<ScriptLoadRequest> req = mLoadingAsyncRequests.Steal(aRequest);
|
||||||
|
mLoadedAsyncRequests.AppendElement(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ScriptLoader::MaybeRemovedDeferRequests()
|
ScriptLoader::MaybeRemovedDeferRequests()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -571,6 +571,7 @@ private:
|
||||||
mozilla::Vector<char16_t> &aString);
|
mozilla::Vector<char16_t> &aString);
|
||||||
|
|
||||||
void AddDeferRequest(ScriptLoadRequest* aRequest);
|
void AddDeferRequest(ScriptLoadRequest* aRequest);
|
||||||
|
void AddAsyncRequest(ScriptLoadRequest* aRequest);
|
||||||
bool MaybeRemovedDeferRequests();
|
bool MaybeRemovedDeferRequests();
|
||||||
|
|
||||||
void MaybeMoveToLoadedList(ScriptLoadRequest* aRequest);
|
void MaybeMoveToLoadedList(ScriptLoadRequest* aRequest);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue