Bug 1908539 restrict MacOS platform audio processing to Nightly r=webrtc-reviewers...
[gecko.git] / dom / base / DOMParser.h
blob47773b5212bbf8c940bc91e35f020ab039864a16
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_DOMParser_h_
8 #define mozilla_dom_DOMParser_h_
10 #include "nsCOMPtr.h"
11 #include "mozilla/dom/Document.h"
12 #include "nsWrapperCache.h"
13 #include "mozilla/Span.h"
14 #include "mozilla/dom/DOMParserBinding.h"
15 #include "mozilla/dom/TypedArray.h"
17 class nsIGlobalObject;
19 namespace mozilla {
20 class ErrorResult;
22 namespace dom {
24 class DOMParser final : public nsISupports, public nsWrapperCache {
25 typedef mozilla::dom::GlobalObject GlobalObject;
27 virtual ~DOMParser();
29 public:
30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
31 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(DOMParser)
33 // WebIDL API
34 static already_AddRefed<DOMParser> Constructor(const GlobalObject& aOwner,
35 mozilla::ErrorResult& rv);
37 already_AddRefed<Document> ParseFromString(const nsAString& aStr,
38 SupportedType aType,
39 ErrorResult& aRv);
41 // ChromeOnly API
42 already_AddRefed<Document> ParseFromSafeString(const nsAString& aStr,
43 SupportedType aType,
44 ErrorResult& aRv);
45 // Sequence converts to Span, so we can use this overload for both
46 // the Sequence case and our internal uses.
47 already_AddRefed<Document> ParseFromBuffer(Span<const uint8_t> aBuf,
48 SupportedType aType,
49 ErrorResult& aRv);
51 already_AddRefed<Document> ParseFromBuffer(const Uint8Array& aBuf,
52 SupportedType aType,
53 ErrorResult& aRv);
55 already_AddRefed<Document> ParseFromStream(nsIInputStream* aStream,
56 const nsAString& aCharset,
57 int32_t aContentLength,
58 SupportedType aType,
59 ErrorResult& aRv);
61 void ForceEnableXULXBL() {
62 mForceEnableXULXBL = true;
63 ForceEnableDTD();
66 void ForceEnableDTD() { mForceEnableDTD = true; }
68 nsIGlobalObject* GetParentObject() const { return mOwner; }
70 virtual JSObject* WrapObject(JSContext* aCx,
71 JS::Handle<JSObject*> aGivenProto) override {
72 return mozilla::dom::DOMParser_Binding::Wrap(aCx, this, aGivenProto);
75 // A way to create a non-global-associated DOMParser from C++.
76 static already_AddRefed<DOMParser> CreateWithoutGlobal(ErrorResult& aRv);
78 private:
79 DOMParser(nsIGlobalObject* aOwner, nsIPrincipal* aDocPrincipal,
80 nsIURI* aDocumentURI);
82 already_AddRefed<Document> SetUpDocument(DocumentFlavor aFlavor,
83 ErrorResult& aRv);
85 nsCOMPtr<nsIGlobalObject> mOwner;
86 nsCOMPtr<nsIPrincipal> mPrincipal;
87 nsCOMPtr<nsIURI> mDocumentURI;
89 bool mForceEnableXULXBL;
90 bool mForceEnableDTD;
93 } // namespace dom
94 } // namespace mozilla
96 #endif