2012-05-29 19:52:43 +04:00
|
|
|
/* 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/. */
|
2009-10-12 17:08:04 +04:00
|
|
|
|
2010-02-26 12:18:38 +03:00
|
|
|
#include "nsHtml5SpeculativeLoad.h"
|
2010-02-02 10:43:18 +03:00
|
|
|
#include "nsHtml5TreeOpExecutor.h"
|
2009-10-12 17:08:04 +04:00
|
|
|
|
2010-02-26 12:18:38 +03:00
|
|
|
nsHtml5SpeculativeLoad::nsHtml5SpeculativeLoad()
|
|
|
|
#ifdef DEBUG
|
|
|
|
: mOpCode(eSpeculativeLoadUninitialized)
|
|
|
|
#endif
|
2009-10-12 17:08:04 +04:00
|
|
|
{
|
2010-02-26 12:18:38 +03:00
|
|
|
MOZ_COUNT_CTOR(nsHtml5SpeculativeLoad);
|
|
|
|
}
|
2009-10-12 17:08:04 +04:00
|
|
|
|
2010-02-26 12:18:38 +03:00
|
|
|
nsHtml5SpeculativeLoad::~nsHtml5SpeculativeLoad()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsHtml5SpeculativeLoad);
|
|
|
|
NS_ASSERTION(mOpCode != eSpeculativeLoadUninitialized,
|
|
|
|
"Uninitialized speculative load.");
|
|
|
|
}
|
2010-02-24 03:36:30 +03:00
|
|
|
|
2010-02-26 12:18:38 +03:00
|
|
|
void
|
|
|
|
nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
|
|
|
|
{
|
|
|
|
switch (mOpCode) {
|
2010-07-26 15:18:43 +04:00
|
|
|
case eSpeculativeLoadBase:
|
2011-08-02 21:45:38 +04:00
|
|
|
aExecutor->SetSpeculationBase(mUrl);
|
2010-07-26 15:18:43 +04:00
|
|
|
break;
|
2015-11-15 06:28:51 +03:00
|
|
|
case eSpeculativeLoadCSP:
|
|
|
|
aExecutor->AddSpeculationCSP(mMetaCSP);
|
|
|
|
break;
|
2014-11-18 16:46:29 +03:00
|
|
|
case eSpeculativeLoadMetaReferrer:
|
2015-06-06 01:25:24 +03:00
|
|
|
aExecutor->SetSpeculationReferrerPolicy(mReferrerPolicy);
|
2014-11-18 16:46:29 +03:00
|
|
|
break;
|
2010-02-26 12:18:38 +03:00
|
|
|
case eSpeculativeLoadImage:
|
2015-06-06 01:25:24 +03:00
|
|
|
aExecutor->PreloadImage(mUrl, mCrossOrigin, mSrcset, mSizes, mReferrerPolicy);
|
2014-12-11 02:54:00 +03:00
|
|
|
break;
|
|
|
|
case eSpeculativeLoadOpenPicture:
|
|
|
|
aExecutor->PreloadOpenPicture();
|
|
|
|
break;
|
|
|
|
case eSpeculativeLoadEndPicture:
|
|
|
|
aExecutor->PreloadEndPicture();
|
|
|
|
break;
|
|
|
|
case eSpeculativeLoadPictureSource:
|
2016-08-25 12:20:58 +03:00
|
|
|
aExecutor->PreloadPictureSource(mSrcset, mSizes, mTypeOrCharsetSourceOrDocumentMode,
|
2014-12-11 02:54:00 +03:00
|
|
|
mMedia);
|
2010-02-26 12:18:38 +03:00
|
|
|
break;
|
|
|
|
case eSpeculativeLoadScript:
|
2016-08-25 12:20:58 +03:00
|
|
|
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode,
|
2015-08-13 06:19:11 +03:00
|
|
|
mCrossOrigin, mIntegrity, false);
|
2012-12-05 03:06:29 +04:00
|
|
|
break;
|
|
|
|
case eSpeculativeLoadScriptFromHead:
|
2016-08-25 12:20:58 +03:00
|
|
|
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSourceOrDocumentMode,
|
2015-08-13 06:19:11 +03:00
|
|
|
mCrossOrigin, mIntegrity, true);
|
2010-02-26 12:18:38 +03:00
|
|
|
break;
|
|
|
|
case eSpeculativeLoadStyle:
|
2015-08-13 06:19:11 +03:00
|
|
|
aExecutor->PreloadStyle(mUrl, mCharset, mCrossOrigin, mIntegrity);
|
2010-02-26 12:18:38 +03:00
|
|
|
break;
|
|
|
|
case eSpeculativeLoadManifest:
|
2011-08-02 21:45:38 +04:00
|
|
|
aExecutor->ProcessOfflineManifest(mUrl);
|
|
|
|
break;
|
|
|
|
case eSpeculativeLoadSetDocumentCharset: {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString narrowName;
|
2012-03-10 20:13:52 +04:00
|
|
|
CopyUTF16toUTF8(mCharset, narrowName);
|
2016-08-25 12:20:58 +03:00
|
|
|
NS_ASSERTION(mTypeOrCharsetSourceOrDocumentMode.Length() == 1,
|
2011-08-02 21:45:38 +04:00
|
|
|
"Unexpected charset source string");
|
2016-08-25 12:20:58 +03:00
|
|
|
int32_t intSource = (int32_t)mTypeOrCharsetSourceOrDocumentMode.First();
|
2011-08-02 21:45:38 +04:00
|
|
|
aExecutor->SetDocumentCharsetAndSource(narrowName,
|
|
|
|
intSource);
|
|
|
|
}
|
2010-02-26 12:18:38 +03:00
|
|
|
break;
|
2016-08-25 12:20:58 +03:00
|
|
|
case eSpeculativeLoadSetDocumentMode: {
|
|
|
|
NS_ASSERTION(mTypeOrCharsetSourceOrDocumentMode.Length() == 1,
|
|
|
|
"Unexpected document mode string");
|
|
|
|
nsHtml5DocumentMode mode =
|
|
|
|
(nsHtml5DocumentMode)mTypeOrCharsetSourceOrDocumentMode.First();
|
|
|
|
aExecutor->SetDocumentMode(mode);
|
|
|
|
}
|
|
|
|
break;
|
2015-05-06 03:55:18 +03:00
|
|
|
case eSpeculativeLoadPreconnect:
|
2015-06-20 00:11:42 +03:00
|
|
|
aExecutor->Preconnect(mUrl, mCrossOrigin);
|
2015-05-06 03:55:18 +03:00
|
|
|
break;
|
2010-02-26 12:18:38 +03:00
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Bogus speculative load.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|