/work/obj-fuzz/dist/include/mozilla/dom/DOMParser.h
Line | Count | Source (jump to first uncovered line) |
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_DOMParser_h_ |
8 | | #define mozilla_dom_DOMParser_h_ |
9 | | |
10 | | #include "nsCOMPtr.h" |
11 | | #include "nsIDocument.h" |
12 | | #include "nsWrapperCache.h" |
13 | | #include "mozilla/ErrorResult.h" |
14 | | #include "mozilla/Span.h" |
15 | | #include "mozilla/dom/DOMParserBinding.h" |
16 | | #include "mozilla/dom/TypedArray.h" |
17 | | |
18 | | class nsIDocument; |
19 | | class nsIGlobalObject; |
20 | | |
21 | | namespace mozilla { |
22 | | namespace dom { |
23 | | |
24 | | class DOMParser final : public nsISupports, |
25 | | public nsWrapperCache |
26 | | { |
27 | | typedef mozilla::dom::GlobalObject GlobalObject; |
28 | | |
29 | | virtual ~DOMParser(); |
30 | | |
31 | | public: |
32 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
33 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMParser) |
34 | | |
35 | | // WebIDL API |
36 | | static already_AddRefed<DOMParser> |
37 | | Constructor(const GlobalObject& aOwner, |
38 | | mozilla::ErrorResult& rv); |
39 | | |
40 | | already_AddRefed<nsIDocument> |
41 | | ParseFromString(const nsAString& aStr, SupportedType aType, ErrorResult& aRv); |
42 | | |
43 | | // Sequence converts to Span, so we can use this overload for both |
44 | | // the Sequence case and our internal uses. |
45 | | already_AddRefed<nsIDocument> |
46 | | ParseFromBuffer(Span<const uint8_t> aBuf, SupportedType aType, |
47 | | ErrorResult& aRv); |
48 | | |
49 | | already_AddRefed<nsIDocument> |
50 | | ParseFromBuffer(const Uint8Array& aBuf, SupportedType aType, |
51 | | ErrorResult& aRv); |
52 | | |
53 | | already_AddRefed<nsIDocument> |
54 | | ParseFromStream(nsIInputStream* aStream, const nsAString& aCharset, |
55 | | int32_t aContentLength, SupportedType aType, |
56 | | ErrorResult& aRv); |
57 | | |
58 | | void |
59 | | ForceEnableXULXBL() |
60 | 0 | { |
61 | 0 | mForceEnableXULXBL = true; |
62 | 0 | } |
63 | | |
64 | | nsIGlobalObject* GetParentObject() const |
65 | 0 | { |
66 | 0 | return mOwner; |
67 | 0 | } |
68 | | |
69 | | virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override |
70 | 0 | { |
71 | 0 | return mozilla::dom::DOMParser_Binding::Wrap(aCx, this, aGivenProto); |
72 | 0 | } |
73 | | |
74 | | // A way to create a non-global-associated DOMParser from C++. |
75 | | static already_AddRefed<DOMParser> CreateWithoutGlobal(ErrorResult& aRv); |
76 | | |
77 | | private: |
78 | | DOMParser(nsIGlobalObject* aOwner, nsIPrincipal* aDocPrincipal, |
79 | | nsIURI* aDocumentURI, nsIURI* aBaseURI); |
80 | | |
81 | | already_AddRefed<nsIDocument> SetUpDocument(DocumentFlavor aFlavor, |
82 | | ErrorResult& aRv); |
83 | | |
84 | | nsCOMPtr<nsIGlobalObject> mOwner; |
85 | | nsCOMPtr<nsIPrincipal> mPrincipal; |
86 | | nsCOMPtr<nsIURI> mDocumentURI; |
87 | | nsCOMPtr<nsIURI> mBaseURI; |
88 | | |
89 | | bool mForceEnableXULXBL; |
90 | | }; |
91 | | |
92 | | } // namespace dom |
93 | | } // namespace mozilla |
94 | | |
95 | | #endif |