diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2020-08-26 11:19:42 -0400 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2020-08-26 11:19:42 -0400 |
commit | 38d13e2779f9bfbf8620ead68a9bf0ffbed5762a (patch) | |
tree | c5aa35810edee4cd678441df73ff8fbfd4ed3e5f /parser/html | |
parent | b78f53ffb09a6aae6dbdc069c7cdd42d11b5eed2 (diff) | |
download | uxp-38d13e2779f9bfbf8620ead68a9bf0ffbed5762a.tar.gz |
Issue #618 - Don't preload nomodule scripts when modules are enabled
Ref: BZ 1382020
Diffstat (limited to 'parser/html')
-rw-r--r-- | parser/html/java/htmlparser/src/nu/validator/htmlparser/impl/AttributeName.java | 2 | ||||
-rw-r--r-- | parser/html/nsHtml5SpeculativeLoad.cpp | 16 | ||||
-rw-r--r-- | parser/html/nsHtml5SpeculativeLoad.h | 17 | ||||
-rw-r--r-- | parser/html/nsHtml5TreeBuilderCppSupplement.h | 10 | ||||
-rw-r--r-- | parser/html/nsHtml5TreeOpExecutor.cpp | 6 | ||||
-rw-r--r-- | parser/html/nsHtml5TreeOpExecutor.h | 3 |
6 files changed, 41 insertions, 13 deletions
diff --git a/parser/html/java/htmlparser/src/nu/validator/htmlparser/impl/AttributeName.java b/parser/html/java/htmlparser/src/nu/validator/htmlparser/impl/AttributeName.java index aaf0b7b911..b08e41baaa 100644 --- a/parser/html/java/htmlparser/src/nu/validator/htmlparser/impl/AttributeName.java +++ b/parser/html/java/htmlparser/src/nu/validator/htmlparser/impl/AttributeName.java @@ -1161,6 +1161,7 @@ public final class AttributeName public static final AttributeName LQUOTE = new AttributeName(ALL_NO_NS, SAME_LOCAL("lquote"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG); public static final AttributeName PANOSE_1 = new AttributeName(ALL_NO_NS, SAME_LOCAL("panose-1"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG); public static final AttributeName NUMOCTAVES = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("numoctaves", "numOctaves"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG); + public static final AttributeName NOMODULE = new AttributeName(ALL_NO_NS, SAME_LOCAL("nomodule"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG | CASE_FOLDED | BOOLEAN); public static final AttributeName ONLOAD = new AttributeName(ALL_NO_NS, SAME_LOCAL("onload"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG); public static final AttributeName ONBOUNCE = new AttributeName(ALL_NO_NS, SAME_LOCAL("onbounce"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG); public static final AttributeName ONCONTROLSELECT = new AttributeName(ALL_NO_NS, SAME_LOCAL("oncontrolselect"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG); @@ -1464,6 +1465,7 @@ public final class AttributeName XLINK_SHOW, COLOR_RENDERING, IDEOGRAPHIC, + NOMODULE, ONMOUSEWHEEL, ONCONTEXTMENU, ONMOUSEMOVE, diff --git a/parser/html/nsHtml5SpeculativeLoad.cpp b/parser/html/nsHtml5SpeculativeLoad.cpp index 7bae0699f4..35c11b739d 100644 --- a/parser/html/nsHtml5SpeculativeLoad.cpp +++ b/parser/html/nsHtml5SpeculativeLoad.cpp @@ -52,17 +52,27 @@ nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor) case eSpeculativeLoadScript: aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode, mCrossOrigin, mIntegrity, false, - mIsAsync, mIsDefer); + mIsAsync, mIsDefer, false); break; case eSpeculativeLoadScriptFromHead: aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode, mCrossOrigin, mIntegrity, true, - mIsAsync, mIsDefer); + mIsAsync, mIsDefer, false); + break; + case eSpeculativeLoadNoModuleScript: + aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode, + mCrossOrigin, mIntegrity, false, + mIsAsync, mIsDefer, true); + break; + case eSpeculativeLoadNoModuleScriptFromHead: + aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode, + mCrossOrigin, mIntegrity, true, + mIsAsync, mIsDefer, true); break; case eSpeculativeLoadStyle: aExecutor->PreloadStyle(mUrl, mCharset, mCrossOrigin, mIntegrity); break; - case eSpeculativeLoadManifest: + case eSpeculativeLoadManifest: aExecutor->ProcessOfflineManifest(mUrl); break; case eSpeculativeLoadSetDocumentCharset: { diff --git a/parser/html/nsHtml5SpeculativeLoad.h b/parser/html/nsHtml5SpeculativeLoad.h index fcc84de4f6..1f4a617416 100644 --- a/parser/html/nsHtml5SpeculativeLoad.h +++ b/parser/html/nsHtml5SpeculativeLoad.h @@ -10,7 +10,8 @@ class nsHtml5TreeOpExecutor; -enum eHtml5SpeculativeLoad { +enum eHtml5SpeculativeLoad +{ #ifdef DEBUG eSpeculativeLoadUninitialized, #endif @@ -23,6 +24,8 @@ enum eHtml5SpeculativeLoad { eSpeculativeLoadPictureSource, eSpeculativeLoadScript, eSpeculativeLoadScriptFromHead, + eSpeculativeLoadNoModuleScript, + eSpeculativeLoadNoModuleScriptFromHead, eSpeculativeLoadStyle, eSpeculativeLoadManifest, eSpeculativeLoadSetDocumentCharset, @@ -130,12 +133,18 @@ class nsHtml5SpeculativeLoad { nsHtml5String aIntegrity, bool aParserInHead, bool aAsync, - bool aDefer) + bool aDefer, + bool aNoModule) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); - mOpCode = aParserInHead ? - eSpeculativeLoadScriptFromHead : eSpeculativeLoadScript; + if (aNoModule) { + mOpCode = aParserInHead ? eSpeculativeLoadNoModuleScriptFromHead + : eSpeculativeLoadNoModuleScript; + } else { + mOpCode = aParserInHead ? eSpeculativeLoadScriptFromHead + : eSpeculativeLoadScript; + } aUrl.ToString(mUrl); aCharset.ToString(mCharset); aType.ToString(mTypeOrCharsetSourceOrDocumentMode); diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h index 634c5c2186..f09cc18539 100644 --- a/parser/html/nsHtml5TreeBuilderCppSupplement.h +++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h @@ -189,15 +189,18 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, aAttributes->contains(nsHtml5AttributeName::ATTR_ASYNC);
bool defer =
aAttributes->contains(nsHtml5AttributeName::ATTR_DEFER); + bool noModule = + aAttributes->contains(nsHtml5AttributeName::ATTR_NOMODULE); mSpeculativeLoadQueue.AppendElement()->InitScript( url, charset, type, crossOrigin, integrity, - mode == nsHtml5TreeBuilder::IN_HEAD,
+ mode == nsHtml5TreeBuilder::IN_HEAD, async,
- defer);
+ defer, + noModule);
mCurrentHtmlScriptIsAsyncOrDefer = async || defer; } } else if (nsHtml5Atoms::link == aName) { @@ -303,7 +306,8 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, integrity, mode == nsHtml5TreeBuilder::IN_HEAD, false /* async */, - false /* defer */); + false /* defer */, + false /* noModule */); } } else if (nsHtml5Atoms::style == aName) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp index 9be7f3b0d6..cd5c689133 100644 --- a/parser/html/nsHtml5TreeOpExecutor.cpp +++ b/parser/html/nsHtml5TreeOpExecutor.cpp @@ -923,14 +923,16 @@ nsHtml5TreeOpExecutor::PreloadScript(const nsAString& aURL, const nsAString& aIntegrity, bool aScriptFromHead, bool aAsync, - bool aDefer) + bool aDefer, + bool aNoModule) { nsCOMPtr<nsIURI> uri = ConvertIfNotPreloadedYet(aURL); if (!uri) { return; } mDocument->ScriptLoader()->PreloadURI(uri, aCharset, aType, aCrossOrigin, - aIntegrity, aScriptFromHead, aAsync, aDefer, + aIntegrity, aScriptFromHead, aAsync, + aDefer, aNoModule, mSpeculationReferrerPolicy); } diff --git a/parser/html/nsHtml5TreeOpExecutor.h b/parser/html/nsHtml5TreeOpExecutor.h index 64a5daa96f..878f359c55 100644 --- a/parser/html/nsHtml5TreeOpExecutor.h +++ b/parser/html/nsHtml5TreeOpExecutor.h @@ -251,7 +251,8 @@ class nsHtml5TreeOpExecutor final : public nsHtml5DocumentBuilder, const nsAString& aIntegrity, bool aScriptFromHead, bool aAsync, - bool aDefer); + bool aDefer, + bool aNoModule); void PreloadStyle(const nsAString& aURL, const nsAString& aCharset, const nsAString& aCrossOrigin, |