Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef nsSAXXMLReader_h__
7 : #define nsSAXXMLReader_h__
8 :
9 : #include "nsCOMPtr.h"
10 : #include "nsIContentSink.h"
11 : #include "nsIExtendedExpatSink.h"
12 : #include "nsIParser.h"
13 : #include "nsIURI.h"
14 : #include "nsISAXXMLReader.h"
15 : #include "nsISAXContentHandler.h"
16 : #include "nsISAXDTDHandler.h"
17 : #include "nsISAXErrorHandler.h"
18 : #include "nsISAXLexicalHandler.h"
19 : #include "nsIMozSAXXMLDeclarationHandler.h"
20 : #include "nsCycleCollectionParticipant.h"
21 : #include "mozilla/Attributes.h"
22 : #include "mozilla/NotNull.h"
23 :
24 : #define NS_SAXXMLREADER_CONTRACTID "@mozilla.org/saxparser/xmlreader;1"
25 : #define NS_SAXXMLREADER_CID \
26 : { 0xab1da296, 0x6125, 0x40ba, \
27 : { 0x96, 0xd0, 0x47, 0xa8, 0x28, 0x2a, 0xe3, 0xdb} }
28 :
29 : class nsSAXXMLReader final : public nsISAXXMLReader,
30 : public nsIExtendedExpatSink,
31 : public nsIContentSink
32 : {
33 : public:
34 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
35 0 : NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsSAXXMLReader, nsISAXXMLReader)
36 : NS_DECL_NSIEXPATSINK
37 : NS_DECL_NSIEXTENDEDEXPATSINK
38 : NS_DECL_NSISAXXMLREADER
39 : NS_DECL_NSIREQUESTOBSERVER
40 : NS_DECL_NSISTREAMLISTENER
41 :
42 : nsSAXXMLReader();
43 :
44 : //nsIContentSink
45 0 : NS_IMETHOD WillParse() override
46 : {
47 0 : return NS_OK;
48 : }
49 :
50 : NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
51 : NS_IMETHOD DidBuildModel(bool aTerminated) override;
52 : NS_IMETHOD SetParser(nsParserBase* aParser) override;
53 :
54 0 : NS_IMETHOD WillInterrupt() override
55 : {
56 0 : return NS_OK;
57 : }
58 :
59 0 : NS_IMETHOD WillResume() override
60 : {
61 0 : return NS_OK;
62 : }
63 :
64 0 : virtual void FlushPendingNotifications(mozilla::FlushType aType) override
65 : {
66 0 : }
67 :
68 0 : virtual void SetDocumentCharset(NotNull<const Encoding*> aEncoding) override
69 : {
70 0 : }
71 :
72 0 : virtual nsISupports *GetTarget() override
73 : {
74 0 : return nullptr;
75 : }
76 :
77 : private:
78 0 : ~nsSAXXMLReader() {}
79 :
80 : nsCOMPtr<nsISAXContentHandler> mContentHandler;
81 : nsCOMPtr<nsISAXDTDHandler> mDTDHandler;
82 : nsCOMPtr<nsISAXErrorHandler> mErrorHandler;
83 : nsCOMPtr<nsISAXLexicalHandler> mLexicalHandler;
84 : nsCOMPtr<nsIMozSAXXMLDeclarationHandler> mDeclarationHandler;
85 : nsCOMPtr<nsIURI> mBaseURI;
86 : nsCOMPtr<nsIStreamListener> mListener;
87 : nsCOMPtr<nsIRequestObserver> mParserObserver;
88 : bool mIsAsyncParse;
89 : static bool TryChannelCharset(nsIChannel *aChannel,
90 : int32_t& aCharsetSource,
91 : NotNull<const Encoding*>& aEncoding);
92 : nsresult EnsureBaseURI();
93 : nsresult InitParser(nsIRequestObserver *aListener, nsIChannel *aChannel);
94 : nsresult SplitExpatName(const char16_t *aExpatName,
95 : nsString &aURI,
96 : nsString &aLocalName,
97 : nsString &aQName);
98 : nsString mPublicId;
99 : nsString mSystemId;
100 :
101 : // Feature flags
102 : bool mEnableNamespacePrefixes;
103 : };
104 :
105 : #endif // nsSAXXMLReader_h__
|