mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 23:38:38 +09:00
Issue #618 - (async) Implement async attribute for inline module scripts.
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.
This commit is contained in:
parent
294721687c
commit
3781c4a6dd
11 changed files with 73 additions and 41 deletions
|
|
@ -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.
|
||||
|
|
@ -292,6 +308,11 @@ protected:
|
|||
*/
|
||||
bool mFrozen;
|
||||
|
||||
/**
|
||||
* The effective moduleness.
|
||||
*/
|
||||
bool mIsModule;
|
||||
|
||||
/**
|
||||
* The effective deferredness.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue