diff --git a/parser/html/nsHtml5SpeculativeLoad.cpp b/parser/html/nsHtml5SpeculativeLoad.cpp
index 7335979399..ddbc6e096a 100644
--- a/parser/html/nsHtml5SpeculativeLoad.cpp
+++ b/parser/html/nsHtml5SpeculativeLoad.cpp
@@ -28,16 +28,18 @@ nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
{
switch (mOpCode) {
case eSpeculativeLoadBase:
- aExecutor->SetSpeculationBase(mUrl);
+ aExecutor->SetSpeculationBase(mUrlOrSizes);
break;
case eSpeculativeLoadCSP:
- aExecutor->AddSpeculationCSP(mMetaCSP);
+ aExecutor->AddSpeculationCSP(mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
break;
case eSpeculativeLoadMetaReferrer:
- aExecutor->SetSpeculationReferrerPolicy(mReferrerPolicy);
+ aExecutor->SetSpeculationReferrerPolicy(mReferrerPolicyOrIntegrity);
break;
case eSpeculativeLoadImage:
- aExecutor->PreloadImage(mUrl, mCrossOrigin, mSrcset, mSizes, mReferrerPolicy);
+ aExecutor->PreloadImage(mUrlOrSizes, mCrossOriginOrMedia, mCharsetOrSrcset,
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
+ mReferrerPolicyOrIntegrity);
break;
case eSpeculativeLoadOpenPicture:
aExecutor->PreloadOpenPicture();
@@ -46,56 +48,61 @@ nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
aExecutor->PreloadEndPicture();
break;
case eSpeculativeLoadPictureSource:
- aExecutor->PreloadPictureSource(mSrcset, mSizes, mTypeOrCharsetSourceOrDocumentMode,
- mMedia);
+ aExecutor->PreloadPictureSource(mCharsetOrSrcset, mUrlOrSizes,
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
+ mCrossOriginOrMedia);
break;
case eSpeculativeLoadScript:
- aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode,
- mCrossOrigin, mIntegrity, false,
+ aExecutor->PreloadScript(mUrlOrSizes, mCharsetOrSrcset,
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
+ mCrossOriginOrMedia, mReferrerPolicyOrIntegrity, false,
mIsAsync, mIsDefer, false);
break;
case eSpeculativeLoadScriptFromHead:
- aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode,
- mCrossOrigin, mIntegrity, true,
+ aExecutor->PreloadScript(mUrlOrSizes, mCharsetOrSrcset,
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
+ mCrossOriginOrMedia, mReferrerPolicyOrIntegrity, true,
mIsAsync, mIsDefer, false);
break;
case eSpeculativeLoadNoModuleScript:
- aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode,
- mCrossOrigin, mIntegrity, false,
+ aExecutor->PreloadScript(mUrlOrSizes, mCharsetOrSrcset,
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
+ mCrossOriginOrMedia, mReferrerPolicyOrIntegrity, false,
mIsAsync, mIsDefer, true);
break;
case eSpeculativeLoadNoModuleScriptFromHead:
- aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode,
- mCrossOrigin, mIntegrity, true,
+ aExecutor->PreloadScript(mUrlOrSizes, mCharsetOrSrcset,
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
+ mCrossOriginOrMedia, mReferrerPolicyOrIntegrity, true,
mIsAsync, mIsDefer, true);
break;
case eSpeculativeLoadStyle:
- aExecutor->PreloadStyle(mUrl, mCharset, mCrossOrigin, mReferrerPolicy,
- mIntegrity);
+ aExecutor->PreloadStyle(mUrlOrSizes, mCharsetOrSrcset, mCrossOriginOrMedia, mReferrerPolicyOrIntegrity,
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
break;
case eSpeculativeLoadManifest:
- aExecutor->ProcessOfflineManifest(mUrl);
+ aExecutor->ProcessOfflineManifest(mUrlOrSizes);
break;
case eSpeculativeLoadSetDocumentCharset: {
nsAutoCString narrowName;
- CopyUTF16toUTF8(mCharset, narrowName);
- NS_ASSERTION(mTypeOrCharsetSourceOrDocumentMode.Length() == 1,
+ CopyUTF16toUTF8(mCharsetOrSrcset, narrowName);
+ NS_ASSERTION(mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.Length() == 1,
"Unexpected charset source string");
- int32_t intSource = (int32_t)mTypeOrCharsetSourceOrDocumentMode.First();
+ int32_t intSource = (int32_t)mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.First();
aExecutor->SetDocumentCharsetAndSource(narrowName,
intSource);
}
break;
case eSpeculativeLoadSetDocumentMode: {
- NS_ASSERTION(mTypeOrCharsetSourceOrDocumentMode.Length() == 1,
+ NS_ASSERTION(mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.Length() == 1,
"Unexpected document mode string");
nsHtml5DocumentMode mode =
- (nsHtml5DocumentMode)mTypeOrCharsetSourceOrDocumentMode.First();
+ (nsHtml5DocumentMode)mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.First();
aExecutor->SetDocumentMode(mode);
}
break;
case eSpeculativeLoadPreconnect:
- aExecutor->Preconnect(mUrl, mCrossOrigin);
+ aExecutor->Preconnect(mUrlOrSizes, mCrossOriginOrMedia);
break;
default:
NS_NOTREACHED("Bogus speculative load.");
diff --git a/parser/html/nsHtml5SpeculativeLoad.h b/parser/html/nsHtml5SpeculativeLoad.h
index 0675c9ea56..27d5263960 100644
--- a/parser/html/nsHtml5SpeculativeLoad.h
+++ b/parser/html/nsHtml5SpeculativeLoad.h
@@ -43,7 +43,7 @@ class nsHtml5SpeculativeLoad {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadBase;
- aUrl.ToString(mUrl);
+ aUrl.ToString(mUrlOrSizes);
}
inline void InitMetaCSP(nsHtml5String aCSP)
@@ -53,7 +53,7 @@ class nsHtml5SpeculativeLoad {
mOpCode = eSpeculativeLoadCSP;
nsString csp; // Not Auto, because using it to hold nsStringBuffer*
aCSP.ToString(csp);
- mMetaCSP.Assign(
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.Assign(
nsContentUtils::TrimWhitespace(csp));
}
@@ -65,7 +65,7 @@ class nsHtml5SpeculativeLoad {
nsString
referrerPolicy; // Not Auto, because using it to hold nsStringBuffer*
aReferrerPolicy.ToString(referrerPolicy);
- mReferrerPolicy.Assign(
+ mReferrerPolicyOrIntegrity.Assign(
nsContentUtils::TrimWhitespace(
referrerPolicy));
}
@@ -79,16 +79,16 @@ class nsHtml5SpeculativeLoad {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadImage;
- aUrl.ToString(mUrl);
- aCrossOrigin.ToString(mCrossOrigin);
+ aUrl.ToString(mUrlOrSizes);
+ aCrossOrigin.ToString(mCrossOriginOrMedia);
nsString
referrerPolicy; // Not Auto, because using it to hold nsStringBuffer*
aReferrerPolicy.ToString(referrerPolicy);
- mReferrerPolicy.Assign(
+ mReferrerPolicyOrIntegrity.Assign(
nsContentUtils::TrimWhitespace(
referrerPolicy));
- aSrcset.ToString(mSrcset);
- aSizes.ToString(mSizes);
+ aSrcset.ToString(mCharsetOrSrcset);
+ aSizes.ToString(mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
}
// elements have multiple nodes followed by an ,
@@ -120,10 +120,10 @@ class nsHtml5SpeculativeLoad {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadPictureSource;
- aSrcset.ToString(mSrcset);
- aSizes.ToString(mSizes);
- aType.ToString(mTypeOrCharsetSourceOrDocumentMode);
- aMedia.ToString(mMedia);
+ aSrcset.ToString(mCharsetOrSrcset);
+ aSizes.ToString(mUrlOrSizes);
+ aType.ToString(mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
+ aMedia.ToString(mCrossOriginOrMedia);
}
inline void InitScript(nsHtml5String aUrl,
@@ -145,11 +145,11 @@ class nsHtml5SpeculativeLoad {
mOpCode = aParserInHead ? eSpeculativeLoadScriptFromHead
: eSpeculativeLoadScript;
}
- aUrl.ToString(mUrl);
- aCharset.ToString(mCharset);
- aType.ToString(mTypeOrCharsetSourceOrDocumentMode);
- aCrossOrigin.ToString(mCrossOrigin);
- aIntegrity.ToString(mIntegrity);
+ aUrl.ToString(mUrlOrSizes);
+ aCharset.ToString(mCharsetOrSrcset);
+ aType.ToString(mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
+ aCrossOrigin.ToString(mCrossOriginOrMedia);
+ aIntegrity.ToString(mReferrerPolicyOrIntegrity);
mIsAsync = aAsync;
mIsDefer = aDefer;
}
@@ -163,11 +163,11 @@ class nsHtml5SpeculativeLoad {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadStyle;
- aUrl.ToString(mUrl);
- aCharset.ToString(mCharset);
- aCrossOrigin.ToString(mCrossOrigin);
- aReferrerPolicy.ToString(mReferrerPolicy);
- aIntegrity.ToString(mIntegrity);
+ aUrl.ToString(mUrlOrSizes);
+ aCharset.ToString(mCharsetOrSrcset);
+ aCrossOrigin.ToString(mCrossOriginOrMedia);
+ aReferrerPolicy.ToString(mReferrerPolicyOrIntegrity);
+ aIntegrity.ToString(mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
}
/**
@@ -186,7 +186,7 @@ class nsHtml5SpeculativeLoad {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadManifest;
- aUrl.ToString(mUrl);
+ aUrl.ToString(mUrlOrSizes);
}
/**
@@ -205,8 +205,8 @@ class nsHtml5SpeculativeLoad {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadSetDocumentCharset;
- CopyUTF8toUTF16(aCharset, mCharset);
- mTypeOrCharsetSourceOrDocumentMode.Assign((char16_t)aCharsetSource);
+ CopyUTF8toUTF16(aCharset, mCharsetOrSrcset);
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.Assign((char16_t)aCharsetSource);
}
/**
@@ -220,7 +220,7 @@ class nsHtml5SpeculativeLoad {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadSetDocumentMode;
- mTypeOrCharsetSourceOrDocumentMode.Assign((char16_t)aMode);
+ mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity.Assign((char16_t)aMode);
}
inline void InitPreconnect(nsHtml5String aUrl, nsHtml5String aCrossOrigin)
@@ -228,8 +228,8 @@ class nsHtml5SpeculativeLoad {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadPreconnect;
- aUrl.ToString(mUrl);
- aCrossOrigin.ToString(mCrossOrigin);
+ aUrl.ToString(mUrlOrSizes);
+ aCrossOrigin.ToString(mCrossOriginOrMedia);
}
void Perform(nsHtml5TreeOpExecutor* aExecutor);
@@ -243,55 +243,50 @@ class nsHtml5SpeculativeLoad {
bool mIsAsync;
bool mIsDefer;
- nsString mUrl;
- nsString mReferrerPolicy;
- nsString mMetaCSP;
+ /* If mOpCode is eSpeculativeLoadPictureSource, this is the value of the
+ * "sizes" attribute. If the attribute is not set, this will be a void
+ * string. Otherwise it empty or the value of the url.
+ */
+ nsString mUrlOrSizes;
+ /**
+ * If mOpCode is eSpeculativeLoadScript[FromHead], this is the value of the
+ * "integrity" attribute. If the attribute is not set, this will be a void
+ * string. Otherwise it is empty or the value of the referrer policy.
+ */
+ nsString mReferrerPolicyOrIntegrity;
/**
* If mOpCode is eSpeculativeLoadStyle or eSpeculativeLoadScript[FromHead]
* then this is the value of the "charset" attribute. For
* eSpeculativeLoadSetDocumentCharset it is the charset that the
- * document's charset is being set to. Otherwise it's empty.
+ * document's charset is being set to. If mOpCode is eSpeculativeLoadImage
+ * or eSpeculativeLoadPictureSource, this is the value of the "srcset" attribute.
+ * If the attribute is not set, this will be a void string. Otherwise it's empty.
*/
- nsString mCharset;
+ nsString mCharsetOrSrcset;
/**
* If mOpCode is eSpeculativeLoadSetDocumentCharset, this is a
* one-character string whose single character's code point is to be
* interpreted as a charset source integer. If mOpCode is
* eSpeculativeLoadSetDocumentMode, this is a one-character string whose
* single character's code point is to be interpreted as an
- * nsHtml5DocumentMode. Otherwise, it is empty or the value of the type
- * attribute.
+ * nsHtml5DocumentMode. If mOpCode is eSpeculativeLoadCSP, this is a meta
+ * element's CSP value. If mOpCode is eSpeculativeLoadImage, this is the
+ * value of the "sizes" attribute. If the attribute is not set, this will
+ * be a void string. If mOpCode is eSpeculativeLoadStyle, this
+ * is the value of the "integrity" attribute. If the attribute is not set,
+ * this will be a void string. Otherwise it is empty or the value of the
+ * referrer policy. Otherwise, it is empty or the value of the type attribute.
*/
- nsString mTypeOrCharsetSourceOrDocumentMode;
+ nsString mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity;
/**
* If mOpCode is eSpeculativeLoadImage or eSpeculativeLoadScript[FromHead]
* or eSpeculativeLoadPreconnect this is the value of the "crossorigin"
* attribute. If the attribute is not set, this will be a void string.
+ * If mOpCode is eSpeculativeLoadPictureSource, this is the value of the
+ * "media" attribute. If the attribute is not set, this will be a void string.
*/
- nsString mCrossOrigin;
- /**
- * If mOpCode is eSpeculativeLoadImage or eSpeculativeLoadPictureSource,
- * this is the value of "srcset" attribute. If the attribute is not set,
- * this will be a void string.
- */
- nsString mSrcset;
- /**
- * If mOpCode is eSpeculativeLoadPictureSource, this is the value of "sizes"
- * attribute. If the attribute is not set, this will be a void string.
- */
- nsString mSizes;
- /**
- * If mOpCode is eSpeculativeLoadPictureSource, this is the value of "media"
- * attribute. If the attribute is not set, this will be a void string.
- */
- nsString mMedia;
- /**
- * If mOpCode is eSpeculativeLoadScript[FromHead], this is the value of the
- * "integrity" attribute. If the attribute is not set, this will be a void
- * string.
- */
- nsString mIntegrity;
+ nsString mCrossOriginOrMedia;
};
#endif // nsHtml5SpeculativeLoad_h