michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsIDTD_h___ michael@0: #define nsIDTD_h___ michael@0: michael@0: /** michael@0: * MODULE NOTES: michael@0: * @update gess 7/20/98 michael@0: * michael@0: * This interface defines standard interface for DTD's. Note that this michael@0: * isn't HTML specific. DTD's have several functions within the parser michael@0: * system: michael@0: * 1) To coordinate the consumption of an input stream via the michael@0: * parser michael@0: * 2) To serve as proxy to represent the containment rules of the michael@0: * underlying document michael@0: * 3) To offer autodetection services to the parser (mainly for doc michael@0: * conversion) michael@0: * */ michael@0: michael@0: #include "nsISupports.h" michael@0: #include "nsString.h" michael@0: #include "nsITokenizer.h" michael@0: michael@0: #define NS_IDTD_IID \ michael@0: { 0x3de05873, 0xefa7, 0x410d, \ michael@0: { 0xa4, 0x61, 0x80, 0x33, 0xaf, 0xd9, 0xe3, 0x26 } } michael@0: michael@0: enum eAutoDetectResult { michael@0: eUnknownDetect, michael@0: eValidDetect, michael@0: ePrimaryDetect, michael@0: eInvalidDetect michael@0: }; michael@0: michael@0: enum nsDTDMode { michael@0: eDTDMode_unknown = 0, michael@0: eDTDMode_quirks, //pre 4.0 versions michael@0: eDTDMode_almost_standards, michael@0: eDTDMode_full_standards, michael@0: eDTDMode_autodetect, michael@0: eDTDMode_fragment michael@0: }; michael@0: michael@0: michael@0: class nsIParser; michael@0: class nsIURI; michael@0: class nsIContentSink; michael@0: class CParserContext; michael@0: michael@0: class nsIDTD : public nsISupports michael@0: { michael@0: public: michael@0: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDTD_IID) michael@0: michael@0: NS_IMETHOD WillBuildModel(const CParserContext& aParserContext, michael@0: nsITokenizer* aTokenizer, michael@0: nsIContentSink* aSink) = 0; michael@0: michael@0: /** michael@0: * Called by the parser after the parsing process has concluded michael@0: * @update gess5/18/98 michael@0: * @param anErrorCode - contains error code resulting from parse process michael@0: * @return michael@0: */ michael@0: NS_IMETHOD DidBuildModel(nsresult anErrorCode) = 0; michael@0: michael@0: /** michael@0: * Called (possibly repeatedly) by the parser to parse tokens and construct michael@0: * the document model via the sink provided to WillBuildModel. michael@0: * michael@0: * @param aTokenizer - tokenizer providing the token stream to be parsed michael@0: * @param aCountLines - informs the DTD whether to count newlines michael@0: * (not wanted, e.g., when handling document.write) michael@0: * @param aCharsetPtr - address of an nsCString containing the charset michael@0: * that the DTD should use (pointer in case the DTD michael@0: * opts to ignore this parameter) michael@0: */ michael@0: NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink) = 0; michael@0: michael@0: /** michael@0: * This method is called to determine whether or not a tag of one michael@0: * type can contain a tag of another type. michael@0: * michael@0: * @update gess 3/25/98 michael@0: * @param aParent -- int tag of parent container michael@0: * @param aChild -- int tag of child container michael@0: * @return true if parent can contain child michael@0: */ michael@0: NS_IMETHOD_(bool) CanContain(int32_t aParent,int32_t aChild) const = 0; michael@0: michael@0: /** michael@0: * This method gets called to determine whether a given michael@0: * tag is itself a container michael@0: * michael@0: * @update gess 3/25/98 michael@0: * @param aTag -- tag to test for containership michael@0: * @return true if given tag can contain other tags michael@0: */ michael@0: NS_IMETHOD_(bool) IsContainer(int32_t aTag) const = 0; michael@0: michael@0: /** michael@0: * Use this id you want to stop the building content model michael@0: * --------------[ Sets DTD to STOP mode ]---------------- michael@0: * It's recommended to use this method in accordance with michael@0: * the parser's terminate() method. michael@0: * michael@0: * @update harishd 07/22/99 michael@0: * @param michael@0: * @return michael@0: */ michael@0: NS_IMETHOD_(void) Terminate() = 0; michael@0: michael@0: NS_IMETHOD_(int32_t) GetType() = 0; michael@0: michael@0: /** michael@0: * Call this method after calling WillBuildModel to determine what mode the michael@0: * DTD actually is using, as it may differ from aParserContext.mDTDMode. michael@0: */ michael@0: NS_IMETHOD_(nsDTDMode) GetMode() const = 0; michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsIDTD, NS_IDTD_IID) michael@0: michael@0: #define NS_DECL_NSIDTD \ michael@0: NS_IMETHOD WillBuildModel( const CParserContext& aParserContext, nsITokenizer* aTokenizer, nsIContentSink* aSink);\ michael@0: NS_IMETHOD DidBuildModel(nsresult anErrorCode);\ michael@0: NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink);\ michael@0: NS_IMETHOD_(bool) CanContain(int32_t aParent,int32_t aChild) const;\ michael@0: NS_IMETHOD_(bool) IsContainer(int32_t aTag) const;\ michael@0: NS_IMETHOD_(void) Terminate();\ michael@0: NS_IMETHOD_(int32_t) GetType();\ michael@0: NS_IMETHOD_(nsDTDMode) GetMode() const; michael@0: #endif /* nsIDTD_h___ */