parser/htmlparser/public/nsIDTD.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial