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"
18 namespace mozilla::dom
{
20 class XMLDocument
: public Document
{
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(nsIPrincipal
* aPrincipal
,
47 nsIPrincipal
* aPartitionedPrincipal
) override
;
49 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
51 virtual void DocAddSizeOfExcludingThis(
52 nsWindowSizes
& aWindowSizes
) const override
;
53 // DocAddSizeOfIncludingThis is inherited from Document.
55 // .location is [Unforgeable], so we have to make it clear that the Document
56 // version applies to us (it's shadowed by the XPCOM thing on Document).
57 using Document::GetLocation
;
60 virtual ~XMLDocument() = default;
62 virtual JSObject
* WrapNode(JSContext
* aCx
,
63 JS::Handle
<JSObject
*> aGivenProto
) override
;
65 friend nsresult(::NS_NewXMLDocument
)(Document
**, nsIPrincipal
*, nsIPrincipal
*,
68 // mChannelIsPending indicates whether we're currently asynchronously loading
69 // data from mChannel. It's set to true when we first find out about the
70 // channel (StartDocumentLoad) and set to false in EndLoad or if ResetToURI()
71 // is called. In the latter case our mChannel is also cancelled. Note that
72 // if this member is true, mChannel cannot be null.
73 bool mChannelIsPending
;
75 // If true. we're really a Document, not an XMLDocument
76 bool mIsPlainDocument
;
78 // If true, do not output <parsererror> elements. Per spec, XMLHttpRequest
79 // shouldn't output them, whereas DOMParser/others should (see bug 918703).
80 bool mSuppressParserErrorElement
;
82 // If true, do not log parsing errors to the web console (see bug 884693).
83 bool mSuppressParserErrorConsoleMessages
;
86 } // namespace mozilla::dom
88 #endif // mozilla_dom_XMLDocument_h