2017-05-08 09:24:44 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_ScriptLoadRequest_h
|
|
|
|
#define mozilla_dom_ScriptLoadRequest_h
|
|
|
|
|
2019-06-15 23:48:40 +03:00
|
|
|
#include "mozilla/Assertions.h"
|
2017-05-08 09:24:44 +03:00
|
|
|
#include "mozilla/CORSMode.h"
|
2020-05-12 22:28:15 +03:00
|
|
|
#include "mozilla/dom/Element.h"
|
2017-05-08 09:24:44 +03:00
|
|
|
#include "mozilla/dom/SRIMetadata.h"
|
|
|
|
#include "mozilla/LinkedList.h"
|
2018-05-16 17:58:13 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2020-05-11 17:07:24 +03:00
|
|
|
#include "mozilla/PreloaderBase.h"
|
2019-06-15 23:48:40 +03:00
|
|
|
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
|
2018-05-16 17:58:13 +03:00
|
|
|
#include "mozilla/Variant.h"
|
2017-05-08 09:24:44 +03:00
|
|
|
#include "mozilla/Vector.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsIScriptElement.h"
|
2020-05-11 17:07:24 +03:00
|
|
|
#include "ScriptKind.h"
|
2017-05-08 09:24:44 +03:00
|
|
|
|
|
|
|
class nsICacheInfoChannel;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class ModuleLoadRequest;
|
|
|
|
class ScriptLoadRequestList;
|
|
|
|
|
2018-08-06 12:54:28 +03:00
|
|
|
/*
|
|
|
|
* Some options used when fetching script resources. This only loosely
|
|
|
|
* corresponds to HTML's "script fetch options".
|
|
|
|
*
|
|
|
|
* These are common to all modules in a module graph, and hence a single
|
|
|
|
* instance is shared by all ModuleLoadRequest objects in a graph.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ScriptFetchOptions {
|
|
|
|
~ScriptFetchOptions();
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(ScriptFetchOptions)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(ScriptFetchOptions)
|
|
|
|
|
|
|
|
ScriptFetchOptions(mozilla::CORSMode aCORSMode,
|
2020-05-12 22:28:15 +03:00
|
|
|
enum ReferrerPolicy aReferrerPolicy, Element* aElement,
|
2018-08-06 12:54:28 +03:00
|
|
|
nsIPrincipal* aTriggeringPrincipal);
|
|
|
|
|
|
|
|
const mozilla::CORSMode mCORSMode;
|
2019-08-21 16:24:45 +03:00
|
|
|
const enum ReferrerPolicy mReferrerPolicy;
|
2018-12-07 00:52:18 +03:00
|
|
|
bool mIsPreload;
|
2020-05-12 22:28:15 +03:00
|
|
|
nsCOMPtr<Element> mElement;
|
2018-08-06 12:54:28 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
|
|
|
};
|
|
|
|
|
2017-05-08 09:24:44 +03:00
|
|
|
/*
|
|
|
|
* A class that handles loading and evaluation of <script> elements.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ScriptLoadRequest
|
2020-05-11 17:07:24 +03:00
|
|
|
: public PreloaderBase,
|
2017-05-08 09:24:44 +03:00
|
|
|
private mozilla::LinkedListElement<ScriptLoadRequest> {
|
|
|
|
typedef LinkedListElement<ScriptLoadRequest> super;
|
|
|
|
|
|
|
|
// Allow LinkedListElement<ScriptLoadRequest> to cast us to itself as needed.
|
|
|
|
friend class mozilla::LinkedListElement<ScriptLoadRequest>;
|
|
|
|
friend class ScriptLoadRequestList;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~ScriptLoadRequest();
|
|
|
|
|
|
|
|
public:
|
|
|
|
ScriptLoadRequest(ScriptKind aKind, nsIURI* aURI,
|
2018-08-06 12:54:28 +03:00
|
|
|
ScriptFetchOptions* aFetchOptions,
|
2017-12-21 13:58:53 +03:00
|
|
|
const SRIMetadata& aIntegrity, nsIURI* aReferrer);
|
2017-05-08 09:24:44 +03:00
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ScriptLoadRequest)
|
|
|
|
|
2020-05-11 17:07:24 +03:00
|
|
|
// PreloaderBase
|
|
|
|
static void PrioritizeAsPreload(nsIChannel* aChannel);
|
|
|
|
virtual void PrioritizeAsPreload() override;
|
|
|
|
|
2018-01-08 18:17:33 +03:00
|
|
|
bool IsModuleRequest() const { return mKind == ScriptKind::eModule; }
|
2017-05-08 09:24:44 +03:00
|
|
|
|
|
|
|
ModuleLoadRequest* AsModuleRequest();
|
|
|
|
|
2020-05-23 21:22:49 +03:00
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
|
|
|
TimeStamp mOffThreadParseStartTime;
|
|
|
|
TimeStamp mOffThreadParseStopTime;
|
|
|
|
#endif
|
|
|
|
|
2017-05-08 09:24:44 +03:00
|
|
|
void FireScriptAvailable(nsresult aResult) {
|
2017-12-01 16:12:48 +03:00
|
|
|
bool isInlineClassicScript = mIsInline && !IsModuleRequest();
|
2020-05-12 22:28:15 +03:00
|
|
|
GetScriptElement()->ScriptAvailable(aResult, GetScriptElement(),
|
|
|
|
isInlineClassicScript, mURI, mLineNo);
|
2017-05-08 09:24:44 +03:00
|
|
|
}
|
|
|
|
void FireScriptEvaluated(nsresult aResult) {
|
2020-05-12 22:28:15 +03:00
|
|
|
GetScriptElement()->ScriptEvaluated(aResult, GetScriptElement(), mIsInline);
|
2017-05-08 09:24:44 +03:00
|
|
|
}
|
|
|
|
|
2018-12-07 00:52:18 +03:00
|
|
|
bool IsPreload() const {
|
2020-05-12 22:28:15 +03:00
|
|
|
MOZ_ASSERT_IF(mFetchOptions->mIsPreload, !GetScriptElement());
|
2018-12-07 00:52:18 +03:00
|
|
|
return mFetchOptions->mIsPreload;
|
|
|
|
}
|
2017-05-08 09:24:44 +03:00
|
|
|
|
|
|
|
virtual void Cancel();
|
|
|
|
|
|
|
|
bool IsCanceled() const { return mIsCanceled; }
|
|
|
|
|
|
|
|
virtual void SetReady();
|
|
|
|
|
2018-05-10 16:51:14 +03:00
|
|
|
JS::OffThreadToken** OffThreadTokenPtr() {
|
2017-05-08 09:24:44 +03:00
|
|
|
return mOffThreadToken ? &mOffThreadToken : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsTracking() const { return mIsTracking; }
|
|
|
|
void SetIsTracking() {
|
|
|
|
MOZ_ASSERT(!mIsTracking);
|
|
|
|
mIsTracking = true;
|
|
|
|
}
|
|
|
|
|
2020-06-10 03:45:26 +03:00
|
|
|
void BlockOnload(Document* aDocument) {
|
|
|
|
MOZ_ASSERT(!mLoadBlockedDocument);
|
|
|
|
aDocument->BlockOnload();
|
|
|
|
mLoadBlockedDocument = aDocument;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MaybeUnblockOnload() {
|
|
|
|
if (mLoadBlockedDocument) {
|
|
|
|
mLoadBlockedDocument->UnblockOnload(false);
|
|
|
|
mLoadBlockedDocument = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-08 09:24:44 +03:00
|
|
|
enum class Progress : uint8_t {
|
2018-01-08 18:17:33 +03:00
|
|
|
eLoading, // Request either source or bytecode
|
|
|
|
eLoading_Source, // Explicitly Request source stream
|
|
|
|
eCompiling,
|
|
|
|
eFetchingImports,
|
|
|
|
eReady
|
2017-05-08 09:24:44 +03:00
|
|
|
};
|
|
|
|
|
2018-01-08 18:17:33 +03:00
|
|
|
bool IsReadyToRun() const { return mProgress == Progress::eReady; }
|
|
|
|
bool IsLoading() const {
|
|
|
|
return mProgress == Progress::eLoading ||
|
|
|
|
mProgress == Progress::eLoading_Source;
|
2017-05-08 09:24:44 +03:00
|
|
|
}
|
2018-01-08 18:17:33 +03:00
|
|
|
bool IsLoadingSource() const {
|
|
|
|
return mProgress == Progress::eLoading_Source;
|
2017-05-08 09:24:44 +03:00
|
|
|
}
|
2018-01-08 18:17:33 +03:00
|
|
|
bool InCompilingStage() const {
|
|
|
|
return mProgress == Progress::eCompiling ||
|
2017-05-08 09:24:44 +03:00
|
|
|
(IsReadyToRun() && mWasCompiledOMT);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type of data provided by the nsChannel.
|
|
|
|
enum class DataType : uint8_t {
|
2018-01-08 18:17:33 +03:00
|
|
|
eUnknown,
|
2018-05-16 17:58:13 +03:00
|
|
|
eTextSource,
|
|
|
|
eBinASTSource,
|
2018-01-08 18:17:33 +03:00
|
|
|
eBytecode
|
2017-05-08 09:24:44 +03:00
|
|
|
};
|
|
|
|
|
2018-01-08 18:17:33 +03:00
|
|
|
bool IsUnknownDataType() const { return mDataType == DataType::eUnknown; }
|
2018-05-16 17:58:13 +03:00
|
|
|
bool IsTextSource() const { return mDataType == DataType::eTextSource; }
|
2020-06-17 17:26:09 +03:00
|
|
|
bool IsBinASTSource() const { return false; }
|
2018-05-16 17:58:13 +03:00
|
|
|
bool IsSource() const { return IsTextSource() || IsBinASTSource(); }
|
2018-01-08 18:17:33 +03:00
|
|
|
bool IsBytecode() const { return mDataType == DataType::eBytecode; }
|
2017-05-08 09:24:44 +03:00
|
|
|
|
2018-05-16 17:58:13 +03:00
|
|
|
void SetUnknownDataType();
|
|
|
|
void SetTextSource();
|
|
|
|
void SetBinASTSource();
|
|
|
|
void SetBytecode();
|
|
|
|
|
2019-06-15 23:48:28 +03:00
|
|
|
// Use a vector backed by the JS allocator for script text so that contents
|
|
|
|
// can be transferred in constant time to the JS engine, not copied in linear
|
|
|
|
// time.
|
2019-06-15 23:48:40 +03:00
|
|
|
template <typename Unit>
|
|
|
|
using ScriptTextBuffer = Vector<Unit, 0, JSMallocAllocPolicy>;
|
2019-06-15 23:48:28 +03:00
|
|
|
|
|
|
|
// BinAST data isn't transferred to the JS engine, so it doesn't need to use
|
|
|
|
// the JS allocator.
|
2018-07-17 16:30:24 +03:00
|
|
|
using BinASTSourceBuffer = Vector<uint8_t>;
|
|
|
|
|
2019-06-15 23:48:40 +03:00
|
|
|
bool IsUTF16Text() const {
|
|
|
|
return mScriptData->is<ScriptTextBuffer<char16_t>>();
|
|
|
|
}
|
|
|
|
bool IsUTF8Text() const {
|
|
|
|
return mScriptData->is<ScriptTextBuffer<Utf8Unit>>();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Unit>
|
|
|
|
const ScriptTextBuffer<Unit>& ScriptText() const {
|
2018-05-16 17:58:13 +03:00
|
|
|
MOZ_ASSERT(IsTextSource());
|
2019-06-15 23:48:40 +03:00
|
|
|
return mScriptData->as<ScriptTextBuffer<Unit>>();
|
2018-05-16 17:58:13 +03:00
|
|
|
}
|
2019-06-15 23:48:40 +03:00
|
|
|
template <typename Unit>
|
|
|
|
ScriptTextBuffer<Unit>& ScriptText() {
|
2018-05-16 17:58:13 +03:00
|
|
|
MOZ_ASSERT(IsTextSource());
|
2019-06-15 23:48:40 +03:00
|
|
|
return mScriptData->as<ScriptTextBuffer<Unit>>();
|
2018-05-16 17:58:13 +03:00
|
|
|
}
|
2019-06-15 23:48:40 +03:00
|
|
|
|
2018-07-17 16:30:24 +03:00
|
|
|
const BinASTSourceBuffer& ScriptBinASTData() const {
|
2018-05-16 17:58:13 +03:00
|
|
|
MOZ_ASSERT(IsBinASTSource());
|
2018-07-17 16:30:24 +03:00
|
|
|
return mScriptData->as<BinASTSourceBuffer>();
|
2018-05-16 17:58:13 +03:00
|
|
|
}
|
2018-07-17 16:30:24 +03:00
|
|
|
BinASTSourceBuffer& ScriptBinASTData() {
|
2018-05-16 17:58:13 +03:00
|
|
|
MOZ_ASSERT(IsBinASTSource());
|
2018-07-17 16:30:24 +03:00
|
|
|
return mScriptData->as<BinASTSourceBuffer>();
|
2018-05-16 17:58:13 +03:00
|
|
|
}
|
|
|
|
|
2019-06-15 23:48:40 +03:00
|
|
|
size_t ScriptTextLength() const {
|
|
|
|
MOZ_ASSERT(IsTextSource());
|
|
|
|
return IsUTF16Text() ? ScriptText<char16_t>().length()
|
|
|
|
: ScriptText<Utf8Unit>().length();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearScriptText() {
|
|
|
|
MOZ_ASSERT(IsTextSource());
|
|
|
|
return IsUTF16Text() ? ScriptText<char16_t>().clearAndFree()
|
|
|
|
: ScriptText<Utf8Unit>().clearAndFree();
|
|
|
|
}
|
|
|
|
|
2019-11-28 00:45:12 +03:00
|
|
|
enum class ScriptMode : uint8_t {
|
|
|
|
eBlocking,
|
|
|
|
eDeferred,
|
|
|
|
eAsync,
|
|
|
|
eLinkPreload // this is a load initiated by <link rel="preload"
|
|
|
|
// as="script"> tag
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetScriptMode(bool aDeferAttr, bool aAsyncAttr, bool aLinkPreload);
|
2018-01-08 18:17:33 +03:00
|
|
|
|
2019-11-28 00:45:12 +03:00
|
|
|
bool IsLinkPreloadScript() const {
|
|
|
|
return mScriptMode == ScriptMode::eLinkPreload;
|
|
|
|
}
|
2018-01-08 18:17:33 +03:00
|
|
|
|
|
|
|
bool IsBlockingScript() const { return mScriptMode == ScriptMode::eBlocking; }
|
|
|
|
|
|
|
|
bool IsDeferredScript() const { return mScriptMode == ScriptMode::eDeferred; }
|
|
|
|
|
|
|
|
bool IsAsyncScript() const { return mScriptMode == ScriptMode::eAsync; }
|
|
|
|
|
2018-02-15 16:18:59 +03:00
|
|
|
virtual bool IsTopLevel() const {
|
|
|
|
// Classic scripts are always top level.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-06 12:54:28 +03:00
|
|
|
mozilla::CORSMode CORSMode() const { return mFetchOptions->mCORSMode; }
|
2019-08-21 16:24:45 +03:00
|
|
|
enum ReferrerPolicy ReferrerPolicy() const {
|
2018-08-06 12:54:28 +03:00
|
|
|
return mFetchOptions->mReferrerPolicy;
|
|
|
|
}
|
2020-05-12 22:28:15 +03:00
|
|
|
nsIScriptElement* GetScriptElement() const {
|
|
|
|
nsCOMPtr<nsIScriptElement> scriptElement =
|
|
|
|
do_QueryInterface(mFetchOptions->mElement);
|
|
|
|
return scriptElement;
|
|
|
|
}
|
2018-08-06 12:54:28 +03:00
|
|
|
nsIPrincipal* TriggeringPrincipal() const {
|
|
|
|
return mFetchOptions->mTriggeringPrincipal;
|
|
|
|
}
|
|
|
|
|
2018-12-07 00:52:18 +03:00
|
|
|
// Make this request a preload (speculative) request.
|
|
|
|
void SetIsPreloadRequest() {
|
2020-05-12 22:28:15 +03:00
|
|
|
MOZ_ASSERT(!GetScriptElement());
|
2018-12-07 00:52:18 +03:00
|
|
|
MOZ_ASSERT(!IsPreload());
|
|
|
|
mFetchOptions->mIsPreload = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make a preload request into an actual load request for the given element.
|
|
|
|
void SetIsLoadRequest(nsIScriptElement* aElement) {
|
2018-08-06 12:54:28 +03:00
|
|
|
MOZ_ASSERT(aElement);
|
2020-05-12 22:28:15 +03:00
|
|
|
MOZ_ASSERT(!GetScriptElement());
|
2018-12-07 00:52:18 +03:00
|
|
|
MOZ_ASSERT(IsPreload());
|
2020-05-12 22:28:15 +03:00
|
|
|
mFetchOptions->mElement = do_QueryInterface(aElement);
|
2018-12-07 00:52:18 +03:00
|
|
|
mFetchOptions->mIsPreload = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
FromParser GetParserCreated() const {
|
2020-05-12 22:28:15 +03:00
|
|
|
nsIScriptElement* element = GetScriptElement();
|
2018-12-07 00:52:18 +03:00
|
|
|
if (!element) {
|
|
|
|
return NOT_FROM_PARSER;
|
|
|
|
}
|
|
|
|
return element->GetParserCreated();
|
2018-08-06 12:54:28 +03:00
|
|
|
}
|
|
|
|
|
2018-05-16 17:58:13 +03:00
|
|
|
bool ShouldAcceptBinASTEncoding() const;
|
|
|
|
|
|
|
|
void ClearScriptSource();
|
2018-02-15 16:18:59 +03:00
|
|
|
|
2018-12-07 00:52:15 +03:00
|
|
|
void SetScript(JSScript* aScript);
|
|
|
|
|
2017-05-08 09:24:44 +03:00
|
|
|
void MaybeCancelOffThreadScript();
|
|
|
|
void DropBytecodeCacheReferences();
|
|
|
|
|
|
|
|
using super::getNext;
|
|
|
|
using super::isInList;
|
|
|
|
|
2019-01-24 17:57:30 +03:00
|
|
|
const ScriptKind mKind; // Whether this is a classic script or a module
|
|
|
|
// script.
|
2018-08-06 12:54:28 +03:00
|
|
|
ScriptMode mScriptMode; // Whether this is a blocking, defer or async script.
|
2017-05-08 09:24:44 +03:00
|
|
|
Progress mProgress; // Are we still waiting for a load to complete?
|
|
|
|
DataType mDataType; // Does this contain Source or Bytecode?
|
2018-08-06 12:54:28 +03:00
|
|
|
bool mScriptFromHead; // Synchronous head script block loading of other non
|
|
|
|
// js/css content.
|
2017-05-08 09:24:44 +03:00
|
|
|
bool mIsInline; // Is the script inline or loaded?
|
2018-01-08 18:17:33 +03:00
|
|
|
bool mInDeferList; // True if we live in mDeferRequests.
|
|
|
|
bool mInAsyncList; // True if we live in mLoadingAsyncRequests or
|
|
|
|
// mLoadedAsyncRequests.
|
2017-05-08 09:24:44 +03:00
|
|
|
bool mIsNonAsyncScriptInserted; // True if we live in
|
|
|
|
// mNonAsyncExternalScriptInsertedRequests
|
|
|
|
bool mIsXSLT; // True if we live in mXSLTRequests.
|
|
|
|
bool mIsCanceled; // True if we have been explicitly canceled.
|
2019-01-24 17:57:30 +03:00
|
|
|
bool mWasCompiledOMT; // True if the script has been compiled off main
|
|
|
|
// thread.
|
|
|
|
bool mIsTracking; // True if the script comes from a source on our
|
|
|
|
// tracking protection list.
|
2018-08-06 12:54:28 +03:00
|
|
|
|
|
|
|
RefPtr<ScriptFetchOptions> mFetchOptions;
|
|
|
|
|
2018-05-10 16:51:14 +03:00
|
|
|
JS::OffThreadToken* mOffThreadToken; // Off-thread parsing token.
|
2020-07-08 00:19:58 +03:00
|
|
|
Maybe<nsString> mSourceMapURL; // Holds source map url for loaded scripts
|
2017-05-08 09:24:44 +03:00
|
|
|
|
|
|
|
// Holds the top-level JSScript that corresponds to the current source, once
|
|
|
|
// it is parsed, and planned to be saved in the bytecode cache.
|
|
|
|
JS::Heap<JSScript*> mScript;
|
|
|
|
|
2019-06-15 23:48:28 +03:00
|
|
|
// Holds script source data for non-inline scripts.
|
2019-06-15 23:48:40 +03:00
|
|
|
Maybe<Variant<ScriptTextBuffer<char16_t>, ScriptTextBuffer<Utf8Unit>,
|
|
|
|
BinASTSourceBuffer>>
|
|
|
|
mScriptData;
|
2018-07-17 16:30:24 +03:00
|
|
|
|
|
|
|
// The length of script source text, set when reading completes. This is used
|
|
|
|
// since mScriptData is cleared when the source is passed to the JS engine.
|
|
|
|
size_t mScriptTextLength;
|
2017-05-08 09:24:44 +03:00
|
|
|
|
|
|
|
// Holds the SRI serialized hash and the script bytecode for non-inline
|
|
|
|
// scripts.
|
|
|
|
mozilla::Vector<uint8_t> mScriptBytecode;
|
|
|
|
uint32_t mBytecodeOffset; // Offset of the bytecode in mScriptBytecode
|
|
|
|
|
2017-12-15 00:13:57 +03:00
|
|
|
const nsCOMPtr<nsIURI> mURI;
|
2017-05-08 09:24:44 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mOriginPrincipal;
|
|
|
|
nsAutoCString
|
|
|
|
mURL; // Keep the URI's filename alive during off thread parsing.
|
|
|
|
int32_t mLineNo;
|
2017-12-21 13:58:53 +03:00
|
|
|
const SRIMetadata mIntegrity;
|
2017-12-19 18:30:49 +03:00
|
|
|
const nsCOMPtr<nsIURI> mReferrer;
|
2017-05-08 09:24:44 +03:00
|
|
|
|
2020-06-10 03:45:26 +03:00
|
|
|
// Non-null if there is a document that this request is blocking from loading.
|
|
|
|
RefPtr<Document> mLoadBlockedDocument;
|
|
|
|
|
2017-05-08 09:24:44 +03:00
|
|
|
// Holds the Cache information, which is used to register the bytecode
|
|
|
|
// on the cache entry, such that we can load it the next time.
|
|
|
|
nsCOMPtr<nsICacheInfoChannel> mCacheInfo;
|
2018-12-07 00:52:17 +03:00
|
|
|
|
|
|
|
// The base URL used for resolving relative module imports.
|
|
|
|
nsCOMPtr<nsIURI> mBaseURL;
|
2019-01-24 17:57:30 +03:00
|
|
|
|
|
|
|
// For preload requests, we defer reporting errors to the console until the
|
|
|
|
// request is used.
|
|
|
|
nsresult mUnreportedPreloadError;
|
2017-05-08 09:24:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class ScriptLoadRequestList : private mozilla::LinkedList<ScriptLoadRequest> {
|
|
|
|
typedef mozilla::LinkedList<ScriptLoadRequest> super;
|
|
|
|
|
|
|
|
public:
|
|
|
|
~ScriptLoadRequestList();
|
|
|
|
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool Contains(ScriptLoadRequest* aElem) const;
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
using super::getFirst;
|
|
|
|
using super::isEmpty;
|
|
|
|
|
|
|
|
void AppendElement(ScriptLoadRequest* aElem) {
|
|
|
|
MOZ_ASSERT(!aElem->isInList());
|
|
|
|
NS_ADDREF(aElem);
|
|
|
|
insertBack(aElem);
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_MUST_USE
|
|
|
|
already_AddRefed<ScriptLoadRequest> Steal(ScriptLoadRequest* aElem) {
|
|
|
|
aElem->removeFrom(*this);
|
|
|
|
return dont_AddRef(aElem);
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_MUST_USE
|
|
|
|
already_AddRefed<ScriptLoadRequest> StealFirst() {
|
|
|
|
MOZ_ASSERT(!isEmpty());
|
|
|
|
return Steal(getFirst());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Remove(ScriptLoadRequest* aElem) {
|
|
|
|
aElem->removeFrom(*this);
|
|
|
|
NS_RELEASE(aElem);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void ImplCycleCollectionUnlink(ScriptLoadRequestList& aField);
|
|
|
|
|
|
|
|
void ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
|
|
|
|
ScriptLoadRequestList& aField,
|
|
|
|
const char* aName, uint32_t aFlags);
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_ScriptLoadRequest_h
|