LCOV - code coverage report
Current view: directory - objdir/dist/include - nsIHTMLContentSink.h (source / functions) Found Hit Coverage
Test: app.info Lines: 4 2 50.0 %
Date: 2012-06-02 Functions: 3 2 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 Communicator client 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                 : #ifndef nsIHTMLContentSink_h___
      38                 : #define nsIHTMLContentSink_h___
      39                 : 
      40                 : /**
      41                 :  * This file declares the concrete HTMLContentSink class.
      42                 :  * This class is used during the parsing process as the
      43                 :  * primary interface between the parser and the content
      44                 :  * model.
      45                 :  *
      46                 :  * After the tokenizer completes, the parser iterates over
      47                 :  * the known token list. As the parser identifies valid 
      48                 :  * elements, it calls the contentsink interface to notify
      49                 :  * the content model that a new node or child node is being
      50                 :  * created and added to the content model.
      51                 :  *
      52                 :  * The HTMLContentSink interface assumes 4 underlying
      53                 :  * containers: HTML, HEAD, BODY and FRAMESET. Before 
      54                 :  * accessing any these, the parser will call the appropriate
      55                 :  * OpennsIHTMLContentSink method: OpenHTML,OpenHead,OpenBody,OpenFrameSet;
      56                 :  * likewise, the ClosensIHTMLContentSink version will be called when the
      57                 :  * parser is done with a given section.
      58                 :  *
      59                 :  * IMPORTANT: The parser may Open each container more than
      60                 :  * once! This is due to the irregular nature of HTML files.
      61                 :  * For example, it is possible to encounter plain text at
      62                 :  * the start of an HTML document (that precedes the HTML tag).
      63                 :  * Such text is treated as if it were part of the body.
      64                 :  * In such cases, the parser will Open the body, pass the text-
      65                 :  * node in and then Close the body. The body will likely be
      66                 :  * re-Opened later when the actual <BODY> tag has been seen.
      67                 :  *
      68                 :  * Containers within the body are Opened and Closed
      69                 :  * using the OpenContainer(...) and CloseContainer(...) calls.
      70                 :  * It is assumed that the document or contentSink is 
      71                 :  * maintaining its state to manage where new content should 
      72                 :  * be added to the underlying document.
      73                 :  *
      74                 :  * NOTE: OpenHTML() and OpenBody() may get called multiple times
      75                 :  *       in the same document. That's fine, and it doesn't mean
      76                 :  *       that we have multiple bodies or HTML's.
      77                 :  *
      78                 :  * NOTE: I haven't figured out how sub-documents (non-frames)
      79                 :  *       are going to be handled. Stay tuned.
      80                 :  */
      81                 : #include "nsIParserNode.h"
      82                 : #include "nsIContentSink.h"
      83                 : #include "nsHTMLTags.h"
      84                 : 
      85                 : #define NS_IHTML_CONTENT_SINK_IID \
      86                 : { 0x1cc778ae, 0xcc2b, 0x45e6, \
      87                 :   { 0x8a, 0x64, 0xa6, 0x80, 0x1a, 0x27, 0x12, 0x4a } }
      88                 : 
      89                 : #define MAX_REFLOW_DEPTH  200
      90                 : 
      91                 : class nsIHTMLContentSink : public nsIContentSink 
      92              28 : {
      93                 : public:
      94                 : 
      95                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID)
      96                 : 
      97                 :   /**
      98                 :    * Checks is this is an instance of HTMLContentSink.
      99                 :    */
     100              28 :   virtual bool IsAboutBlank() { return false; }
     101                 : 
     102                 :   /**
     103                 :    * This method is used to open the HEAD container. It is useful if a tag
     104                 :    * is forcing us to open the head (probably again), like if we find a <meta>
     105                 :    * tag in the body.
     106                 :    */
     107                 :   NS_IMETHOD OpenHead() = 0;
     108                 : 
     109                 :   /**
     110                 :    * This gets called when handling illegal contents, especially
     111                 :    * in dealing with tables. This method creates a new context.
     112                 :    * 
     113                 :    * @update 04/04/99 harishd
     114                 :    * @param aPosition - The position from where the new context begins.
     115                 :    */
     116                 :   NS_IMETHOD BeginContext(PRInt32 aPosition) = 0;
     117                 :   
     118                 :   /**
     119                 :    * This method terminates any new context that got created by
     120                 :    * BeginContext and switches back to the main context.  
     121                 :    *
     122                 :    * @update 04/04/99 harishd
     123                 :    * @param aPosition - Validates the end of a context.
     124                 :    */
     125                 :   NS_IMETHOD EndContext(PRInt32 aPosition) = 0;
     126                 :   
     127                 :   /**
     128                 :    * @update 01/09/2003 harishd
     129                 :    * @param aTag - Check if this tag is enabled or not.
     130                 :    */
     131                 :   NS_IMETHOD IsEnabled(PRInt32 aTag, bool* aReturn) = 0;
     132                 : 
     133                 :   /**
     134                 :    * This method is called when parser has
     135                 :    * completed processing a chunk of tokens. The processing of the
     136                 :    * tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from
     137                 :    * DidProcessAToken.
     138                 :    */
     139                 :   NS_IMETHOD DidProcessTokens() = 0;
     140                 : 
     141                 :   /**
     142                 :    * This method is called when parser is about to
     143                 :    * process a single token
     144                 :    */
     145                 :   NS_IMETHOD WillProcessAToken(void) = 0;
     146                 : 
     147                 :   /**
     148                 :    * This method is called when parser has completed
     149                 :    * the processing for a single token.
     150                 :    * @return NS_OK if processing should not be interrupted
     151                 :    *         NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted
     152                 :    */
     153                 :   NS_IMETHOD DidProcessAToken(void) = 0;
     154                 : 
     155                 :     /**
     156                 :    * This method is used to open a generic container in the sink.
     157                 :    *
     158                 :    * @update 4/1/98 gess
     159                 :    * @param  nsIParserNode reference to parser node interface
     160                 :    */     
     161                 :   NS_IMETHOD OpenContainer(const nsIParserNode& aNode) = 0;
     162                 : 
     163                 :   /**
     164                 :    *  This method gets called by the parser when a close
     165                 :    *  container tag has been consumed and needs to be closed.
     166                 :    *
     167                 :    * @param  aTag - The tag to be closed.
     168                 :    */     
     169                 :   NS_IMETHOD CloseContainer(const nsHTMLTag aTag) = 0;
     170                 : 
     171                 :   /**
     172                 :    * This method is used when we're closing a tag that was malformed
     173                 :    * in some way. This way, the content sink can do special processing
     174                 :    * (e.g., not execute a malformed script tag).
     175                 :    *
     176                 :    * @param aTag The tag to be closed.
     177                 :    */
     178               0 :   NS_IMETHOD CloseMalformedContainer(const nsHTMLTag aTag)
     179                 :   {
     180               0 :     return CloseContainer(aTag);
     181                 :   }
     182                 : 
     183                 :   /**
     184                 :    * This gets called by the parser when you want to add
     185                 :    * a leaf node to the current container in the content
     186                 :    * model.
     187                 :    *
     188                 :    * @update 4/1/98 gess
     189                 :    * @param  nsIParserNode reference to parser node interface
     190                 :    */     
     191                 :   NS_IMETHOD AddLeaf(const nsIParserNode& aNode) = 0;
     192                 : };
     193                 : 
     194                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLContentSink, NS_IHTML_CONTENT_SINK_IID)
     195                 : 
     196                 : #endif /* nsIHTMLContentSink_h___ */
     197                 : 

Generated by: LCOV version 1.7