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