mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Bug 1362119 - part 2 - Fixing the code style in dom/script, r=ehsan
This commit is contained in:
parent
9326c6d072
commit
cd805aa7fd
@ -27,7 +27,7 @@ NS_IMPL_RELEASE_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
|
||||
ModuleLoadRequest::ModuleLoadRequest(nsIScriptElement* aElement,
|
||||
uint32_t aVersion,
|
||||
CORSMode aCORSMode,
|
||||
const SRIMetadata &aIntegrity,
|
||||
const SRIMetadata& aIntegrity,
|
||||
ScriptLoader* aLoader)
|
||||
: ScriptLoadRequest(ScriptKind::Module,
|
||||
aElement,
|
||||
|
@ -37,7 +37,8 @@ public:
|
||||
const SRIMetadata& aIntegrity,
|
||||
ScriptLoader* aLoader);
|
||||
|
||||
bool IsTopLevel() const {
|
||||
bool IsTopLevel() const
|
||||
{
|
||||
return mIsTopLevel;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(ModuleScript)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(ModuleScript)
|
||||
|
||||
ModuleScript::ModuleScript(ScriptLoader *aLoader, nsIURI* aBaseURL,
|
||||
ModuleScript::ModuleScript(ScriptLoader* aLoader, nsIURI* aBaseURL,
|
||||
JS::Handle<JSObject*> aModuleRecord)
|
||||
: mLoader(aLoader),
|
||||
mBaseURL(aBaseURL),
|
||||
|
@ -48,13 +48,19 @@ public:
|
||||
nsIURI* BaseURL() const { return mBaseURL; }
|
||||
|
||||
void SetInstantiationResult(JS::Handle<JS::Value> aMaybeException);
|
||||
bool IsUninstantiated() const {
|
||||
|
||||
bool IsUninstantiated() const
|
||||
{
|
||||
return mInstantiationState == Uninstantiated;
|
||||
}
|
||||
bool IsInstantiated() const {
|
||||
|
||||
bool IsInstantiated() const
|
||||
{
|
||||
return mInstantiationState == Instantiated;
|
||||
}
|
||||
bool InstantiationFailed() const {
|
||||
|
||||
bool InstantiationFailed() const
|
||||
{
|
||||
return mInstantiationState == Errored;
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,9 @@ using namespace mozilla::dom;
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScriptElement::ScriptAvailable(nsresult aResult,
|
||||
nsIScriptElement *aElement,
|
||||
nsIScriptElement* aElement,
|
||||
bool aIsInline,
|
||||
nsIURI *aURI,
|
||||
nsIURI* aURI,
|
||||
int32_t aLineNo)
|
||||
{
|
||||
if (!aIsInline && NS_FAILED(aResult)) {
|
||||
@ -54,7 +54,7 @@ ScriptElement::FireErrorEvent()
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScriptElement::ScriptEvaluated(nsresult aResult,
|
||||
nsIScriptElement *aElement,
|
||||
nsIScriptElement* aElement,
|
||||
bool aIsInline)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@ -78,7 +78,7 @@ ScriptElement::ScriptEvaluated(nsresult aResult,
|
||||
}
|
||||
|
||||
void
|
||||
ScriptElement::CharacterDataChanged(nsIDocument *aDocument,
|
||||
ScriptElement::CharacterDataChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
CharacterDataChangeInfo* aInfo)
|
||||
{
|
||||
@ -106,7 +106,7 @@ ScriptElement::ContentAppended(nsIDocument* aDocument,
|
||||
}
|
||||
|
||||
void
|
||||
ScriptElement::ContentInserted(nsIDocument *aDocument,
|
||||
ScriptElement::ContentInserted(nsIDocument* aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
int32_t aIndexInContainer)
|
||||
|
@ -21,9 +21,9 @@ namespace dom {
|
||||
#define LOG_ENABLED() \
|
||||
MOZ_LOG_TEST(ScriptLoader::gScriptLoaderLog, mozilla::LogLevel::Debug)
|
||||
|
||||
ScriptLoadHandler::ScriptLoadHandler(ScriptLoader *aScriptLoader,
|
||||
ScriptLoadRequest *aRequest,
|
||||
mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier)
|
||||
ScriptLoadHandler::ScriptLoadHandler(ScriptLoader* aScriptLoader,
|
||||
ScriptLoadRequest* aRequest,
|
||||
SRICheckDataVerifier* aSRIDataVerifier)
|
||||
: mScriptLoader(aScriptLoader),
|
||||
mRequest(aRequest),
|
||||
mSRIDataVerifier(aSRIDataVerifier),
|
||||
@ -44,7 +44,7 @@ ScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
|
||||
nsISupports* aContext,
|
||||
uint32_t aDataLength,
|
||||
const uint8_t* aData,
|
||||
uint32_t *aConsumedLength)
|
||||
uint32_t* aConsumedLength)
|
||||
{
|
||||
if (mRequest->IsCanceled()) {
|
||||
// If request cancelled, ignore any incoming data.
|
||||
@ -99,7 +99,7 @@ ScriptLoadHandler::DecodeRawData(const uint8_t* aData,
|
||||
bool aEndOfStream)
|
||||
{
|
||||
int32_t srcLen = aDataLength;
|
||||
const char* src = reinterpret_cast<const char *>(aData);
|
||||
const char* src = reinterpret_cast<const char*>(aData);
|
||||
int32_t dstLen;
|
||||
nsresult rv =
|
||||
mDecoder->GetMaxLength(src, srcLen, &dstLen);
|
||||
@ -130,7 +130,7 @@ ScriptLoadHandler::DecodeRawData(const uint8_t* aData,
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
|
||||
ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader* aLoader,
|
||||
const uint8_t* aData,
|
||||
uint32_t aDataLength,
|
||||
bool aEndOfStream)
|
||||
@ -153,7 +153,7 @@ ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
|
||||
ScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader* aLoader,
|
||||
const uint8_t* aData,
|
||||
uint32_t aDataLength,
|
||||
bool aEndOfStream,
|
||||
@ -258,7 +258,7 @@ ScriptLoadHandler::MaybeDecodeSRI()
|
||||
}
|
||||
|
||||
nsresult
|
||||
ScriptLoadHandler::EnsureKnownDataType(nsIIncrementalStreamLoader *aLoader)
|
||||
ScriptLoadHandler::EnsureKnownDataType(nsIIncrementalStreamLoader* aLoader)
|
||||
{
|
||||
MOZ_ASSERT(mRequest->IsUnknownDataType());
|
||||
MOZ_ASSERT(mRequest->IsLoading());
|
||||
|
@ -45,10 +45,10 @@ private:
|
||||
* tag, and other indicators. Returns true if charset has been
|
||||
* discovered.
|
||||
*/
|
||||
bool EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
|
||||
bool EnsureDecoder(nsIIncrementalStreamLoader* aLoader,
|
||||
const uint8_t* aData, uint32_t aDataLength,
|
||||
bool aEndOfStream);
|
||||
bool EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
|
||||
bool EnsureDecoder(nsIIncrementalStreamLoader* aLoader,
|
||||
const uint8_t* aData, uint32_t aDataLength,
|
||||
bool aEndOfStream, nsCString& oCharset);
|
||||
|
||||
@ -59,22 +59,22 @@ private:
|
||||
nsresult MaybeDecodeSRI();
|
||||
|
||||
// Query the channel to find the data type associated with the input stream.
|
||||
nsresult EnsureKnownDataType(nsIIncrementalStreamLoader *aLoader);
|
||||
nsresult EnsureKnownDataType(nsIIncrementalStreamLoader* aLoader);
|
||||
|
||||
// ScriptLoader which will handle the parsed script.
|
||||
RefPtr<ScriptLoader> mScriptLoader;
|
||||
RefPtr<ScriptLoader> mScriptLoader;
|
||||
|
||||
// The ScriptLoadRequest for this load. Decoded data are accumulated on it.
|
||||
RefPtr<ScriptLoadRequest> mRequest;
|
||||
RefPtr<ScriptLoadRequest> mRequest;
|
||||
|
||||
// SRI data verifier.
|
||||
nsAutoPtr<SRICheckDataVerifier> mSRIDataVerifier;
|
||||
|
||||
// Status of SRI data operations.
|
||||
nsresult mSRIStatus;
|
||||
nsresult mSRIStatus;
|
||||
|
||||
// Unicode decoder for charset.
|
||||
nsCOMPtr<nsIUnicodeDecoder> mDecoder;
|
||||
nsCOMPtr<nsIUnicodeDecoder> mDecoder;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -42,7 +42,7 @@ ScriptLoadRequest::ScriptLoadRequest(ScriptKind aKind,
|
||||
nsIScriptElement* aElement,
|
||||
uint32_t aVersion,
|
||||
mozilla::CORSMode aCORSMode,
|
||||
const mozilla::dom::SRIMetadata &aIntegrity)
|
||||
const mozilla::dom::SRIMetadata& aIntegrity)
|
||||
: mKind(aKind)
|
||||
, mElement(aElement)
|
||||
, mScriptFromHead(false)
|
||||
|
@ -232,9 +232,9 @@ IsScriptEventHandler(nsIContent* aScriptElement)
|
||||
|
||||
nsresult
|
||||
ScriptLoader::CheckContentPolicy(nsIDocument* aDocument,
|
||||
nsISupports *aContext,
|
||||
nsIURI *aURI,
|
||||
const nsAString &aType,
|
||||
nsISupports* aContext,
|
||||
nsIURI* aURI,
|
||||
const nsAString& aType,
|
||||
bool aIsPreLoad)
|
||||
{
|
||||
nsContentPolicyType contentPolicyType = aIsPreLoad
|
||||
@ -275,7 +275,7 @@ ScriptLoader::ModuleScriptsEnabled()
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptLoader::ModuleMapContainsModule(ModuleLoadRequest *aRequest) const
|
||||
ScriptLoader::ModuleMapContainsModule(ModuleLoadRequest* aRequest) const
|
||||
{
|
||||
// Returns whether we have fetched, or are currently fetching, a module script
|
||||
// for the request's URL.
|
||||
@ -284,7 +284,7 @@ ScriptLoader::ModuleMapContainsModule(ModuleLoadRequest *aRequest) const
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptLoader::IsFetchingModule(ModuleLoadRequest *aRequest) const
|
||||
ScriptLoader::IsFetchingModule(ModuleLoadRequest* aRequest) const
|
||||
{
|
||||
bool fetching = mFetchingModules.Contains(aRequest->mURI);
|
||||
MOZ_ASSERT_IF(fetching, !mFetchedModules.Contains(aRequest->mURI));
|
||||
@ -292,7 +292,7 @@ ScriptLoader::IsFetchingModule(ModuleLoadRequest *aRequest) const
|
||||
}
|
||||
|
||||
void
|
||||
ScriptLoader::SetModuleFetchStarted(ModuleLoadRequest *aRequest)
|
||||
ScriptLoader::SetModuleFetchStarted(ModuleLoadRequest* aRequest)
|
||||
{
|
||||
// Update the module map to indicate that a module is currently being fetched.
|
||||
|
||||
@ -302,7 +302,7 @@ ScriptLoader::SetModuleFetchStarted(ModuleLoadRequest *aRequest)
|
||||
}
|
||||
|
||||
void
|
||||
ScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest *aRequest,
|
||||
ScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest* aRequest,
|
||||
nsresult aResult)
|
||||
{
|
||||
// Update module map with the result of fetching a single module script. The
|
||||
@ -328,7 +328,7 @@ ScriptLoader::SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest *
|
||||
}
|
||||
|
||||
RefPtr<GenericPromise>
|
||||
ScriptLoader::WaitForModuleFetch(ModuleLoadRequest *aRequest)
|
||||
ScriptLoader::WaitForModuleFetch(ModuleLoadRequest* aRequest)
|
||||
{
|
||||
MOZ_ASSERT(ModuleMapContainsModule(aRequest));
|
||||
|
||||
@ -553,7 +553,7 @@ RequestedModuleIsInAncestorList(ModuleLoadRequest* aRequest, nsIURI* aURL, bool*
|
||||
}
|
||||
|
||||
static nsresult
|
||||
ResolveRequestedModules(ModuleLoadRequest* aRequest, nsCOMArray<nsIURI> &aUrls)
|
||||
ResolveRequestedModules(ModuleLoadRequest* aRequest, nsCOMArray<nsIURI>& aUrls)
|
||||
{
|
||||
ModuleScript* ms = aRequest->mModuleScript;
|
||||
|
||||
@ -819,7 +819,7 @@ ScriptLoader::IsBytecodeCacheEnabled()
|
||||
}
|
||||
|
||||
nsresult
|
||||
ScriptLoader::RestartLoad(ScriptLoadRequest *aRequest)
|
||||
ScriptLoader::RestartLoad(ScriptLoadRequest* aRequest)
|
||||
{
|
||||
MOZ_ASSERT(aRequest->IsBytecode());
|
||||
aRequest->mScriptBytecode.clearAndFree();
|
||||
@ -839,7 +839,7 @@ ScriptLoader::RestartLoad(ScriptLoadRequest *aRequest)
|
||||
}
|
||||
|
||||
nsresult
|
||||
ScriptLoader::StartLoad(ScriptLoadRequest *aRequest)
|
||||
ScriptLoader::StartLoad(ScriptLoadRequest* aRequest)
|
||||
{
|
||||
MOZ_ASSERT(aRequest->IsLoading());
|
||||
NS_ENSURE_TRUE(mDocument, NS_ERROR_NULL_POINTER);
|
||||
@ -880,7 +880,7 @@ ScriptLoader::StartLoad(ScriptLoadRequest *aRequest)
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = mDocument->GetDocumentLoadGroup();
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = mDocument->MasterDocument()->GetWindow();
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_NULL_POINTER);
|
||||
nsIDocShell *docshell = window->GetDocShell();
|
||||
nsIDocShell* docshell = window->GetDocShell();
|
||||
nsCOMPtr<nsIInterfaceRequestor> prompter(do_QueryInterface(docshell));
|
||||
|
||||
nsSecurityFlags securityFlags;
|
||||
@ -943,7 +943,7 @@ ScriptLoader::StartLoad(ScriptLoadRequest *aRequest)
|
||||
}
|
||||
}
|
||||
|
||||
nsIScriptElement *script = aRequest->mElement;
|
||||
nsIScriptElement* script = aRequest->mElement;
|
||||
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(channel));
|
||||
|
||||
if (cos) {
|
||||
@ -1007,8 +1007,8 @@ ScriptLoader::StartLoad(ScriptLoadRequest *aRequest)
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptLoader::PreloadURIComparator::Equals(const PreloadInfo &aPi,
|
||||
nsIURI * const &aURI) const
|
||||
ScriptLoader::PreloadURIComparator::Equals(const PreloadInfo& aPi,
|
||||
nsIURI* const& aURI) const
|
||||
{
|
||||
bool same;
|
||||
return NS_SUCCEEDED(aPi.mRequest->mURI->Equals(aURI, &same)) &&
|
||||
@ -1063,7 +1063,7 @@ ParseTypeAttribute(const nsAString& aType, JSVersion* aVersion)
|
||||
}
|
||||
|
||||
static bool
|
||||
CSPAllowsInlineScript(nsIScriptElement *aElement, nsIDocument *aDocument)
|
||||
CSPAllowsInlineScript(nsIScriptElement* aElement, nsIDocument* aDocument)
|
||||
{
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
// Note: For imports NodePrincipal and the principal of the master are
|
||||
@ -1098,7 +1098,7 @@ ScriptLoadRequest*
|
||||
ScriptLoader::CreateLoadRequest(ScriptKind aKind,
|
||||
nsIScriptElement* aElement,
|
||||
uint32_t aVersion, CORSMode aCORSMode,
|
||||
const SRIMetadata &aIntegrity)
|
||||
const SRIMetadata& aIntegrity)
|
||||
{
|
||||
if (aKind == ScriptKind::Classic) {
|
||||
return new ScriptLoadRequest(aKind, aElement, aVersion, aCORSMode,
|
||||
@ -1110,7 +1110,7 @@ ScriptLoader::CreateLoadRequest(ScriptKind aKind,
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
||||
ScriptLoader::ProcessScriptElement(nsIScriptElement* aElement)
|
||||
{
|
||||
// We need a document to evaluate scripts.
|
||||
NS_ENSURE_TRUE(mDocument, false);
|
||||
@ -1447,7 +1447,7 @@ class NotifyOffThreadScriptLoadCompletedRunnable : public Runnable
|
||||
RefPtr<ScriptLoadRequest> mRequest;
|
||||
RefPtr<ScriptLoader> mLoader;
|
||||
RefPtr<DocGroup> mDocGroup;
|
||||
void *mToken;
|
||||
void* mToken;
|
||||
|
||||
public:
|
||||
NotifyOffThreadScriptLoadCompletedRunnable(ScriptLoadRequest* aRequest,
|
||||
@ -1546,7 +1546,7 @@ NotifyOffThreadScriptLoadCompletedRunnable::Run()
|
||||
}
|
||||
|
||||
static void
|
||||
OffThreadScriptLoaderCallback(void *aToken, void *aCallbackData)
|
||||
OffThreadScriptLoaderCallback(void* aToken, void* aCallbackData)
|
||||
{
|
||||
RefPtr<NotifyOffThreadScriptLoadCompletedRunnable> aRunnable =
|
||||
dont_AddRef(static_cast<NotifyOffThreadScriptLoadCompletedRunnable*>(aCallbackData));
|
||||
@ -1715,7 +1715,7 @@ ScriptLoader::ProcessRequest(ScriptLoadRequest* aRequest)
|
||||
nsAutoMicroTask mt;
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner *pwin = master->GetInnerWindow();
|
||||
nsPIDOMWindowInner* pwin = master->GetInnerWindow();
|
||||
bool runScript = !!pwin;
|
||||
if (runScript) {
|
||||
nsContentUtils::DispatchTrustedEvent(scriptElem->OwnerDoc(),
|
||||
@ -1801,7 +1801,7 @@ already_AddRefed<nsIScriptGlobalObject>
|
||||
ScriptLoader::GetScriptGlobalObject()
|
||||
{
|
||||
nsCOMPtr<nsIDocument> master = mDocument->MasterDocument();
|
||||
nsPIDOMWindowInner *pwin = master->GetInnerWindow();
|
||||
nsPIDOMWindowInner* pwin = master->GetInnerWindow();
|
||||
if (!pwin) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -2844,9 +2844,9 @@ ScriptLoader::ParsingComplete(bool aTerminated)
|
||||
}
|
||||
|
||||
void
|
||||
ScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
|
||||
const nsAString &aType,
|
||||
const nsAString &aCrossOrigin,
|
||||
ScriptLoader::PreloadURI(nsIURI* aURI, const nsAString& aCharset,
|
||||
const nsAString& aType,
|
||||
const nsAString& aCrossOrigin,
|
||||
const nsAString& aIntegrity,
|
||||
bool aScriptFromHead,
|
||||
const mozilla::net::ReferrerPolicy aReferrerPolicy)
|
||||
@ -2887,7 +2887,7 @@ ScriptLoader::PreloadURI(nsIURI *aURI, const nsAString &aCharset,
|
||||
return;
|
||||
}
|
||||
|
||||
PreloadInfo *pi = mPreloads.AppendElement();
|
||||
PreloadInfo* pi = mPreloads.AppendElement();
|
||||
pi->mRequest = request;
|
||||
pi->mCharset = aCharset;
|
||||
}
|
||||
|
@ -58,10 +58,12 @@ class ScriptLoader final : public nsISupports
|
||||
{
|
||||
mScriptLoader->mCurrentScript = aCurrentScript;
|
||||
}
|
||||
|
||||
~AutoCurrentScriptUpdater()
|
||||
{
|
||||
mScriptLoader->mCurrentScript.swap(mOldScript);
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIScriptElement> mOldScript;
|
||||
ScriptLoader* mScriptLoader;
|
||||
@ -151,6 +153,7 @@ public:
|
||||
{
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
void SetEnabled(bool aEnabled)
|
||||
{
|
||||
if (!mEnabled && aEnabled) {
|
||||
@ -168,6 +171,7 @@ public:
|
||||
{
|
||||
++mParserBlockingBlockerCount;
|
||||
}
|
||||
|
||||
void RemoveParserBlockingScriptExecutionBlocker()
|
||||
{
|
||||
if (!--mParserBlockingBlockerCount && ReadyToExecuteScripts()) {
|
||||
@ -183,6 +187,7 @@ public:
|
||||
{
|
||||
++mBlockerCount;
|
||||
}
|
||||
|
||||
void RemoveExecuteBlocker()
|
||||
{
|
||||
MOZ_ASSERT(mBlockerCount);
|
||||
@ -219,8 +224,8 @@ public:
|
||||
JS::UniqueTwoByteChars& aBufOut, size_t& aLengthOut)
|
||||
{
|
||||
char16_t* bufOut;
|
||||
nsresult rv = ConvertToUTF16(aChannel, aData, aLength, aHintCharset, aDocument,
|
||||
bufOut, aLengthOut);
|
||||
nsresult rv = ConvertToUTF16(aChannel, aData, aLength, aHintCharset,
|
||||
aDocument, bufOut, aLengthOut);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aBufOut.reset(bufOut);
|
||||
}
|
||||
@ -291,9 +296,9 @@ public:
|
||||
* @param aIntegrity The expect hash url, if avail, of the request
|
||||
* @param aScriptFromHead Whether or not the script was a child of head
|
||||
*/
|
||||
virtual void PreloadURI(nsIURI *aURI, const nsAString &aCharset,
|
||||
const nsAString &aType,
|
||||
const nsAString &aCrossOrigin,
|
||||
virtual void PreloadURI(nsIURI* aURI, const nsAString& aCharset,
|
||||
const nsAString& aType,
|
||||
const nsAString& aCrossOrigin,
|
||||
const nsAString& aIntegrity,
|
||||
bool aScriptFromHead,
|
||||
const mozilla::net::ReferrerPolicy aReferrerPolicy);
|
||||
@ -302,9 +307,10 @@ public:
|
||||
* Process a request that was deferred so that the script could be compiled
|
||||
* off thread.
|
||||
*/
|
||||
nsresult ProcessOffThreadRequest(ScriptLoadRequest *aRequest);
|
||||
nsresult ProcessOffThreadRequest(ScriptLoadRequest* aRequest);
|
||||
|
||||
bool AddPendingChildLoader(ScriptLoader* aChild) {
|
||||
bool AddPendingChildLoader(ScriptLoader* aChild)
|
||||
{
|
||||
return mPendingChildLoaders.AppendElement(aChild) != nullptr;
|
||||
}
|
||||
|
||||
@ -323,12 +329,11 @@ public:
|
||||
private:
|
||||
virtual ~ScriptLoader();
|
||||
|
||||
ScriptLoadRequest* CreateLoadRequest(
|
||||
ScriptKind aKind,
|
||||
nsIScriptElement* aElement,
|
||||
uint32_t aVersion,
|
||||
mozilla::CORSMode aCORSMode,
|
||||
const mozilla::dom::SRIMetadata &aIntegrity);
|
||||
ScriptLoadRequest* CreateLoadRequest(ScriptKind aKind,
|
||||
nsIScriptElement* aElement,
|
||||
uint32_t aVersion,
|
||||
mozilla::CORSMode aCORSMode,
|
||||
const mozilla::dom::SRIMetadata& aIntegrity);
|
||||
|
||||
/**
|
||||
* Unblocks the creator parser of the parser-blocking scripts.
|
||||
@ -345,22 +350,22 @@ private:
|
||||
* Helper function to check the content policy for a given request.
|
||||
*/
|
||||
static nsresult CheckContentPolicy(nsIDocument* aDocument,
|
||||
nsISupports *aContext,
|
||||
nsIURI *aURI,
|
||||
const nsAString &aType,
|
||||
nsISupports* aContext,
|
||||
nsIURI* aURI,
|
||||
const nsAString& aType,
|
||||
bool aIsPreLoad);
|
||||
|
||||
/**
|
||||
* Start a load for aRequest's URI.
|
||||
*/
|
||||
nsresult StartLoad(ScriptLoadRequest *aRequest);
|
||||
nsresult StartLoad(ScriptLoadRequest* aRequest);
|
||||
|
||||
/**
|
||||
* Abort the current stream, and re-start with a new load request from scratch
|
||||
* without requesting any alternate data. Returns NS_BINDING_RETARGETED on
|
||||
* success, as this error code is used to abort the input stream.
|
||||
*/
|
||||
nsresult RestartLoad(ScriptLoadRequest *aRequest);
|
||||
nsresult RestartLoad(ScriptLoadRequest* aRequest);
|
||||
|
||||
/**
|
||||
* Process any pending requests asynchronously (i.e. off an event) if there
|
||||
@ -451,13 +456,13 @@ private:
|
||||
bool ModuleScriptsEnabled();
|
||||
|
||||
void SetModuleFetchStarted(ModuleLoadRequest *aRequest);
|
||||
void SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest *aRequest,
|
||||
void SetModuleFetchFinishedAndResumeWaitingRequests(ModuleLoadRequest* aRequest,
|
||||
nsresult aResult);
|
||||
|
||||
bool IsFetchingModule(ModuleLoadRequest *aRequest) const;
|
||||
bool IsFetchingModule(ModuleLoadRequest* aRequest) const;
|
||||
|
||||
bool ModuleMapContainsModule(ModuleLoadRequest *aRequest) const;
|
||||
RefPtr<mozilla::GenericPromise> WaitForModuleFetch(ModuleLoadRequest *aRequest);
|
||||
bool ModuleMapContainsModule(ModuleLoadRequest* aRequest) const;
|
||||
RefPtr<mozilla::GenericPromise> WaitForModuleFetch(ModuleLoadRequest* aRequest);
|
||||
ModuleScript* GetFetchedModule(nsIURI* aURL) const;
|
||||
|
||||
friend bool
|
||||
@ -491,7 +496,8 @@ private:
|
||||
ScriptLoadRequestList mBytecodeEncodingQueue;
|
||||
|
||||
// In mRequests, the additional information here is stored by the element.
|
||||
struct PreloadInfo {
|
||||
struct PreloadInfo
|
||||
{
|
||||
RefPtr<ScriptLoadRequest> mRequest;
|
||||
nsString mCharset;
|
||||
};
|
||||
@ -501,16 +507,19 @@ private:
|
||||
ScriptLoader::PreloadInfo& aField,
|
||||
const char* aName, uint32_t aFlags);
|
||||
|
||||
struct PreloadRequestComparator {
|
||||
bool Equals(const PreloadInfo &aPi, ScriptLoadRequest * const &aRequest)
|
||||
const
|
||||
struct PreloadRequestComparator
|
||||
{
|
||||
bool Equals(const PreloadInfo& aPi, ScriptLoadRequest* const& aRequest) const
|
||||
{
|
||||
return aRequest == aPi.mRequest;
|
||||
}
|
||||
};
|
||||
struct PreloadURIComparator {
|
||||
bool Equals(const PreloadInfo &aPi, nsIURI * const &aURI) const;
|
||||
|
||||
struct PreloadURIComparator
|
||||
{
|
||||
bool Equals(const PreloadInfo& aPi, nsIURI* const &aURI) const;
|
||||
};
|
||||
|
||||
nsTArray<PreloadInfo> mPreloads;
|
||||
|
||||
nsCOMPtr<nsIScriptElement> mCurrentScript;
|
||||
|
@ -29,13 +29,15 @@ namespace dom {
|
||||
static MOZ_THREAD_LOCAL(ScriptSettingsStackEntry*) sScriptSettingsTLS;
|
||||
static bool sScriptSettingsTLSInitialized;
|
||||
|
||||
class ScriptSettingsStack {
|
||||
class ScriptSettingsStack
|
||||
{
|
||||
public:
|
||||
static ScriptSettingsStackEntry* Top() {
|
||||
return sScriptSettingsTLS.get();
|
||||
}
|
||||
|
||||
static void Push(ScriptSettingsStackEntry *aEntry) {
|
||||
static void Push(ScriptSettingsStackEntry* aEntry)
|
||||
{
|
||||
MOZ_ASSERT(!aEntry->mOlder);
|
||||
// Whenever JSAPI use is disabled, the next stack entry pushed must
|
||||
// not be an AutoIncumbentScript.
|
||||
@ -50,13 +52,15 @@ public:
|
||||
sScriptSettingsTLS.set(aEntry);
|
||||
}
|
||||
|
||||
static void Pop(ScriptSettingsStackEntry *aEntry) {
|
||||
static void Pop(ScriptSettingsStackEntry* aEntry)
|
||||
{
|
||||
MOZ_ASSERT(aEntry == Top());
|
||||
sScriptSettingsTLS.set(aEntry->mOlder);
|
||||
}
|
||||
|
||||
static nsIGlobalObject* IncumbentGlobal() {
|
||||
ScriptSettingsStackEntry *entry = Top();
|
||||
static nsIGlobalObject* IncumbentGlobal()
|
||||
{
|
||||
ScriptSettingsStackEntry* entry = Top();
|
||||
while (entry) {
|
||||
if (entry->IsIncumbentCandidate()) {
|
||||
return entry->mGlobalObject;
|
||||
@ -66,8 +70,9 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static ScriptSettingsStackEntry* EntryPoint() {
|
||||
ScriptSettingsStackEntry *entry = Top();
|
||||
static ScriptSettingsStackEntry* EntryPoint()
|
||||
{
|
||||
ScriptSettingsStackEntry* entry = Top();
|
||||
while (entry) {
|
||||
if (entry->IsEntryCandidate()) {
|
||||
return entry;
|
||||
@ -77,8 +82,9 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static nsIGlobalObject* EntryGlobal() {
|
||||
ScriptSettingsStackEntry *entry = EntryPoint();
|
||||
static nsIGlobalObject* EntryGlobal()
|
||||
{
|
||||
ScriptSettingsStackEntry* entry = EntryPoint();
|
||||
if (!entry) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -86,8 +92,9 @@ public:
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static ScriptSettingsStackEntry* TopNonIncumbentScript() {
|
||||
ScriptSettingsStackEntry *entry = Top();
|
||||
static ScriptSettingsStackEntry* TopNonIncumbentScript()
|
||||
{
|
||||
ScriptSettingsStackEntry* entry = Top();
|
||||
while (entry) {
|
||||
if (!entry->IsIncumbentScript()) {
|
||||
return entry;
|
||||
@ -141,7 +148,7 @@ ScriptSettingsInitialized()
|
||||
return sScriptSettingsTLSInitialized;
|
||||
}
|
||||
|
||||
ScriptSettingsStackEntry::ScriptSettingsStackEntry(nsIGlobalObject *aGlobal,
|
||||
ScriptSettingsStackEntry::ScriptSettingsStackEntry(nsIGlobalObject* aGlobal,
|
||||
Type aType)
|
||||
: mGlobalObject(aGlobal)
|
||||
, mType(aType)
|
||||
@ -227,7 +234,7 @@ GetIncumbentGlobal()
|
||||
// manipulated the stack. If it's null, that means that there
|
||||
// must be no entry global on the stack, and therefore no incumbent
|
||||
// global either.
|
||||
JSContext *cx = nsContentUtils::GetCurrentJSContextForThread();
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContextForThread();
|
||||
if (!cx) {
|
||||
MOZ_ASSERT(ScriptSettingsStack::EntryGlobal() == nullptr);
|
||||
return nullptr;
|
||||
@ -237,7 +244,7 @@ GetIncumbentGlobal()
|
||||
// override in place, the JS engine will lie to us and pretend that
|
||||
// there's nothing on the JS stack, which will cause us to check the
|
||||
// incumbent script stack below.
|
||||
if (JSObject *global = JS::GetScriptedCallerGlobal(cx)) {
|
||||
if (JSObject* global = JS::GetScriptedCallerGlobal(cx)) {
|
||||
return ClampToSubject(xpc::NativeGlobal(global));
|
||||
}
|
||||
|
||||
@ -249,12 +256,12 @@ GetIncumbentGlobal()
|
||||
nsIGlobalObject*
|
||||
GetCurrentGlobal()
|
||||
{
|
||||
JSContext *cx = nsContentUtils::GetCurrentJSContextForThread();
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContextForThread();
|
||||
if (!cx) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSObject *global = JS::CurrentGlobalOrNull(cx);
|
||||
JSObject* global = JS::CurrentGlobalOrNull(cx);
|
||||
if (!global) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -266,7 +273,7 @@ nsIPrincipal*
|
||||
GetWebIDLCallerPrincipal()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
ScriptSettingsStackEntry *entry = ScriptSettingsStack::EntryPoint();
|
||||
ScriptSettingsStackEntry* entry = ScriptSettingsStack::EntryPoint();
|
||||
|
||||
// If we have an entry point that is not NoJSAPI, we know it must be an
|
||||
// AutoEntryScript.
|
||||
@ -658,7 +665,7 @@ AutoJSAPI::IsStackTop() const
|
||||
#endif // DEBUG
|
||||
|
||||
AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
|
||||
const char *aReason,
|
||||
const char* aReason,
|
||||
bool aIsMainThread)
|
||||
: AutoJSAPI(aGlobalObject, aIsMainThread, eEntryScript)
|
||||
, mWebIDLCallerPrincipal(nullptr)
|
||||
@ -674,7 +681,7 @@ AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
|
||||
}
|
||||
|
||||
AutoEntryScript::AutoEntryScript(JSObject* aObject,
|
||||
const char *aReason,
|
||||
const char* aReason,
|
||||
bool aIsMainThread)
|
||||
: AutoEntryScript(xpc::NativeGlobal(aObject), aReason, aIsMainThread)
|
||||
{
|
||||
|
@ -24,7 +24,8 @@
|
||||
/**
|
||||
* Internal interface implemented by script elements
|
||||
*/
|
||||
class nsIScriptElement : public nsIScriptLoaderObserver {
|
||||
class nsIScriptElement : public nsIScriptLoaderObserver
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTELEMENT_IID)
|
||||
|
||||
@ -118,6 +119,7 @@ public:
|
||||
{
|
||||
mLineNumber = aLineNumber;
|
||||
}
|
||||
|
||||
uint32_t GetScriptLineNumber()
|
||||
{
|
||||
return mLineNumber;
|
||||
@ -127,6 +129,7 @@ public:
|
||||
{
|
||||
mMalformed = true;
|
||||
}
|
||||
|
||||
bool IsMalformed()
|
||||
{
|
||||
return mMalformed;
|
||||
|
Loading…
x
Reference in New Issue
Block a user