source: trunk/third/mozilla/htmlparser/public/nsIDTD.h @ 20192

Revision 20192, 9.3 KB checked in by rbasch, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20191, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Netscape Public License
6 * Version 1.1 (the "License"); you may not use this file except in
7 * compliance with the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/NPL/
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 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the NPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the NPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39#ifndef nsIDTD_h___
40#define nsIDTD_h___
41
42/**
43 * MODULE NOTES:
44 * @update  gess 7/20/98
45 *
46 * This interface defines standard interface for DTD's. Note that this
47 * isn't HTML specific. DTD's have several functions within the parser
48 * system:
49 *      1) To coordinate the consumption of an input stream via the
50 *      parser
51 *      2) To serve as proxy to represent the containment rules of the
52 *      underlying document
53 *      3) To offer autodetection services to the parser (mainly for doc
54 *      conversion)
55 * */
56
57#include "nsISupports.h"
58#include "nsString.h"
59#include "prtypes.h"
60#include "nsITokenizer.h"
61
62#define NS_IDTD_IID \
63 { 0xa6cf9053, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
64
65enum eAutoDetectResult {
66    eUnknownDetect,
67    eValidDetect,
68    ePrimaryDetect,
69    eInvalidDetect
70};
71
72enum nsDTDMode {
73    eDTDMode_unknown = 0,
74    eDTDMode_quirks,        //pre 4.0 versions
75    eDTDMode_almost_standards,
76    eDTDMode_full_standards,
77    eDTDMode_autodetect,
78    eDTDMode_fragment
79};
80
81
82class nsIParser;
83class CToken;
84class nsIURI;
85class nsIContentSink;
86class CParserContext;
87class nsIAtom;
88
89class nsIDTD : public nsISupports
90{
91public:
92
93    NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDTD_IID)
94
95
96    NS_IMETHOD_(const nsIID&) GetMostDerivedIID(void) const = 0;
97
98    /**
99     * Call this method if you want the DTD to construct a clone of itself.
100     * @update  gess7/23/98
101     * @param
102     * @return
103     */
104    NS_IMETHOD CreateNewInstance(nsIDTD** aInstancePtrResult) = 0;
105
106    /**
107     * This method is called to determine if the given DTD can parse
108     * a document in a given source-type.
109     * NOTE: Parsing always assumes that the end result will involve
110     *       storing the result in the main content model.
111     * @update  gess6/24/98
112     * @param aContentType -- string representing type of doc to be
113     * converted (ie text/html)
114     * @return TRUE if this DTD can satisfy the request; FALSE otherwise.
115     */
116    NS_IMETHOD_(eAutoDetectResult) CanParse(CParserContext& aParserContext,
117                                            const nsString& aBuffer,
118                                            PRInt32 aVersion) = 0;
119
120    NS_IMETHOD WillBuildModel(const CParserContext& aParserContext,
121                              nsITokenizer* aTokenizer,
122                              nsIContentSink* aSink) = 0;
123
124    /**
125     * Called by the parser after the parsing process has concluded
126     * @update  gess5/18/98
127     * @param   anErrorCode - contains error code resulting from parse process
128     * @return
129     */
130    NS_IMETHOD DidBuildModel(nsresult anErrorCode, PRBool aNotifySink,
131                             nsIParser* aParser,
132                             nsIContentSink* aSink) = 0;
133
134    /**
135     * Called by the parser after the parsing process has concluded
136     * @update  gess5/18/98
137     * @param   anErrorCode - contains error code resulting from parse process
138     * @return
139     */
140    NS_IMETHOD BuildModel(nsIParser* aParser, nsITokenizer* aTokenizer,
141                          nsITokenObserver* anObserver,
142                          nsIContentSink* aSink) = 0;
143
144    /**
145     * Called during model building phase of parse process. Each token
146     * created during the parse phase is stored in a deque (in the
147     * parser) and are passed to this method so that the DTD can
148     * process the token. Ultimately, the DTD will transform given
149     * token into calls onto a contentsink.
150     * @update  gess 3/25/98
151     * @param   aToken -- token object to be put into content model
152     * @return error code (usually 0)
153     */
154    NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser) = 0;
155
156    /**
157     * If the parse process gets interrupted midway, this method is
158     * called by the parser prior to resuming the process.
159     * @update  gess5/18/98
160     * @return ignored
161     */
162    NS_IMETHOD WillResumeParse(nsIContentSink* aSink) = 0;
163
164    /**
165     * If the parse process gets interrupted, this method is called by
166     * the parser to notify the DTD that interruption will occur.
167     * @update  gess5/18/98
168     * @return ignored
169     */
170    NS_IMETHOD WillInterruptParse(nsIContentSink* aSink) = 0;
171
172    /**
173     * This method is called to determine whether or not a tag of one
174     * type can contain a tag of another type.
175     *
176     * @update  gess 3/25/98
177     * @param   aParent -- int tag of parent container
178     * @param   aChild -- int tag of child container
179     * @return PR_TRUE if parent can contain child
180     */
181    NS_IMETHOD_(PRBool) CanContain(PRInt32 aParent,PRInt32 aChild) const = 0;
182
183    /**
184     * This method gets called to determine whether a given
185     * tag is itself a container
186     *
187     * @update  gess 3/25/98
188     * @param   aTag -- tag to test for containership
189     * @return  PR_TRUE if given tag can contain other tags
190     */
191    NS_IMETHOD_(PRBool) IsContainer(PRInt32 aTag) const = 0;
192
193    /**
194     * Use this id you want to stop the building content model
195     * --------------[ Sets DTD to STOP mode ]----------------
196     * It's recommended to use this method in accordance with
197     * the parser's terminate() method.
198     *
199     * @update  harishd 07/22/99
200     * @param
201     * @return
202     */
203    NS_IMETHOD_(void) Terminate() = 0;
204
205    NS_IMETHOD_(PRInt32) GetType() = 0;
206
207    NS_IMETHOD CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLineNo) = 0;
208
209/* XXX Temporary measure, pending further work by RickG  */
210
211
212    //  Whaaaa! These are useless methods, use nsIParserService!
213
214
215    /**
216     * Give rest of world access to our tag enums, so that CanContain(), etc,
217     * become useful.
218     */
219    NS_IMETHOD StringTagToIntTag(const nsAString &aTag,
220                                 PRInt32* aIntTag) const = 0;
221   
222    NS_IMETHOD_(const PRUnichar *) IntTagToStringTag(PRInt32 aIntTag) const = 0;
223   
224    NS_IMETHOD_(nsIAtom *) IntTagToAtom(PRInt32 aIntTag) const = 0;
225
226    NS_IMETHOD_(PRBool) IsBlockElement(PRInt32 aTagID,
227                                       PRInt32 aParentID) const = 0;
228   
229    NS_IMETHOD_(PRBool) IsInlineElement(PRInt32 aTagID,
230                                        PRInt32 aParentID) const = 0;
231};
232
233#define NS_DECL_NSIDTD \
234    NS_IMETHOD_(const nsIID&)  GetMostDerivedIID(void) const;\
235    NS_IMETHOD CreateNewInstance(nsIDTD** aInstancePtrResult);\
236    NS_IMETHOD_(eAutoDetectResult) CanParse(CParserContext& aParserContext, const nsString& aBuffer, PRInt32 aVersion);\
237    NS_IMETHOD WillBuildModel(  const CParserContext& aParserContext, nsITokenizer* aTokenizer, nsIContentSink* aSink);\
238    NS_IMETHOD DidBuildModel(nsresult anErrorCode,PRBool aNotifySink,nsIParser* aParser,nsIContentSink* aSink);\
239    NS_IMETHOD BuildModel(nsIParser* aParser,nsITokenizer* aTokenizer,nsITokenObserver* anObserver,nsIContentSink* aSink);\
240    NS_IMETHOD HandleToken(CToken* aToken,nsIParser* aParser);\
241    NS_IMETHOD WillResumeParse(nsIContentSink* aSink = 0);\
242    NS_IMETHOD WillInterruptParse(nsIContentSink* aSink = 0);\
243    NS_IMETHOD_(PRBool) CanContain(PRInt32 aParent,PRInt32 aChild) const;\
244    NS_IMETHOD_(PRBool) IsContainer(PRInt32 aTag) const;\
245    NS_IMETHOD CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLineNo);\
246    NS_IMETHOD_(void)  Terminate();\
247    NS_IMETHOD_(PRInt32) GetType(); \
248    NS_IMETHOD StringTagToIntTag(const nsAString &aTag, PRInt32* aIntTag) const ;\
249    NS_IMETHOD_(const PRUnichar *) IntTagToStringTag(PRInt32 aIntTag) const ;\
250    NS_IMETHOD_(nsIAtom *) IntTagToAtom(PRInt32 aIntTag) const;\
251    NS_IMETHOD_(PRBool)  IsBlockElement(PRInt32 aTagID,PRInt32 aParentID) const;\
252    NS_IMETHOD_(PRBool)  IsInlineElement(PRInt32 aTagID,PRInt32 aParentID) const;
253#endif /* nsIDTD_h___ */
Note: See TracBrowser for help on using the repository browser.