[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
darin at chromium.org
darin at chromium.org
Wed Mar 17 18:44:00 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 8bb5110a15afd797ff047429193860a7b6ce0182
Author: darin at chromium.org <darin at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Mar 16 17:26:59 2010 +0000
2010-03-15 Darin Fisher <darin at chromium.org>
Reviewed by Adam Barth.
https://bugs.webkit.org/show_bug.cgi?id=36152
[chromium] Add support for history.pushState and history.replaceState
This is covered by the existing tests in fast/loader/stateobjects
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@56070 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 38881fd..c2e12a3 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-03-15 Darin Fisher <darin at chromium.org>
+
+ Reviewed by Adam Barth.
+
+ https://bugs.webkit.org/show_bug.cgi?id=36152
+ [chromium] Add support for history.pushState and history.replaceState
+
+ This is covered by the existing tests in fast/loader/stateobjects
+
+ * bindings/v8/SerializedScriptValue.cpp:
+ (WebCore::ZigZag::Deserializer::deserialize):
+ (WebCore::SerializedScriptValue::deserialize):
+ * bindings/v8/SerializedScriptValue.h:
+ Switch to returning v8::Null instead of the empty value to match JSC
+ and the spec.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::loadInSameDocument): Call
+ dispatchDidNavigateWithinPage just before dispatching events to the
+ page. This ordering is important since the event handlers could
+ destroy the page or start another navigation.
+
+ * loader/FrameLoaderClient.h: Add dispatchDidNavigateWithinPage to
+ notify the client whenever a navigation occurs without changing any of
+ the documents in the page.
+
2010-03-16 Adam Roben <aroben at apple.com>
Fix linker warnings when building WebCore on Windows
diff --git a/WebCore/bindings/v8/SerializedScriptValue.cpp b/WebCore/bindings/v8/SerializedScriptValue.cpp
index bac7f20..46645d5 100644
--- a/WebCore/bindings/v8/SerializedScriptValue.cpp
+++ b/WebCore/bindings/v8/SerializedScriptValue.cpp
@@ -590,15 +590,15 @@ public:
{
}
- v8::Local<v8::Value> deserialize()
+ v8::Handle<v8::Value> deserialize()
{
v8::HandleScope scope;
while (!m_reader.isEof()) {
if (!doDeserialize())
- return v8::Local<v8::Value>();
+ return v8::Null();
}
if (stackDepth() != 1)
- return v8::Local<v8::Value>();
+ return v8::Null();
return scope.Close(element(0));
}
@@ -686,10 +686,10 @@ SerializedScriptValue::SerializedScriptValue(String data, StringDataMode mode)
}
}
-v8::Local<v8::Value> SerializedScriptValue::deserialize()
+v8::Handle<v8::Value> SerializedScriptValue::deserialize()
{
if (!m_data.impl())
- return v8::Local<v8::Value>();
+ return v8::Null();
COMPILE_ASSERT(sizeof(BufferValueType) == 2, BufferValueTypeIsTwoBytes);
Reader reader(reinterpret_cast<const char*>(m_data.impl()->characters()), 2 * m_data.length());
Deserializer deserializer(reader);
diff --git a/WebCore/bindings/v8/SerializedScriptValue.h b/WebCore/bindings/v8/SerializedScriptValue.h
index 7eb8935..ba4d5ed 100644
--- a/WebCore/bindings/v8/SerializedScriptValue.h
+++ b/WebCore/bindings/v8/SerializedScriptValue.h
@@ -74,9 +74,9 @@ public:
String toWireString() const { return m_data; }
- // Deserializes the value (in the current context). Returns an
- // empty handle in case of failure.
- v8::Local<v8::Value> deserialize();
+ // Deserializes the value (in the current context). Returns a null value in
+ // case of failure.
+ v8::Handle<v8::Value> deserialize();
private:
enum StringDataMode {
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index e10b58f..4e198b0 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -1773,6 +1773,8 @@ void FrameLoader::loadInSameDocument(const KURL& url, SerializedScriptValue* sta
checkLoadComplete();
}
+ m_client->dispatchDidNavigateWithinPage();
+
if (stateObject) {
m_frame->document()->statePopped(stateObject);
m_client->dispatchDidPopStateWithinPage();
diff --git a/WebCore/loader/FrameLoaderClient.h b/WebCore/loader/FrameLoaderClient.h
index 4e0f763..4397f12 100644
--- a/WebCore/loader/FrameLoaderClient.h
+++ b/WebCore/loader/FrameLoaderClient.h
@@ -115,6 +115,7 @@ namespace WebCore {
virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0;
virtual void dispatchDidCancelClientRedirect() = 0;
virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate) = 0;
+ virtual void dispatchDidNavigateWithinPage() { }
virtual void dispatchDidChangeLocationWithinPage() = 0;
virtual void dispatchDidPushStateWithinPage() = 0;
virtual void dispatchDidReplaceStateWithinPage() = 0;
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index e6f726e..a43a71e 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -64,6 +64,54 @@
2010-03-15 Darin Fisher <darin at chromium.org>
+ Reviewed by Adam Barth.
+
+ https://bugs.webkit.org/show_bug.cgi?id=36152
+ [chromium] Add support for history.pushState and history.replaceState
+
+ * public/WebFrameClient.h:
+ (WebKit::WebFrameClient::didNavigateWithinPage): Move implementation of
+ didChangeLocationWithinPage to here. Only add to the redirect chain if
+ we are performing a simple hash change (i.e., no state object on the
+ history item). Call the old didChangeLocationWithinPage for backwards
+ compat with Chromium. This will be removed in a subsequent patch.
+
+ (WebKit::WebFrameClient::didChangeLocationWithinPage):
+ * src/FrameLoaderClientImpl.cpp:
+ (WebKit::FrameLoaderClientImpl::dispatchDidNavigateWithinPage):
+ (WebKit::FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage):
+ Call the new version of didChangeLocationWithinPage without the
+ parameter to indicate whether this is a new navigation or not. We only
+ need this method on WebFrameClient to support TestShell / DRT.
+
+ (WebKit::FrameLoaderClientImpl::dispatchDidPushStateWithinPage):
+ Call dispatchDidNavigateWithinPage since pushState is just a type of
+ in-page navigation. This is an in-page navigation that adds another
+ entry to session history.
+
+ (WebKit::FrameLoaderClientImpl::dispatchDidReplaceStateWithinPage):
+ Call dispatchDidNavigateWithinPage since replaceState is just a type of
+ in-page navigation. This is an in-page navigation that replaces the
+ current session history entry.
+
+ (WebKit::FrameLoaderClientImpl::dispatchDidPopStateWithinPage): Do
+ nothing since dispatchDidNavigateWithinPage is called in this case by
+ the FrameLoader.
+
+ (WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction):
+ (WebKit::FrameLoaderClientImpl::shouldGoToHistoryItem): Move the code
+ for handling the dummy chrome-back-forward://go/ URLs from
+ dispatchDecidePolicyForNavigationAction to shouldGoToHistoryItem, which
+ prevents the URLs from leaking into session history.
+ shouldGoToHistoryItem is called before any work is done by history
+ traversal, so this is a better place for this hack. Ultimately, this
+ code should be eliminatd in favor of better integration with
+ FrameLoader or HistoryController.
+
+ * src/FrameLoaderClientImpl.h:
+
+2010-03-15 Darin Fisher <darin at chromium.org>
+
Fix build bustage. We also need to pull down "third_party/tcmalloc"
* DEPS:
diff --git a/WebKit/chromium/public/WebFrameClient.h b/WebKit/chromium/public/WebFrameClient.h
index 136b158..c6f51b6 100644
--- a/WebKit/chromium/public/WebFrameClient.h
+++ b/WebKit/chromium/public/WebFrameClient.h
@@ -199,9 +199,16 @@ public:
// The frame's document and all of its subresources succeeded to load.
virtual void didFinishLoad(WebFrame*) { }
+ // The navigation resulted in no change to the documents within the page.
+ // For example, the navigation may have just resulted in scrolling to a
+ // named anchor or a PopState event may have been dispatched.
+ virtual void didNavigateWithinPage(WebFrame*, bool isNewNavigation) { }
+
// The navigation resulted in scrolling the page to a named anchor instead
// of downloading a new document.
+ // FIXME: The isNewNavigation parameter is DEPRECATED.
virtual void didChangeLocationWithinPage(WebFrame*, bool isNewNavigation) { }
+ virtual void didChangeLocationWithinPage(WebFrame*) { }
// Called upon update to scroll position, document state, and other
// non-navigational events related to the data held by WebHistoryItem.
diff --git a/WebKit/chromium/src/FrameLoaderClientImpl.cpp b/WebKit/chromium/src/FrameLoaderClientImpl.cpp
index d298ab2..5973c97 100644
--- a/WebKit/chromium/src/FrameLoaderClientImpl.cpp
+++ b/WebKit/chromium/src/FrameLoaderClientImpl.cpp
@@ -38,6 +38,7 @@
#include "FormState.h"
#include "FrameLoader.h"
#include "FrameLoadRequest.h"
+#include "HistoryItem.h"
#include "HitTestResult.h"
#include "HTMLAppletElement.h"
#include "HTMLFormElement.h" // needed by FormState.h
@@ -568,7 +569,7 @@ void FrameLoaderClientImpl::dispatchWillPerformClientRedirect(
}
}
-void FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage()
+void FrameLoaderClientImpl::dispatchDidNavigateWithinPage()
{
// Anchor fragment navigations are not normal loads, so we need to synthesize
// some events for our delegate.
@@ -585,6 +586,10 @@ void FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage()
if (webView->client() && loaderCompleted)
webView->client()->didStartLoading();
+ // We need to classify some hash changes as client redirects.
+ bool isHashChange =
+ !m_webFrame->frame()->loader()->history()->currentItem()->stateObject();
+
WebDataSourceImpl* ds = m_webFrame->dataSourceImpl();
ASSERT(ds); // Should not be null when navigating to a reference fragment!
if (ds) {
@@ -595,27 +600,29 @@ void FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage()
ds->clearRedirectChain();
}
- // Figure out if this location change is because of a JS-initiated
- // client redirect (e.g onload/setTimeout document.location.href=).
- // FIXME: (bugs 1085325, 1046841) We don't get proper redirect
- // performed/cancelled notifications across anchor navigations, so the
- // other redirect-tracking code in this class (see
- // dispatch*ClientRedirect() and dispatchDidStartProvisionalLoad) is
- // insufficient to catch and properly flag these transitions. Once a
- // proper fix for this bug is identified and applied the following
- // block may no longer be required.
- bool wasClientRedirect =
- (url == m_expectedClientRedirectDest && chainEnd == m_expectedClientRedirectSrc)
- || !m_webFrame->isProcessingUserGesture();
-
- if (wasClientRedirect) {
- if (m_webFrame->client())
- m_webFrame->client()->didCompleteClientRedirect(m_webFrame, chainEnd);
- ds->appendRedirect(chainEnd);
- // Make sure we clear the expected redirect since we just effectively
- // completed it.
- m_expectedClientRedirectSrc = KURL();
- m_expectedClientRedirectDest = KURL();
+ if (isHashChange) {
+ // Figure out if this location change is because of a JS-initiated
+ // client redirect (e.g onload/setTimeout document.location.href=).
+ // FIXME: (b/1085325, b/1046841) We don't get proper redirect
+ // performed/cancelled notifications across anchor navigations, so the
+ // other redirect-tracking code in this class (see
+ // dispatch*ClientRedirect() and dispatchDidStartProvisionalLoad) is
+ // insufficient to catch and properly flag these transitions. Once a
+ // proper fix for this bug is identified and applied the following
+ // block may no longer be required.
+ bool wasClientRedirect =
+ (url == m_expectedClientRedirectDest && chainEnd == m_expectedClientRedirectSrc)
+ || !m_webFrame->isProcessingUserGesture();
+
+ if (wasClientRedirect) {
+ if (m_webFrame->client())
+ m_webFrame->client()->didCompleteClientRedirect(m_webFrame, chainEnd);
+ ds->appendRedirect(chainEnd);
+ // Make sure we clear the expected redirect since we just effectively
+ // completed it.
+ m_expectedClientRedirectSrc = KURL();
+ m_expectedClientRedirectDest = KURL();
+ }
}
// Regardless of how we got here, we are navigating to a URL so we need to
@@ -625,27 +632,38 @@ void FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage()
bool isNewNavigation;
webView->didCommitLoad(&isNewNavigation);
- if (m_webFrame->client())
- m_webFrame->client()->didChangeLocationWithinPage(m_webFrame, isNewNavigation);
+ if (m_webFrame->client()) {
+ m_webFrame->client()->didNavigateWithinPage(m_webFrame, isNewNavigation);
+
+ // FIXME: Remove this notification once it is no longer consumed downstream.
+ if (isHashChange)
+ m_webFrame->client()->didChangeLocationWithinPage(m_webFrame, isNewNavigation);
+ }
// Generate didStopLoading if loader is completed.
if (webView->client() && loaderCompleted)
webView->client()->didStopLoading();
}
+void FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage()
+{
+ if (m_webFrame)
+ m_webFrame->client()->didChangeLocationWithinPage(m_webFrame);
+}
+
void FrameLoaderClientImpl::dispatchDidPushStateWithinPage()
{
- // FIXME
+ dispatchDidNavigateWithinPage();
}
void FrameLoaderClientImpl::dispatchDidReplaceStateWithinPage()
{
- // FIXME
+ dispatchDidNavigateWithinPage();
}
void FrameLoaderClientImpl::dispatchDidPopStateWithinPage()
{
- // FIXME
+ // Ignored since dispatchDidNavigateWithinPage was already called.
}
void FrameLoaderClientImpl::dispatchWillClose()
@@ -910,51 +928,48 @@ void FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction(
// The null check here is to fix a crash that seems strange
// (see - https://bugs.webkit.org/show_bug.cgi?id=23554).
if (m_webFrame->client() && !request.url().isNull()) {
- WebNavigationPolicy navigationPolicy = WebNavigationPolicyCurrentTab;
- actionSpecifiesNavigationPolicy(action, &navigationPolicy);
-
- // Give the delegate a chance to change the navigation policy.
- const WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl();
- if (ds) {
- KURL url = ds->request().url();
- if (url.protocolIs(backForwardNavigationScheme)) {
- handleBackForwardNavigation(url);
- navigationPolicy = WebNavigationPolicyIgnore;
- } else {
- bool isRedirect = ds->hasRedirectChain();
-
- WebNavigationType webnavType =
- WebDataSourceImpl::toWebNavigationType(action.type());
-
- RefPtr<Node> node;
- for (const Event* event = action.event(); event; event = event->underlyingEvent()) {
- if (event->isMouseEvent()) {
- const MouseEvent* mouseEvent =
- static_cast<const MouseEvent*>(event);
- node = m_webFrame->frame()->eventHandler()->hitTestResultAtPoint(
- mouseEvent->absoluteLocation(), false).innerNonSharedNode();
- break;
- }
- }
- WebNode originatingNode(node);
-
- navigationPolicy = m_webFrame->client()->decidePolicyForNavigation(
- m_webFrame, ds->request(), webnavType, originatingNode,
- navigationPolicy, isRedirect);
- }
- }
-
- if (navigationPolicy == WebNavigationPolicyCurrentTab)
- policyAction = PolicyUse;
- else if (navigationPolicy == WebNavigationPolicyDownload)
- policyAction = PolicyDownload;
- else {
- if (navigationPolicy != WebNavigationPolicyIgnore) {
- WrappedResourceRequest webreq(request);
- m_webFrame->client()->loadURLExternally(m_webFrame, webreq, navigationPolicy);
- }
- policyAction = PolicyIgnore;
- }
+ WebNavigationPolicy navigationPolicy = WebNavigationPolicyCurrentTab;
+ actionSpecifiesNavigationPolicy(action, &navigationPolicy);
+
+ // Give the delegate a chance to change the navigation policy.
+ const WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl();
+ if (ds) {
+ KURL url = ds->request().url();
+ ASSERT(!url.protocolIs(backForwardNavigationScheme));
+
+ bool isRedirect = ds->hasRedirectChain();
+
+ WebNavigationType webnavType =
+ WebDataSourceImpl::toWebNavigationType(action.type());
+
+ RefPtr<Node> node;
+ for (const Event* event = action.event(); event; event = event->underlyingEvent()) {
+ if (event->isMouseEvent()) {
+ const MouseEvent* mouseEvent =
+ static_cast<const MouseEvent*>(event);
+ node = m_webFrame->frame()->eventHandler()->hitTestResultAtPoint(
+ mouseEvent->absoluteLocation(), false).innerNonSharedNode();
+ break;
+ }
+ }
+ WebNode originatingNode(node);
+
+ navigationPolicy = m_webFrame->client()->decidePolicyForNavigation(
+ m_webFrame, ds->request(), webnavType, originatingNode,
+ navigationPolicy, isRedirect);
+ }
+
+ if (navigationPolicy == WebNavigationPolicyCurrentTab)
+ policyAction = PolicyUse;
+ else if (navigationPolicy == WebNavigationPolicyDownload)
+ policyAction = PolicyDownload;
+ else {
+ if (navigationPolicy != WebNavigationPolicyIgnore) {
+ WrappedResourceRequest webreq(request);
+ m_webFrame->client()->loadURLExternally(m_webFrame, webreq, navigationPolicy);
+ }
+ policyAction = PolicyIgnore;
+ }
}
(m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction);
@@ -1099,10 +1114,28 @@ void FrameLoaderClientImpl::updateGlobalHistoryRedirectLinks()
{
}
-bool FrameLoaderClientImpl::shouldGoToHistoryItem(HistoryItem*) const
+bool FrameLoaderClientImpl::shouldGoToHistoryItem(HistoryItem* item) const
{
- // FIXME
- return true;
+ const KURL& url = item->url();
+ if (!url.protocolIs(backForwardNavigationScheme))
+ return true;
+
+ // Else, we'll punt this history navigation to the embedder. It is
+ // necessary that we intercept this here, well before the FrameLoader
+ // has made any state changes for this history traversal.
+
+ bool ok;
+ int offset = url.lastPathComponent().toIntStrict(&ok);
+ if (!ok) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ WebViewImpl* webview = m_webFrame->viewImpl();
+ if (webview->client())
+ webview->client()->navigateBackForwardSoon(offset);
+
+ return false;
}
void FrameLoaderClientImpl::dispatchDidAddBackForwardItem(HistoryItem*) const
@@ -1495,20 +1528,6 @@ bool FrameLoaderClientImpl::actionSpecifiesNavigationPolicy(
event->metaKey(), policy);
}
-void FrameLoaderClientImpl::handleBackForwardNavigation(const KURL& url)
-{
- ASSERT(url.protocolIs(backForwardNavigationScheme));
-
- bool ok;
- int offset = url.lastPathComponent().toIntStrict(&ok);
- if (!ok)
- return;
-
- WebViewImpl* webview = m_webFrame->viewImpl();
- if (webview->client())
- webview->client()->navigateBackForwardSoon(offset);
-}
-
PassOwnPtr<WebPluginLoadObserver> FrameLoaderClientImpl::pluginLoadObserver()
{
WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(
diff --git a/WebKit/chromium/src/FrameLoaderClientImpl.h b/WebKit/chromium/src/FrameLoaderClientImpl.h
index e0ee98c..89d7ad1 100644
--- a/WebKit/chromium/src/FrameLoaderClientImpl.h
+++ b/WebKit/chromium/src/FrameLoaderClientImpl.h
@@ -94,6 +94,7 @@ public:
virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
virtual void dispatchDidCancelClientRedirect();
virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate);
+ virtual void dispatchDidNavigateWithinPage();
virtual void dispatchDidChangeLocationWithinPage();
virtual void dispatchDidPushStateWithinPage();
virtual void dispatchDidReplaceStateWithinPage();
@@ -206,9 +207,6 @@ private:
static bool actionSpecifiesNavigationPolicy(
const WebCore::NavigationAction& action, WebNavigationPolicy* policy);
- // Called when a dummy back-forward navigation is intercepted.
- void handleBackForwardNavigation(const WebCore::KURL&);
-
PassOwnPtr<WebPluginLoadObserver> pluginLoadObserver();
// The WebFrame that owns this object and manages its lifetime. Therefore,
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list