summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/loader/HistoryController.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-18 13:36:51 +0100
committerSteve Block <steveblock@google.com>2011-05-24 15:38:28 +0100
commit2fc2651226baac27029e38c9d6ef883fa32084db (patch)
treee396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebCore/loader/HistoryController.cpp
parentb3725cedeb43722b3b175aaeff70552e562d2c94 (diff)
downloadexternal_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebCore/loader/HistoryController.cpp')
-rw-r--r--Source/WebCore/loader/HistoryController.cpp54
1 files changed, 37 insertions, 17 deletions
diff --git a/Source/WebCore/loader/HistoryController.cpp b/Source/WebCore/loader/HistoryController.cpp
index 7c0fc97..7bfe380 100644
--- a/Source/WebCore/loader/HistoryController.cpp
+++ b/Source/WebCore/loader/HistoryController.cpp
@@ -236,7 +236,7 @@ void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type)
// Set the BF cursor before commit, which lets the user quickly click back/forward again.
// - plus, it only makes sense for the top level of the operation through the frametree,
// as opposed to happening for some/one of the page commits that might happen soon
- HistoryItem* currentItem = page->backForward()->currentItem();
+ RefPtr<HistoryItem> currentItem = page->backForward()->currentItem();
page->backForward()->setCurrentItem(targetItem);
Settings* settings = m_frame->settings();
page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : targetItem);
@@ -245,9 +245,9 @@ void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type)
// This must be done before trying to navigate the desired frame, because some
// navigations can commit immediately (such as about:blank). We must be sure that
// all frames have provisional items set before the commit.
- recursiveSetProvisionalItem(targetItem, currentItem, type);
+ recursiveSetProvisionalItem(targetItem, currentItem.get(), type);
// Now that all other frames have provisional items, do the actual navigation.
- recursiveGoToItem(targetItem, currentItem, type);
+ recursiveGoToItem(targetItem, currentItem.get(), type);
}
void HistoryController::updateForBackForwardNavigation()
@@ -323,7 +323,7 @@ void HistoryController::updateForStandardLoad(HistoryUpdateType updateType)
if (Page* page = m_frame->page())
addVisitedLink(page, historyURL);
- if (!frameLoader->documentLoader()->didCreateGlobalHistoryEntry() && frameLoader->documentLoader()->unreachableURL().isEmpty() && !frameLoader->url().isEmpty())
+ if (!frameLoader->documentLoader()->didCreateGlobalHistoryEntry() && frameLoader->documentLoader()->unreachableURL().isEmpty() && !m_frame->document()->url().isEmpty())
frameLoader->client()->updateGlobalHistoryRedirectLinks();
}
}
@@ -365,7 +365,7 @@ void HistoryController::updateForRedirectWithLockedBackForwardList()
if (Page* page = m_frame->page())
addVisitedLink(page, historyURL);
- if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry() && m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame->loader()->url().isEmpty())
+ if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry() && m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame->document()->url().isEmpty())
m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
}
}
@@ -402,8 +402,9 @@ void HistoryController::updateForCommit()
LOG(History, "WebCoreHistory: Updating History for commit in frame %s", frameLoader->documentLoader()->title().utf8().data());
#endif
FrameLoadType type = frameLoader->loadType();
- if (isBackForwardLoadType(type) ||
- ((type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && !frameLoader->provisionalDocumentLoader()->unreachableURL().isEmpty())) {
+ if (isBackForwardLoadType(type)
+ || isReplaceLoadTypeWithProvisionalItem(type)
+ || ((type == FrameLoadTypeReload || type == FrameLoadTypeReloadFromOrigin) && !frameLoader->provisionalDocumentLoader()->unreachableURL().isEmpty())) {
// Once committed, we want to use current item for saving DocState, and
// the provisional item for restoring state.
// Note previousItem must be set before we close the URL, which will
@@ -423,6 +424,13 @@ void HistoryController::updateForCommit()
}
}
+bool HistoryController::isReplaceLoadTypeWithProvisionalItem(FrameLoadType type)
+{
+ // Going back to an error page in a subframe can trigger a FrameLoadTypeReplace
+ // while m_provisionalItem is set, so we need to commit it.
+ return type == FrameLoadTypeReplace && m_provisionalItem;
+}
+
void HistoryController::recursiveUpdateForCommit()
{
// The frame that navigated will now have a null provisional item.
@@ -459,7 +467,7 @@ void HistoryController::recursiveUpdateForCommit()
void HistoryController::updateForSameDocumentNavigation()
{
- if (m_frame->loader()->url().isEmpty())
+ if (m_frame->document()->url().isEmpty())
return;
Settings* settings = m_frame->settings();
@@ -470,7 +478,26 @@ void HistoryController::updateForSameDocumentNavigation()
if (!page)
return;
- addVisitedLink(page, m_frame->loader()->url());
+ addVisitedLink(page, m_frame->document()->url());
+ page->mainFrame()->loader()->history()->recursiveUpdateForSameDocumentNavigation();
+}
+
+void HistoryController::recursiveUpdateForSameDocumentNavigation()
+{
+ // The frame that navigated will now have a null provisional item.
+ // Ignore it and its children.
+ if (!m_provisionalItem)
+ return;
+
+ // Commit the provisional item.
+ m_frameLoadComplete = false;
+ m_previousItem = m_currentItem;
+ m_currentItem = m_provisionalItem;
+ m_provisionalItem = 0;
+
+ // Iterate over the rest of the tree.
+ for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
+ child->loader()->history()->recursiveUpdateForSameDocumentNavigation();
}
void HistoryController::updateForFrameLoadCompleted()
@@ -620,6 +647,7 @@ void HistoryController::recursiveSetProvisionalItem(HistoryItem* item, HistoryIt
const HistoryItemVector& childItems = item->children();
int size = childItems.size();
+
for (int i = 0; i < size; ++i) {
String childFrameName = childItems[i]->target();
HistoryItem* fromChildItem = fromItem->childItemWithTarget(childFrameName);
@@ -658,14 +686,6 @@ void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt
bool HistoryController::itemsAreClones(HistoryItem* item1, HistoryItem* item2) const
{
- // It appears that one of the items can be null in release builds, leading
- // to the crashes seen in http://webkit.org/b/52819. For now, try to
- // narrow it down with a more specific crash.
- if (!item1)
- CRASH();
- if (!item2)
- CRASH();
-
// If the item we're going to is a clone of the item we're at, then we do
// not need to load it again. The current frame tree and the frame tree
// snapshot in the item have to match.