Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: Source/core/loader/HistoryController.h

Issue 28983004: Split the frame tree logic out of HistoryItem (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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);
55 HistoryItem* value() { return m_value.get(); }
56 const Vector<OwnPtr<HistoryEntryItem> >& children() const;
57
58 private:
59 HistoryEntryItem(HistoryEntry*, HistoryItem*);
60
61 Vector<OwnPtr<HistoryEntryItem> > m_children;
62 RefPtr<HistoryItem> m_value;
63 HistoryEntry* m_entry;
64 };
65
66 class HistoryEntry {
67 public:
68 static PassOwnPtr<HistoryEntry> create(HistoryItem* root);
69 PassOwnPtr<HistoryEntry> cloneAndReplace(HistoryItem* newItem, HistoryItem* oldItem, bool clipAtTarget);
70
71 HistoryEntryItem* entryForFrame(Frame*);
72 HistoryItem* itemForFrame(Frame*);
73 HistoryItem* root();
74 HistoryEntryItem* rootEntry();
75
76 HistoryItemVector childrenForItem(HistoryItem*);
77
78 private:
79 friend class HistoryEntryItem;
80
81 HistoryEntry() { }
82 explicit HistoryEntry(HistoryItem* root);
83
84 OwnPtr<HistoryEntryItem> m_root;
85 HashMap<String, HistoryEntryItem*> m_framesToItems;
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() const { return m_previousEntry->root(); }
68 void setProvisionalItem(HistoryItem*);
69 113
70 void pushState(PassRefPtr<SerializedScriptValue>, const String& url); 114 HistoryItem* provisionalItem(Frame*) const;
71 void replaceState(PassRefPtr<SerializedScriptValue>, const String& url); 115 void clearProvisionalEntry();
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>);
79 126
80 void initializeItem(HistoryItem*); 127 void initializeItem(HistoryItem*, Frame*);
81 PassRefPtr<HistoryItem> createItem(); 128 PassRefPtr<HistoryItem> createItem(Frame*);
82 PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget ); 129 HistoryItem* createItemTree(Frame* targetFrame, bool clipAtTarget);
83 130
84 void updateForStandardLoad(); 131 void updateForStandardLoad(Frame*);
85 void updateForInitialLoadInChildFrame(); 132 void updateForInitialLoadInChildFrame(Frame*);
86 133
87 void recursiveSetProvisionalItem(HistoryItem*, HistoryItem*); 134 void createNewBackForwardItem(Frame*, bool doClip);
88 void recursiveGoToItem(HistoryItem*, HistoryItem*); 135 void updateWithoutCreatingNewBackForwardItem(Frame*);
89 void recursiveUpdateForCommit();
90 void recursiveUpdateForSameDocumentNavigation();
91 bool itemsAreClones(HistoryItem*, HistoryItem*) const;
92 bool currentFramesMatchItem(HistoryItem*) const;
93 136
94 void createNewBackForwardItem(bool doClip); 137 PassRefPtr<HistoryItem> itemForExport(HistoryEntryItem*);
95 void updateWithoutCreatingNewBackForwardItem();
96 138
97 void clearProvisionalItemsInAllFrames(); 139 Page* m_page;
98 140
99 Frame* m_frame; 141 OwnPtr<HistoryEntry> m_currentEntry;
100 142 OwnPtr<HistoryEntry> m_previousEntry;
101 RefPtr<HistoryItem> m_currentItem; 143 OwnPtr<HistoryEntry> m_provisionalEntry;
102 RefPtr<HistoryItem> m_previousItem;
103 RefPtr<HistoryItem> m_provisionalItem;
104 144
105 bool m_defersLoading; 145 bool m_defersLoading;
106 RefPtr<HistoryItem> m_deferredItem; 146 RefPtr<HistoryItem> m_deferredItem;
107 }; 147 };
108 148
109 } // namespace WebCore 149 } // namespace WebCore
110 150
111 #endif // HistoryController_h 151 #endif // HistoryController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698