LCOV - code coverage report
Current view: directory - parser/htmlparser/src - nsExpatDriver.h (source / functions) Found Hit Coverage
Test: app.info Lines: 4 3 75.0 %
Date: 2012-06-02 Functions: 6 4 66.7 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or 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 NS_EXPAT_DRIVER__
      39                 : #define NS_EXPAT_DRIVER__
      40                 : 
      41                 : #include "expat_config.h"
      42                 : #include "expat.h"
      43                 : #include "nsCOMPtr.h"
      44                 : #include "nsString.h"
      45                 : #include "nsIDTD.h"
      46                 : #include "nsITokenizer.h"
      47                 : #include "nsIInputStream.h"
      48                 : #include "nsIParser.h"
      49                 : #include "nsCycleCollectionParticipant.h"
      50                 : 
      51                 : class nsIExpatSink;
      52                 : class nsIExtendedExpatSink;
      53                 : struct nsCatalogData;
      54                 : 
      55                 : class nsExpatDriver : public nsIDTD,
      56                 :                       public nsITokenizer
      57                 : {
      58                 : public:
      59               0 :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      60                 :   NS_DECL_NSIDTD
      61                 :   NS_DECL_NSITOKENIZER
      62           21700 :   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsExpatDriver, nsIDTD)
      63                 : 
      64                 :   nsExpatDriver();
      65                 :   virtual ~nsExpatDriver();
      66                 : 
      67                 :   int HandleExternalEntityRef(const PRUnichar *aOpenEntityNames,
      68                 :                               const PRUnichar *aBase,
      69                 :                               const PRUnichar *aSystemId,
      70                 :                               const PRUnichar *aPublicId);
      71                 :   nsresult HandleStartElement(const PRUnichar *aName, const PRUnichar **aAtts);
      72                 :   nsresult HandleEndElement(const PRUnichar *aName);
      73                 :   nsresult HandleCharacterData(const PRUnichar *aCData, const PRUint32 aLength);
      74                 :   nsresult HandleComment(const PRUnichar *aName);
      75                 :   nsresult HandleProcessingInstruction(const PRUnichar *aTarget,
      76                 :                                        const PRUnichar *aData);
      77                 :   nsresult HandleXMLDeclaration(const PRUnichar *aVersion,
      78                 :                                 const PRUnichar *aEncoding,
      79                 :                                 PRInt32 aStandalone);
      80                 :   nsresult HandleDefault(const PRUnichar *aData, const PRUint32 aLength);
      81                 :   nsresult HandleStartCdataSection();
      82                 :   nsresult HandleEndCdataSection();
      83                 :   nsresult HandleStartDoctypeDecl(const PRUnichar* aDoctypeName,
      84                 :                                   const PRUnichar* aSysid,
      85                 :                                   const PRUnichar* aPubid,
      86                 :                                   bool aHasInternalSubset);
      87                 :   nsresult HandleEndDoctypeDecl();
      88                 :   nsresult HandleStartNamespaceDecl(const PRUnichar* aPrefix,
      89                 :                                     const PRUnichar* aUri);
      90                 :   nsresult HandleEndNamespaceDecl(const PRUnichar* aPrefix);
      91                 :   nsresult HandleNotationDecl(const PRUnichar* aNotationName,
      92                 :                               const PRUnichar* aBase,
      93                 :                               const PRUnichar* aSysid,
      94                 :                               const PRUnichar* aPubid);
      95                 :   nsresult HandleUnparsedEntityDecl(const PRUnichar* aEntityName,
      96                 :                                     const PRUnichar* aBase,
      97                 :                                     const PRUnichar* aSysid,
      98                 :                                     const PRUnichar* aPubid,
      99                 :                                     const PRUnichar* aNotationName);
     100                 : 
     101                 : private:
     102                 :   nsresult HandleToken(CToken* aToken);
     103                 : 
     104                 :   // Load up an external stream to get external entity information
     105                 :   nsresult OpenInputStreamFromExternalDTD(const PRUnichar* aFPIStr,
     106                 :                                           const PRUnichar* aURLStr,
     107                 :                                           const PRUnichar* aBaseURL,
     108                 :                                           nsIInputStream** aStream,
     109                 :                                           nsAString& aAbsURL);
     110                 : 
     111                 :   /**
     112                 :    * Pass a buffer to Expat. If Expat is blocked aBuffer should be null and
     113                 :    * aLength should be 0. The result of the call will be stored in
     114                 :    * mInternalState. Expat will parse as much of the buffer as it can and store
     115                 :    * the rest in its internal buffer.
     116                 :    *
     117                 :    * @param aBuffer the buffer to pass to Expat. May be null.
     118                 :    * @param aLength the length of the buffer to pass to Expat (in number of
     119                 :    *                PRUnichar's). Must be 0 if aBuffer is null and > 0 if
     120                 :    *                aBuffer is not null.
     121                 :    * @param aIsFinal whether there will definitely not be any more new buffers
     122                 :    *                 passed in to ParseBuffer
     123                 :    * @param aConsumed [out] the number of PRUnichars that Expat consumed. This
     124                 :    *                        doesn't include the PRUnichars that Expat stored in
     125                 :    *                        its buffer but didn't parse yet.
     126                 :    */
     127                 :   void ParseBuffer(const PRUnichar *aBuffer, PRUint32 aLength, bool aIsFinal,
     128                 :                    PRUint32 *aConsumed);
     129                 :   nsresult HandleError();
     130                 : 
     131                 :   void MaybeStopParser(nsresult aState);
     132                 : 
     133           33655 :   bool BlockedOrInterrupted()
     134                 :   {
     135                 :     return mInternalState == NS_ERROR_HTMLPARSER_BLOCK ||
     136           33655 :            mInternalState == NS_ERROR_HTMLPARSER_INTERRUPTED;
     137                 :   }
     138                 : 
     139                 :   XML_Parser       mExpatParser;
     140                 :   nsString         mLastLine;
     141                 :   nsString         mCDataText;
     142                 :   // Various parts of a doctype
     143                 :   nsString         mDoctypeName;
     144                 :   nsString         mSystemID;
     145                 :   nsString         mPublicID;
     146                 :   nsString         mInternalSubset;
     147                 :   bool             mInCData;
     148                 :   bool             mInInternalSubset;
     149                 :   bool             mInExternalDTD;
     150                 :   bool             mMadeFinalCallToExpat;
     151                 : 
     152                 :   // Whether we're sure that we won't be getting more buffers to parse from
     153                 :   // Necko
     154                 :   bool             mIsFinalChunk;
     155                 : 
     156                 :   nsresult         mInternalState;
     157                 : 
     158                 :   // The length of the data in Expat's buffer (in number of PRUnichars).
     159                 :   PRUint32         mExpatBuffered;
     160                 : 
     161                 :   // These sinks all refer the same conceptual object. mOriginalSink is
     162                 :   // identical with the nsIContentSink* passed to WillBuildModel, and exists
     163                 :   // only to avoid QI-ing back to nsIContentSink*.
     164                 :   nsCOMPtr<nsIContentSink> mOriginalSink;
     165                 :   nsCOMPtr<nsIExpatSink> mSink;
     166                 :   nsCOMPtr<nsIExtendedExpatSink> mExtendedSink;
     167                 : 
     168                 :   const nsCatalogData* mCatalogData; // weak
     169                 :   nsString         mURISpec;
     170                 : 
     171                 :   // Used for error reporting.
     172                 :   PRUint64         mInnerWindowID;
     173                 : };
     174                 : 
     175                 : #endif

Generated by: LCOV version 1.7