/parser/htmlparser/public/nsIDTD.h

http://github.com/zpao/v8monkey · C Header · 174 lines · 56 code · 20 blank · 98 comment · 0 complexity · b51a8790732be9628bccc179b085f80f MD5 · raw file

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either of the GNU General Public License Version 2 or later (the "GPL"),
  26. * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #ifndef nsIDTD_h___
  38. #define nsIDTD_h___
  39. /**
  40. * MODULE NOTES:
  41. * @update gess 7/20/98
  42. *
  43. * This interface defines standard interface for DTD's. Note that this
  44. * isn't HTML specific. DTD's have several functions within the parser
  45. * system:
  46. * 1) To coordinate the consumption of an input stream via the
  47. * parser
  48. * 2) To serve as proxy to represent the containment rules of the
  49. * underlying document
  50. * 3) To offer autodetection services to the parser (mainly for doc
  51. * conversion)
  52. * */
  53. #include "nsISupports.h"
  54. #include "nsStringGlue.h"
  55. #include "prtypes.h"
  56. #include "nsITokenizer.h"
  57. #define NS_IDTD_IID \
  58. { 0x3de05873, 0xefa7, 0x410d, \
  59. { 0xa4, 0x61, 0x80, 0x33, 0xaf, 0xd9, 0xe3, 0x26 } }
  60. enum eAutoDetectResult {
  61. eUnknownDetect,
  62. eValidDetect,
  63. ePrimaryDetect,
  64. eInvalidDetect
  65. };
  66. enum nsDTDMode {
  67. eDTDMode_unknown = 0,
  68. eDTDMode_quirks, //pre 4.0 versions
  69. eDTDMode_almost_standards,
  70. eDTDMode_full_standards,
  71. eDTDMode_autodetect,
  72. eDTDMode_fragment
  73. };
  74. class nsIParser;
  75. class CToken;
  76. class nsIURI;
  77. class nsIContentSink;
  78. class CParserContext;
  79. class nsIDTD : public nsISupports
  80. {
  81. public:
  82. NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDTD_IID)
  83. NS_IMETHOD WillBuildModel(const CParserContext& aParserContext,
  84. nsITokenizer* aTokenizer,
  85. nsIContentSink* aSink) = 0;
  86. /**
  87. * Called by the parser after the parsing process has concluded
  88. * @update gess5/18/98
  89. * @param anErrorCode - contains error code resulting from parse process
  90. * @return
  91. */
  92. NS_IMETHOD DidBuildModel(nsresult anErrorCode) = 0;
  93. /**
  94. * Called (possibly repeatedly) by the parser to parse tokens and construct
  95. * the document model via the sink provided to WillBuildModel.
  96. *
  97. * @param aTokenizer - tokenizer providing the token stream to be parsed
  98. * @param aCountLines - informs the DTD whether to count newlines
  99. * (not wanted, e.g., when handling document.write)
  100. * @param aCharsetPtr - address of an nsCString containing the charset
  101. * that the DTD should use (pointer in case the DTD
  102. * opts to ignore this parameter)
  103. */
  104. NS_IMETHOD BuildModel(nsITokenizer* aTokenizer,
  105. bool aCountLines,
  106. const nsCString* aCharsetPtr) = 0;
  107. /**
  108. * This method is called to determine whether or not a tag of one
  109. * type can contain a tag of another type.
  110. *
  111. * @update gess 3/25/98
  112. * @param aParent -- int tag of parent container
  113. * @param aChild -- int tag of child container
  114. * @return true if parent can contain child
  115. */
  116. NS_IMETHOD_(bool) CanContain(PRInt32 aParent,PRInt32 aChild) const = 0;
  117. /**
  118. * This method gets called to determine whether a given
  119. * tag is itself a container
  120. *
  121. * @update gess 3/25/98
  122. * @param aTag -- tag to test for containership
  123. * @return true if given tag can contain other tags
  124. */
  125. NS_IMETHOD_(bool) IsContainer(PRInt32 aTag) const = 0;
  126. /**
  127. * Use this id you want to stop the building content model
  128. * --------------[ Sets DTD to STOP mode ]----------------
  129. * It's recommended to use this method in accordance with
  130. * the parser's terminate() method.
  131. *
  132. * @update harishd 07/22/99
  133. * @param
  134. * @return
  135. */
  136. NS_IMETHOD_(void) Terminate() = 0;
  137. NS_IMETHOD_(PRInt32) GetType() = 0;
  138. /**
  139. * Call this method after calling WillBuildModel to determine what mode the
  140. * DTD actually is using, as it may differ from aParserContext.mDTDMode.
  141. */
  142. NS_IMETHOD_(nsDTDMode) GetMode() const = 0;
  143. };
  144. NS_DEFINE_STATIC_IID_ACCESSOR(nsIDTD, NS_IDTD_IID)
  145. #define NS_DECL_NSIDTD \
  146. NS_IMETHOD WillBuildModel( const CParserContext& aParserContext, nsITokenizer* aTokenizer, nsIContentSink* aSink);\
  147. NS_IMETHOD DidBuildModel(nsresult anErrorCode);\
  148. NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, bool aCountLines, const nsCString* aCharsetPtr);\
  149. NS_IMETHOD_(bool) CanContain(PRInt32 aParent,PRInt32 aChild) const;\
  150. NS_IMETHOD_(bool) IsContainer(PRInt32 aTag) const;\
  151. NS_IMETHOD_(void) Terminate();\
  152. NS_IMETHOD_(PRInt32) GetType();\
  153. NS_IMETHOD_(nsDTDMode) GetMode() const;
  154. #endif /* nsIDTD_h___ */