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