webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
BackForwardList.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
3  * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
4  * Copyright (C) 2009 Google, Inc. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
19  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #pragma once
29 
30 #include <WebCore/BackForwardClient.h>
31 #include <wtf/HashSet.h>
32 #include <wtf/Vector.h>
33 
35 
36 typedef HashSet<RefPtr<WebCore::HistoryItem>> HistoryItemHashSet;
37 
39 public:
40  static Ref<BackForwardList> create(WebView *webView) { return adoptRef(*new BackForwardList(webView)); }
41  virtual ~BackForwardList();
42 
43  WebView *webView() { return m_webView; }
44 
45  void addItem(Ref<WebCore::HistoryItem>&&) override;
46  void goBack();
47  void goForward();
48  void goToItem(WebCore::HistoryItem*) override;
49 
53  WebCore::HistoryItem* itemAtIndex(int) override;
54 
55  void backListWithLimit(int, Vector<Ref<WebCore::HistoryItem>>&);
56  void forwardListWithLimit(int, Vector<Ref<WebCore::HistoryItem>>&);
57 
58  int capacity();
59  void setCapacity(int);
60  bool enabled();
61  void setEnabled(bool);
62  int backListCount() override;
63  int forwardListCount() override;
65 
66  void close() override;
67  bool closed();
68 
70  const Vector<Ref<WebCore::HistoryItem>>& entries() const { return m_entries; }
71 
72 #if PLATFORM(IOS)
73  unsigned current();
74  void setCurrent(unsigned newCurrent);
75 #endif
76 
77 private:
78  explicit BackForwardList(WebView *);
79 
80  WebView* m_webView;
81  Vector<Ref<WebCore::HistoryItem>> m_entries;
82  HistoryItemHashSet m_entryHash;
83  unsigned m_current;
84  unsigned m_capacity;
85  bool m_closed;
86  bool m_enabled;
87 };
WebCore::HistoryItem * forwardItem()
Definition: BackForwardList.mm:123
OBJC_CLASS WebView
Definition: BackForwardList.h:34
#define OBJC_CLASS
Definition: Compiler.h:270
bool containsItem(WebCore::HistoryItem &)
Definition: BackForwardList.mm:259
WebCore::HistoryItem * itemAtIndex(int) override
Definition: BackForwardList.mm:202
virtual ~BackForwardList()
Definition: BackForwardList.mm:45
Definition: BackForwardClient.h:37
int forwardListCount() override
Definition: BackForwardList.mm:197
void removeItem(WebCore::HistoryItem &)
Definition: BackForwardList.mm:239
WebView * webView()
Definition: BackForwardList.h:43
bool enabled()
Definition: BackForwardList.mm:177
WebCore::HistoryItem * currentItem()
Definition: BackForwardList.mm:116
void backListWithLimit(int, Vector< Ref< WebCore::HistoryItem >> &)
Definition: BackForwardList.mm:130
const Vector< Ref< WebCore::HistoryItem > > & entries() const
Definition: BackForwardList.h:70
void setEnabled(bool)
Definition: BackForwardList.mm:182
Definition: HistoryItem.h:60
HashSet< RefPtr< WebCore::HistoryItem > > HistoryItemHashSet
Definition: BackForwardList.h:36
Definition: WebView.h:127
static Ref< BackForwardList > create(WebView *webView)
Definition: BackForwardList.h:40
void close() override
Definition: BackForwardList.mm:226
bool closed()
Definition: BackForwardList.mm:234
void addItem(Ref< WebCore::HistoryItem > &&) override
Definition: BackForwardList.mm:50
int backListCount() override
Definition: BackForwardList.mm:192
void forwardListWithLimit(int, Vector< Ref< WebCore::HistoryItem >> &)
Definition: BackForwardList.mm:140
void goForward()
Definition: BackForwardList.mm:87
WebCore::HistoryItem * backItem()
Definition: BackForwardList.mm:109
void goToItem(WebCore::HistoryItem *) override
Definition: BackForwardList.mm:94
void goBack()
Definition: BackForwardList.mm:80
int capacity()
Definition: BackForwardList.mm:156
Definition: BackForwardList.h:38
Ref< T > adoptRef(T &)
Definition: Ref.h:208
void setCapacity(int)
Definition: BackForwardList.mm:161