1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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"
30 0x3de05873, 0xefa7, 0x410d, { \
31 0xa4, 0x61, 0x80, 0x33, 0xaf, 0xd9, 0xe3, 0x26 \
35 enum eAutoDetectResult
{
44 eDTDMode_quirks
, // pre 4.0 versions
45 eDTDMode_almost_standards
,
46 eDTDMode_full_standards
,
54 class nsIDTD
: public nsISupports
{
56 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDTD_IID
)
58 NS_IMETHOD
WillBuildModel(const CParserContext
& aParserContext
,
59 nsITokenizer
* aTokenizer
,
60 nsIContentSink
* aSink
) = 0;
63 * Called by the parser after the parsing process has concluded
65 * @param anErrorCode - contains error code resulting from parse process
68 NS_IMETHOD
DidBuildModel(nsresult anErrorCode
) = 0;
71 * Called (possibly repeatedly) by the parser to parse tokens and construct
72 * the document model via the sink provided to WillBuildModel.
74 * @param aTokenizer - tokenizer providing the token stream to be parsed
75 * @param aCountLines - informs the DTD whether to count newlines
76 * (not wanted, e.g., when handling document.write)
77 * @param aCharsetPtr - address of an nsCString containing the charset
78 * that the DTD should use (pointer in case the DTD
79 * opts to ignore this parameter)
81 NS_IMETHOD
BuildModel(nsITokenizer
* aTokenizer
, nsIContentSink
* aSink
) = 0;
84 * This method is called to determine whether or not a tag of one
85 * type can contain a tag of another type.
87 * @update gess 3/25/98
88 * @param aParent -- int tag of parent container
89 * @param aChild -- int tag of child container
90 * @return true if parent can contain child
92 NS_IMETHOD_(bool) CanContain(int32_t aParent
, int32_t aChild
) const = 0;
95 * This method gets called to determine whether a given
96 * tag is itself a container
98 * @update gess 3/25/98
99 * @param aTag -- tag to test for containership
100 * @return true if given tag can contain other tags
102 NS_IMETHOD_(bool) IsContainer(int32_t aTag
) const = 0;
105 * Use this id you want to stop the building content model
106 * --------------[ Sets DTD to STOP mode ]----------------
107 * It's recommended to use this method in accordance with
108 * the parser's terminate() method.
110 * @update harishd 07/22/99
114 NS_IMETHOD_(void) Terminate() = 0;
116 NS_IMETHOD_(int32_t) GetType() = 0;
119 * Call this method after calling WillBuildModel to determine what mode the
120 * DTD actually is using, as it may differ from aParserContext.mDTDMode.
122 NS_IMETHOD_(nsDTDMode
) GetMode() const = 0;
125 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDTD
, NS_IDTD_IID
)
127 #define NS_DECL_NSIDTD \
128 NS_IMETHOD WillBuildModel(const CParserContext& aParserContext, \
129 nsITokenizer* aTokenizer, nsIContentSink* aSink) \
131 NS_IMETHOD DidBuildModel(nsresult anErrorCode) override; \
132 NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink) \
135 CanContain(int32_t aParent, int32_t aChild) const override; \
136 NS_IMETHOD_(bool) IsContainer(int32_t aTag) const override; \
137 NS_IMETHOD_(void) Terminate() override; \
138 NS_IMETHOD_(int32_t) GetType() override; \
139 NS_IMETHOD_(nsDTDMode) GetMode() const override;
140 #endif /* nsIDTD_h___ */