- Revision
- 90346
- Author
- [email protected]
- Date
- 2011-07-03 13:34:14 -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 (90345 => 90346)
--- trunk/LayoutTests/ChangeLog 2011-07-03 20:22:22 UTC (rev 90345)
+++ trunk/LayoutTests/ChangeLog 2011-07-03 20:34:14 UTC (rev 90346)
@@ -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-07-03 Dirk Schulze <[email protected]>
SVGAnimateTransform accumulate=sum restarts on every repeat
Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-expected.txt (0 => 90346)
--- 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 20:34:14 UTC (rev 90346)
@@ -0,0 +1 @@
+SUCCESS
Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2-expected.txt (0 => 90346)
--- 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 20:34:14 UTC (rev 90346)
@@ -0,0 +1 @@
+SUCCESS
Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier-2.html (0 => 90346)
--- 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 20:34:14 UTC (rev 90346)
@@ -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 => 90346)
--- 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 20:34:14 UTC (rev 90346)
@@ -0,0 +1 @@
+SUCCESS
Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-http-equiv-refresh-fragment-identifier.html (0 => 90346)
--- 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 20:34:14 UTC (rev 90346)
@@ -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 => 90346)
--- 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 20:34:14 UTC (rev 90346)
@@ -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 == 20) {
+ document.body.innerHTML = "SUCCESS";
+ layoutTestController.notifyDone();
+ } else
+ window.scroll(0,20);
+ }, 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 => 90346)
--- 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 20:34:14 UTC (rev 90346)
@@ -0,0 +1 @@
+SUCCESS
Added: trunk/LayoutTests/http/tests/navigation/scrollstate-after-location-reload.html (0 => 90346)
--- 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 20:34:14 UTC (rev 90346)
@@ -0,0 +1,61 @@
+<html>
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.waitUntilDone();
+ layoutTestController.dumpAsText();
+ }
+ function testScroll() {
+ window.setTimeout(function() {
+ if (window.pageYOffset == 20) {
+ document.body.innerHTML = "SUCCESS";
+ layoutTestController.notifyDone();
+ } else {
+ window.scroll(0,20);
+ 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 (90345 => 90346)
--- trunk/Source/WebCore/ChangeLog 2011-07-03 20:22:22 UTC (rev 90345)
+++ trunk/Source/WebCore/ChangeLog 2011-07-03 20:34:14 UTC (rev 90346)
@@ -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-07-03 Dirk Schulze <[email protected]>
SVGAnimateTransform accumulate=sum restarts on every repeat
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (90345 => 90346)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2011-07-03 20:22:22 UTC (rev 90345)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2011-07-03 20:34:14 UTC (rev 90346)
@@ -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 (90345 => 90346)
--- trunk/Source/WebCore/loader/NavigationScheduler.cpp 2011-07-03 20:22:22 UTC (rev 90345)
+++ trunk/Source/WebCore/loader/NavigationScheduler.cpp 2011-07-03 20:34:14 UTC (rev 90346)
@@ -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 {