parser/html/nsHtml5SpeculativeLoad.cpp

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include "nsHtml5SpeculativeLoad.h"
michael@0 6 #include "nsHtml5TreeOpExecutor.h"
michael@0 7
michael@0 8 nsHtml5SpeculativeLoad::nsHtml5SpeculativeLoad()
michael@0 9 #ifdef DEBUG
michael@0 10 : mOpCode(eSpeculativeLoadUninitialized)
michael@0 11 #endif
michael@0 12 {
michael@0 13 MOZ_COUNT_CTOR(nsHtml5SpeculativeLoad);
michael@0 14 }
michael@0 15
michael@0 16 nsHtml5SpeculativeLoad::~nsHtml5SpeculativeLoad()
michael@0 17 {
michael@0 18 MOZ_COUNT_DTOR(nsHtml5SpeculativeLoad);
michael@0 19 NS_ASSERTION(mOpCode != eSpeculativeLoadUninitialized,
michael@0 20 "Uninitialized speculative load.");
michael@0 21 }
michael@0 22
michael@0 23 void
michael@0 24 nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
michael@0 25 {
michael@0 26 switch (mOpCode) {
michael@0 27 case eSpeculativeLoadBase:
michael@0 28 aExecutor->SetSpeculationBase(mUrl);
michael@0 29 break;
michael@0 30 case eSpeculativeLoadImage:
michael@0 31 aExecutor->PreloadImage(mUrl, mCrossOrigin);
michael@0 32 break;
michael@0 33 case eSpeculativeLoadScript:
michael@0 34 aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
michael@0 35 mCrossOrigin, false);
michael@0 36 break;
michael@0 37 case eSpeculativeLoadScriptFromHead:
michael@0 38 aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
michael@0 39 mCrossOrigin, true);
michael@0 40 break;
michael@0 41 case eSpeculativeLoadStyle:
michael@0 42 aExecutor->PreloadStyle(mUrl, mCharset, mCrossOrigin);
michael@0 43 break;
michael@0 44 case eSpeculativeLoadManifest:
michael@0 45 aExecutor->ProcessOfflineManifest(mUrl);
michael@0 46 break;
michael@0 47 case eSpeculativeLoadSetDocumentCharset: {
michael@0 48 nsAutoCString narrowName;
michael@0 49 CopyUTF16toUTF8(mCharset, narrowName);
michael@0 50 NS_ASSERTION(mTypeOrCharsetSource.Length() == 1,
michael@0 51 "Unexpected charset source string");
michael@0 52 int32_t intSource = (int32_t)mTypeOrCharsetSource.First();
michael@0 53 aExecutor->SetDocumentCharsetAndSource(narrowName,
michael@0 54 intSource);
michael@0 55 }
michael@0 56 break;
michael@0 57 default:
michael@0 58 NS_NOTREACHED("Bogus speculative load.");
michael@0 59 break;
michael@0 60 }
michael@0 61 }

mercurial