NavigationDestination.h (2375B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 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_NavigationDestination_h___ 8 #define mozilla_dom_NavigationDestination_h___ 9 10 #include "mozilla/dom/BindingDeclarations.h" 11 #include "nsISupports.h" 12 #include "nsStructuredCloneContainer.h" 13 #include "nsWrapperCache.h" 14 15 class nsIGlobalObject; 16 class nsIURI; 17 18 namespace mozilla { 19 class ErrorResult; 20 } 21 22 namespace mozilla::dom { 23 24 class NavigationHistoryEntry; 25 26 // https://html.spec.whatwg.org/#the-navigationdestination-interface 27 class NavigationDestination final : public nsISupports, public nsWrapperCache { 28 public: 29 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 30 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(NavigationDestination) 31 32 NavigationDestination(nsIGlobalObject* aGlobal, nsIURI* aURI, 33 NavigationHistoryEntry* aEntry, 34 nsIStructuredCloneContainer* aState, 35 bool aIsSameDocument); 36 37 void GetUrl(nsString& aURL) const; 38 void GetKey(nsString& aKey) const; 39 void GetId(nsString& aId) const; 40 int64_t Index() const; 41 bool SameDocument() const; 42 void GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aRetVal, 43 ErrorResult& aRv) const; 44 void SetState(nsIStructuredCloneContainer* aState); 45 46 JSObject* WrapObject(JSContext* aCx, 47 JS::Handle<JSObject*> aGivenProto) override; 48 nsIGlobalObject* GetParentObject(); 49 50 NavigationHistoryEntry* GetEntry() const; 51 nsIURI* GetURL() const; 52 void SetURL(nsIURI* aURI); 53 54 private: 55 ~NavigationDestination() = default; 56 57 nsCOMPtr<nsIGlobalObject> mGlobal; 58 59 // https://html.spec.whatwg.org/#concept-navigationdestination-url 60 nsCOMPtr<nsIURI> mURL; 61 62 // https://html.spec.whatwg.org/#concept-navigationdestination-entry 63 RefPtr<NavigationHistoryEntry> mEntry; 64 65 // https://html.spec.whatwg.org/#concept-navigationdestination-state 66 RefPtr<nsIStructuredCloneContainer> mState; 67 68 // https://html.spec.whatwg.org/#concept-navigationdestination-samedocument 69 bool mIsSameDocument = false; 70 }; 71 72 } // namespace mozilla::dom 73 74 #endif // mozilla_dom_NavigationDestination_h___