[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
darin at chromium.org
darin at chromium.org
Thu Feb 4 21:28:15 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 40a0007d26ac03bdef1ee217744d82da6a38210f
Author: darin at chromium.org <darin at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 26 19:30:17 2010 +0000
2010-01-25 Darin Fisher <darin at chromium.org>
Reviewed by Brady Eidson.
Chains of history items representing same-document navigation need to
always remember that association
https://bugs.webkit.org/show_bug.cgi?id=33224
Replace HistoryItem's Document pointer with a DocumentSequenceNumber.
During session history traversal, if the current HistoryItem and the
target HistoryItem have the same DocumentSequenceNumber, then it means
that the current Document should remain.
NOTE: To support Chromium's serialization of HistoryItems, I generate
DocumentSequenceNumbers that are unique across application launches.
DocumentSequenceNumbers are generated using a counter initialized with
the time of day.
Test: fast/loader/stateobjects/document-destroyed-navigate-back.html
* dom/Document.cpp:
(WebCore::Document::detach):
* dom/Document.h:
* history/BackForwardList.cpp:
(WebCore::BackForwardList::pushStateItem):
* history/BackForwardListChromium.cpp:
(WebCore::BackForwardList::pushStateItem):
* history/HistoryItem.cpp:
(WebCore::generateDocumentSequenceNumber):
(WebCore::HistoryItem::HistoryItem):
(WebCore::HistoryItem::~HistoryItem):
(WebCore::HistoryItem::setStateObject):
* history/HistoryItem.h:
(WebCore::HistoryItem::setDocumentSequenceNumber):
(WebCore::HistoryItem::documentSequenceNumber):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::navigateWithinDocument):
(WebCore::FrameLoader::loadItem):
* loader/HistoryController.cpp:
(WebCore::HistoryController::updateBackForwardListForFragmentScroll):
(WebCore::HistoryController::pushState):
(WebCore::HistoryController::replaceState):
* loader/RedirectScheduler.cpp:
(WebCore::RedirectScheduler::scheduleHistoryNavigation):
* page/History.cpp:
(WebCore::History::stateObjectAdded):
* page/Page.cpp:
(WebCore::Page::goToItem):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 55102f4..2bff1ea 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-01-25 Darin Fisher <darin at chromium.org>
+
+ Reviewed by Brady Eidson.
+
+ Chains of history items representing same-document navigation need to
+ always remember that association
+
+ https://bugs.webkit.org/show_bug.cgi?id=33224
+
+ * fast/loader/stateobjects/document-destroyed-navigate-back-expected.txt:
+ * fast/loader/stateobjects/document-destroyed-navigate-back.html: Revised
+ test results to match corrected behavior. Also removed the redundant
+ history.back() call, which helps make the test a bit easier to understand.
+
2010-01-26 Chris Fleizach <cfleizach at apple.com>
One more attempt to get GTK version to pass.
diff --git a/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-expected.txt b/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-expected.txt
index da3ae80..0e8a11d 100644
--- a/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-expected.txt
+++ b/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-expected.txt
@@ -5,8 +5,6 @@ ALERT: Navigating back...
main frame - has 1 onunload handler(s)
ALERT: Last path component of location is document-destroyed-navigate-back.html?SecondEntryWillLaterBeReactivated
ALERT: State popped - SecondEntryWillLaterBeReactivated (type string)
-main frame - has 1 onunload handler(s)
-ALERT: Last path component of location is document-destroyed-navigate-back.html?FirstEntryWillLaterBeReactivated
ALERT: State popped - FirstEntryWillLaterBeReactivated (type string)
ALERT: Test complete
This test:
diff --git a/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html b/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html
index 8e6a644..7dca361 100644
--- a/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html
+++ b/LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back.html
@@ -24,7 +24,6 @@ function runFirstStageOfTest()
function runSecondStageOfTest()
{
alert("Last path component of location is " + lastPathComponent());
- history.back();
}
function runThirdStageOfTest()
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ef8dba1..9f3120c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,53 @@
+2010-01-25 Darin Fisher <darin at chromium.org>
+
+ Reviewed by Brady Eidson.
+
+ Chains of history items representing same-document navigation need to
+ always remember that association
+
+ https://bugs.webkit.org/show_bug.cgi?id=33224
+
+ Replace HistoryItem's Document pointer with a DocumentSequenceNumber.
+ During session history traversal, if the current HistoryItem and the
+ target HistoryItem have the same DocumentSequenceNumber, then it means
+ that the current Document should remain.
+
+ NOTE: To support Chromium's serialization of HistoryItems, I generate
+ DocumentSequenceNumbers that are unique across application launches.
+ DocumentSequenceNumbers are generated using a counter initialized with
+ the time of day.
+
+ Test: fast/loader/stateobjects/document-destroyed-navigate-back.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::detach):
+ * dom/Document.h:
+ * history/BackForwardList.cpp:
+ (WebCore::BackForwardList::pushStateItem):
+ * history/BackForwardListChromium.cpp:
+ (WebCore::BackForwardList::pushStateItem):
+ * history/HistoryItem.cpp:
+ (WebCore::generateDocumentSequenceNumber):
+ (WebCore::HistoryItem::HistoryItem):
+ (WebCore::HistoryItem::~HistoryItem):
+ (WebCore::HistoryItem::setStateObject):
+ * history/HistoryItem.h:
+ (WebCore::HistoryItem::setDocumentSequenceNumber):
+ (WebCore::HistoryItem::documentSequenceNumber):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::navigateWithinDocument):
+ (WebCore::FrameLoader::loadItem):
+ * loader/HistoryController.cpp:
+ (WebCore::HistoryController::updateBackForwardListForFragmentScroll):
+ (WebCore::HistoryController::pushState):
+ (WebCore::HistoryController::replaceState):
+ * loader/RedirectScheduler.cpp:
+ (WebCore::RedirectScheduler::scheduleHistoryNavigation):
+ * page/History.cpp:
+ (WebCore::History::stateObjectAdded):
+ * page/Page.cpp:
+ (WebCore::Page::goToItem):
+
2010-01-26 Chris Fleizach <cfleizach at apple.com>
Reviewed by Darin Adler.
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index af456b4..272f1a0 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -1548,12 +1548,6 @@ void Document::detach()
if (render)
render->destroy();
- HashSet<RefPtr<HistoryItem> > associatedHistoryItems;
- associatedHistoryItems.swap(m_associatedHistoryItems);
- HashSet<RefPtr<HistoryItem> >::iterator end = associatedHistoryItems.end();
- for (HashSet<RefPtr<HistoryItem> >::iterator i = associatedHistoryItems.begin(); i != end; ++i)
- (*i)->documentDetached(this);
-
// This is required, as our Frame might delete itself as soon as it detaches
// us. However, this violates Node::detach() semantics, as it's never
// possible to re-attach. Eventually Document::detach() should be renamed,
@@ -4494,18 +4488,6 @@ void Document::statePopped(SerializedScriptValue* stateObject)
m_pendingStateObject = stateObject;
}
-void Document::registerHistoryItem(HistoryItem* item)
-{
- ASSERT(!m_associatedHistoryItems.contains(item));
- m_associatedHistoryItems.add(item);
-}
-
-void Document::unregisterHistoryItem(HistoryItem* item)
-{
- ASSERT(m_associatedHistoryItems.contains(item) || m_associatedHistoryItems.isEmpty());
- m_associatedHistoryItems.remove(item);
-}
-
void Document::updateSandboxFlags()
{
if (m_frame && securityOrigin())
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 265b351..909f961 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -907,8 +907,6 @@ public:
void updateURLForPushOrReplaceState(const KURL&);
void statePopped(SerializedScriptValue*);
- void registerHistoryItem(HistoryItem* item);
- void unregisterHistoryItem(HistoryItem* item);
void updateSandboxFlags(); // Set sandbox flags as determined by the frame.
diff --git a/WebCore/history/BackForwardList.cpp b/WebCore/history/BackForwardList.cpp
index 56e1b2e..721d949 100644
--- a/WebCore/history/BackForwardList.cpp
+++ b/WebCore/history/BackForwardList.cpp
@@ -239,20 +239,15 @@ HistoryItemVector& BackForwardList::entries()
void BackForwardList::pushStateItem(PassRefPtr<HistoryItem> newItem)
{
ASSERT(newItem);
- ASSERT(newItem->document());
ASSERT(newItem->stateObject());
RefPtr<HistoryItem> current = currentItem();
ASSERT(current);
- Document* newItemDocument = newItem->document();
-
addItem(newItem);
- if (!current->document()) {
- current->setDocument(newItemDocument);
+ if (!current->stateObject())
current->setStateObject(SerializedScriptValue::create());
- }
}
void BackForwardList::close()
diff --git a/WebCore/history/BackForwardListChromium.cpp b/WebCore/history/BackForwardListChromium.cpp
index f539e80..a780b7d 100644
--- a/WebCore/history/BackForwardListChromium.cpp
+++ b/WebCore/history/BackForwardListChromium.cpp
@@ -123,7 +123,12 @@ HistoryItem* BackForwardList::itemAtIndex(int index)
void BackForwardList::pushStateItem(PassRefPtr<HistoryItem> newItem)
{
- // FIXME: Need to implement state support for chromium.
+ RefPtr<HistoryItem> current = m_client->currentItem();
+
+ addItem(newItem);
+
+ if (!current->stateObject())
+ current->setStateObject(SerializedScriptValue::create());
}
HistoryItemVector& BackForwardList::entries()
diff --git a/WebCore/history/HistoryItem.cpp b/WebCore/history/HistoryItem.cpp
index 4c9eabe..d641d4e 100644
--- a/WebCore/history/HistoryItem.cpp
+++ b/WebCore/history/HistoryItem.cpp
@@ -33,9 +33,18 @@
#include "PageCache.h"
#include "ResourceRequest.h"
#include <stdio.h>
+#include <wtf/CurrentTime.h>
namespace WebCore {
+static long long generateDocumentSequenceNumber()
+{
+ // Initialize to the current time to reduce the likelihood of generating
+ // identifiers that overlap with those from past/future browser sessions.
+ static long long next = static_cast<long long>(currentTime() * 1000000.0);
+ return ++next;
+}
+
static void defaultNotifyHistoryItemChanged(HistoryItem*)
{
}
@@ -48,7 +57,7 @@ HistoryItem::HistoryItem()
, m_lastVisitWasFailure(false)
, m_isTargetItem(false)
, m_visitCount(0)
- , m_document(0)
+ , m_documentSequenceNumber(generateDocumentSequenceNumber())
{
}
@@ -61,7 +70,7 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, double ti
, m_lastVisitWasFailure(false)
, m_isTargetItem(false)
, m_visitCount(0)
- , m_document(0)
+ , m_documentSequenceNumber(generateDocumentSequenceNumber())
{
iconDatabase()->retainIconForPageURL(m_urlString);
}
@@ -76,7 +85,7 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, const Str
, m_lastVisitWasFailure(false)
, m_isTargetItem(false)
, m_visitCount(0)
- , m_document(0)
+ , m_documentSequenceNumber(generateDocumentSequenceNumber())
{
iconDatabase()->retainIconForPageURL(m_urlString);
}
@@ -92,7 +101,7 @@ HistoryItem::HistoryItem(const KURL& url, const String& target, const String& pa
, m_lastVisitWasFailure(false)
, m_isTargetItem(false)
, m_visitCount(0)
- , m_document(0)
+ , m_documentSequenceNumber(generateDocumentSequenceNumber())
{
iconDatabase()->retainIconForPageURL(m_urlString);
}
@@ -100,7 +109,6 @@ HistoryItem::HistoryItem(const KURL& url, const String& target, const String& pa
HistoryItem::~HistoryItem()
{
ASSERT(!m_cachedPage);
- ASSERT(!m_document);
iconDatabase()->releaseIconForPageURL(m_urlString);
#if PLATFORM(ANDROID)
if (m_bridge)
@@ -125,7 +133,7 @@ inline HistoryItem::HistoryItem(const HistoryItem& item)
, m_visitCount(item.m_visitCount)
, m_dailyVisitCounts(item.m_dailyVisitCounts)
, m_weeklyVisitCounts(item.m_weeklyVisitCounts)
- , m_document(0)
+ , m_documentSequenceNumber(generateDocumentSequenceNumber())
, m_formContentType(item.m_formContentType)
{
if (item.m_formData)
@@ -397,29 +405,9 @@ void HistoryItem::setIsTargetItem(bool flag)
void HistoryItem::setStateObject(PassRefPtr<SerializedScriptValue> object)
{
- ASSERT(m_document);
m_stateObject = object;
}
-void HistoryItem::setDocument(Document* document)
-{
- if (m_document == document)
- return;
-
- if (m_document)
- m_document->unregisterHistoryItem(this);
- if (document)
- document->registerHistoryItem(this);
-
- m_document = document;
-}
-
-void HistoryItem::documentDetached(Document* document)
-{
- ASSERT_UNUSED(document, m_document == document);
- m_document = 0;
-}
-
void HistoryItem::addChildItem(PassRefPtr<HistoryItem> child)
{
ASSERT(!childItemWithTarget(child->target()));
diff --git a/WebCore/history/HistoryItem.h b/WebCore/history/HistoryItem.h
index 4c91e76..ee8c0c8 100644
--- a/WebCore/history/HistoryItem.h
+++ b/WebCore/history/HistoryItem.h
@@ -135,9 +135,9 @@ public:
void setStateObject(PassRefPtr<SerializedScriptValue> object);
SerializedScriptValue* stateObject() const { return m_stateObject.get(); }
- void setDocument(Document* document);
- Document* document() const { return m_document; }
- void documentDetached(Document*);
+
+ void setDocumentSequenceNumber(long long number) { m_documentSequenceNumber = number; }
+ long long documentSequenceNumber() const { return m_documentSequenceNumber; }
void setFormInfoFromRequest(const ResourceRequest&);
void setFormData(PassRefPtr<FormData>);
@@ -244,7 +244,7 @@ private:
// Support for HTML5 History
RefPtr<SerializedScriptValue> m_stateObject;
- Document* m_document;
+ long long m_documentSequenceNumber;
// info used to repost form data
RefPtr<FormData> m_formData;
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index c5475e8..24fa19a 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -3693,7 +3693,7 @@ Frame* FrameLoader::findFrameForNavigation(const AtomicString& name)
void FrameLoader::navigateWithinDocument(HistoryItem* item)
{
- ASSERT(!item->document() || item->document() == m_frame->document());
+ ASSERT(item->documentSequenceNumber() == history()->currentItem()->documentSequenceNumber());
// Save user view state to the current history item here since we don't do a normal load.
// FIXME: Does form state need to be saved here too?
@@ -3814,7 +3814,7 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType)
// - The HistoryItem has a history state object
// - Navigating to an anchor within the page, with no form data stored on the target item or the current history entry,
// and the URLs in the frame tree match the history item for fragment scrolling.
- bool sameDocumentNavigation = (!item->formData() && !(history()->currentItem() && history()->currentItem()->formData()) && history()->urlsMatchItem(item)) || item->document() == m_frame->document();
+ bool sameDocumentNavigation = (!item->formData() && !(history()->currentItem() && history()->currentItem()->formData()) && history()->urlsMatchItem(item)) || item->documentSequenceNumber() == history()->currentItem()->documentSequenceNumber();
#if ENABLE(WML)
// All WML decks should go through the real load mechanism, not the scroll-to-anchor code
diff --git a/WebCore/loader/HistoryController.cpp b/WebCore/loader/HistoryController.cpp
index 90bd60b..43c9979 100644
--- a/WebCore/loader/HistoryController.cpp
+++ b/WebCore/loader/HistoryController.cpp
@@ -106,6 +106,10 @@ void HistoryController::restoreScrollPositionAndViewState()
void HistoryController::updateBackForwardListForFragmentScroll()
{
updateBackForwardListClippedAtTarget(false);
+
+ // Since the document isn't changed as a result of a fragment scroll, we should
+ // preserve the DocumentSequenceNumber of the previous item.
+ m_currentItem->setDocumentSequenceNumber(m_previousItem->documentSequenceNumber());
}
void HistoryController::saveDocumentState()
@@ -635,10 +639,13 @@ void HistoryController::pushState(PassRefPtr<SerializedScriptValue> stateObject,
ASSERT(item->isTargetItem());
// Override data in the target item to reflect the pushState() arguments.
- item->setDocument(m_frame->document());
item->setTitle(title);
item->setStateObject(stateObject);
item->setURLString(urlString);
+
+ // Since the document isn't changed as a result of a pushState call, we
+ // should preserve the DocumentSequenceNumber of the previous item.
+ item->setDocumentSequenceNumber(m_previousItem->documentSequenceNumber());
page->backForwardList()->pushStateItem(item.release());
}
@@ -649,10 +656,7 @@ void HistoryController::replaceState(PassRefPtr<SerializedScriptValue> stateObje
ASSERT(page);
HistoryItem* current = page->backForwardList()->currentItem();
ASSERT(current);
-
- ASSERT(!current->document() || current->document() == m_frame->document());
- current->setDocument(m_frame->document());
-
+
if (!urlString.isEmpty())
current->setURLString(urlString);
current->setTitle(title);
diff --git a/WebCore/loader/RedirectScheduler.cpp b/WebCore/loader/RedirectScheduler.cpp
index 04e9642..4b44422 100644
--- a/WebCore/loader/RedirectScheduler.cpp
+++ b/WebCore/loader/RedirectScheduler.cpp
@@ -277,7 +277,7 @@ void RedirectScheduler::scheduleHistoryNavigation(int steps)
// If the specified entry and the current entry have the same document, this is either a state object traversal or a fragment
// traversal (or both) and should be performed synchronously.
HistoryItem* currentEntry = m_frame->loader()->history()->currentItem();
- if (currentEntry != specifiedEntry && specifiedEntry->document() && currentEntry->document() == specifiedEntry->document()) {
+ if (currentEntry != specifiedEntry && currentEntry->documentSequenceNumber() == specifiedEntry->documentSequenceNumber()) {
m_frame->loader()->history()->goToItem(specifiedEntry, FrameLoadTypeIndexedBackForward);
return;
}
diff --git a/WebCore/page/History.cpp b/WebCore/page/History.cpp
index f352bc9..78e8ea6 100644
--- a/WebCore/page/History.cpp
+++ b/WebCore/page/History.cpp
@@ -112,13 +112,13 @@ void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str
else if (stateObjectType == StateObjectReplace)
m_frame->loader()->history()->replaceState(data, title, fullURL.string());
- if (!urlString.isEmpty()) {
+ if (!urlString.isEmpty())
m_frame->document()->updateURLForPushOrReplaceState(fullURL);
- if (stateObjectType == StateObjectPush)
- m_frame->loader()->client()->dispatchDidPushStateWithinPage();
- else if (stateObjectType == StateObjectReplace)
- m_frame->loader()->client()->dispatchDidReplaceStateWithinPage();
- }
+
+ if (stateObjectType == StateObjectPush)
+ m_frame->loader()->client()->dispatchDidPushStateWithinPage();
+ else if (stateObjectType == StateObjectReplace)
+ m_frame->loader()->client()->dispatchDidReplaceStateWithinPage();
}
} // namespace WebCore
diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp
index dee120a..643da9d 100644
--- a/WebCore/page/Page.cpp
+++ b/WebCore/page/Page.cpp
@@ -290,7 +290,7 @@ void Page::goBackOrForward(int distance)
void Page::goToItem(HistoryItem* item, FrameLoadType type)
{
// Abort any current load unless we're navigating the current document to a new state object
- if (!item->stateObject() || item->document() != m_mainFrame->document()) {
+ if (!item->stateObject() || item->documentSequenceNumber() != m_mainFrame->loader()->history()->currentItem()->documentSequenceNumber()) {
// Define what to do with any open database connections. By default we stop them and terminate the database thread.
DatabasePolicy databasePolicy = DatabasePolicyStop;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list