[WK2] TiledBackingStore: Scroll position is not reset when new page is loaded
authormikhail.pozdnyakov@intel.com <mikhail.pozdnyakov@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2012 13:40:40 +0000 (13:40 +0000)
committermikhail.pozdnyakov@intel.com <mikhail.pozdnyakov@intel.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Dec 2012 13:40:40 +0000 (13:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105627

Reviewed by Kenneth Rohde Christiansen.

Source/WebKit2:

Reset scroll position to (0,0) when new page is loaded.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::sendViewportAttributesChanged):

LayoutTests:

Added a layout test checking scroll position for newly loaded pages.

* fast/dom/resources/check-scroll-position-onload.html: Added.
* fast/dom/scroll-position-for-new-loads-expected.txt: Added.
* fast/dom/scroll-position-for-new-loads.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138367 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/resources/check-scroll-position-onload.html [new file with mode: 0644]
LayoutTests/fast/dom/scroll-position-for-new-loads-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/scroll-position-for-new-loads.html [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index cecd839..4610b03 100644 (file)
@@ -1,3 +1,16 @@
+2012-12-21  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        [WK2] TiledBackingStore: Scroll position is not reset when new page is loaded
+        https://bugs.webkit.org/show_bug.cgi?id=105627
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added a layout test checking scroll position for newly loaded pages.
+
+        * fast/dom/resources/check-scroll-position-onload.html: Added.
+        * fast/dom/scroll-position-for-new-loads-expected.txt: Added.
+        * fast/dom/scroll-position-for-new-loads.html: Added.
+
 2012-12-21  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Unreviewed gardening. Rebaseline after r138365.
diff --git a/LayoutTests/fast/dom/resources/check-scroll-position-onload.html b/LayoutTests/fast/dom/resources/check-scroll-position-onload.html
new file mode 100644 (file)
index 0000000..f45bcf7
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style type="text/css">
+        div { min-height: 3000px; }
+    </style>
+    <script type="text/javascript">
+        function load() {
+            var result = document.getElementById("result");
+            result.innerHTML = (document.body.scrollTop == 0) ? "PASS" : "FAIL";
+            if (window.testRunner) {
+                testRunner.notifyDone();
+            }
+        }
+    </script>
+</head>
+<body onload="load()">
+    <div id="result">
+        <p></p>
+    </div>
+<body>
+</html>
diff --git a/LayoutTests/fast/dom/scroll-position-for-new-loads-expected.txt b/LayoutTests/fast/dom/scroll-position-for-new-loads-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/fast/dom/scroll-position-for-new-loads.html b/LayoutTests/fast/dom/scroll-position-for-new-loads.html
new file mode 100644 (file)
index 0000000..a87c800
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Check that document.body.scrollTop is equal to '0' for newly loaded pages</title>
+    <link rel="author" title="Mikhail Pozdnyakov" href="mailto:mikhail.pozdnyakov@intel.com" />
+    <style type="text/css">
+        div { min-height: 3000px; }
+    </style>
+    <script type="text/javascript">
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        function update() {
+            var result = document.getElementById("result");
+            window.location = "resources/check-scroll-position-onload.html";
+        }
+
+        function load() {
+            window.scrollBy(0, 1000);
+            setTimeout(update, 0);
+        }
+    </script>
+</head>
+<body onload="load()">
+    <div id="result">
+        <p></p>
+    </div>
+<body>
+</html>
index 13c04c3..793c7b8 100644 (file)
@@ -1,3 +1,15 @@
+2012-12-21  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        [WK2] TiledBackingStore: Scroll position is not reset when new page is loaded
+        https://bugs.webkit.org/show_bug.cgi?id=105627
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Reset scroll position to (0,0) when new page is loaded.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::sendViewportAttributesChanged):
+
 2012-12-21  Tim Horton  <timothy_horton@apple.com>
 
         PDFPlugin: Cannot drop files/URLs on PDFPlugin
index dc157b2..e6d9295 100644 (file)
@@ -1031,10 +1031,10 @@ void WebPage::sendViewportAttributesChanged()
 
     ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, deviceWidth, deviceHeight, m_page->deviceScaleFactor(), m_viewportSize);
 
-    // Keep the current position, update size only.
-    // For the new loads position is already reset to (0,0).
     FrameView* view = m_page->mainFrame()->view();
-    IntPoint contentFixedOrigin = view->fixedVisibleContentRect().location();
+
+    // If no layout was done yet set contentFixedOrigin to (0,0).
+    IntPoint contentFixedOrigin = view->didFirstLayout() ? view->fixedVisibleContentRect().location() : IntPoint();
 
     // Put the width and height to the viewport width and height. In css units however.
     // Use FloatSize to avoid truncated values during scale.