/* 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/. */ #ifndef nsHtml5SpeculativeLoad_h #define nsHtml5SpeculativeLoad_h #include "nsString.h" class nsHtml5TreeOpExecutor; enum eHtml5SpeculativeLoad { #ifdef DEBUG eSpeculativeLoadUninitialized, #endif eSpeculativeLoadBase, eSpeculativeLoadImage, eSpeculativeLoadScript, eSpeculativeLoadScriptFromHead, eSpeculativeLoadStyle, eSpeculativeLoadManifest, eSpeculativeLoadSetDocumentCharset }; class nsHtml5SpeculativeLoad { public: nsHtml5SpeculativeLoad(); ~nsHtml5SpeculativeLoad(); inline void InitBase(const nsAString& aUrl) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadBase; mUrl.Assign(aUrl); } inline void InitImage(const nsAString& aUrl, const nsAString& aCrossOrigin) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadImage; mUrl.Assign(aUrl); mCrossOrigin.Assign(aCrossOrigin); } inline void InitScript(const nsAString& aUrl, const nsAString& aCharset, const nsAString& aType, const nsAString& aCrossOrigin, bool aParserInHead) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = aParserInHead ? eSpeculativeLoadScriptFromHead : eSpeculativeLoadScript; mUrl.Assign(aUrl); mCharset.Assign(aCharset); mTypeOrCharsetSource.Assign(aType); mCrossOrigin.Assign(aCrossOrigin); } inline void InitStyle(const nsAString& aUrl, const nsAString& aCharset, const nsAString& aCrossOrigin) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadStyle; mUrl.Assign(aUrl); mCharset.Assign(aCharset); mCrossOrigin.Assign(aCrossOrigin); } /** * "Speculative" manifest loads aren't truly speculative--if a manifest * gets loaded, we are committed to it. There can never be a