LCOV - app.info - parser/html/nsHtml5SpeculativeLoad.h

LCOV - code coverage report
| Current view: | directory - parser/html - nsHtml5SpeculativeLoad.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 36 | 0 | 0.0 %
| Date: | 2012-07-07 | Functions: | 6 | 0 | 0.0 %

           1                 : /* ***** BEGIN LICENSE BLOCK *****
           2                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           3                 :  *
           4                 :  * The contents of this file are subject to the Mozilla Public License Version
           5                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           6                 :  * the License. You may obtain a copy of the License at
           7                 :  * http://www.mozilla.org/MPL/
           8                 :  *
           9                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          10                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          11                 :  * for the specific language governing rights and limitations under the
          12                 :  * License.
          13                 :  *
          14                 :  * The Original Code is HTML Parser C++ Translator code.
          15                 :  *
          16                 :  * The Initial Developer of the Original Code is
          17                 :  * Mozilla Foundation.
          18                 :  * Portions created by the Initial Developer are Copyright (C) 2010
          19                 :  * the Initial Developer. All Rights Reserved.
          20                 :  *
          21                 :  * Contributor(s):
          22                 :  *   Henri Sivonen <hsivonen@iki.fi>
          23                 :  *
          24                 :  * Alternatively, the contents of this file may be used under the terms of
          25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          28                 :  * of those above. If you wish to allow use of your version of this file only
          29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          30                 :  * use your version of this file under the terms of the MPL, indicate your
          31                 :  * decision by deleting the provisions above and replace them with the notice
          32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          33                 :  * the provisions above, a recipient may use your version of this file under
          34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          35                 :  *
          36                 :  * ***** END LICENSE BLOCK ***** */
          37                 :
          38                 : #ifndef nsHtml5SpeculativeLoad_h_
          39                 : #define nsHtml5SpeculativeLoad_h_
          40                 :
          41                 : #include "nsString.h"
          42                 :
          43                 : class nsHtml5TreeOpExecutor;
          44                 :
          45                 : enum eHtml5SpeculativeLoad {
          46                 : #ifdef DEBUG
          47                 :   eSpeculativeLoadUninitialized,
          48                 : #endif
          49                 :   eSpeculativeLoadBase,
          50                 :   eSpeculativeLoadImage,
          51                 :   eSpeculativeLoadScript,
          52                 :   eSpeculativeLoadStyle,
          53                 :   eSpeculativeLoadManifest,
          54                 :   eSpeculativeLoadSetDocumentCharset
          55                 : };
          56                 :
          57                 : class nsHtml5SpeculativeLoad {
          58                 :   public:
          59                 :     nsHtml5SpeculativeLoad();
          60                 :     ~nsHtml5SpeculativeLoad();
          61                 :
          62               0 :     inline void InitBase(const nsAString& aUrl) {
          63               0 :       NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
          64                 :                       "Trying to reinitialize a speculative load!");
          65               0 :       mOpCode = eSpeculativeLoadBase;
          66               0 :       mUrl.Assign(aUrl);
          67               0 :     }
          68                 :
          69               0 :     inline void InitImage(const nsAString& aUrl,
          70                 :                           const nsAString& aCrossOrigin) {
          71               0 :       NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
          72                 :                       "Trying to reinitialize a speculative load!");
          73               0 :       mOpCode = eSpeculativeLoadImage;
          74               0 :       mUrl.Assign(aUrl);
          75               0 :       mCrossOrigin.Assign(aCrossOrigin);
          76               0 :     }
          77                 :
          78               0 :     inline void InitScript(const nsAString& aUrl,
          79                 :                            const nsAString& aCharset,
          80                 :                            const nsAString& aType,
          81                 :                            const nsAString& aCrossOrigin) {
          82               0 :       NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
          83                 :                       "Trying to reinitialize a speculative load!");
          84               0 :       mOpCode = eSpeculativeLoadScript;
          85               0 :       mUrl.Assign(aUrl);
          86               0 :       mCharset.Assign(aCharset);
          87               0 :       mTypeOrCharsetSource.Assign(aType);
          88               0 :       mCrossOrigin.Assign(aCrossOrigin);
          89               0 :     }
          90                 :
          91               0 :     inline void InitStyle(const nsAString& aUrl, const nsAString& aCharset) {
          92               0 :       NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
          93                 :                       "Trying to reinitialize a speculative load!");
          94               0 :       mOpCode = eSpeculativeLoadStyle;
          95               0 :       mUrl.Assign(aUrl);
          96               0 :       mCharset.Assign(aCharset);
          97               0 :     }
          98                 :
          99                 :     /**
         100                 :      * "Speculative" manifest loads aren't truly speculative--if a manifest
         101                 :      * gets loaded, we are committed to it. There can never be a <script>
         102                 :      * before the manifest, so the situation of having to undo a manifest due
         103                 :      * to document.write() never arises. The reason why a parser
         104                 :      * thread-discovered manifest gets loaded via the speculative load queue
         105                 :      * as opposed to tree operation queue is that the manifest must get
         106                 :      * processed before any actual speculative loads such as scripts. Thus,
         107                 :      * manifests seen by the parser thread have to maintain the queue order
         108                 :      * relative to true speculative loads. See bug 541079.
         109                 :      */
         110               0 :     inline void InitManifest(const nsAString& aUrl) {
         111               0 :       NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
         112                 :                       "Trying to reinitialize a speculative load!");
         113               0 :       mOpCode = eSpeculativeLoadManifest;
         114               0 :       mUrl.Assign(aUrl);
         115               0 :     }
         116                 :
         117                 :     /**
         118                 :      * "Speculative" charset setting isn't truly speculative. If the charset
         119                 :      * is set via this operation, we are committed to it unless chardet or
         120                 :      * a late meta cause a reload. The reason why a parser
         121                 :      * thread-discovered charset gets communicated via the speculative load
         122                 :      * queue as opposed to tree operation queue is that the charset change
         123                 :      * must get processed before any actual speculative loads such as style
         124                 :      * sheets. Thus, encoding decisions by the parser thread have to maintain
         125                 :      * the queue order relative to true speculative loads. See bug 675499.
         126                 :      */
         127               0 :     inline void InitSetDocumentCharset(nsACString& aCharset,
         128                 :                                        PRInt32 aCharsetSource) {
         129               0 :       NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
         130                 :                       "Trying to reinitialize a speculative load!");
         131               0 :       mOpCode = eSpeculativeLoadSetDocumentCharset;
         132               0 :       CopyUTF8toUTF16(aCharset, mCharset);
         133               0 :       mTypeOrCharsetSource.Assign((PRUnichar)aCharsetSource);
         134               0 :     }
         135                 :
         136                 :     void Perform(nsHtml5TreeOpExecutor* aExecutor);
         137                 :
         138                 :   private:
         139                 :     eHtml5SpeculativeLoad mOpCode;
         140                 :     nsString mUrl;
         141                 :     /**
         142                 :      * If mOpCode is eSpeculativeLoadStyle or eSpeculativeLoadScript
         143                 :      * then this is the value of the "charset" attribute. For
         144                 :      * eSpeculativeLoadSetDocumentCharset it is the charset that the
         145                 :      * document's charset is being set to. Otherwise it's empty.
         146                 :      */
         147                 :     nsString mCharset;
         148                 :     /**
         149                 :      * If mOpCode is eSpeculativeLoadSetDocumentCharset, this is a
         150                 :      * one-character string whose single character's code point is to be
         151                 :      * interpreted as a charset source integer. Otherwise, it is empty or
         152                 :      * the value of the type attribute.
         153                 :      */
         154                 :     nsString mTypeOrCharsetSource;
         155                 :     /**
         156                 :      * If mOpCode is eSpeculativeLoadImage or eSpeculativeLoadScript,
         157                 :      * this is the value of the "crossorigin" attribute.  If the
         158                 :      * attribute is not set, this will be a void string.
         159                 :      */
         160                 :     nsString mCrossOrigin;
         161                 : };
         162                 :
         163                 : #endif // nsHtml5SpeculativeLoad_h_

Generated by: LCOV version 1.7