Bug 1890277: part 2) Add `require-trusted-types-for` directive to CSP parser, guarded...
[gecko.git] / dom / base / DOMImplementation.h
blobb42538741bdf1225e5ecc0f5e2e916af82872905
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_DOMImplementation_h
8 #define mozilla_dom_DOMImplementation_h
10 #include "nsWrapperCache.h"
12 #include "mozilla/Attributes.h"
13 #include "nsCOMPtr.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsIScriptGlobalObject.h"
16 #include "nsIURI.h"
17 #include "nsIWeakReferenceUtils.h"
18 #include "nsString.h"
20 namespace mozilla {
21 class ErrorResult;
23 namespace dom {
24 class Document;
25 class DocumentType;
26 template <typename T>
27 class Optional;
29 class DOMImplementation final : public nsISupports, public nsWrapperCache {
30 ~DOMImplementation();
32 public:
33 DOMImplementation(Document* aOwner, nsIGlobalObject* aScriptObject,
34 nsIURI* aDocumentURI, nsIURI* aBaseURI);
36 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
37 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(DOMImplementation)
39 Document* GetParentObject() const { return mOwner; }
41 virtual JSObject* WrapObject(JSContext* aCx,
42 JS::Handle<JSObject*> aGivenProto) override;
44 bool HasFeature() { return true; }
46 already_AddRefed<DocumentType> CreateDocumentType(
47 const nsAString& aQualifiedName, const nsAString& aPublicId,
48 const nsAString& aSystemId, ErrorResult& aRv);
50 already_AddRefed<Document> CreateDocument(const nsAString& aNamespaceURI,
51 const nsAString& aQualifiedName,
52 DocumentType* aDoctype,
53 ErrorResult& aRv);
55 already_AddRefed<Document> CreateHTMLDocument(
56 const Optional<nsAString>& aTitle, ErrorResult& aRv);
58 private:
59 nsresult CreateDocument(const nsAString& aNamespaceURI,
60 const nsAString& aQualifiedName,
61 DocumentType* aDoctype, Document** aDocument);
62 nsresult CreateHTMLDocument(const nsAString& aTitle, Document** aDocument);
64 nsCOMPtr<Document> mOwner;
65 nsWeakPtr mScriptObject;
66 nsCOMPtr<nsIURI> mDocumentURI;
67 nsCOMPtr<nsIURI> mBaseURI;
70 } // namespace dom
71 } // namespace mozilla
73 #endif // mozilla_dom_DOMImplementation_h