nsHistory.h (3315B)
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 #ifndef nsHistory_h___ 7 #define nsHistory_h___ 8 9 #include "mozilla/Attributes.h" 10 #include "mozilla/dom/ChildSHistory.h" 11 #include "mozilla/dom/HistoryBinding.h" 12 #include "nsCOMPtr.h" 13 #include "nsCycleCollectionParticipant.h" 14 #include "nsIWeakReferenceUtils.h" // for nsWeakPtr 15 #include "nsPIDOMWindow.h" // for GetParentObject 16 #include "nsStringFwd.h" 17 #include "nsWrapperCache.h" 18 19 class nsIDocShell; 20 class nsISHistory; 21 class nsIWeakReference; 22 class nsPIDOMWindowInner; 23 24 namespace mozilla { 25 class ErrorResult; 26 } 27 28 // Script "History" object 29 class nsHistory final : public nsISupports, public nsWrapperCache { 30 public: 31 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 32 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(nsHistory) 33 34 public: 35 explicit nsHistory(nsPIDOMWindowInner* aInnerWindow); 36 37 nsPIDOMWindowInner* GetParentObject() const; 38 virtual JSObject* WrapObject(JSContext* aCx, 39 JS::Handle<JSObject*> aGivenProto) override; 40 41 uint32_t GetLength(mozilla::ErrorResult& aRv) const; 42 mozilla::dom::ScrollRestoration GetScrollRestoration( 43 mozilla::dom::CallerType aCallerType, mozilla::ErrorResult& aRv); 44 void SetScrollRestoration(mozilla::dom::ScrollRestoration aMode, 45 mozilla::dom::CallerType aCallerType, 46 mozilla::ErrorResult& aRv); 47 void GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aResult, 48 mozilla::ErrorResult& aRv) const; 49 50 MOZ_CAN_RUN_SCRIPT 51 void Go(JSContext* aCx, int32_t aDelta, mozilla::dom::CallerType aCallerType, 52 mozilla::ErrorResult& aRv); 53 54 MOZ_CAN_RUN_SCRIPT 55 void Back(mozilla::dom::CallerType aCallerType, mozilla::ErrorResult& aRv); 56 57 MOZ_CAN_RUN_SCRIPT 58 void Forward(mozilla::dom::CallerType aCallerType, mozilla::ErrorResult& aRv); 59 60 MOZ_CAN_RUN_SCRIPT 61 void PushState(JSContext* aCx, JS::Handle<JS::Value> aData, 62 const nsAString& aTitle, const nsAString& aUrl, 63 mozilla::dom::CallerType aCallerType, 64 mozilla::ErrorResult& aRv); 65 66 MOZ_CAN_RUN_SCRIPT 67 void ReplaceState(JSContext* aCx, JS::Handle<JS::Value> aData, 68 const nsAString& aTitle, const nsAString& aUrl, 69 mozilla::dom::CallerType aCallerType, 70 mozilla::ErrorResult& aRv); 71 72 protected: 73 virtual ~nsHistory(); 74 75 MOZ_CAN_RUN_SCRIPT 76 void PushOrReplaceState(JSContext* aCx, JS::Handle<JS::Value> aData, 77 const nsAString& aTitle, const nsAString& aUrl, 78 mozilla::dom::CallerType aCallerType, 79 mozilla::ErrorResult& aRv, bool aReplace); 80 81 already_AddRefed<mozilla::dom::ChildSHistory> GetSessionHistory() const; 82 83 MOZ_CAN_RUN_SCRIPT 84 void DeltaTraverse(mozilla::Maybe<mozilla::NotNull<JSContext*>> aCx, 85 int32_t aDelta, mozilla::dom::CallerType aCallerType, 86 mozilla::ErrorResult& aRv); 87 88 nsWeakPtr mInnerWindow; 89 }; 90 91 #endif /* nsHistory_h___ */