Bug 452317 - FeedConverter.js: QueryInterface should throw NS_ERROR_NO_INTERFACE...
[wine-gecko.git] / parser / htmlparser / public / nsIHTMLContentSink.h
bloba268d84f204137165b3704be008301de0507ef86
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
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/
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.
15 * The Original Code is Mozilla Communicator client code.
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.
22 * Contributor(s):
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.
36 * ***** END LICENSE BLOCK ***** */
37 #ifndef nsIHTMLContentSink_h___
38 #define nsIHTMLContentSink_h___
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.
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.
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.
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 preceeds 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.
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.
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.
78 * NOTE: I haven't figured out how sub-documents (non-frames)
79 * are going to be handled. Stay tuned.
81 #include "nsIParserNode.h"
82 #include "nsIContentSink.h"
83 #include "nsHTMLTags.h"
85 #define NS_IHTML_CONTENT_SINK_IID \
86 { 0x73b5a072, 0x0f87, 0x4d07, \
87 { 0xa8, 0x16, 0xe6, 0xac, 0x73, 0xa7, 0x04, 0x3c } }
90 #if defined(XP_MAC) || defined(WINCE)
91 #define MAX_REFLOW_DEPTH 75 //setting to 75 to prevent layout from crashing on mac. Bug 55095.
92 //We will also change this for WinCE as it usually has a strict
93 //memory upper limit (no vm, ~32mb)
94 #else
95 #define MAX_REFLOW_DEPTH 200 //windows and linux (etc) can do much deeper structures.
96 #endif
98 class nsIHTMLContentSink : public nsIContentSink
100 public:
102 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID)
105 * This method is used to open the HEAD container. It is useful if a tag
106 * is forcing us to open the head (probably again), like if we find a <meta>
107 * tag in the body.
109 NS_IMETHOD OpenHead() = 0;
112 * This gets called when handling illegal contents, especially
113 * in dealing with tables. This method creates a new context.
115 * @update 04/04/99 harishd
116 * @param aPosition - The position from where the new context begins.
118 NS_IMETHOD BeginContext(PRInt32 aPosition) = 0;
121 * This method terminates any new context that got created by
122 * BeginContext and switches back to the main context.
124 * @update 04/04/99 harishd
125 * @param aPosition - Validates the end of a context.
127 NS_IMETHOD EndContext(PRInt32 aPosition) = 0;
130 * @update 01/09/2003 harishd
131 * @param aTag - Check if this tag is enabled or not.
133 NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn) = 0;
136 * This method is called when parser is about to begin
137 * synchronously processing a chunk of tokens.
139 NS_IMETHOD WillProcessTokens(void) = 0;
142 * This method is called when parser has
143 * completed processing a chunk of tokens. The processing of the
144 * tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from
145 * DidProcessAToken.
147 NS_IMETHOD DidProcessTokens() = 0;
150 * This method is called when parser is about to
151 * process a single token
153 NS_IMETHOD WillProcessAToken(void) = 0;
156 * This method is called when parser has completed
157 * the processing for a single token.
158 * @return NS_OK if processing should not be interrupted
159 * NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted
161 NS_IMETHOD DidProcessAToken(void) = 0;
164 * This method is used to open a generic container in the sink.
166 * @update 4/1/98 gess
167 * @param nsIParserNode reference to parser node interface
169 NS_IMETHOD OpenContainer(const nsIParserNode& aNode) = 0;
172 * This method gets called by the parser when a close
173 * container tag has been consumed and needs to be closed.
175 * @param aTag - The tag to be closed.
177 NS_IMETHOD CloseContainer(const nsHTMLTag aTag) = 0;
180 * This method is used when we're closing a tag that was malformed
181 * in some way. This way, the content sink can do special processing
182 * (e.g., not execute a malformed script tag).
184 * @param aTag The tag to be closed.
186 NS_IMETHOD CloseMalformedContainer(const nsHTMLTag aTag)
188 return CloseContainer(aTag);
192 * This gets called by the parser when you want to add
193 * a leaf node to the current container in the content
194 * model.
196 * @update 4/1/98 gess
197 * @param nsIParserNode reference to parser node interface
199 NS_IMETHOD AddLeaf(const nsIParserNode& aNode) = 0;
202 * This gets called by the parser when you want to add
203 * a leaf node to the current container in the content
204 * model.
206 * @update 4/1/98 gess
207 * @param nsIParserNode reference to parser node interface
209 NS_IMETHOD AddComment(const nsIParserNode& aNode) = 0;
212 * This gets called by the parser when you want to add
213 * a leaf node to the current container in the content
214 * model.
216 * @update 4/1/98 gess
217 * @param nsIParserNode reference to parser node interface
219 NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode) = 0;
222 * This method is called by the parser when it encounters
223 * a document type declaration.
225 * XXX Should the parser also parse the internal subset?
227 * @param nsIParserNode reference to parser node interface
229 NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode) = 0;
232 * This gets called by the parser to notify observers of
233 * the tag
235 * @param aErrorResult the error code
237 NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) = 0;
240 * Call this method to determnine if a FORM is on the sink's stack
242 * @return PR_TRUE if found else PR_FALSE
244 NS_IMETHOD_(PRBool) IsFormOnStack() = 0;
248 NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLContentSink, NS_IHTML_CONTENT_SINK_IID)
250 #endif /* nsIHTMLContentSink_h___ */