parser/html/nsHtml5SpeculativeLoad.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/parser/html/nsHtml5SpeculativeLoad.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "nsHtml5SpeculativeLoad.h"
     1.9 +#include "nsHtml5TreeOpExecutor.h"
    1.10 +
    1.11 +nsHtml5SpeculativeLoad::nsHtml5SpeculativeLoad()
    1.12 +#ifdef DEBUG
    1.13 + : mOpCode(eSpeculativeLoadUninitialized)
    1.14 +#endif
    1.15 +{
    1.16 +  MOZ_COUNT_CTOR(nsHtml5SpeculativeLoad);
    1.17 +}
    1.18 +
    1.19 +nsHtml5SpeculativeLoad::~nsHtml5SpeculativeLoad()
    1.20 +{
    1.21 +  MOZ_COUNT_DTOR(nsHtml5SpeculativeLoad);
    1.22 +  NS_ASSERTION(mOpCode != eSpeculativeLoadUninitialized,
    1.23 +               "Uninitialized speculative load.");
    1.24 +}
    1.25 +
    1.26 +void
    1.27 +nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
    1.28 +{
    1.29 +  switch (mOpCode) {
    1.30 +    case eSpeculativeLoadBase:
    1.31 +      aExecutor->SetSpeculationBase(mUrl);
    1.32 +      break;
    1.33 +    case eSpeculativeLoadImage:
    1.34 +      aExecutor->PreloadImage(mUrl, mCrossOrigin);
    1.35 +      break;
    1.36 +    case eSpeculativeLoadScript:
    1.37 +      aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
    1.38 +                               mCrossOrigin, false);
    1.39 +      break;
    1.40 +    case eSpeculativeLoadScriptFromHead:
    1.41 +      aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
    1.42 +                               mCrossOrigin, true);
    1.43 +      break;
    1.44 +    case eSpeculativeLoadStyle:
    1.45 +      aExecutor->PreloadStyle(mUrl, mCharset, mCrossOrigin);
    1.46 +      break;
    1.47 +    case eSpeculativeLoadManifest:  
    1.48 +      aExecutor->ProcessOfflineManifest(mUrl);
    1.49 +      break;
    1.50 +    case eSpeculativeLoadSetDocumentCharset: {
    1.51 +        nsAutoCString narrowName;
    1.52 +        CopyUTF16toUTF8(mCharset, narrowName);
    1.53 +        NS_ASSERTION(mTypeOrCharsetSource.Length() == 1,
    1.54 +            "Unexpected charset source string");
    1.55 +        int32_t intSource = (int32_t)mTypeOrCharsetSource.First();
    1.56 +        aExecutor->SetDocumentCharsetAndSource(narrowName,
    1.57 +                                               intSource);
    1.58 +      }
    1.59 +      break;
    1.60 +    default:
    1.61 +      NS_NOTREACHED("Bogus speculative load.");
    1.62 +      break;
    1.63 +  }
    1.64 +}

mercurial