diff options
author | Moonchild <moonchild@palemoon.org> | 2020-08-25 07:06:43 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-08-30 09:51:18 +0000 |
commit | 77e8ba7eaf3ca00f25d0507cf17de2f50741f335 (patch) | |
tree | b9025ffd0f46746481cd809598cd62142764f225 /dom/script/nsIScriptElement.h | |
parent | e854d58633a2c877778410393914146f7a137495 (diff) | |
download | UXP-77e8ba7eaf3ca00f25d0507cf17de2f50741f335.tar UXP-77e8ba7eaf3ca00f25d0507cf17de2f50741f335.tar.gz UXP-77e8ba7eaf3ca00f25d0507cf17de2f50741f335.tar.lz UXP-77e8ba7eaf3ca00f25d0507cf17de2f50741f335.tar.xz UXP-77e8ba7eaf3ca00f25d0507cf17de2f50741f335.zip |
Issue #618 - Implement async attribute for inline module scripts. (uplift)
This commit does several things:
- Moves the pref check from ScriptLoader to ns[I]Document so it can be called on
the document.
- Changes the atrribute freezing function to a better name that takes the
document as a parameter.
- Sets the proper async/defer attributes on HTML script elements based on
keywords and whether they are module scripts or not.
Diffstat (limited to 'dom/script/nsIScriptElement.h')
-rw-r--r-- | dom/script/nsIScriptElement.h | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/dom/script/nsIScriptElement.h b/dom/script/nsIScriptElement.h index 470d51c94..e3e1bc49a 100644 --- a/dom/script/nsIScriptElement.h +++ b/dom/script/nsIScriptElement.h @@ -13,6 +13,7 @@ #include "nsIScriptLoaderObserver.h" #include "nsWeakPtr.h" #include "nsIParser.h" +#include "nsIDocument.h" #include "nsContentCreatorFunctions.h" #include "nsIDOMHTMLScriptElement.h" #include "mozilla/CORSMode.h" @@ -37,6 +38,7 @@ public: mForceAsync(aFromParser == mozilla::dom::NOT_FROM_PARSER || aFromParser == mozilla::dom::FROM_PARSER_FRAGMENT), mFrozen(false), + mIsModule(false), mDefer(false), mAsync(false), mExternal(false), @@ -73,11 +75,25 @@ public: virtual void GetScriptCharset(nsAString& charset) = 0; /** - * Freezes the return values of GetScriptDeferred(), GetScriptAsync() and - * GetScriptURI() so that subsequent modifications to the attributes don't - * change execution behavior. + * Freezes the return values of the following methods so that subsequent + * modifications to the attributes don't change execution behavior: + * - GetScriptIsModule() + * - GetScriptDeferred() + * - GetScriptAsync() + * - GetScriptURI() + * - GetScriptExternal() */ - virtual void FreezeUriAsyncDefer() = 0; + virtual void FreezeExecutionAttrs(nsIDocument* aOwnerDoc) = 0; + + /** + * Is the script a module script? + * Currently only supported by HTML scripts. + */ + bool GetScriptIsModule() + { + NS_PRECONDITION(mFrozen, "Execution attributes not yet frozen: Not ready for this call!"); + return mIsModule; + } /** * Is the script deferred. Currently only supported by HTML scripts. @@ -293,6 +309,11 @@ protected: bool mFrozen; /** + * The effective moduleness. + */ + bool mIsModule; + + /** * The effective deferredness. */ bool mDefer; |