1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/parser/htmlparser/public/nsIDTD.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,138 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsIDTD_h___ 1.10 +#define nsIDTD_h___ 1.11 + 1.12 +/** 1.13 + * MODULE NOTES: 1.14 + * @update gess 7/20/98 1.15 + * 1.16 + * This interface defines standard interface for DTD's. Note that this 1.17 + * isn't HTML specific. DTD's have several functions within the parser 1.18 + * system: 1.19 + * 1) To coordinate the consumption of an input stream via the 1.20 + * parser 1.21 + * 2) To serve as proxy to represent the containment rules of the 1.22 + * underlying document 1.23 + * 3) To offer autodetection services to the parser (mainly for doc 1.24 + * conversion) 1.25 + * */ 1.26 + 1.27 +#include "nsISupports.h" 1.28 +#include "nsString.h" 1.29 +#include "nsITokenizer.h" 1.30 + 1.31 +#define NS_IDTD_IID \ 1.32 +{ 0x3de05873, 0xefa7, 0x410d, \ 1.33 + { 0xa4, 0x61, 0x80, 0x33, 0xaf, 0xd9, 0xe3, 0x26 } } 1.34 + 1.35 +enum eAutoDetectResult { 1.36 + eUnknownDetect, 1.37 + eValidDetect, 1.38 + ePrimaryDetect, 1.39 + eInvalidDetect 1.40 +}; 1.41 + 1.42 +enum nsDTDMode { 1.43 + eDTDMode_unknown = 0, 1.44 + eDTDMode_quirks, //pre 4.0 versions 1.45 + eDTDMode_almost_standards, 1.46 + eDTDMode_full_standards, 1.47 + eDTDMode_autodetect, 1.48 + eDTDMode_fragment 1.49 +}; 1.50 + 1.51 + 1.52 +class nsIParser; 1.53 +class nsIURI; 1.54 +class nsIContentSink; 1.55 +class CParserContext; 1.56 + 1.57 +class nsIDTD : public nsISupports 1.58 +{ 1.59 +public: 1.60 + 1.61 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDTD_IID) 1.62 + 1.63 + NS_IMETHOD WillBuildModel(const CParserContext& aParserContext, 1.64 + nsITokenizer* aTokenizer, 1.65 + nsIContentSink* aSink) = 0; 1.66 + 1.67 + /** 1.68 + * Called by the parser after the parsing process has concluded 1.69 + * @update gess5/18/98 1.70 + * @param anErrorCode - contains error code resulting from parse process 1.71 + * @return 1.72 + */ 1.73 + NS_IMETHOD DidBuildModel(nsresult anErrorCode) = 0; 1.74 + 1.75 + /** 1.76 + * Called (possibly repeatedly) by the parser to parse tokens and construct 1.77 + * the document model via the sink provided to WillBuildModel. 1.78 + * 1.79 + * @param aTokenizer - tokenizer providing the token stream to be parsed 1.80 + * @param aCountLines - informs the DTD whether to count newlines 1.81 + * (not wanted, e.g., when handling document.write) 1.82 + * @param aCharsetPtr - address of an nsCString containing the charset 1.83 + * that the DTD should use (pointer in case the DTD 1.84 + * opts to ignore this parameter) 1.85 + */ 1.86 + NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink) = 0; 1.87 + 1.88 + /** 1.89 + * This method is called to determine whether or not a tag of one 1.90 + * type can contain a tag of another type. 1.91 + * 1.92 + * @update gess 3/25/98 1.93 + * @param aParent -- int tag of parent container 1.94 + * @param aChild -- int tag of child container 1.95 + * @return true if parent can contain child 1.96 + */ 1.97 + NS_IMETHOD_(bool) CanContain(int32_t aParent,int32_t aChild) const = 0; 1.98 + 1.99 + /** 1.100 + * This method gets called to determine whether a given 1.101 + * tag is itself a container 1.102 + * 1.103 + * @update gess 3/25/98 1.104 + * @param aTag -- tag to test for containership 1.105 + * @return true if given tag can contain other tags 1.106 + */ 1.107 + NS_IMETHOD_(bool) IsContainer(int32_t aTag) const = 0; 1.108 + 1.109 + /** 1.110 + * Use this id you want to stop the building content model 1.111 + * --------------[ Sets DTD to STOP mode ]---------------- 1.112 + * It's recommended to use this method in accordance with 1.113 + * the parser's terminate() method. 1.114 + * 1.115 + * @update harishd 07/22/99 1.116 + * @param 1.117 + * @return 1.118 + */ 1.119 + NS_IMETHOD_(void) Terminate() = 0; 1.120 + 1.121 + NS_IMETHOD_(int32_t) GetType() = 0; 1.122 + 1.123 + /** 1.124 + * Call this method after calling WillBuildModel to determine what mode the 1.125 + * DTD actually is using, as it may differ from aParserContext.mDTDMode. 1.126 + */ 1.127 + NS_IMETHOD_(nsDTDMode) GetMode() const = 0; 1.128 +}; 1.129 + 1.130 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIDTD, NS_IDTD_IID) 1.131 + 1.132 +#define NS_DECL_NSIDTD \ 1.133 + NS_IMETHOD WillBuildModel( const CParserContext& aParserContext, nsITokenizer* aTokenizer, nsIContentSink* aSink);\ 1.134 + NS_IMETHOD DidBuildModel(nsresult anErrorCode);\ 1.135 + NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink);\ 1.136 + NS_IMETHOD_(bool) CanContain(int32_t aParent,int32_t aChild) const;\ 1.137 + NS_IMETHOD_(bool) IsContainer(int32_t aTag) const;\ 1.138 + NS_IMETHOD_(void) Terminate();\ 1.139 + NS_IMETHOD_(int32_t) GetType();\ 1.140 + NS_IMETHOD_(nsDTDMode) GetMode() const; 1.141 +#endif /* nsIDTD_h___ */