Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / xml / XMLDocument.h
blob54ac3fb9ba08ba98d9ceb113e0ad2387ed24589b
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/. */
7 #ifndef mozilla_dom_XMLDocument_h
8 #define mozilla_dom_XMLDocument_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/BindingDeclarations.h"
12 #include "mozilla/dom/Document.h"
13 #include "nsIScriptContext.h"
15 class nsIURI;
16 class nsIChannel;
18 namespace mozilla::dom {
20 class XMLDocument : public Document {
21 public:
22 explicit XMLDocument(const char* aContentType = "application/xml");
24 NS_INLINE_DECL_REFCOUNTING_INHERITED(XMLDocument, Document)
26 virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) override;
27 virtual void ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
28 nsIPrincipal* aPrincipal,
29 nsIPrincipal* aPartitionedPrincipal) override;
31 virtual void SetSuppressParserErrorElement(bool aSuppress) override;
32 virtual bool SuppressParserErrorElement() override;
34 virtual void SetSuppressParserErrorConsoleMessages(bool aSuppress) override;
35 virtual bool SuppressParserErrorConsoleMessages() override;
37 virtual nsresult StartDocumentLoad(const char* aCommand, nsIChannel* channel,
38 nsILoadGroup* aLoadGroup,
39 nsISupports* aContainer,
40 nsIStreamListener** aDocListener,
41 bool aReset = true) override;
43 // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230, bug 1535398)
44 MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void EndLoad() override;
46 virtual nsresult Init() override;
48 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
50 virtual void DocAddSizeOfExcludingThis(
51 nsWindowSizes& aWindowSizes) const override;
52 // DocAddSizeOfIncludingThis is inherited from Document.
54 // .location is [Unforgeable], so we have to make it clear that the Document
55 // version applies to us (it's shadowed by the XPCOM thing on Document).
56 using Document::GetLocation;
58 protected:
59 virtual ~XMLDocument() = default;
61 virtual JSObject* WrapNode(JSContext* aCx,
62 JS::Handle<JSObject*> aGivenProto) override;
64 friend nsresult(::NS_NewXMLDocument)(Document**, bool, bool);
66 // mChannelIsPending indicates whether we're currently asynchronously loading
67 // data from mChannel. It's set to true when we first find out about the
68 // channel (StartDocumentLoad) and set to false in EndLoad or if ResetToURI()
69 // is called. In the latter case our mChannel is also cancelled. Note that
70 // if this member is true, mChannel cannot be null.
71 bool mChannelIsPending;
73 // If true. we're really a Document, not an XMLDocument
74 bool mIsPlainDocument;
76 // If true, do not output <parsererror> elements. Per spec, XMLHttpRequest
77 // shouldn't output them, whereas DOMParser/others should (see bug 918703).
78 bool mSuppressParserErrorElement;
80 // If true, do not log parsing errors to the web console (see bug 884693).
81 bool mSuppressParserErrorConsoleMessages;
84 } // namespace mozilla::dom
86 #endif // mozilla_dom_XMLDocument_h