|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef mozilla_dom_DOMImplementation_h |
|
6 #define mozilla_dom_DOMImplementation_h |
|
7 |
|
8 #include "nsIDOMDOMImplementation.h" |
|
9 #include "nsWrapperCache.h" |
|
10 |
|
11 #include "mozilla/Attributes.h" |
|
12 #include "mozilla/ErrorResult.h" |
|
13 #include "nsCOMPtr.h" |
|
14 #include "nsCycleCollectionParticipant.h" |
|
15 #include "nsIDocument.h" |
|
16 #include "nsIScriptGlobalObject.h" |
|
17 #include "nsIURI.h" |
|
18 #include "nsIWeakReferenceUtils.h" |
|
19 #include "nsString.h" |
|
20 |
|
21 class nsIDOMDocument; |
|
22 |
|
23 namespace mozilla { |
|
24 namespace dom { |
|
25 class DocumentType; |
|
26 |
|
27 class DOMImplementation MOZ_FINAL : public nsIDOMDOMImplementation |
|
28 , public nsWrapperCache |
|
29 { |
|
30 public: |
|
31 DOMImplementation(nsIDocument* aOwner, |
|
32 nsIGlobalObject* aScriptObject, |
|
33 nsIURI* aDocumentURI, |
|
34 nsIURI* aBaseURI) |
|
35 : mOwner(aOwner) |
|
36 , mScriptObject(do_GetWeakReference(aScriptObject)) |
|
37 , mDocumentURI(aDocumentURI) |
|
38 , mBaseURI(aBaseURI) |
|
39 { |
|
40 MOZ_ASSERT(aOwner); |
|
41 SetIsDOMBinding(); |
|
42 } |
|
43 |
|
44 ~DOMImplementation() |
|
45 { |
|
46 } |
|
47 |
|
48 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
49 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMImplementation) |
|
50 |
|
51 nsIDocument* GetParentObject() const |
|
52 { |
|
53 return mOwner; |
|
54 } |
|
55 |
|
56 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
57 |
|
58 // nsIDOMDOMImplementation |
|
59 NS_DECL_NSIDOMDOMIMPLEMENTATION |
|
60 |
|
61 bool HasFeature(const nsAString& aFeature, const nsAString& aVersion); |
|
62 |
|
63 already_AddRefed<DocumentType> |
|
64 CreateDocumentType(const nsAString& aQualifiedName, |
|
65 const nsAString& aPublicId, |
|
66 const nsAString& aSystemId, |
|
67 ErrorResult& aRv); |
|
68 |
|
69 already_AddRefed<nsIDocument> |
|
70 CreateDocument(const nsAString& aNamespaceURI, |
|
71 const nsAString& aQualifiedName, |
|
72 nsIDOMDocumentType* aDoctype, |
|
73 ErrorResult& aRv); |
|
74 |
|
75 already_AddRefed<nsIDocument> |
|
76 CreateHTMLDocument(const Optional<nsAString>& aTitle, ErrorResult& aRv); |
|
77 |
|
78 private: |
|
79 nsresult CreateDocument(const nsAString& aNamespaceURI, |
|
80 const nsAString& aQualifiedName, |
|
81 nsIDOMDocumentType* aDoctype, |
|
82 nsIDocument** aDocument, |
|
83 nsIDOMDocument** aDOMDocument); |
|
84 nsresult CreateHTMLDocument(const nsAString& aTitle, |
|
85 nsIDocument** aDocument, |
|
86 nsIDOMDocument** aDOMDocument); |
|
87 |
|
88 nsCOMPtr<nsIDocument> mOwner; |
|
89 nsWeakPtr mScriptObject; |
|
90 nsCOMPtr<nsIURI> mDocumentURI; |
|
91 nsCOMPtr<nsIURI> mBaseURI; |
|
92 }; |
|
93 |
|
94 } // namespace dom |
|
95 } // namespace mozilla |
|
96 |
|
97 #endif // mozilla_dom_DOMImplementation_h |