Line data Source code
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/ErrorResult.h"
11 : #include "mozilla/dom/HistoryBinding.h"
12 : #include "nsCOMPtr.h"
13 : #include "nsCycleCollectionParticipant.h"
14 : #include "nsIDOMHistory.h"
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 : // Script "History" object
25 : class nsHistory final : public nsIDOMHistory, // Empty, needed for extension
26 : // backwards compat
27 : public nsWrapperCache
28 : {
29 : public:
30 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
31 1 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsHistory)
32 :
33 : public:
34 : explicit nsHistory(nsPIDOMWindowInner* aInnerWindow);
35 :
36 : nsPIDOMWindowInner* GetParentObject() const;
37 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
38 :
39 : uint32_t GetLength(mozilla::ErrorResult& aRv) const;
40 : mozilla::dom::ScrollRestoration GetScrollRestoration(mozilla::ErrorResult& aRv);
41 : void SetScrollRestoration(mozilla::dom::ScrollRestoration aMode,
42 : mozilla::ErrorResult& aRv);
43 : void GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
44 : mozilla::ErrorResult& aRv) const;
45 : void Go(int32_t aDelta, mozilla::ErrorResult& aRv);
46 : void Back(mozilla::ErrorResult& aRv);
47 : void Forward(mozilla::ErrorResult& aRv);
48 : void PushState(JSContext* aCx, JS::Handle<JS::Value> aData,
49 : const nsAString& aTitle, const nsAString& aUrl,
50 : mozilla::ErrorResult& aRv);
51 : void ReplaceState(JSContext* aCx, JS::Handle<JS::Value> aData,
52 : const nsAString& aTitle, const nsAString& aUrl,
53 : mozilla::ErrorResult& aRv);
54 :
55 : protected:
56 : virtual ~nsHistory();
57 :
58 : nsIDocShell* GetDocShell() const;
59 :
60 : void PushOrReplaceState(JSContext* aCx, JS::Handle<JS::Value> aData,
61 : const nsAString& aTitle, const nsAString& aUrl,
62 : mozilla::ErrorResult& aRv, bool aReplace);
63 :
64 : already_AddRefed<nsISHistory> GetSessionHistory() const;
65 :
66 : nsCOMPtr<nsIWeakReference> mInnerWindow;
67 : };
68 :
69 : #endif /* nsHistory_h___ */
|