Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / parser / htmlparser / public / nsIHTMLContentSink.h
blob73e6b50867676f77e65906fd171cd249183579f5
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 // d19e6730-5e2f-4131-89db-8a918515097d
86 #define NS_IHTML_CONTENT_SINK_IID \
87 { 0xd19e6730, 0x5e2f, 0x4131, \
88 { 0x89, 0xdb, 0x8a, 0x91, 0x85, 0x15, 0x09, 0x7d } }
91 #if defined(XP_MAC)
92 #define MAX_REFLOW_DEPTH 75 //setting to 75 to prevent layout from crashing on mac. Bug 55095.
93 #else
94 #define MAX_REFLOW_DEPTH 200 //windows and linux (etc) can do much deeper structures.
95 #endif
97 class nsIHTMLContentSink : public nsIContentSink
99 public:
101 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID)
104 * This method is used to open the HEAD container. It is useful if a tag
105 * is forcing us to open the head (probably again), like if we find a <meta>
106 * tag in the body.
108 NS_IMETHOD OpenHead() = 0;
111 * This gets called when handling illegal contents, especially
112 * in dealing with tables. This method creates a new context.
114 * @update 04/04/99 harishd
115 * @param aPosition - The position from where the new context begins.
117 NS_IMETHOD BeginContext(PRInt32 aPosition) = 0;
120 * This method terminates any new context that got created by
121 * BeginContext and switches back to the main context.
123 * @update 04/04/99 harishd
124 * @param aPosition - Validates the end of a context.
126 NS_IMETHOD EndContext(PRInt32 aPosition) = 0;
129 * @update 01/09/2003 harishd
130 * @param aTag - Check if this tag is enabled or not.
132 NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn) = 0;
135 * This method is called when parser has
136 * completed processing a chunk of tokens. The processing of the
137 * tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from
138 * DidProcessAToken.
140 NS_IMETHOD DidProcessTokens() = 0;
143 * This method is called when parser is about to
144 * process a single token
146 NS_IMETHOD WillProcessAToken(void) = 0;
149 * This method is called when parser has completed
150 * the processing for a single token.
151 * @return NS_OK if processing should not be interrupted
152 * NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted
154 NS_IMETHOD DidProcessAToken(void) = 0;
157 * This method is used to open a generic container in the sink.
159 * @update 4/1/98 gess
160 * @param nsIParserNode reference to parser node interface
162 NS_IMETHOD OpenContainer(const nsIParserNode& aNode) = 0;
165 * This method gets called by the parser when a close
166 * container tag has been consumed and needs to be closed.
168 * @param aTag - The tag to be closed.
170 NS_IMETHOD CloseContainer(const nsHTMLTag aTag) = 0;
173 * This method is used when we're closing a tag that was malformed
174 * in some way. This way, the content sink can do special processing
175 * (e.g., not execute a malformed script tag).
177 * @param aTag The tag to be closed.
179 NS_IMETHOD CloseMalformedContainer(const nsHTMLTag aTag)
181 return CloseContainer(aTag);
185 * This gets called by the parser when you want to add
186 * a leaf node to the current container in the content
187 * model.
189 * @update 4/1/98 gess
190 * @param nsIParserNode reference to parser node interface
192 NS_IMETHOD AddLeaf(const nsIParserNode& aNode) = 0;
195 * This gets called by the parser when you want to add
196 * a leaf node to the current container in the content
197 * model.
199 * @update 4/1/98 gess
200 * @param nsIParserNode reference to parser node interface
202 NS_IMETHOD AddComment(const nsIParserNode& aNode) = 0;
205 * This gets called by the parser when you want to add
206 * a leaf node to the current container in the content
207 * model.
209 * @update 4/1/98 gess
210 * @param nsIParserNode reference to parser node interface
212 NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode) = 0;
215 * This method is called by the parser when it encounters
216 * a document type declaration.
218 * XXX Should the parser also parse the internal subset?
220 * @param nsIParserNode reference to parser node interface
222 NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode) = 0;
225 * This gets called by the parser to notify observers of
226 * the tag
228 * @param aErrorResult the error code
230 NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) = 0;
233 * Call this method to determnine if a FORM is on the sink's stack
235 * @return PR_TRUE if found else PR_FALSE
237 NS_IMETHOD_(PRBool) IsFormOnStack() = 0;
241 NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLContentSink, NS_IHTML_CONTENT_SINK_IID)
243 #endif /* nsIHTMLContentSink_h___ */