Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_dom_DOMParser_h_ |
michael@0 | 7 | #define mozilla_dom_DOMParser_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsCOMPtr.h" |
michael@0 | 10 | #include "nsIDocument.h" |
michael@0 | 11 | #include "nsIDOMParser.h" |
michael@0 | 12 | #include "nsWeakReference.h" |
michael@0 | 13 | #include "nsWrapperCache.h" |
michael@0 | 14 | #include "mozilla/ErrorResult.h" |
michael@0 | 15 | #include "mozilla/dom/DOMParserBinding.h" |
michael@0 | 16 | #include "mozilla/dom/TypedArray.h" |
michael@0 | 17 | |
michael@0 | 18 | class nsIDocument; |
michael@0 | 19 | |
michael@0 | 20 | namespace mozilla { |
michael@0 | 21 | namespace dom { |
michael@0 | 22 | |
michael@0 | 23 | class DOMParser MOZ_FINAL : public nsIDOMParser, |
michael@0 | 24 | public nsSupportsWeakReference, |
michael@0 | 25 | public nsWrapperCache |
michael@0 | 26 | { |
michael@0 | 27 | typedef mozilla::dom::GlobalObject GlobalObject; |
michael@0 | 28 | public: |
michael@0 | 29 | DOMParser(); |
michael@0 | 30 | virtual ~DOMParser(); |
michael@0 | 31 | |
michael@0 | 32 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 33 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(DOMParser, |
michael@0 | 34 | nsIDOMParser) |
michael@0 | 35 | |
michael@0 | 36 | // nsIDOMParser |
michael@0 | 37 | NS_DECL_NSIDOMPARSER |
michael@0 | 38 | |
michael@0 | 39 | // WebIDL API |
michael@0 | 40 | static already_AddRefed<DOMParser> |
michael@0 | 41 | Constructor(const GlobalObject& aOwner, |
michael@0 | 42 | mozilla::ErrorResult& rv); |
michael@0 | 43 | |
michael@0 | 44 | static already_AddRefed<DOMParser> |
michael@0 | 45 | Constructor(const GlobalObject& aOwner, |
michael@0 | 46 | nsIPrincipal* aPrincipal, nsIURI* aDocumentURI, nsIURI* aBaseURI, |
michael@0 | 47 | mozilla::ErrorResult& rv); |
michael@0 | 48 | |
michael@0 | 49 | already_AddRefed<nsIDocument> |
michael@0 | 50 | ParseFromString(const nsAString& aStr, mozilla::dom::SupportedType aType, |
michael@0 | 51 | mozilla::ErrorResult& rv); |
michael@0 | 52 | |
michael@0 | 53 | already_AddRefed<nsIDocument> |
michael@0 | 54 | ParseFromBuffer(const mozilla::dom::Sequence<uint8_t>& aBuf, |
michael@0 | 55 | uint32_t aBufLen, mozilla::dom::SupportedType aType, |
michael@0 | 56 | mozilla::ErrorResult& rv); |
michael@0 | 57 | |
michael@0 | 58 | already_AddRefed<nsIDocument> |
michael@0 | 59 | ParseFromBuffer(const mozilla::dom::Uint8Array& aBuf, uint32_t aBufLen, |
michael@0 | 60 | mozilla::dom::SupportedType aType, |
michael@0 | 61 | mozilla::ErrorResult& rv); |
michael@0 | 62 | |
michael@0 | 63 | already_AddRefed<nsIDocument> |
michael@0 | 64 | ParseFromStream(nsIInputStream* aStream, const nsAString& aCharset, |
michael@0 | 65 | int32_t aContentLength, mozilla::dom::SupportedType aType, |
michael@0 | 66 | mozilla::ErrorResult& rv); |
michael@0 | 67 | |
michael@0 | 68 | void Init(nsIPrincipal* aPrincipal, nsIURI* aDocumentURI, |
michael@0 | 69 | nsIURI* aBaseURI, mozilla::ErrorResult& rv); |
michael@0 | 70 | |
michael@0 | 71 | nsISupports* GetParentObject() const |
michael@0 | 72 | { |
michael@0 | 73 | return mOwner; |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE |
michael@0 | 77 | { |
michael@0 | 78 | return mozilla::dom::DOMParserBinding::Wrap(aCx, this); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | private: |
michael@0 | 82 | DOMParser(nsISupports* aOwner) : mOwner(aOwner), mAttemptedInit(false) |
michael@0 | 83 | { |
michael@0 | 84 | MOZ_ASSERT(aOwner); |
michael@0 | 85 | SetIsDOMBinding(); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | nsresult InitInternal(nsISupports* aOwner, nsIPrincipal* prin, |
michael@0 | 89 | nsIURI* documentURI, nsIURI* baseURI); |
michael@0 | 90 | |
michael@0 | 91 | nsresult SetUpDocument(DocumentFlavor aFlavor, nsIDOMDocument** aResult); |
michael@0 | 92 | |
michael@0 | 93 | // Helper for ParseFromString |
michael@0 | 94 | nsresult ParseFromString(const nsAString& str, const char *contentType, |
michael@0 | 95 | nsIDOMDocument **aResult); |
michael@0 | 96 | |
michael@0 | 97 | class AttemptedInitMarker { |
michael@0 | 98 | public: |
michael@0 | 99 | AttemptedInitMarker(bool* aAttemptedInit) : |
michael@0 | 100 | mAttemptedInit(aAttemptedInit) |
michael@0 | 101 | {} |
michael@0 | 102 | |
michael@0 | 103 | ~AttemptedInitMarker() { |
michael@0 | 104 | *mAttemptedInit = true; |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | private: |
michael@0 | 108 | bool* mAttemptedInit; |
michael@0 | 109 | }; |
michael@0 | 110 | |
michael@0 | 111 | nsCOMPtr<nsISupports> mOwner; |
michael@0 | 112 | nsCOMPtr<nsIPrincipal> mPrincipal; |
michael@0 | 113 | nsCOMPtr<nsIPrincipal> mOriginalPrincipal; |
michael@0 | 114 | nsCOMPtr<nsIURI> mDocumentURI; |
michael@0 | 115 | nsCOMPtr<nsIURI> mBaseURI; |
michael@0 | 116 | nsWeakPtr mScriptHandlingObject; |
michael@0 | 117 | |
michael@0 | 118 | bool mAttemptedInit; |
michael@0 | 119 | }; |
michael@0 | 120 | |
michael@0 | 121 | } // namespace dom |
michael@0 | 122 | } // namespace mozilla |
michael@0 | 123 | |
michael@0 | 124 | #endif |