2012-05-29 15:52:43 +00: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 13:08:04 +00:00
|
|
|
|
2010-02-26 09:18:38 +00:00
|
|
|
#include "nsHtml5SpeculativeLoad.h"
|
2010-02-02 07:43:18 +00:00
|
|
|
#include "nsHtml5TreeOpExecutor.h"
|
2009-10-12 13:08:04 +00:00
|
|
|
|
2010-02-26 09:18:38 +00:00
|
|
|
nsHtml5SpeculativeLoad::nsHtml5SpeculativeLoad()
|
|
|
|
#ifdef DEBUG
|
|
|
|
: mOpCode(eSpeculativeLoadUninitialized)
|
|
|
|
#endif
|
2009-10-12 13:08:04 +00:00
|
|
|
{
|
2010-02-26 09:18:38 +00:00
|
|
|
MOZ_COUNT_CTOR(nsHtml5SpeculativeLoad);
|
|
|
|
}
|
2009-10-12 13:08:04 +00:00
|
|
|
|
2010-02-26 09:18:38 +00:00
|
|
|
nsHtml5SpeculativeLoad::~nsHtml5SpeculativeLoad()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsHtml5SpeculativeLoad);
|
|
|
|
NS_ASSERTION(mOpCode != eSpeculativeLoadUninitialized,
|
|
|
|
"Uninitialized speculative load.");
|
|
|
|
}
|
2010-02-24 00:36:30 +00:00
|
|
|
|
2010-02-26 09:18:38 +00:00
|
|
|
void
|
|
|
|
nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
|
|
|
|
{
|
|
|
|
switch (mOpCode) {
|
2010-07-26 11:18:43 +00:00
|
|
|
case eSpeculativeLoadBase:
|
2011-08-02 17:45:38 +00:00
|
|
|
aExecutor->SetSpeculationBase(mUrl);
|
2010-07-26 11:18:43 +00:00
|
|
|
break;
|
2014-11-18 13:46:29 +00:00
|
|
|
case eSpeculativeLoadMetaReferrer:
|
|
|
|
aExecutor->SetSpeculationReferrerPolicy(mMetaReferrerPolicy);
|
|
|
|
break;
|
2010-02-26 09:18:38 +00:00
|
|
|
case eSpeculativeLoadImage:
|
2012-03-10 16:13:52 +00:00
|
|
|
aExecutor->PreloadImage(mUrl, mCrossOrigin);
|
2010-02-26 09:18:38 +00:00
|
|
|
break;
|
|
|
|
case eSpeculativeLoadScript:
|
2012-03-10 16:13:52 +00:00
|
|
|
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
|
2012-12-04 23:06:29 +00:00
|
|
|
mCrossOrigin, false);
|
|
|
|
break;
|
|
|
|
case eSpeculativeLoadScriptFromHead:
|
|
|
|
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
|
|
|
|
mCrossOrigin, true);
|
2010-02-26 09:18:38 +00:00
|
|
|
break;
|
|
|
|
case eSpeculativeLoadStyle:
|
2012-08-28 17:10:08 +00:00
|
|
|
aExecutor->PreloadStyle(mUrl, mCharset, mCrossOrigin);
|
2010-02-26 09:18:38 +00:00
|
|
|
break;
|
|
|
|
case eSpeculativeLoadManifest:
|
2011-08-02 17:45:38 +00:00
|
|
|
aExecutor->ProcessOfflineManifest(mUrl);
|
|
|
|
break;
|
|
|
|
case eSpeculativeLoadSetDocumentCharset: {
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString narrowName;
|
2012-03-10 16:13:52 +00:00
|
|
|
CopyUTF16toUTF8(mCharset, narrowName);
|
2011-08-02 17:45:38 +00:00
|
|
|
NS_ASSERTION(mTypeOrCharsetSource.Length() == 1,
|
|
|
|
"Unexpected charset source string");
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t intSource = (int32_t)mTypeOrCharsetSource.First();
|
2011-08-02 17:45:38 +00:00
|
|
|
aExecutor->SetDocumentCharsetAndSource(narrowName,
|
|
|
|
intSource);
|
|
|
|
}
|
2010-02-26 09:18:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Bogus speculative load.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|