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