mirror of
https://github.com/ManchildProductions/UXP-Fixed.git
synced 2026-07-21 03:48:43 +00:00
Issue #618 - (async) Keep track of script modes in a single mode state.
This simplifies handling of combinations of async/defer by assigning one and only one state to scripts. If async then always async > if defer or module then defer > otherwise blocking.
This commit is contained in:
@@ -72,12 +72,11 @@ public:
|
||||
: mKind(aKind),
|
||||
mElement(aElement),
|
||||
mProgress(Progress::Loading),
|
||||
mScriptMode(ScriptMode::eBlocking),
|
||||
mIsInline(true),
|
||||
mHasSourceMapURL(false),
|
||||
mInDeferList(false),
|
||||
mInAsyncList(false),
|
||||
mPreloadAsAsync(false),
|
||||
mPreloadAsDefer(false),
|
||||
mIsNonAsyncScriptInserted(false),
|
||||
mIsXSLT(false),
|
||||
mIsCanceled(false),
|
||||
@@ -151,6 +150,29 @@ public:
|
||||
(IsReadyToRun() && mWasCompiledOMT);
|
||||
}
|
||||
|
||||
enum class ScriptMode : uint8_t {
|
||||
eBlocking,
|
||||
eDeferred,
|
||||
eAsync
|
||||
};
|
||||
|
||||
void SetScriptMode(bool aDeferAttr, bool aAsyncAttr);
|
||||
|
||||
bool IsBlockingScript() const
|
||||
{
|
||||
return mScriptMode == ScriptMode::eBlocking;
|
||||
}
|
||||
|
||||
bool IsDeferredScript() const
|
||||
{
|
||||
return mScriptMode == ScriptMode::eDeferred;
|
||||
}
|
||||
|
||||
bool IsAsyncScript() const
|
||||
{
|
||||
return mScriptMode == ScriptMode::eAsync;
|
||||
}
|
||||
|
||||
void MaybeCancelOffThreadScript();
|
||||
|
||||
using super::getNext;
|
||||
@@ -159,12 +181,11 @@ public:
|
||||
const ScriptKind mKind;
|
||||
nsCOMPtr<nsIScriptElement> mElement;
|
||||
Progress mProgress; // Are we still waiting for a load to complete?
|
||||
ScriptMode mScriptMode; // Whether this script is blocking, deferred or async.
|
||||
bool mIsInline; // Is the script inline or loaded?
|
||||
bool mHasSourceMapURL; // Does the HTTP header have a source map url?
|
||||
bool mInDeferList; // True if we live in mDeferRequests.
|
||||
bool mInAsyncList; // True if we live in mLoadingAsyncRequests or mLoadedAsyncRequests.
|
||||
bool mPreloadAsAsync; // True if this is a preload request and the script is async
|
||||
bool mPreloadAsDefer; // True if this is a preload request and the script is defer
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user