Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_XMLDocument_h
8 : #define mozilla_dom_XMLDocument_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "mozilla/dom/BindingDeclarations.h"
12 : #include "nsDocument.h"
13 : #include "nsIDOMXMLDocument.h"
14 : #include "nsIScriptContext.h"
15 :
16 : class nsIURI;
17 : class nsIChannel;
18 :
19 : namespace mozilla {
20 : namespace dom {
21 :
22 : class XMLDocument : public nsDocument,
23 : public nsIDOMXMLDocument
24 : {
25 : public:
26 : explicit XMLDocument(const char* aContentType = "application/xml");
27 :
28 : NS_DECL_ISUPPORTS_INHERITED
29 :
30 : virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) override;
31 : virtual void ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
32 : nsIPrincipal* aPrincipal) override;
33 :
34 : virtual void SetSuppressParserErrorElement(bool aSuppress) override;
35 : virtual bool SuppressParserErrorElement() override;
36 :
37 : virtual void SetSuppressParserErrorConsoleMessages(bool aSuppress) override;
38 : virtual bool SuppressParserErrorConsoleMessages() override;
39 :
40 : virtual nsresult StartDocumentLoad(const char* aCommand, nsIChannel* channel,
41 : nsILoadGroup* aLoadGroup,
42 : nsISupports* aContainer,
43 : nsIStreamListener **aDocListener,
44 : bool aReset = true,
45 : nsIContentSink* aSink = nullptr) override;
46 :
47 : virtual void EndLoad() override;
48 :
49 : // nsIDOMXMLDocument
50 : NS_DECL_NSIDOMXMLDOCUMENT
51 :
52 : virtual nsresult Init() override;
53 :
54 : virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
55 : bool aPreallocateChildren) const override;
56 :
57 : virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const override;
58 : // DocAddSizeOfIncludingThis is inherited from nsIDocument.
59 :
60 :
61 : // WebIDL API
62 : bool Load(const nsAString& aUrl, CallerType aCallerType, ErrorResult& aRv);
63 0 : bool Async() const
64 : {
65 0 : return mAsync;
66 : }
67 0 : void SetAsync(bool aAsync)
68 : {
69 0 : mAsync = aAsync;
70 0 : }
71 :
72 : // .location is [Unforgeable], so we have to make it clear that the
73 : // nsIDocument version applies to us (it's shadowed by the XPCOM thing on
74 : // nsDocument).
75 : using nsIDocument::GetLocation;
76 :
77 : protected:
78 : virtual ~XMLDocument();
79 :
80 : virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
81 :
82 : friend nsresult (::NS_NewXMLDocument)(nsIDocument**, bool, bool);
83 :
84 :
85 : // mChannelIsPending indicates whether we're currently asynchronously loading
86 : // data from mChannel (via document.load() or normal load). It's set to true
87 : // when we first find out about the channel (StartDocumentLoad) and set to
88 : // false in EndLoad or if ResetToURI() is called. In the latter case our
89 : // mChannel is also cancelled. Note that if this member is true, mChannel
90 : // cannot be null.
91 : bool mChannelIsPending;
92 : bool mAsync;
93 : bool mLoopingForSyncLoad;
94 :
95 : // If true. we're really a Document, not an XMLDocument
96 : bool mIsPlainDocument;
97 :
98 : // If true, do not output <parsererror> elements. Per spec, XMLHttpRequest
99 : // shouldn't output them, whereas DOMParser/others should (see bug 918703).
100 : bool mSuppressParserErrorElement;
101 :
102 : // If true, do not log parsing errors to the web console (see bug 884693).
103 : bool mSuppressParserErrorConsoleMessages;
104 : };
105 :
106 : } // namespace dom
107 : } // namespace mozilla
108 :
109 : #endif // mozilla_dom_XMLDocument_h
|