diff options
author | Moonchild <moonchild@palemoon.org> | 2020-08-25 05:52:40 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-08-30 09:48:07 +0000 |
commit | e854d58633a2c877778410393914146f7a137495 (patch) | |
tree | a9d1a7e502e515784232af20042ff5fa6db68671 /dom/script/ScriptLoader.h | |
parent | d58cb8e11b15c054f0773918cd7fd89ce2a7464e (diff) | |
download | UXP-e854d58633a2c877778410393914146f7a137495.tar UXP-e854d58633a2c877778410393914146f7a137495.tar.gz UXP-e854d58633a2c877778410393914146f7a137495.tar.lz UXP-e854d58633a2c877778410393914146f7a137495.tar.xz UXP-e854d58633a2c877778410393914146f7a137495.zip |
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.
Diffstat (limited to 'dom/script/ScriptLoader.h')
-rw-r--r-- | dom/script/ScriptLoader.h | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/dom/script/ScriptLoader.h b/dom/script/ScriptLoader.h index b7e20c7ee..e9b663acd 100644 --- a/dom/script/ScriptLoader.h +++ b/dom/script/ScriptLoader.h @@ -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. |