OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 3 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 14 matching lines...) Expand all Loading... | |
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #ifndef HistoryController_h | 30 #ifndef HistoryController_h |
31 #define HistoryController_h | 31 #define HistoryController_h |
32 | 32 |
33 #include "core/history/HistoryItem.h" | 33 #include "core/history/HistoryItem.h" |
34 #include "core/loader/FrameLoaderTypes.h" | 34 #include "core/loader/FrameLoaderTypes.h" |
35 #include "wtf/HashMap.h" | |
35 #include "wtf/Noncopyable.h" | 36 #include "wtf/Noncopyable.h" |
36 #include "wtf/RefPtr.h" | 37 #include "wtf/RefPtr.h" |
37 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
38 | 39 |
39 namespace WebCore { | 40 namespace WebCore { |
40 | 41 |
41 class Frame; | 42 class Frame; |
43 class HistoryEntry; | |
44 class Page; | |
42 class SerializedScriptValue; | 45 class SerializedScriptValue; |
43 | 46 |
47 | |
48 class HistoryEntryItem { | |
49 public: | |
50 static PassOwnPtr<HistoryEntryItem> create(HistoryEntry*, HistoryItem*); | |
51 ~HistoryEntryItem() { } | |
52 | |
53 HistoryEntryItem* addChild(PassRefPtr<HistoryItem>); | |
54 PassOwnPtr<HistoryEntryItem> cloneAndReplace(HistoryEntry*, HistoryItem* new Item, HistoryItem* oldItem, bool clipAtTarget, Frame*); | |
55 HistoryItem* value() { return m_value.get(); } | |
56 void updateValue(PassRefPtr<HistoryItem> item) { m_value = item; } | |
57 const Vector<OwnPtr<HistoryEntryItem> >& children() const { return m_childre n; } | |
58 | |
59 private: | |
60 HistoryEntryItem(HistoryEntry*, HistoryItem*); | |
61 | |
62 Vector<OwnPtr<HistoryEntryItem> > m_children; | |
63 RefPtr<HistoryItem> m_value; | |
64 HistoryEntry* m_entry; | |
65 }; | |
66 | |
67 class HistoryEntry { | |
68 public: | |
69 static PassOwnPtr<HistoryEntry> create(HistoryItem* root); | |
70 PassOwnPtr<HistoryEntry> cloneAndReplace(HistoryItem* newItem, HistoryItem* oldItem, bool clipAtTarget, Page*); | |
71 | |
72 HistoryEntryItem* entryForFrame(Frame*); | |
73 HistoryItem* itemForFrame(Frame*); | |
74 HistoryItem* root() const { return m_root->value(); } | |
75 HistoryEntryItem* rootEntry() const { return m_root.get(); } | |
76 | |
77 private: | |
78 friend class HistoryEntryItem; | |
79 | |
80 HistoryEntry() { } | |
81 explicit HistoryEntry(HistoryItem* root); | |
82 | |
83 OwnPtr<HistoryEntryItem> m_root; | |
84 HashMap<uint64_t, HistoryEntryItem*> m_framesToItems; | |
abarth-chromium
2013/10/29 20:36:58
uint64_t -> I wonder if we should have a typedef f
| |
85 HashMap<String, HistoryEntryItem*> m_uniqueNamesToItems; | |
86 }; | |
87 | |
44 class HistoryController { | 88 class HistoryController { |
45 WTF_MAKE_NONCOPYABLE(HistoryController); | 89 WTF_MAKE_NONCOPYABLE(HistoryController); |
46 public: | 90 public: |
47 explicit HistoryController(Frame*); | 91 explicit HistoryController(Page*); |
48 ~HistoryController(); | 92 ~HistoryController(); |
49 | 93 |
50 void clearScrollPositionAndViewState(); | 94 void clearScrollPositionAndViewState(); |
51 void restoreScrollPositionAndViewState(); | 95 void restoreScrollPositionAndViewState(Frame*); |
52 | 96 |
53 void updateBackForwardListForFragmentScroll(); | 97 void updateBackForwardListForFragmentScroll(Frame*); |
54 | 98 |
55 void saveDocumentAndScrollState(); | 99 void saveDocumentAndScrollState(Frame*); |
56 void restoreDocumentState(); | 100 void restoreDocumentState(Frame*); |
57 | 101 |
58 void updateForCommit(); | 102 void updateForCommit(Frame*); |
59 void updateForSameDocumentNavigation(); | 103 void updateForSameDocumentNavigation(Frame*); |
60 | 104 |
61 HistoryItem* currentItem() const { return m_currentItem.get(); } | 105 PassRefPtr<HistoryItem> currentItemForExport(Frame*); |
62 void setCurrentItem(HistoryItem*); | 106 PassRefPtr<HistoryItem> previousItemForExport(Frame*); |
63 bool currentItemShouldBeReplaced() const; | 107 PassRefPtr<HistoryItem> provisionalItemForExport(Frame*); |
64 | 108 |
65 HistoryItem* previousItem() const { return m_previousItem.get(); } | 109 HistoryItem* currentItem(Frame*) const; |
110 bool currentItemShouldBeReplaced(Frame*) const; | |
66 | 111 |
67 HistoryItem* provisionalItem() const { return m_provisionalItem.get(); } | 112 HistoryItem* previousItem(Frame*) const; |
68 void setProvisionalItem(HistoryItem*); | 113 void clearProvisionalEntry(); |
69 | 114 |
70 void pushState(PassRefPtr<SerializedScriptValue>, const String& url); | 115 bool shouldPerformSameDocumentHistoryNavigation(Frame*, HistoryItem*) const; |
71 void replaceState(PassRefPtr<SerializedScriptValue>, const String& url); | 116 |
117 void pushState(Frame*, PassRefPtr<SerializedScriptValue>, const String& url) ; | |
118 void replaceState(Frame*, PassRefPtr<SerializedScriptValue>, const String& u rl); | |
72 | 119 |
73 void setDefersLoading(bool); | 120 void setDefersLoading(bool); |
74 | 121 |
75 private: | 122 private: |
76 friend class Page; | 123 friend class Page; |
77 bool shouldStopLoadingForHistoryItem(HistoryItem*) const; | |
78 void goToItem(HistoryItem*); | 124 void goToItem(HistoryItem*); |
125 void goToEntry(PassOwnPtr<HistoryEntry>); | |
126 void recursiveGoToEntry(Frame*, HistoryEntryItem* newEntry, HistoryEntryItem * oldEntry); | |
79 | 127 |
80 void initializeItem(HistoryItem*); | 128 void initializeItem(HistoryItem*, Frame*); |
81 PassRefPtr<HistoryItem> createItem(); | 129 PassRefPtr<HistoryItem> createItem(Frame*); |
82 PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget ); | 130 HistoryItem* createItemTree(Frame* targetFrame, bool clipAtTarget); |
83 | 131 |
84 void updateForStandardLoad(); | 132 void updateForStandardLoad(Frame*); |
85 void updateForInitialLoadInChildFrame(); | 133 void updateForInitialLoadInChildFrame(Frame*); |
86 | 134 |
87 void recursiveSetProvisionalItem(HistoryItem*, HistoryItem*); | 135 void createNewBackForwardItem(Frame*, bool doClip); |
88 void recursiveGoToItem(HistoryItem*, HistoryItem*); | 136 void updateWithoutCreatingNewBackForwardItem(Frame*); |
89 void recursiveUpdateForCommit(); | |
90 void recursiveUpdateForSameDocumentNavigation(); | |
91 bool itemsAreClones(HistoryItem*, HistoryItem*) const; | |
92 bool currentFramesMatchItem(HistoryItem*) const; | |
93 | 137 |
94 void createNewBackForwardItem(bool doClip); | 138 PassRefPtr<HistoryItem> itemForExport(HistoryEntryItem*); |
95 void updateWithoutCreatingNewBackForwardItem(); | |
96 | 139 |
97 void clearProvisionalItemsInAllFrames(); | 140 Page* m_page; |
98 | 141 |
99 Frame* m_frame; | 142 OwnPtr<HistoryEntry> m_currentEntry; |
143 OwnPtr<HistoryEntry> m_previousEntry; | |
144 OwnPtr<HistoryEntry> m_provisionalEntry; | |
100 | 145 |
101 RefPtr<HistoryItem> m_currentItem; | 146 typedef HashMap<Frame*, HistoryItem*> HistoryFrameLoadSet; |
102 RefPtr<HistoryItem> m_previousItem; | 147 HistoryFrameLoadSet m_sameDocumentLoadsInProgress; |
103 RefPtr<HistoryItem> m_provisionalItem; | 148 HistoryFrameLoadSet m_differentDocumentLoadsInProgress; |
104 | 149 |
105 bool m_defersLoading; | 150 bool m_defersLoading; |
106 RefPtr<HistoryItem> m_deferredItem; | 151 RefPtr<HistoryItem> m_deferredItem; |
107 }; | 152 }; |
108 | 153 |
109 } // namespace WebCore | 154 } // namespace WebCore |
110 | 155 |
111 #endif // HistoryController_h | 156 #endif // HistoryController_h |
OLD | NEW |