mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1293252
- Transfer document quirkiness via the speculative load queue. r=wchen
MozReview-Commit-ID: 4lTbxSSrCf4 --HG-- extra : rebase_source : ccd67d8326f5cb9fb0372d5a42b15481aa886d66
This commit is contained in:
parent
e3a3466f75
commit
48c797f422
@ -43,15 +43,15 @@ nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
|
||||
aExecutor->PreloadEndPicture();
|
||||
break;
|
||||
case eSpeculativeLoadPictureSource:
|
||||
aExecutor->PreloadPictureSource(mSrcset, mSizes, mTypeOrCharsetSource,
|
||||
aExecutor->PreloadPictureSource(mSrcset, mSizes, mTypeOrCharsetSourceOrDocumentMode,
|
||||
mMedia);
|
||||
break;
|
||||
case eSpeculativeLoadScript:
|
||||
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
|
||||
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode,
|
||||
mCrossOrigin, mIntegrity, false);
|
||||
break;
|
||||
case eSpeculativeLoadScriptFromHead:
|
||||
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
|
||||
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode,
|
||||
mCrossOrigin, mIntegrity, true);
|
||||
break;
|
||||
case eSpeculativeLoadStyle:
|
||||
@ -63,13 +63,21 @@ nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
|
||||
case eSpeculativeLoadSetDocumentCharset: {
|
||||
nsAutoCString narrowName;
|
||||
CopyUTF16toUTF8(mCharset, narrowName);
|
||||
NS_ASSERTION(mTypeOrCharsetSource.Length() == 1,
|
||||
NS_ASSERTION(mTypeOrCharsetSourceOrDocumentMode.Length() == 1,
|
||||
"Unexpected charset source string");
|
||||
int32_t intSource = (int32_t)mTypeOrCharsetSource.First();
|
||||
int32_t intSource = (int32_t)mTypeOrCharsetSourceOrDocumentMode.First();
|
||||
aExecutor->SetDocumentCharsetAndSource(narrowName,
|
||||
intSource);
|
||||
}
|
||||
break;
|
||||
case eSpeculativeLoadSetDocumentMode: {
|
||||
NS_ASSERTION(mTypeOrCharsetSourceOrDocumentMode.Length() == 1,
|
||||
"Unexpected document mode string");
|
||||
nsHtml5DocumentMode mode =
|
||||
(nsHtml5DocumentMode)mTypeOrCharsetSourceOrDocumentMode.First();
|
||||
aExecutor->SetDocumentMode(mode);
|
||||
}
|
||||
break;
|
||||
case eSpeculativeLoadPreconnect:
|
||||
aExecutor->Preconnect(mUrl, mCrossOrigin);
|
||||
break;
|
||||
|
@ -26,6 +26,7 @@ enum eHtml5SpeculativeLoad {
|
||||
eSpeculativeLoadStyle,
|
||||
eSpeculativeLoadManifest,
|
||||
eSpeculativeLoadSetDocumentCharset,
|
||||
eSpeculativeLoadSetDocumentMode,
|
||||
eSpeculativeLoadPreconnect
|
||||
};
|
||||
|
||||
@ -106,7 +107,7 @@ class nsHtml5SpeculativeLoad {
|
||||
mOpCode = eSpeculativeLoadPictureSource;
|
||||
mSrcset.Assign(aSrcset);
|
||||
mSizes.Assign(aSizes);
|
||||
mTypeOrCharsetSource.Assign(aType);
|
||||
mTypeOrCharsetSourceOrDocumentMode.Assign(aType);
|
||||
mMedia.Assign(aMedia);
|
||||
}
|
||||
|
||||
@ -123,7 +124,7 @@ class nsHtml5SpeculativeLoad {
|
||||
eSpeculativeLoadScriptFromHead : eSpeculativeLoadScript;
|
||||
mUrl.Assign(aUrl);
|
||||
mCharset.Assign(aCharset);
|
||||
mTypeOrCharsetSource.Assign(aType);
|
||||
mTypeOrCharsetSourceOrDocumentMode.Assign(aType);
|
||||
mCrossOrigin.Assign(aCrossOrigin);
|
||||
mIntegrity.Assign(aIntegrity);
|
||||
}
|
||||
@ -177,7 +178,21 @@ class nsHtml5SpeculativeLoad {
|
||||
"Trying to reinitialize a speculative load!");
|
||||
mOpCode = eSpeculativeLoadSetDocumentCharset;
|
||||
CopyUTF8toUTF16(aCharset, mCharset);
|
||||
mTypeOrCharsetSource.Assign((char16_t)aCharsetSource);
|
||||
mTypeOrCharsetSourceOrDocumentMode.Assign((char16_t)aCharsetSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Speculative document mode setting isn't really speculative. Once it
|
||||
* happens, we are committed to it. However, this information needs to
|
||||
* travel in the speculation queue in order to have this information
|
||||
* available before parsing the speculatively loaded style sheets.
|
||||
*/
|
||||
inline void InitSetDocumentMode(nsHtml5DocumentMode aMode)
|
||||
{
|
||||
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
|
||||
"Trying to reinitialize a speculative load!");
|
||||
mOpCode = eSpeculativeLoadSetDocumentMode;
|
||||
mTypeOrCharsetSourceOrDocumentMode.Assign((char16_t)aMode);
|
||||
}
|
||||
|
||||
inline void InitPreconnect(const nsAString& aUrl,
|
||||
@ -208,10 +223,13 @@ class nsHtml5SpeculativeLoad {
|
||||
/**
|
||||
* 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. Otherwise, it is empty or
|
||||
* the value of the type attribute.
|
||||
* 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.
|
||||
*/
|
||||
nsString mTypeOrCharsetSource;
|
||||
nsString mTypeOrCharsetSourceOrDocumentMode;
|
||||
/**
|
||||
* If mOpCode is eSpeculativeLoadImage or eSpeculativeLoadScript[FromHead]
|
||||
* or eSpeculativeLoadPreconnect this is the value of the "crossorigin"
|
||||
|
@ -1223,6 +1223,10 @@ nsHtml5TreeBuilder::documentMode(nsHtml5DocumentMode m)
|
||||
mBuilder->SetDocumentMode(m);
|
||||
return;
|
||||
}
|
||||
if (mSpeculativeLoadStage) {
|
||||
mSpeculativeLoadQueue.AppendElement()->InitSetDocumentMode(m);
|
||||
return;
|
||||
}
|
||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||
treeOp->Init(m);
|
||||
|
Loading…
Reference in New Issue
Block a user