Title: [90342] trunk
Revision
90342
Author
[email protected]
Date
2011-07-03 10:27:51 -0700 (Sun, 03 Jul 2011)

Log Message

2011-07-03  Robert Hogan  <[email protected]>

        Restore scroll position on page reloads scheduled by <meta http-equiv="refresh" content="XX"/>
        https://bugs.webkit.org/show_bug.cgi?id=62482

        If a <meta http-equiv="refresh"> directive schedules a page reload rather than
        a redirect restore the scroll position after the reload. Do the same on location.reload().

        Reviewed by Adam Barth.

        * http/tests/navigation/scrollstate-after-http-equiv-refresh-expected.txt: Added.
        * http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2-expected.txt: Added.
        * http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2.html: Added.
        * http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-expected.txt: Added.
        * http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier.html: Added.
        * http/tests/navigation/scrollstate-after-http-equiv-refresh.html: Added.
        * http/tests/navigation/scrollstate-after-location-reload-expected.txt: Added.
        * http/tests/navigation/scrollstate-after-location-reload.html: Added.
2011-07-03  Robert Hogan  <[email protected]>

        Restore scroll position on page reloads scheduled by <meta http-equiv="refresh" content="XX"/>
        https://bugs.webkit.org/show_bug.cgi?id=62482

        If a <meta http-equiv="refresh"> directive schedules a page reload rather than
        a redirect restore the scroll position after the reload. Do the same on location.reload().

        Reviewed by Adam Barth.

        Tests: http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2.html
               http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier.html
               http/tests/navigation/scrollstate-after-http-equiv-refresh.html
               http/tests/navigation/scrollstate-after-location-reload.html

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::loadURL):
        Only make the load FrameLoadTypeSame if it has not already been set as FrameLoadTypeReload*.
        FrameLoadTypeReload* loads are set through http-equiv refreshes, manual reloads, or location.reload()
        and honour the user's scroll position in the frame. A FrameLoadTypeSame is for when the frame is loading
        the same page again, e.g. by clicking a link.

        * loader/NavigationScheduler.cpp:
        (WebCore::ScheduledRedirect::fire): Tell FrameLoader::changeLocation() if this is a reload.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (90341 => 90342)


--- trunk/LayoutTests/ChangeLog	2011-07-03 17:14:16 UTC (rev 90341)
+++ trunk/LayoutTests/ChangeLog	2011-07-03 17:27:51 UTC (rev 90342)
@@ -1,3 +1,22 @@
+2011-07-03  Robert Hogan  <[email protected]>
+
+        Restore scroll position on page reloads scheduled by <meta http-equiv="refresh" content="XX"/>
+        https://bugs.webkit.org/show_bug.cgi?id=62482
+
+        If a <meta http-equiv="refresh"> directive schedules a page reload rather than
+        a redirect restore the scroll position after the reload. Do the same on location.reload().
+
+        Reviewed by Adam Barth.
+
+        * http/tests/navigation/scrollstate-after-http-equiv-refresh-expected.txt: Added.
+        * http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2-expected.txt: Added.
+        * http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2.html: Added.
+        * http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-expected.txt: Added.
+        * http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier.html: Added.
+        * http/tests/navigation/scrollstate-after-http-equiv-refresh.html: Added.
+        * http/tests/navigation/scrollstate-after-location-reload-expected.txt: Added.
+        * http/tests/navigation/scrollstate-after-location-reload.html: Added.
+
 2011-04-02  Robert Hogan  <[email protected]>
 
         Reviewed by Benjamin Poulain.

Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-expected.txt (0 => 90342)


--- trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-expected.txt	2011-07-03 17:27:51 UTC (rev 90342)
@@ -0,0 +1 @@
+SUCCESS

Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2-expected.txt (0 => 90342)


--- trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2-expected.txt	2011-07-03 17:27:51 UTC (rev 90342)
@@ -0,0 +1 @@
+SUCCESS

Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2.html (0 => 90342)


--- trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2.html	2011-07-03 17:27:51 UTC (rev 90342)
@@ -0,0 +1,117 @@
+<html>
+<meta http-equiv="refresh" content="2">
+<script>
+
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.dumpAsText();
+}
+
+function testScroll() {
+  window.setTimeout(function() {
+        if (window.pageYOffset != 0) {
+          document.body.innerHTML = "SUCCESS";
+          layoutTestController.notifyDone();
+        } else
+          location.assign('scrollstate-after-http-equiv-refresh-fragment-identifier-2.html#1');
+    }, 0);
+}
+
+_onload_ = testScroll;
+
+</script>
+
+<body>
+This test checks that a page reloaded by http-equiv="refresh" respects the user's navigation to
+fragment identifiers within the page when reloading.
+https://bugs.webkit.org/show_bug.cgi?id=62482
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<div id="1"></div>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-expected.txt (0 => 90342)


--- trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-expected.txt	2011-07-03 17:27:51 UTC (rev 90342)
@@ -0,0 +1 @@
+SUCCESS

Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier.html (0 => 90342)


--- trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier.html	2011-07-03 17:27:51 UTC (rev 90342)
@@ -0,0 +1,131 @@
+<html>
+<meta http-equiv="refresh" content="2">
+<script>
+
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.dumpAsText();
+}
+function documentURLHash()
+{
+    var index = document.URL.lastIndexOf("#");
+    if (index == -1)
+        return "";
+    return document.URL.substring(index);
+}
+
+function hashChanged()
+{
+    document.body.innerHTML += "scrolled to hash " + documentURLHash();
+    window.scroll(0,100);
+}
+
+function testScroll() {
+  window.setTimeout(function() {
+        if (window.pageYOffset == 100) {
+          document.body.innerHTML = "SUCCESS";
+          layoutTestController.notifyDone();
+        } else
+          location.assign('scrollstate-after-http-equiv-refresh-fragment-identifier.html#1');
+    }, 0);
+}
+
+_onload_ = testScroll;
+_onhashchange_ = hashChanged;
+
+</script>
+
+<body>
+This test checks that a page reloaded by http-equiv="refresh" restores its scroll state even
+when the user has loaded a fragment within the document.
+https://bugs.webkit.org/show_bug.cgi?id=62482
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<div id="1"></div>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh.html (0 => 90342)


--- trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh.html	2011-07-03 17:27:51 UTC (rev 90342)
@@ -0,0 +1,58 @@
+<html>
+<meta http-equiv="refresh" content="2">
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.waitUntilDone();
+        layoutTestController.dumpAsText();
+    }
+    function testScroll() {
+      window.setTimeout(function() {
+          if (window.pageYOffset == 100) {
+            document.body.innerHTML = "SUCCESS";
+            layoutTestController.notifyDone();
+          } else
+            window.scroll(0,100);
+        }, 0);
+    }
+    _onload_ = testScroll;
+</script>
+
+<body>
+This test checks that a page reloaded by http-equiv="refresh" restores its scroll state.
+https://bugs.webkit.org/show_bug.cgi?id=62482
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-location-reload-expected.txt (0 => 90342)


--- trunk/LayoutTests/http/tests/navigation/scrollstate-after-location-reload-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/scrollstate-after-location-reload-expected.txt	2011-07-03 17:27:51 UTC (rev 90342)
@@ -0,0 +1 @@
+SUCCESS

Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-location-reload.html (0 => 90342)


--- trunk/LayoutTests/http/tests/navigation/scrollstate-after-location-reload.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/scrollstate-after-location-reload.html	2011-07-03 17:27:51 UTC (rev 90342)
@@ -0,0 +1,61 @@
+<html>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.waitUntilDone();
+        layoutTestController.dumpAsText();
+    }
+    function testScroll() {
+      window.setTimeout(function() {
+          if (window.pageYOffset == 100) {
+            document.body.innerHTML = "SUCCESS";
+            layoutTestController.notifyDone();
+          } else {
+            window.scroll(0,100);
+            window.setTimeout(function() {
+              window.location.reload();
+            }, 1000);
+          }
+        }, 0);
+    }
+    _onload_ = testScroll;
+</script>
+
+<body>
+This test checks that a page reloaded by window.location.reload() restores its scroll state.
+https://bugs.webkit.org/show_bug.cgi?id=62482
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (90341 => 90342)


--- trunk/Source/WebCore/ChangeLog	2011-07-03 17:14:16 UTC (rev 90341)
+++ trunk/Source/WebCore/ChangeLog	2011-07-03 17:27:51 UTC (rev 90342)
@@ -1,3 +1,28 @@
+2011-07-03  Robert Hogan  <[email protected]>
+
+        Restore scroll position on page reloads scheduled by <meta http-equiv="refresh" content="XX"/>
+        https://bugs.webkit.org/show_bug.cgi?id=62482
+
+        If a <meta http-equiv="refresh"> directive schedules a page reload rather than
+        a redirect restore the scroll position after the reload. Do the same on location.reload().
+
+        Reviewed by Adam Barth.
+
+        Tests: http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2.html
+               http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier.html
+               http/tests/navigation/scrollstate-after-http-equiv-refresh.html
+               http/tests/navigation/scrollstate-after-location-reload.html
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadURL):
+        Only make the load FrameLoadTypeSame if it has not already been set as FrameLoadTypeReload*.
+        FrameLoadTypeReload* loads are set through http-equiv refreshes, manual reloads, or location.reload()
+        and honour the user's scroll position in the frame. A FrameLoadTypeSame is for when the frame is loading
+        the same page again, e.g. by clicking a link.
+
+        * loader/NavigationScheduler.cpp:
+        (WebCore::ScheduledRedirect::fire): Tell FrameLoader::changeLocation() if this is a reload.
+
 2011-04-02  Robert Hogan  <[email protected]>
 
         Reviewed by Benjamin Poulain.

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (90341 => 90342)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2011-07-03 17:14:16 UTC (rev 90341)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2011-07-03 17:27:51 UTC (rev 90342)
@@ -1217,7 +1217,7 @@
             m_quickRedirectComing = false;
             if (m_provisionalDocumentLoader)
                 m_provisionalDocumentLoader->setIsClientRedirect(true);
-        } else if (sameURL)
+        } else if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoadTypeReloadFromOrigin)
             // Example of this case are sites that reload the same URL with a different cookie
             // driving the generated content, or a master frame with links that drive a target
             // frame, where the user has clicked on the same link repeatedly.

Modified: trunk/Source/WebCore/loader/NavigationScheduler.cpp (90341 => 90342)


--- trunk/Source/WebCore/loader/NavigationScheduler.cpp	2011-07-03 17:14:16 UTC (rev 90341)
+++ trunk/Source/WebCore/loader/NavigationScheduler.cpp	2011-07-03 17:27:51 UTC (rev 90342)
@@ -153,6 +153,13 @@
     }
 
     virtual bool shouldStartTimer(Frame* frame) { return frame->loader()->allAncestorsAreComplete(); }
+
+    virtual void fire(Frame* frame)
+    {
+        UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
+        bool refresh = equalIgnoringFragmentIdentifier(frame->document()->url(), KURL(ParsedURLString, url()));
+        frame->loader()->changeLocation(securityOrigin(), KURL(ParsedURLString, url()), referrer(), lockHistory(), lockBackForwardList(), refresh);
+    }
 };
 
 class ScheduledLocationChange : public ScheduledURLNavigation {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to