Title: [114082] trunk/Source/WebCore
Revision
114082
Author
[email protected]
Date
2012-04-12 22:31:20 -0700 (Thu, 12 Apr 2012)

Log Message

Prepare window.location for seamless navigation
https://bugs.webkit.org/show_bug.cgi?id=83843

Reviewed by Eric Seidel.

This patch refactors window.location to flow through
FrameLoader::findFrameForNavigation, which is where we're going to
implement the seamless navigation redirect.  This patch shouldn't cause
any observable changes in behavior today, but it will make all the
seamless-window-location* tests in
https://github.com/eseidel/webkit/tree/seamless/LayoutTests/fast/frames/seamless
pass once we merge the seamlesss branch.  See
https://github.com/eseidel/webkit/commit/a6e708fa6c643b156397e9a287b40a0868c7959c
for context.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::setLocation):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::locationAccessorSetter):
* page/Location.cpp:
(WebCore::Location::setHref):
(WebCore::Location::setProtocol):
(WebCore::Location::setHost):
(WebCore::Location::setHostname):
(WebCore::Location::setPort):
(WebCore::Location::setPathname):
(WebCore::Location::setSearch):
(WebCore::Location::setHash):
(WebCore::Location::assign):
(WebCore::Location::replace):
(WebCore::Location::setLocation):
(WebCore):
* page/Location.h:
(Location):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (114081 => 114082)


--- trunk/Source/WebCore/ChangeLog	2012-04-13 05:28:44 UTC (rev 114081)
+++ trunk/Source/WebCore/ChangeLog	2012-04-13 05:31:20 UTC (rev 114082)
@@ -1,3 +1,40 @@
+2012-04-12  Adam Barth  <[email protected]>
+
+        Prepare window.location for seamless navigation
+        https://bugs.webkit.org/show_bug.cgi?id=83843
+
+        Reviewed by Eric Seidel.
+
+        This patch refactors window.location to flow through
+        FrameLoader::findFrameForNavigation, which is where we're going to
+        implement the seamless navigation redirect.  This patch shouldn't cause
+        any observable changes in behavior today, but it will make all the
+        seamless-window-location* tests in
+        https://github.com/eseidel/webkit/tree/seamless/LayoutTests/fast/frames/seamless
+        pass once we merge the seamlesss branch.  See
+        https://github.com/eseidel/webkit/commit/a6e708fa6c643b156397e9a287b40a0868c7959c
+        for context.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::setLocation):
+        * bindings/v8/custom/V8DOMWindowCustom.cpp:
+        (WebCore::V8DOMWindow::locationAccessorSetter):
+        * page/Location.cpp:
+        (WebCore::Location::setHref):
+        (WebCore::Location::setProtocol):
+        (WebCore::Location::setHost):
+        (WebCore::Location::setHostname):
+        (WebCore::Location::setPort):
+        (WebCore::Location::setPathname):
+        (WebCore::Location::setSearch):
+        (WebCore::Location::setHash):
+        (WebCore::Location::assign):
+        (WebCore::Location::replace):
+        (WebCore::Location::setLocation):
+        (WebCore):
+        * page/Location.h:
+        (Location):
+
 2012-04-12  Dana Jansens  <[email protected]>
 
         [chromium] Background filters for composited layers

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (114081 => 114082)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2012-04-13 05:28:44 UTC (rev 114081)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2012-04-13 05:31:20 UTC (rev 114082)
@@ -424,7 +424,8 @@
     if (exec->hadException())
         return;
 
-    impl()->setLocation(ustringToString(locationString), activeDOMWindow(exec), firstDOMWindow(exec));
+    if (Location* location = impl()->location())
+        location->setHref(ustringToString(locationString), activeDOMWindow(exec), firstDOMWindow(exec));
 }
 
 JSValue JSDOMWindow::event(ExecState* exec) const

Modified: trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp (114081 => 114082)


--- trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2012-04-13 05:28:44 UTC (rev 114081)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2012-04-13 05:31:20 UTC (rev 114082)
@@ -42,6 +42,7 @@
 #include "FrameView.h"
 #include "HTMLCollection.h"
 #include "HTMLDocument.h"
+#include "Location.h"
 #include "MediaPlayer.h"
 #include "MessagePort.h"
 #include "Page.h"
@@ -195,7 +196,8 @@
     if (!firstWindow)
       return;
 
-    imp->setLocation(toWebCoreString(value), activeWindow, firstWindow);
+    if (Location* location = imp->location())
+        location->setHref(toWebCoreString(value), activeWindow, firstWindow);
 }
 
 void V8DOMWindow::openerAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)

Modified: trunk/Source/WebCore/page/Location.cpp (114081 => 114082)


--- trunk/Source/WebCore/page/Location.cpp	2012-04-13 05:28:44 UTC (rev 114081)
+++ trunk/Source/WebCore/page/Location.cpp	2012-04-13 05:31:20 UTC (rev 114082)
@@ -143,11 +143,11 @@
     return fragmentIdentifier.isEmpty() ? emptyString() : "#" + fragmentIdentifier;
 }
 
-void Location::setHref(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow)
+void Location::setHref(const String& url, DOMWindow* activeWindow, DOMWindow* firstWindow)
 {
     if (!m_frame)
         return;
-    m_frame->domWindow()->setLocation(urlString, activeWindow, firstWindow);
+    setLocation(url, activeWindow, firstWindow);
 }
 
 void Location::setProtocol(const String& protocol, DOMWindow* activeWindow, DOMWindow* firstWindow, ExceptionCode& ec)
@@ -159,7 +159,7 @@
         ec = SYNTAX_ERR;
         return;
     }
-    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+    setLocation(url.string(), activeWindow, firstWindow);
 }
 
 void Location::setHost(const String& host, DOMWindow* activeWindow, DOMWindow* firstWindow)
@@ -168,7 +168,7 @@
         return;
     KURL url = ""
     url.setHostAndPort(host);
-    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+    setLocation(url.string(), activeWindow, firstWindow);
 }
 
 void Location::setHostname(const String& hostname, DOMWindow* activeWindow, DOMWindow* firstWindow)
@@ -177,7 +177,7 @@
         return;
     KURL url = ""
     url.setHost(hostname);
-    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+    setLocation(url.string(), activeWindow, firstWindow);
 }
 
 void Location::setPort(const String& portString, DOMWindow* activeWindow, DOMWindow* firstWindow)
@@ -190,7 +190,7 @@
         url.removePort();
     else
         url.setPort(port);
-    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+    setLocation(url.string(), activeWindow, firstWindow);
 }
 
 void Location::setPathname(const String& pathname, DOMWindow* activeWindow, DOMWindow* firstWindow)
@@ -199,7 +199,7 @@
         return;
     KURL url = ""
     url.setPath(pathname);
-    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+    setLocation(url.string(), activeWindow, firstWindow);
 }
 
 void Location::setSearch(const String& search, DOMWindow* activeWindow, DOMWindow* firstWindow)
@@ -208,7 +208,7 @@
         return;
     KURL url = ""
     url.setQuery(search);
-    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+    setLocation(url.string(), activeWindow, firstWindow);
 }
 
 void Location::setHash(const String& hash, DOMWindow* activeWindow, DOMWindow* firstWindow)
@@ -226,21 +226,22 @@
     // cases where fragment identifiers are ignored or invalid. 
     if (equalIgnoringNullity(oldFragmentIdentifier, url.fragmentIdentifier()))
         return;
-    m_frame->domWindow()->setLocation(url.string(), activeWindow, firstWindow);
+    setLocation(url.string(), activeWindow, firstWindow);
 }
 
-void Location::assign(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow)
+void Location::assign(const String& url, DOMWindow* activeWindow, DOMWindow* firstWindow)
 {
     if (!m_frame)
         return;
-    m_frame->domWindow()->setLocation(urlString, activeWindow, firstWindow);
+    setLocation(url, activeWindow, firstWindow);
 }
 
-void Location::replace(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow)
+void Location::replace(const String& url, DOMWindow* activeWindow, DOMWindow* firstWindow)
 {
     if (!m_frame)
         return;
-    m_frame->domWindow()->setLocation(urlString, activeWindow, firstWindow, LockHistoryAndBackForwardList);
+    // Note: We call DOMWindow::setLocation directly here because replace() always operates on the current frame.
+    m_frame->domWindow()->setLocation(url, activeWindow, firstWindow, LockHistoryAndBackForwardList);
 }
 
 void Location::reload(DOMWindow* activeWindow)
@@ -260,4 +261,14 @@
     m_frame->navigationScheduler()->scheduleRefresh();
 }
 
+void Location::setLocation(const String& url, DOMWindow* activeWindow, DOMWindow* firstWindow)
+{
+    ASSERT(m_frame);
+    // We call findFrameForNavigation to handle the case of a seamless iframe correctly.
+    Frame* frame = m_frame->loader()->findFrameForNavigation(String(), activeWindow->document());
+    if (!frame)
+        return;
+    frame->domWindow()->setLocation(url, activeWindow, firstWindow);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/Location.h (114081 => 114082)


--- trunk/Source/WebCore/page/Location.h	2012-04-13 05:28:44 UTC (rev 114081)
+++ trunk/Source/WebCore/page/Location.h	2012-04-13 05:31:20 UTC (rev 114082)
@@ -77,6 +77,8 @@
 private:
     explicit Location(Frame*);
 
+    void setLocation(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow);
+
     const KURL& url() const;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to