Source/WebCore: Allow updateFixedElementsAfterScrolling() to run during layout.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2012 16:33:39 +0000 (16:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2012 16:33:39 +0000 (16:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84965

This is needed because HistoryController restores the previous scroll
position during layout (because we don't want an ugly flash of wrongly-
scrolled content).

Patch by Iain Merrick <husky@google.com> on 2012-06-18
Reviewed by Simon Fraser.

Test: compositing/fixed-position-scroll-offset-history-restore.html

* page/FrameView.cpp:
(WebCore::FrameView::updateFixedElementsAfterScrolling):

LayoutTests: Allow updateFixedElementsAfterScrolling() to run during layout.
https://bugs.webkit.org/show_bug.cgi?id=84965

This is needed because HistoryController restores the previous scroll
position during layout (because we don't want an ugly flash of wrongly-
scrolled content).

Patch by Iain Merrick <husky@google.com> on 2012-06-18
Reviewed by Simon Fraser.

* compositing/fixed-position-scroll-offset-history-restore-expected.txt: Added.
* compositing/fixed-position-scroll-offset-history-restore.html: Added.
* compositing/resources/fixed-position-scroll-offset-history-restore-2.html: Added.
* platform/chromium-linux/compositing/fixed-position-scroll-offset-history-restore-expected.png: Added.

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

LayoutTests/ChangeLog
LayoutTests/compositing/fixed-position-scroll-offset-history-restore-expected.txt [new file with mode: 0644]
LayoutTests/compositing/fixed-position-scroll-offset-history-restore.html [new file with mode: 0644]
LayoutTests/compositing/resources/fixed-position-scroll-offset-history-restore-2.html [new file with mode: 0644]
LayoutTests/platform/chromium-linux/compositing/fixed-position-scroll-offset-history-restore-expected.png [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp

index 6c8b6ae..317d01a 100644 (file)
@@ -1,3 +1,19 @@
+2012-06-18  Iain Merrick  <husky@google.com>
+
+        Allow updateFixedElementsAfterScrolling() to run during layout.
+        https://bugs.webkit.org/show_bug.cgi?id=84965
+
+        This is needed because HistoryController restores the previous scroll
+        position during layout (because we don't want an ugly flash of wrongly-
+        scrolled content).
+
+        Reviewed by Simon Fraser.
+
+        * compositing/fixed-position-scroll-offset-history-restore-expected.txt: Added.
+        * compositing/fixed-position-scroll-offset-history-restore.html: Added.
+        * compositing/resources/fixed-position-scroll-offset-history-restore-2.html: Added.
+        * platform/chromium-linux/compositing/fixed-position-scroll-offset-history-restore-expected.png: Added.
+
 2012-06-18  Alexander Pavlov  <apavlov@chromium.org>
 
         CSSOM wrappers are not built for rules in the per-document and page group user stylesheets
diff --git a/LayoutTests/compositing/fixed-position-scroll-offset-history-restore-expected.txt b/LayoutTests/compositing/fixed-position-scroll-offset-history-restore-expected.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/LayoutTests/compositing/fixed-position-scroll-offset-history-restore.html b/LayoutTests/compositing/fixed-position-scroll-offset-history-restore.html
new file mode 100644 (file)
index 0000000..47e9d20
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<body style="overflow:hidden">
+  <div style="height:2000px;"></div>
+
+  <!-- Red div to indicate test failure -->
+  <div style="position: absolute; top: 250px; width: 200px; height: 100px; background-color: red;"></div>
+
+  <!-- Green fixed-position, composited div which covers the red div after we scroll -->
+  <div style="position: fixed; -webkit-transform: translateZ(0); top: 50px; width: 200px; height: 100px; background-color: green;"></div>
+
+<script>
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+}
+
+onload = function() {
+    if (window.localStorage.stage == 'two') {
+        // We went foward and back again.
+        // If the scroll position is restored correctly the red div won't be visible.
+        delete window.localStorage.stage;
+        if (window.layoutTestController) {
+            layoutTestController.dumpAsText(true);
+            layoutTestController.notifyDone();
+        }
+    } else {
+        window.localStorage.stage = 'two';
+        window.scrollTo(0, 200);
+        setTimeout(function() {
+            window.location.href = 'resources/fixed-position-scroll-offset-history-restore-2.html';
+        }, 0);
+    }
+};
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/compositing/resources/fixed-position-scroll-offset-history-restore-2.html b/LayoutTests/compositing/resources/fixed-position-scroll-offset-history-restore-2.html
new file mode 100644 (file)
index 0000000..9d73fdf
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This page just immediately goes back.
+<script>
+onload = function() {
+    setTimeout(function() {
+        window.history.back();
+    }, 0);
+};
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/platform/chromium-linux/compositing/fixed-position-scroll-offset-history-restore-expected.png b/LayoutTests/platform/chromium-linux/compositing/fixed-position-scroll-offset-history-restore-expected.png
new file mode 100644 (file)
index 0000000..c28d037
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/compositing/fixed-position-scroll-offset-history-restore-expected.png differ
index 74bc517..33e858f 100644 (file)
@@ -1,3 +1,19 @@
+2012-06-18  Iain Merrick  <husky@google.com>
+
+        Allow updateFixedElementsAfterScrolling() to run during layout.       
+        https://bugs.webkit.org/show_bug.cgi?id=84965
+
+        This is needed because HistoryController restores the previous scroll
+        position during layout (because we don't want an ugly flash of wrongly-
+        scrolled content).
+
+        Reviewed by Simon Fraser.
+
+        Test: compositing/fixed-position-scroll-offset-history-restore.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::updateFixedElementsAfterScrolling):
+
 2012-06-18  Alexander Pavlov  <apavlov@chromium.org>
 
         CSSOM wrappers are not built for rules in the per-document and page group user stylesheets
index caa8963..bea7e28 100644 (file)
@@ -1756,7 +1756,7 @@ void FrameView::repaintFixedElementsAfterScrolling()
 void FrameView::updateFixedElementsAfterScrolling()
 {
 #if USE(ACCELERATED_COMPOSITING)
-    if (!m_nestedLayoutCount && hasFixedObjects()) {
+    if (m_nestedLayoutCount <= 1 && hasFixedObjects()) {
         if (RenderView* root = rootRenderer(this)) {
             root->compositor()->updateCompositingLayers(CompositingUpdateOnScroll);
         }