tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DOMImplementation.h (2365B)


      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_DOMImplementation_h
      8 #define mozilla_dom_DOMImplementation_h
      9 
     10 #include "nsCOMPtr.h"
     11 #include "nsCycleCollectionParticipant.h"
     12 #include "nsIScriptGlobalObject.h"
     13 #include "nsIURI.h"
     14 #include "nsIWeakReferenceUtils.h"
     15 #include "nsString.h"
     16 #include "nsWrapperCache.h"
     17 
     18 namespace mozilla {
     19 class ErrorResult;
     20 
     21 namespace dom {
     22 class Document;
     23 class DocumentType;
     24 template <typename T>
     25 class Optional;
     26 
     27 class DOMImplementation final : public nsISupports, public nsWrapperCache {
     28  ~DOMImplementation();
     29 
     30 public:
     31  DOMImplementation(Document* aOwner, nsIGlobalObject* aScriptObject,
     32                    nsIURI* aDocumentURI, nsIURI* aBaseURI);
     33 
     34  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     35  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(DOMImplementation)
     36 
     37  Document* GetParentObject() const { return mOwner; }
     38 
     39  virtual JSObject* WrapObject(JSContext* aCx,
     40                               JS::Handle<JSObject*> aGivenProto) override;
     41 
     42  bool HasFeature() { return true; }
     43 
     44  already_AddRefed<DocumentType> CreateDocumentType(
     45      const nsAString& aQualifiedName, const nsAString& aPublicId,
     46      const nsAString& aSystemId, ErrorResult& aRv);
     47 
     48  already_AddRefed<Document> CreateDocument(const nsAString& aNamespaceURI,
     49                                            const nsAString& aQualifiedName,
     50                                            DocumentType* aDoctype,
     51                                            ErrorResult& aRv);
     52 
     53  already_AddRefed<Document> CreateHTMLDocument(
     54      const Optional<nsAString>& aTitle, ErrorResult& aRv);
     55 
     56 private:
     57  nsresult CreateDocument(const nsAString& aNamespaceURI,
     58                          const nsAString& aQualifiedName,
     59                          DocumentType* aDoctype, Document** aDocument);
     60  nsresult CreateHTMLDocument(const nsAString& aTitle, Document** aDocument);
     61 
     62  nsCOMPtr<Document> mOwner;
     63  nsWeakPtr mScriptObject;
     64  nsCOMPtr<nsIURI> mDocumentURI;
     65  nsCOMPtr<nsIURI> mBaseURI;
     66 };
     67 
     68 }  // namespace dom
     69 }  // namespace mozilla
     70 
     71 #endif  // mozilla_dom_DOMImplementation_h