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/. */
11 * @update gess 7/20/98
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
16 * 1) To coordinate the consumption of an input stream via the
18 * 2) To serve as proxy to represent the containment rules of the
20 * 3) To offer autodetection services to the parser (mainly for doc
24 #include "nsISupports.h"
26 #include "nsITokenizer.h"
29 { 0x3de05873, 0xefa7, 0x410d, \
30 { 0xa4, 0x61, 0x80, 0x33, 0xaf, 0xd9, 0xe3, 0x26 } }
32 enum eAutoDetectResult
{
41 eDTDMode_quirks
, //pre 4.0 versions
42 eDTDMode_almost_standards
,
43 eDTDMode_full_standards
,
54 class nsIDTD
: public nsISupports
58 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDTD_IID
)
60 NS_IMETHOD
WillBuildModel(const CParserContext
& aParserContext
,
61 nsITokenizer
* aTokenizer
,
62 nsIContentSink
* aSink
) = 0;
65 * Called by the parser after the parsing process has concluded
67 * @param anErrorCode - contains error code resulting from parse process
70 NS_IMETHOD
DidBuildModel(nsresult anErrorCode
) = 0;
73 * Called (possibly repeatedly) by the parser to parse tokens and construct
74 * the document model via the sink provided to WillBuildModel.
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)
83 NS_IMETHOD
BuildModel(nsITokenizer
* aTokenizer
, nsIContentSink
* aSink
) = 0;
86 * This method is called to determine whether or not a tag of one
87 * type can contain a tag of another type.
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
94 NS_IMETHOD_(bool) CanContain(int32_t aParent
,int32_t aChild
) const = 0;
97 * This method gets called to determine whether a given
98 * tag is itself a container
100 * @update gess 3/25/98
101 * @param aTag -- tag to test for containership
102 * @return true if given tag can contain other tags
104 NS_IMETHOD_(bool) IsContainer(int32_t aTag
) const = 0;
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.
112 * @update harishd 07/22/99
116 NS_IMETHOD_(void) Terminate() = 0;
118 NS_IMETHOD_(int32_t) GetType() = 0;
121 * Call this method after calling WillBuildModel to determine what mode the
122 * DTD actually is using, as it may differ from aParserContext.mDTDMode.
124 NS_IMETHOD_(nsDTDMode
) GetMode() const = 0;
127 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDTD
, NS_IDTD_IID
)
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___ */