Files
palemoon27/parser/html/nsHtml5SpeculativeLoad.cpp
T
roytam1 3dc3bde9f2 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 524674, nsIEventListenerService: tracking of dynamically added and removed event listeners, r=masayuki (a1779bcaf)
- Bug 418986 - Resist fingerprinting by preventing exposure of screen and system info. r=mrbkap, r=heycam (97710708a)
- bug 1171785 create nsContentUtils::RunInStableState helper r=bholley (c71678a0e)
- bug 1172377 change RunInStableState API to receive ownership of nsIRunnable r=roc (3d5c72cac)
- bug 1171785 use nsContentUtils::RunInStableState() r=bholley (1c0acca87)
- Bug 1172784 (part 1) - Remove unused argument from UnmarkGrayJSListenersInCCGenerationDocuments(). r=mccr8. (a3a26ec9f)
- Bug 1172784 (part 2) - Remove PL_DHashTableEnumerate use from nsContentUtils. r=mccr8. (792b83f8e)
- Bug 1171832 - Remove PL_DHashTableEnumerator use from nsDocument. r=smaug. (eb265bb3a)
- Bug 819090 - Convert nsRefMapEntry::mRefContentList to nsTArray. r=froydnj (509060d38)
- Bug 819090 - Convert BroadcasterMapEntry::mListeners to nsTArray. r=froydnj (6b1bd7232)
- Bug 819090 - Convert nsDocument::mIdContentList to nsTArray. r=froydnj (41ebb3a64)
- Bug 819090 - Remove nsVoidArray.{cpp,h}. r=froydnj (6038b4fc7)
- Bug 1199143 - Inline heavyweight functions. r=shu (798a24e44)
- bug 1150136 - rel=preconnect from html parser r=hsivonen (1a078efcb)
- Bug 1135812 - Make picture element react to viewport changes. r=dbaron,johns (4b405d69c)
- add missing testcase (cb6c04747)
2021-01-21 14:16:50 +08:00

78 lines
2.5 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsHtml5SpeculativeLoad.h"
#include "nsHtml5TreeOpExecutor.h"
nsHtml5SpeculativeLoad::nsHtml5SpeculativeLoad()
#ifdef DEBUG
: mOpCode(eSpeculativeLoadUninitialized)
#endif
{
MOZ_COUNT_CTOR(nsHtml5SpeculativeLoad);
}
nsHtml5SpeculativeLoad::~nsHtml5SpeculativeLoad()
{
MOZ_COUNT_DTOR(nsHtml5SpeculativeLoad);
NS_ASSERTION(mOpCode != eSpeculativeLoadUninitialized,
"Uninitialized speculative load.");
}
void
nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
{
switch (mOpCode) {
case eSpeculativeLoadBase:
aExecutor->SetSpeculationBase(mUrl);
break;
case eSpeculativeLoadMetaReferrer:
aExecutor->SetSpeculationReferrerPolicy(mMetaReferrerPolicy);
break;
case eSpeculativeLoadImage:
aExecutor->PreloadImage(mUrl, mCrossOrigin, mSrcset, mSizes);
break;
case eSpeculativeLoadOpenPicture:
aExecutor->PreloadOpenPicture();
break;
case eSpeculativeLoadEndPicture:
aExecutor->PreloadEndPicture();
break;
case eSpeculativeLoadPictureSource:
aExecutor->PreloadPictureSource(mSrcset, mSizes, mTypeOrCharsetSource,
mMedia);
break;
case eSpeculativeLoadScript:
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
mCrossOrigin, false);
break;
case eSpeculativeLoadScriptFromHead:
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
mCrossOrigin, true);
break;
case eSpeculativeLoadStyle:
aExecutor->PreloadStyle(mUrl, mCharset, mCrossOrigin);
break;
case eSpeculativeLoadManifest:
aExecutor->ProcessOfflineManifest(mUrl);
break;
case eSpeculativeLoadSetDocumentCharset: {
nsAutoCString narrowName;
CopyUTF16toUTF8(mCharset, narrowName);
NS_ASSERTION(mTypeOrCharsetSource.Length() == 1,
"Unexpected charset source string");
int32_t intSource = (int32_t)mTypeOrCharsetSource.First();
aExecutor->SetDocumentCharsetAndSource(narrowName,
intSource);
}
break;
case eSpeculativeLoadPreconnect:
aExecutor->Preconnect(mUrl);
break;
default:
NS_NOTREACHED("Bogus speculative load.");
break;
}
}