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/. */
9 #include "mozilla/Attributes.h"
10 #include "mozilla/dom/HistoryBinding.h"
11 #include "mozilla/dom/ChildSHistory.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"
21 class nsIWeakReference
;
22 class nsPIDOMWindowInner
;
28 // Script "History" object
29 class nsHistory final
: public nsISupports
, public nsWrapperCache
{
31 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(nsHistory
)
35 explicit nsHistory(nsPIDOMWindowInner
* aInnerWindow
);
37 nsPIDOMWindowInner
* GetParentObject() const;
38 virtual JSObject
* WrapObject(JSContext
* aCx
,
39 JS::Handle
<JSObject
*> aGivenProto
) override
;
41 uint32_t GetLength(mozilla::ErrorResult
& aRv
) const;
42 mozilla::dom::ScrollRestoration
GetScrollRestoration(
43 mozilla::ErrorResult
& aRv
);
44 void SetScrollRestoration(mozilla::dom::ScrollRestoration aMode
,
45 mozilla::ErrorResult
& aRv
);
46 void GetState(JSContext
* aCx
, JS::MutableHandle
<JS::Value
> aResult
,
47 mozilla::ErrorResult
& aRv
) const;
48 void Go(int32_t aDelta
, nsIPrincipal
& aSubjectPrincipal
,
49 mozilla::ErrorResult
& aRv
);
50 void Back(mozilla::dom::CallerType aCallerType
, mozilla::ErrorResult
& aRv
);
51 void Forward(mozilla::dom::CallerType aCallerType
, mozilla::ErrorResult
& aRv
);
52 void PushState(JSContext
* aCx
, JS::Handle
<JS::Value
> aData
,
53 const nsAString
& aTitle
, const nsAString
& aUrl
,
54 mozilla::dom::CallerType aCallerType
,
55 mozilla::ErrorResult
& aRv
);
56 void ReplaceState(JSContext
* aCx
, JS::Handle
<JS::Value
> aData
,
57 const nsAString
& aTitle
, const nsAString
& aUrl
,
58 mozilla::dom::CallerType aCallerType
,
59 mozilla::ErrorResult
& aRv
);
64 void PushOrReplaceState(JSContext
* aCx
, JS::Handle
<JS::Value
> aData
,
65 const nsAString
& aTitle
, const nsAString
& aUrl
,
66 mozilla::dom::CallerType aCallerType
,
67 mozilla::ErrorResult
& aRv
, bool aReplace
);
69 already_AddRefed
<mozilla::dom::ChildSHistory
> GetSessionHistory() const;
71 nsWeakPtr mInnerWindow
;
74 #endif /* nsHistory_h___ */