|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsIDTD_h___ |
|
7 #define nsIDTD_h___ |
|
8 |
|
9 /** |
|
10 * MODULE NOTES: |
|
11 * @update gess 7/20/98 |
|
12 * |
|
13 * This interface defines standard interface for DTD's. Note that this |
|
14 * isn't HTML specific. DTD's have several functions within the parser |
|
15 * system: |
|
16 * 1) To coordinate the consumption of an input stream via the |
|
17 * parser |
|
18 * 2) To serve as proxy to represent the containment rules of the |
|
19 * underlying document |
|
20 * 3) To offer autodetection services to the parser (mainly for doc |
|
21 * conversion) |
|
22 * */ |
|
23 |
|
24 #include "nsISupports.h" |
|
25 #include "nsString.h" |
|
26 #include "nsITokenizer.h" |
|
27 |
|
28 #define NS_IDTD_IID \ |
|
29 { 0x3de05873, 0xefa7, 0x410d, \ |
|
30 { 0xa4, 0x61, 0x80, 0x33, 0xaf, 0xd9, 0xe3, 0x26 } } |
|
31 |
|
32 enum eAutoDetectResult { |
|
33 eUnknownDetect, |
|
34 eValidDetect, |
|
35 ePrimaryDetect, |
|
36 eInvalidDetect |
|
37 }; |
|
38 |
|
39 enum nsDTDMode { |
|
40 eDTDMode_unknown = 0, |
|
41 eDTDMode_quirks, //pre 4.0 versions |
|
42 eDTDMode_almost_standards, |
|
43 eDTDMode_full_standards, |
|
44 eDTDMode_autodetect, |
|
45 eDTDMode_fragment |
|
46 }; |
|
47 |
|
48 |
|
49 class nsIParser; |
|
50 class nsIURI; |
|
51 class nsIContentSink; |
|
52 class CParserContext; |
|
53 |
|
54 class nsIDTD : public nsISupports |
|
55 { |
|
56 public: |
|
57 |
|
58 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDTD_IID) |
|
59 |
|
60 NS_IMETHOD WillBuildModel(const CParserContext& aParserContext, |
|
61 nsITokenizer* aTokenizer, |
|
62 nsIContentSink* aSink) = 0; |
|
63 |
|
64 /** |
|
65 * Called by the parser after the parsing process has concluded |
|
66 * @update gess5/18/98 |
|
67 * @param anErrorCode - contains error code resulting from parse process |
|
68 * @return |
|
69 */ |
|
70 NS_IMETHOD DidBuildModel(nsresult anErrorCode) = 0; |
|
71 |
|
72 /** |
|
73 * Called (possibly repeatedly) by the parser to parse tokens and construct |
|
74 * the document model via the sink provided to WillBuildModel. |
|
75 * |
|
76 * @param aTokenizer - tokenizer providing the token stream to be parsed |
|
77 * @param aCountLines - informs the DTD whether to count newlines |
|
78 * (not wanted, e.g., when handling document.write) |
|
79 * @param aCharsetPtr - address of an nsCString containing the charset |
|
80 * that the DTD should use (pointer in case the DTD |
|
81 * opts to ignore this parameter) |
|
82 */ |
|
83 NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink) = 0; |
|
84 |
|
85 /** |
|
86 * This method is called to determine whether or not a tag of one |
|
87 * type can contain a tag of another type. |
|
88 * |
|
89 * @update gess 3/25/98 |
|
90 * @param aParent -- int tag of parent container |
|
91 * @param aChild -- int tag of child container |
|
92 * @return true if parent can contain child |
|
93 */ |
|
94 NS_IMETHOD_(bool) CanContain(int32_t aParent,int32_t aChild) const = 0; |
|
95 |
|
96 /** |
|
97 * This method gets called to determine whether a given |
|
98 * tag is itself a container |
|
99 * |
|
100 * @update gess 3/25/98 |
|
101 * @param aTag -- tag to test for containership |
|
102 * @return true if given tag can contain other tags |
|
103 */ |
|
104 NS_IMETHOD_(bool) IsContainer(int32_t aTag) const = 0; |
|
105 |
|
106 /** |
|
107 * Use this id you want to stop the building content model |
|
108 * --------------[ Sets DTD to STOP mode ]---------------- |
|
109 * It's recommended to use this method in accordance with |
|
110 * the parser's terminate() method. |
|
111 * |
|
112 * @update harishd 07/22/99 |
|
113 * @param |
|
114 * @return |
|
115 */ |
|
116 NS_IMETHOD_(void) Terminate() = 0; |
|
117 |
|
118 NS_IMETHOD_(int32_t) GetType() = 0; |
|
119 |
|
120 /** |
|
121 * Call this method after calling WillBuildModel to determine what mode the |
|
122 * DTD actually is using, as it may differ from aParserContext.mDTDMode. |
|
123 */ |
|
124 NS_IMETHOD_(nsDTDMode) GetMode() const = 0; |
|
125 }; |
|
126 |
|
127 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDTD, NS_IDTD_IID) |
|
128 |
|
129 #define NS_DECL_NSIDTD \ |
|
130 NS_IMETHOD WillBuildModel( const CParserContext& aParserContext, nsITokenizer* aTokenizer, nsIContentSink* aSink);\ |
|
131 NS_IMETHOD DidBuildModel(nsresult anErrorCode);\ |
|
132 NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink);\ |
|
133 NS_IMETHOD_(bool) CanContain(int32_t aParent,int32_t aChild) const;\ |
|
134 NS_IMETHOD_(bool) IsContainer(int32_t aTag) const;\ |
|
135 NS_IMETHOD_(void) Terminate();\ |
|
136 NS_IMETHOD_(int32_t) GetType();\ |
|
137 NS_IMETHOD_(nsDTDMode) GetMode() const; |
|
138 #endif /* nsIDTD_h___ */ |