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.

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

mercurial