1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
---|
2 | /* ***** BEGIN LICENSE BLOCK ***** |
---|
3 | * Version: NPL 1.1/GPL 2.0/LGPL 2.1 |
---|
4 | * |
---|
5 | * The contents of this file are subject to the Netscape Public License |
---|
6 | * Version 1.1 (the "License"); you may not use this file except in |
---|
7 | * compliance with the License. You may obtain a copy of the License at |
---|
8 | * http://www.mozilla.org/NPL/ |
---|
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 | * |
---|
25 | * Alternatively, the contents of this file may be used under the terms of |
---|
26 | * either the GNU General Public License Version 2 or later (the "GPL"), or |
---|
27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
---|
28 | * in which case the provisions of the GPL or the LGPL are applicable instead |
---|
29 | * of those above. If you wish to allow use of your version of this file only |
---|
30 | * under the terms of either the GPL or the LGPL, and not to allow others to |
---|
31 | * use your version of this file under the terms of the NPL, indicate your |
---|
32 | * decision by deleting the provisions above and replace them with the notice |
---|
33 | * and other provisions required by the GPL or the LGPL. If you do not delete |
---|
34 | * the provisions above, a recipient may use your version of this file under |
---|
35 | * the terms of any one of the NPL, the GPL or the LGPL. |
---|
36 | * |
---|
37 | * ***** END LICENSE BLOCK ***** */ |
---|
38 | |
---|
39 | |
---|
40 | /** |
---|
41 | * MODULE NOTES: |
---|
42 | * @update gess 4/1/98 |
---|
43 | * |
---|
44 | */ |
---|
45 | |
---|
46 | #ifndef __NSHTMLTOKENIZER |
---|
47 | #define __NSHTMLTOKENIZER |
---|
48 | |
---|
49 | #include "nsISupports.h" |
---|
50 | #include "nsITokenizer.h" |
---|
51 | #include "nsIDTD.h" |
---|
52 | #include "prtypes.h" |
---|
53 | #include "nsDeque.h" |
---|
54 | #include "nsScanner.h" |
---|
55 | #include "nsHTMLTokens.h" |
---|
56 | #include "nsDTDUtils.h" |
---|
57 | |
---|
58 | #define NS_HTMLTOKENIZER_IID \ |
---|
59 | {0xe4238ddd, 0x9eb6, 0x11d2, \ |
---|
60 | {0xba, 0xa5, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }} |
---|
61 | |
---|
62 | |
---|
63 | /*************************************************************** |
---|
64 | Notes: |
---|
65 | ***************************************************************/ |
---|
66 | |
---|
67 | #ifdef _MSC_VER |
---|
68 | #pragma warning( disable : 4275 ) |
---|
69 | #endif |
---|
70 | |
---|
71 | class nsHTMLTokenizer : public nsITokenizer { |
---|
72 | public: |
---|
73 | |
---|
74 | NS_DECL_ISUPPORTS |
---|
75 | NS_DECL_NSITOKENIZER |
---|
76 | nsHTMLTokenizer(PRInt32 aParseMode = eDTDMode_quirks, |
---|
77 | eParserDocType aDocType = eHTML3_Quirks, |
---|
78 | eParserCommands aCommand = eViewNormal); |
---|
79 | virtual ~nsHTMLTokenizer(); |
---|
80 | |
---|
81 | protected: |
---|
82 | |
---|
83 | virtual nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens); |
---|
84 | virtual nsresult ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,PRBool& aFlushTokens); |
---|
85 | virtual nsresult ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); |
---|
86 | virtual nsresult ConsumeAttributes(PRUnichar aChar, CToken* aToken, nsScanner& aScanner); |
---|
87 | virtual nsresult ConsumeEntity(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); |
---|
88 | virtual nsresult ConsumeWhitespace(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); |
---|
89 | virtual nsresult ConsumeComment(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); |
---|
90 | virtual nsresult ConsumeNewline(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); |
---|
91 | virtual nsresult ConsumeText(CToken*& aToken,nsScanner& aScanner); |
---|
92 | virtual nsresult ConsumeSpecialMarkup(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); |
---|
93 | virtual nsresult ConsumeProcessingInstruction(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner); |
---|
94 | |
---|
95 | nsresult ScanDocStructure(PRBool aIsFinalChunk); |
---|
96 | |
---|
97 | virtual void PreserveToken(CStartToken* aStartToken, nsScanner& aScanner, nsScannerIterator aOrigin); |
---|
98 | |
---|
99 | static void AddToken(CToken*& aToken,nsresult aResult,nsDeque* aDeque,nsTokenAllocator* aTokenAllocator); |
---|
100 | |
---|
101 | nsDeque mTokenDeque; |
---|
102 | PRPackedBool mIsFinalChunk; |
---|
103 | nsTokenAllocator* mTokenAllocator; |
---|
104 | PRInt32 mTokenScanPos; |
---|
105 | PRUint32 mFlags; |
---|
106 | eHTMLTags mPreserveTarget; // Tag whose content is preserved |
---|
107 | }; |
---|
108 | |
---|
109 | extern nsresult NS_NewHTMLTokenizer(nsITokenizer** aInstancePtrResult, |
---|
110 | PRInt32 aMode,eParserDocType aDocType, |
---|
111 | eParserCommands aCommand); |
---|
112 | |
---|
113 | #endif |
---|
114 | |
---|
115 | |
---|