Bug 452317 - FeedConverter.js: QueryInterface should throw NS_ERROR_NO_INTERFACE...
[wine-gecko.git] / parser / htmlparser / public / nsIDTD.h
blob1ebc8f8c0a04812f4dfad5269161c349b0c1bcca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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.org 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 ***** */
38 #ifndef nsIDTD_h___
39 #define nsIDTD_h___
41 /**
42 * MODULE NOTES:
43 * @update gess 7/20/98
45 * This interface defines standard interface for DTD's. Note that this
46 * isn't HTML specific. DTD's have several functions within the parser
47 * system:
48 * 1) To coordinate the consumption of an input stream via the
49 * parser
50 * 2) To serve as proxy to represent the containment rules of the
51 * underlying document
52 * 3) To offer autodetection services to the parser (mainly for doc
53 * conversion)
54 * */
56 #include "nsISupports.h"
57 #include "nsStringGlue.h"
58 #include "prtypes.h"
59 #include "nsITokenizer.h"
61 #define NS_IDTD_IID \
62 { 0xcc374204, 0xcea2, 0x41a2, \
63 { 0xb2, 0x7f, 0x83, 0x75, 0xe2, 0xcf, 0x97, 0xcf } }
66 enum eAutoDetectResult {
67 eUnknownDetect,
68 eValidDetect,
69 ePrimaryDetect,
70 eInvalidDetect
73 enum nsDTDMode {
74 eDTDMode_unknown = 0,
75 eDTDMode_quirks, //pre 4.0 versions
76 eDTDMode_almost_standards,
77 eDTDMode_full_standards,
78 eDTDMode_autodetect,
79 eDTDMode_fragment
83 class nsIParser;
84 class CToken;
85 class nsIURI;
86 class nsIContentSink;
87 class CParserContext;
89 class nsIDTD : public nsISupports
91 public:
93 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDTD_IID)
95 NS_IMETHOD WillBuildModel(const CParserContext& aParserContext,
96 nsITokenizer* aTokenizer,
97 nsIContentSink* aSink) = 0;
99 /**
100 * Called by the parser after the parsing process has concluded
101 * @update gess5/18/98
102 * @param anErrorCode - contains error code resulting from parse process
103 * @return
105 NS_IMETHOD DidBuildModel(nsresult anErrorCode, PRBool aNotifySink,
106 nsIParser* aParser,
107 nsIContentSink* aSink) = 0;
110 * Called by the parser after the parsing process has concluded
111 * @update gess5/18/98
112 * @param anErrorCode - contains error code resulting from parse process
113 * @return
115 NS_IMETHOD BuildModel(nsIParser* aParser, nsITokenizer* aTokenizer,
116 nsITokenObserver* anObserver,
117 nsIContentSink* aSink) = 0;
120 * Called during model building phase of parse process. Each token
121 * created during the parse phase is stored in a deque (in the
122 * parser) and are passed to this method so that the DTD can
123 * process the token. Ultimately, the DTD will transform given
124 * token into calls onto a contentsink.
125 * @update gess 3/25/98
126 * @param aToken -- token object to be put into content model
127 * @return error code (usually 0)
129 NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser) = 0;
132 * If the parse process gets interrupted midway, this method is
133 * called by the parser prior to resuming the process.
134 * @update gess5/18/98
135 * @return ignored
137 NS_IMETHOD WillResumeParse(nsIContentSink* aSink) = 0;
140 * If the parse process gets interrupted, this method is called by
141 * the parser to notify the DTD that interruption will occur.
142 * @update gess5/18/98
143 * @return ignored
145 NS_IMETHOD WillInterruptParse(nsIContentSink* aSink) = 0;
148 * This method is called to determine whether or not a tag of one
149 * type can contain a tag of another type.
151 * @update gess 3/25/98
152 * @param aParent -- int tag of parent container
153 * @param aChild -- int tag of child container
154 * @return PR_TRUE if parent can contain child
156 NS_IMETHOD_(PRBool) CanContain(PRInt32 aParent,PRInt32 aChild) const = 0;
159 * This method gets called to determine whether a given
160 * tag is itself a container
162 * @update gess 3/25/98
163 * @param aTag -- tag to test for containership
164 * @return PR_TRUE if given tag can contain other tags
166 NS_IMETHOD_(PRBool) IsContainer(PRInt32 aTag) const = 0;
169 * Use this id you want to stop the building content model
170 * --------------[ Sets DTD to STOP mode ]----------------
171 * It's recommended to use this method in accordance with
172 * the parser's terminate() method.
174 * @update harishd 07/22/99
175 * @param
176 * @return
178 NS_IMETHOD_(void) Terminate() = 0;
180 NS_IMETHOD_(PRInt32) GetType() = 0;
183 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDTD, NS_IDTD_IID)
185 #define NS_DECL_NSIDTD \
186 NS_IMETHOD WillBuildModel( const CParserContext& aParserContext, nsITokenizer* aTokenizer, nsIContentSink* aSink);\
187 NS_IMETHOD DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParser* aParser,nsIContentSink* aSink);\
188 NS_IMETHOD BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink);\
189 NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);\
190 NS_IMETHOD WillResumeParse(nsIContentSink* aSink = 0);\
191 NS_IMETHOD WillInterruptParse(nsIContentSink* aSink = 0);\
192 NS_IMETHOD_(PRBool) CanContain(PRInt32 aParent,PRInt32 aChild) const;\
193 NS_IMETHOD_(PRBool) IsContainer(PRInt32 aTag) const;\
194 NS_IMETHOD_(void) Terminate();\
195 NS_IMETHOD_(PRInt32) GetType();
196 #endif /* nsIDTD_h___ */