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

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, 1 month 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 {
abarth-chromium 2013/11/13 19:15:37 HistoryNode?
Nate Chapin 2013/11/13 19:30:39 Yeah, that's a better name. Will change it.
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 HistoryEntry* m_entry;
63 Vector<OwnPtr<HistoryEntryItem> > m_children;
64 RefPtr<HistoryItem> m_value;
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*);
abarth-chromium 2013/11/13 19:15:37 It's awkward that this returns a HistoryEntryItem
Nate Chapin 2013/11/13 19:30:39 Will do.
73 HistoryItem* itemForFrame(Frame*);
74 HistoryItem* root() const { return m_root->value(); }
75 HistoryEntryItem* rootEntry() const { return m_root.get(); }
abarth-chromium 2013/11/13 19:15:37 Same comment here w/ rootNode
Nate Chapin 2013/11/13 19:30:39 Will do.
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;
85 HashMap<String, HistoryEntryItem*> m_uniqueNamesToItems;
abarth-chromium 2013/11/13 19:15:37 It's unfortunate that we need both these maps...
Nate Chapin 2013/11/13 19:30:39 Yeah, it's lame, and I'm not sure there's a way ar
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
94 // Should only be called by embedder. To request a back/forward
95 // navigation, call FrameLoaderClient::navigateBackForward().
96 void goToItem(HistoryItem*);
97
50 void clearScrollPositionAndViewState(); 98 void clearScrollPositionAndViewState();
51 void restoreScrollPositionAndViewState(); 99 void restoreScrollPositionAndViewState(Frame*);
52 100
53 void updateBackForwardListForFragmentScroll(); 101 void updateBackForwardListForFragmentScroll(Frame*);
54 102
55 void saveDocumentAndScrollState(); 103 void saveDocumentAndScrollState(Frame*);
56 void restoreDocumentState(); 104 void restoreDocumentState(Frame*);
57 105
58 void updateForCommit(); 106 void updateForCommit(Frame*);
59 void updateForSameDocumentNavigation(); 107 void updateForSameDocumentNavigation(Frame*);
60 108
61 HistoryItem* currentItem() const { return m_currentItem.get(); } 109 PassRefPtr<HistoryItem> currentItemForExport(Frame*);
62 void setCurrentItem(HistoryItem*); 110 PassRefPtr<HistoryItem> previousItemForExport(Frame*);
63 bool currentItemShouldBeReplaced() const; 111 PassRefPtr<HistoryItem> provisionalItemForExport(Frame*);
64 112
65 HistoryItem* previousItem() const { return m_previousItem.get(); } 113 HistoryItem* currentItem(Frame*) const;
114 bool currentItemShouldBeReplaced(Frame*) const;
66 115
67 HistoryItem* provisionalItem() const { return m_provisionalItem.get(); } 116 HistoryItem* previousItem(Frame*) const;
68 void setProvisionalItem(HistoryItem*); 117 void clearProvisionalEntry();
69 118
70 void pushState(PassRefPtr<SerializedScriptValue>, const String& url); 119 bool inSameDocumentLoad() const { return !m_sameDocumentLoadsInProgress.isEm pty() && m_differentDocumentLoadsInProgress.isEmpty(); }
71 void replaceState(PassRefPtr<SerializedScriptValue>, const String& url); 120
121 void pushState(Frame*, PassRefPtr<SerializedScriptValue>, const String& url) ;
122 void replaceState(Frame*, PassRefPtr<SerializedScriptValue>, const String& u rl);
72 123
73 void setDefersLoading(bool); 124 void setDefersLoading(bool);
74 125
75 private: 126 private:
76 friend class Page; 127 void goToEntry(PassOwnPtr<HistoryEntry>);
77 bool shouldStopLoadingForHistoryItem(HistoryItem*) const; 128 void recursiveGoToEntry(Frame*);
78 void goToItem(HistoryItem*);
79 129
80 void initializeItem(HistoryItem*); 130 void initializeItem(HistoryItem*, Frame*);
81 PassRefPtr<HistoryItem> createItem(); 131 PassRefPtr<HistoryItem> createItem(Frame*);
82 PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget ); 132 HistoryItem* createItemTree(Frame* targetFrame, bool clipAtTarget);
83 133
84 void updateForStandardLoad(); 134 void updateForStandardLoad(Frame*);
85 void updateForInitialLoadInChildFrame(); 135 void updateForInitialLoadInChildFrame(Frame*);
86 136
87 void recursiveSetProvisionalItem(HistoryItem*, HistoryItem*); 137 void createNewBackForwardItem(Frame*, bool doClip);
88 void recursiveGoToItem(HistoryItem*, HistoryItem*); 138 void updateWithoutCreatingNewBackForwardItem(Frame*);
89 void recursiveUpdateForCommit();
90 void recursiveUpdateForSameDocumentNavigation();
91 bool itemsAreClones(HistoryItem*, HistoryItem*) const;
92 bool currentFramesMatchItem(HistoryItem*) const;
93 139
94 void createNewBackForwardItem(bool doClip); 140 Page* m_page;
95 void updateWithoutCreatingNewBackForwardItem();
96 141
97 void clearProvisionalItemsInAllFrames(); 142 OwnPtr<HistoryEntry> m_currentEntry;
143 OwnPtr<HistoryEntry> m_previousEntry;
144 OwnPtr<HistoryEntry> m_provisionalEntry;
98 145
99 Frame* m_frame; 146 typedef HashMap<Frame*, HistoryItem*> HistoryFrameLoadSet;
100 147 HistoryFrameLoadSet m_sameDocumentLoadsInProgress;
101 RefPtr<HistoryItem> m_currentItem; 148 HistoryFrameLoadSet m_differentDocumentLoadsInProgress;
102 RefPtr<HistoryItem> m_previousItem;
103 RefPtr<HistoryItem> m_provisionalItem;
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698