import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1187146 - Replace nsBaseHashtable::Enumerate() calls in js/xpconnect/ with iterators. r=mrbkap. (28d2b6078d)
- Bug 1226119 - Clear pending exception from script cache writing failure. r=bholley (cca6220b3e)
- Bug 1218029 - Adds IncrementalStreamLoader interface stubs. r=djvj (d2eaf684d5)
- Bug 1218029 - Adds ScriptLoadHandler and implements OnIncrementalData callback. r=djvj (8f841b143d)
- Bug 1228467 - Don't preprocess dom/base/UseCounters.conf. r=froydnj (534610a94c)
- add EME bits to keep PP happy (47840e6c56)
This commit is contained in:
2023-04-24 11:03:39 +08:00
parent 5602866910
commit 0394c7f1d2
23 changed files with 636 additions and 85 deletions
+46 -39
View File
@@ -157,10 +157,10 @@ nsScriptLoader::~nsScriptLoader()
// subtree in the meantime and therefore aren't actually going away.
for (uint32_t j = 0; j < mPendingChildLoaders.Length(); ++j) {
mPendingChildLoaders[j]->RemoveExecuteBlocker();
}
}
}
NS_IMPL_ISUPPORTS(nsScriptLoader, nsIStreamLoaderObserver)
NS_IMPL_ISUPPORTS(nsScriptLoader, nsISupports)
// Helper method for checking if the script element is an event-handler
// This means that it has both a for-attribute and a event-attribute.
@@ -269,37 +269,6 @@ nsScriptLoader::ShouldLoadScript(nsIDocument* aDocument,
return NS_OK;
}
class ContextMediator : public nsIStreamLoaderObserver
{
public:
explicit ContextMediator(nsScriptLoader *aScriptLoader, nsISupports *aContext)
: mScriptLoader(aScriptLoader)
, mContext(aContext) {}
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMLOADEROBSERVER
private:
virtual ~ContextMediator() {}
RefPtr<nsScriptLoader> mScriptLoader;
nsCOMPtr<nsISupports> mContext;
};
NS_IMPL_ISUPPORTS(ContextMediator, nsIStreamLoaderObserver)
NS_IMETHODIMP
ContextMediator::OnStreamComplete(nsIStreamLoader* aLoader,
nsISupports* aContext,
nsresult aStatus,
uint32_t aStringLen,
const uint8_t* aString)
{
// pass arguments through except for the aContext,
// we have to mediate and use mContext instead.
return mScriptLoader->OnStreamComplete(aLoader, mContext, aStatus,
aStringLen, aString);
}
nsresult
nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
bool aScriptFromHead)
@@ -383,10 +352,10 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
timedChannel->SetInitiatorType(NS_LITERAL_STRING("script"));
}
RefPtr<ContextMediator> mediator = new ContextMediator(this, aRequest);
RefPtr<nsScriptLoadHandler> handler = new nsScriptLoadHandler(this, aRequest);
nsCOMPtr<nsIStreamLoader> loader;
rv = NS_NewStreamLoader(getter_AddRefs(loader), mediator);
nsCOMPtr<nsIIncrementalStreamLoader> loader;
rv = NS_NewIncrementalStreamLoader(getter_AddRefs(loader), handler);
NS_ENSURE_SUCCESS(rv, rv);
return channel->AsyncOpen2(loader);
@@ -1453,8 +1422,8 @@ nsScriptLoader::ConvertToUTF16(nsIChannel* aChannel, const uint8_t* aData,
return rv;
}
NS_IMETHODIMP
nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader,
nsresult
nsScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
nsISupports* aContext,
nsresult aStatus,
uint32_t aStringLen,
@@ -1550,7 +1519,7 @@ nsScriptLoader::NumberOfProcessors()
nsresult
nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
nsIStreamLoader* aLoader,
nsIIncrementalStreamLoader* aLoader,
nsresult aStatus,
uint32_t aStringLen,
const uint8_t* aString)
@@ -1757,3 +1726,41 @@ nsScriptLoader::MaybeRemovedDeferRequests()
}
return false;
}
//////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////
nsScriptLoadHandler::nsScriptLoadHandler(nsScriptLoader *aScriptLoader,
nsScriptLoadRequest *aRequest)
: mScriptLoader(aScriptLoader),
mRequest(aRequest)
{}
nsScriptLoadHandler::~nsScriptLoadHandler()
{}
NS_IMPL_ISUPPORTS(nsScriptLoadHandler, nsIIncrementalStreamLoaderObserver)
NS_IMETHODIMP
nsScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
nsISupports* aContext,
uint32_t aDataLength,
const uint8_t* aData,
uint32_t *aConsumedLength)
{
return NS_OK;
}
NS_IMETHODIMP
nsScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
nsISupports* aContext,
nsresult aStatus,
uint32_t aStringLen,
const uint8_t* aString)
{
// pass arguments through except for the aContext,
// we have to mediate and use mRequest instead.
return mScriptLoader->OnStreamComplete(aLoader, mRequest, aStatus,
aStringLen, aString);
}