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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/loader/HistoryController.h
diff --git a/Source/core/loader/HistoryController.h b/Source/core/loader/HistoryController.h
index f70840843cbf81dc51aede0abe16dd27c1c0c1d7..df461bc0281fa24c844b0fb054909fac2e9a5a98 100644
--- a/Source/core/loader/HistoryController.h
+++ b/Source/core/loader/HistoryController.h
@@ -32,6 +32,7 @@
#include "core/history/HistoryItem.h"
#include "core/loader/FrameLoaderTypes.h"
+#include "wtf/HashMap.h"
#include "wtf/Noncopyable.h"
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
@@ -39,68 +40,112 @@
namespace WebCore {
class Frame;
+class HistoryEntry;
+class Page;
class SerializedScriptValue;
+
+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.
+public:
+ static PassOwnPtr<HistoryEntryItem> create(HistoryEntry*, HistoryItem*);
+ ~HistoryEntryItem() { }
+
+ HistoryEntryItem* addChild(PassRefPtr<HistoryItem>);
+ PassOwnPtr<HistoryEntryItem> cloneAndReplace(HistoryEntry*, HistoryItem* newItem, HistoryItem* oldItem, bool clipAtTarget, Frame*);
+ HistoryItem* value() { return m_value.get(); }
+ void updateValue(PassRefPtr<HistoryItem> item) { m_value = item; }
+ const Vector<OwnPtr<HistoryEntryItem> >& children() const { return m_children; }
+
+private:
+ HistoryEntryItem(HistoryEntry*, HistoryItem*);
+
+ HistoryEntry* m_entry;
+ Vector<OwnPtr<HistoryEntryItem> > m_children;
+ RefPtr<HistoryItem> m_value;
+};
+
+class HistoryEntry {
+public:
+ static PassOwnPtr<HistoryEntry> create(HistoryItem* root);
+ PassOwnPtr<HistoryEntry> cloneAndReplace(HistoryItem* newItem, HistoryItem* oldItem, bool clipAtTarget, Page*);
+
+ 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.
+ HistoryItem* itemForFrame(Frame*);
+ HistoryItem* root() const { return m_root->value(); }
+ 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.
+
+private:
+ friend class HistoryEntryItem;
+
+ HistoryEntry() { }
+ explicit HistoryEntry(HistoryItem* root);
+
+ OwnPtr<HistoryEntryItem> m_root;
+ HashMap<uint64_t, HistoryEntryItem*> m_framesToItems;
+ 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
+};
+
class HistoryController {
WTF_MAKE_NONCOPYABLE(HistoryController);
public:
- explicit HistoryController(Frame*);
+ explicit HistoryController(Page*);
~HistoryController();
+ // Should only be called by embedder. To request a back/forward
+ // navigation, call FrameLoaderClient::navigateBackForward().
+ void goToItem(HistoryItem*);
+
void clearScrollPositionAndViewState();
- void restoreScrollPositionAndViewState();
+ void restoreScrollPositionAndViewState(Frame*);
+
+ void updateBackForwardListForFragmentScroll(Frame*);
- void updateBackForwardListForFragmentScroll();
+ void saveDocumentAndScrollState(Frame*);
+ void restoreDocumentState(Frame*);
- void saveDocumentAndScrollState();
- void restoreDocumentState();
+ void updateForCommit(Frame*);
+ void updateForSameDocumentNavigation(Frame*);
- void updateForCommit();
- void updateForSameDocumentNavigation();
+ PassRefPtr<HistoryItem> currentItemForExport(Frame*);
+ PassRefPtr<HistoryItem> previousItemForExport(Frame*);
+ PassRefPtr<HistoryItem> provisionalItemForExport(Frame*);
- HistoryItem* currentItem() const { return m_currentItem.get(); }
- void setCurrentItem(HistoryItem*);
- bool currentItemShouldBeReplaced() const;
+ HistoryItem* currentItem(Frame*) const;
+ bool currentItemShouldBeReplaced(Frame*) const;
- HistoryItem* previousItem() const { return m_previousItem.get(); }
+ HistoryItem* previousItem(Frame*) const;
+ void clearProvisionalEntry();
- HistoryItem* provisionalItem() const { return m_provisionalItem.get(); }
- void setProvisionalItem(HistoryItem*);
+ bool inSameDocumentLoad() const { return !m_sameDocumentLoadsInProgress.isEmpty() && m_differentDocumentLoadsInProgress.isEmpty(); }
- void pushState(PassRefPtr<SerializedScriptValue>, const String& url);
- void replaceState(PassRefPtr<SerializedScriptValue>, const String& url);
+ void pushState(Frame*, PassRefPtr<SerializedScriptValue>, const String& url);
+ void replaceState(Frame*, PassRefPtr<SerializedScriptValue>, const String& url);
void setDefersLoading(bool);
private:
- friend class Page;
- bool shouldStopLoadingForHistoryItem(HistoryItem*) const;
- void goToItem(HistoryItem*);
-
- void initializeItem(HistoryItem*);
- PassRefPtr<HistoryItem> createItem();
- PassRefPtr<HistoryItem> createItemTree(Frame* targetFrame, bool clipAtTarget);
+ void goToEntry(PassOwnPtr<HistoryEntry>);
+ void recursiveGoToEntry(Frame*);
- void updateForStandardLoad();
- void updateForInitialLoadInChildFrame();
+ void initializeItem(HistoryItem*, Frame*);
+ PassRefPtr<HistoryItem> createItem(Frame*);
+ HistoryItem* createItemTree(Frame* targetFrame, bool clipAtTarget);
- void recursiveSetProvisionalItem(HistoryItem*, HistoryItem*);
- void recursiveGoToItem(HistoryItem*, HistoryItem*);
- void recursiveUpdateForCommit();
- void recursiveUpdateForSameDocumentNavigation();
- bool itemsAreClones(HistoryItem*, HistoryItem*) const;
- bool currentFramesMatchItem(HistoryItem*) const;
+ void updateForStandardLoad(Frame*);
+ void updateForInitialLoadInChildFrame(Frame*);
- void createNewBackForwardItem(bool doClip);
- void updateWithoutCreatingNewBackForwardItem();
+ void createNewBackForwardItem(Frame*, bool doClip);
+ void updateWithoutCreatingNewBackForwardItem(Frame*);
- void clearProvisionalItemsInAllFrames();
+ Page* m_page;
- Frame* m_frame;
+ OwnPtr<HistoryEntry> m_currentEntry;
+ OwnPtr<HistoryEntry> m_previousEntry;
+ OwnPtr<HistoryEntry> m_provisionalEntry;
- RefPtr<HistoryItem> m_currentItem;
- RefPtr<HistoryItem> m_previousItem;
- RefPtr<HistoryItem> m_provisionalItem;
+ typedef HashMap<Frame*, HistoryItem*> HistoryFrameLoadSet;
+ HistoryFrameLoadSet m_sameDocumentLoadsInProgress;
+ HistoryFrameLoadSet m_differentDocumentLoadsInProgress;
bool m_defersLoading;
RefPtr<HistoryItem> m_deferredItem;

Powered by Google App Engine
This is Rietveld 408576698