1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 Robert Sayre.
18 : *
19 : * Portions created by the Initial Developer are Copyright (C) 2005
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 the GNU General Public License Version 2 or later (the "GPL"), or
26 : * 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 :
38 : #ifndef nsSAXXMLReader_h__
39 : #define nsSAXXMLReader_h__
40 :
41 : #include "nsCOMPtr.h"
42 : #include "nsIContentSink.h"
43 : #include "nsIExtendedExpatSink.h"
44 : #include "nsIParser.h"
45 : #include "nsIURI.h"
46 : #include "nsISAXXMLReader.h"
47 : #include "nsISAXContentHandler.h"
48 : #include "nsISAXDTDHandler.h"
49 : #include "nsISAXErrorHandler.h"
50 : #include "nsISAXLexicalHandler.h"
51 : #include "nsCycleCollectionParticipant.h"
52 :
53 : #define NS_SAXXMLREADER_CONTRACTID "@mozilla.org/saxparser/xmlreader;1"
54 : #define NS_SAXXMLREADER_CLASSNAME "SAX XML Reader"
55 : #define NS_SAXXMLREADER_CID \
56 : { 0xab1da296, 0x6125, 0x40ba, \
57 : { 0x96, 0xd0, 0x47, 0xa8, 0x28, 0x2a, 0xe3, 0xdb} }
58 :
59 : class nsSAXXMLReader : public nsISAXXMLReader,
60 : public nsIExtendedExpatSink,
61 : public nsIContentSink
62 205 : {
63 : public:
64 0 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
65 5568 : NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsSAXXMLReader, nsISAXXMLReader)
66 : NS_DECL_NSIEXPATSINK
67 : NS_DECL_NSIEXTENDEDEXPATSINK
68 : NS_DECL_NSISAXXMLREADER
69 : NS_DECL_NSIREQUESTOBSERVER
70 : NS_DECL_NSISTREAMLISTENER
71 :
72 : nsSAXXMLReader();
73 :
74 : //nsIContentSink
75 409 : NS_IMETHOD WillParse()
76 : {
77 409 : return NS_OK;
78 : }
79 :
80 : NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode);
81 : NS_IMETHOD DidBuildModel(bool aTerminated);
82 : NS_IMETHOD SetParser(nsParserBase* aParser);
83 :
84 204 : NS_IMETHOD WillInterrupt()
85 : {
86 204 : return NS_OK;
87 : }
88 :
89 409 : NS_IMETHOD WillResume()
90 : {
91 409 : return NS_OK;
92 : }
93 :
94 0 : virtual void FlushPendingNotifications(mozFlushType aType)
95 : {
96 0 : }
97 :
98 193 : NS_IMETHOD SetDocumentCharset(nsACString& aCharset)
99 : {
100 193 : return NS_OK;
101 : }
102 :
103 207 : virtual nsISupports *GetTarget()
104 : {
105 207 : return nsnull;
106 : }
107 :
108 : private:
109 : nsCOMPtr<nsISAXContentHandler> mContentHandler;
110 : nsCOMPtr<nsISAXDTDHandler> mDTDHandler;
111 : nsCOMPtr<nsISAXErrorHandler> mErrorHandler;
112 : nsCOMPtr<nsISAXLexicalHandler> mLexicalHandler;
113 : nsCOMPtr<nsIURI> mBaseURI;
114 : nsCOMPtr<nsIStreamListener> mListener;
115 : nsCOMPtr<nsIRequestObserver> mParserObserver;
116 : bool mIsAsyncParse;
117 : static bool TryChannelCharset(nsIChannel *aChannel,
118 : PRInt32& aCharsetSource,
119 : nsACString& aCharset);
120 : nsresult EnsureBaseURI();
121 : nsresult InitParser(nsIRequestObserver *aListener, nsIChannel *aChannel);
122 : nsresult SplitExpatName(const PRUnichar *aExpatName,
123 : nsString &aURI,
124 : nsString &aLocalName,
125 : nsString &aQName);
126 : nsString mPublicId;
127 : nsString mSystemId;
128 : };
129 :
130 : #endif // nsSAXXMLReader_h__
|