Out-of-view check of fixed position element in frame is incorrect when page is scaled
https://bugs.webkit.org/show_bug.cgi?id=104943
Reviewed by Simon Fraser.
Source/WebCore:
Use frameScaleFactor instead of pageScaleFactor to scale the layer bounds.
Tests: compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll.html
compositing/layer-creation/fixed-position-out-of-view-scaled-iframe.html
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingForPosition):
LayoutTests:
Test cases.
* compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-expected.txt: Added.
* compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll-expected.txt: Added.
* compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll.html: Added.
* compositing/layer-creation/fixed-position-out-of-view-scaled-iframe.html: Added.
* compositing/layer-creation/resources/fixed-position-out-of-view-frame-scroll.html: Added.
* compositing/layer-creation/resources/fixed-position-out-of-view-frame.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 255d0dc..e0a3359 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2012-12-13 Xianzhu Wang <wangxianzhu@chromium.org>
+
+ Out-of-view check of fixed position element in frame is incorrect when page is scaled
+ https://bugs.webkit.org/show_bug.cgi?id=104943
+
+ Reviewed by Simon Fraser.
+
+ Test cases.
+
+ * compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-expected.txt: Added.
+ * compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll-expected.txt: Added.
+ * compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll.html: Added.
+ * compositing/layer-creation/fixed-position-out-of-view-scaled-iframe.html: Added.
+ * compositing/layer-creation/resources/fixed-position-out-of-view-frame-scroll.html: Added.
+ * compositing/layer-creation/resources/fixed-position-out-of-view-frame.html: Added.
+
2012-12-13 Bear Travis <betravis@adobe.com>
Positioned replaced elements should resolve vertical margins against their
diff --git a/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-expected.txt b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-expected.txt
new file mode 100644
index 0000000..aa44e7c
--- /dev/null
+++ b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-expected.txt
@@ -0,0 +1,2 @@
+
+PASS
diff --git a/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll-expected.txt b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll-expected.txt
new file mode 100644
index 0000000..aa44e7c
--- /dev/null
+++ b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll-expected.txt
@@ -0,0 +1,2 @@
+
+PASS
diff --git a/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll.html b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll.html
new file mode 100644
index 0000000..808fd39
--- /dev/null
+++ b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+ if (window.internals) {
+ window.internals.settings.setEnableCompositingForFixedPosition(true);
+ window.internals.settings.setFixedPositionCreatesStackingContext(true);
+
+ addEventListener("load", function() {
+ window.internals.setPageScaleFactor(0.5, 0, 0);
+ setTimeout(function() {
+ var layerTreeScaledDown = internals.layerTreeAsText(document.getElementById("iframe").contentDocument);
+
+ window.internals.setPageScaleFactor(1.5, 0, 0);
+ setTimeout(function() {
+ var layerTreeScaledUp = internals.layerTreeAsText(document.getElementById("iframe").contentDocument);
+ // Because logical size of the frame is unchanged, the layer tree in the frame should not be affected by the page scale.
+ document.getElementById("result").innerText =
+ layerTreeScaledUp == layerTreeScaledDown ? "PASS" : "FAIL";
+ testRunner.notifyDone();
+ }, 0);
+ }, 0);
+ }, false);
+ }
+</script>
+</head>
+<body>
+<iframe id="iframe" src="resources/fixed-position-out-of-view-frame-scroll.html" style="width: 800px; height: 600px"></iframe>
+<pre id="result"></pre>
+</body>
+</html>
diff --git a/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe.html b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe.html
new file mode 100644
index 0000000..a6f29c2
--- /dev/null
+++ b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-iframe.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+ if (window.internals) {
+ window.internals.settings.setEnableCompositingForFixedPosition(true);
+ window.internals.settings.setFixedPositionCreatesStackingContext(true);
+
+ addEventListener("load", function() {
+ window.internals.setPageScaleFactor(0.5, 0, 0);
+ setTimeout(function() {
+ var layerTreeScaledDown = internals.layerTreeAsText(document.getElementById("iframe").contentDocument);
+
+ window.internals.setPageScaleFactor(1.5, 0, 0);
+ setTimeout(function() {
+ var layerTreeScaledUp = internals.layerTreeAsText(document.getElementById("iframe").contentDocument);
+ // Because logical size of the frame is unchanged, the layer tree in the frame should not be affected by the page scale.
+ document.getElementById("result").innerText =
+ layerTreeScaledUp == layerTreeScaledDown ? "PASS" : "FAIL";
+ testRunner.notifyDone();
+ }, 0);
+ }, 0);
+ }, false);
+ }
+</script>
+</head>
+<body>
+<iframe id="iframe" src="resources/fixed-position-out-of-view-frame.html" style="width: 800px; height: 600px"></iframe>
+<pre id="result"></pre>
+</body>
+</html>
diff --git a/LayoutTests/compositing/layer-creation/resources/fixed-position-out-of-view-frame-scroll.html b/LayoutTests/compositing/layer-creation/resources/fixed-position-out-of-view-frame-scroll.html
new file mode 100644
index 0000000..1cc74cf
--- /dev/null
+++ b/LayoutTests/compositing/layer-creation/resources/fixed-position-out-of-view-frame-scroll.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ .fixed {
+ position: fixed;
+ width: 10px;
+ height: 10px;
+ }
+ </style>
+</head>
+<body onload="window.scrollTo(300, 600)">
+ <div style="width: 1500px; height: 1500px"></div>
+ <!-- When the size of the frame is 800x600, the first 3 divs are out-of-view and should not be composited, and the last 2 divs should be composited. -->
+ <div class="fixed" style="top: -100px"></div>
+ <div class="fixed"></div>
+ <div class="fixed" style="top: 0px; left: 1000px"></div>
+ <div class="fixed" style="top: 0px; left: 600px"></div>
+ <div class="fixed" style="top: 0px; left: 0px"></div>
+</body>
+</html>
+
diff --git a/LayoutTests/compositing/layer-creation/resources/fixed-position-out-of-view-frame.html b/LayoutTests/compositing/layer-creation/resources/fixed-position-out-of-view-frame.html
new file mode 100644
index 0000000..66bd0d8
--- /dev/null
+++ b/LayoutTests/compositing/layer-creation/resources/fixed-position-out-of-view-frame.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ .fixed {
+ position: fixed;
+ width: 10px;
+ height: 10px;
+ }
+ </style>
+</head>
+<body>
+ <div style="width: 1500px; height: 1500px"></div>
+ <!-- When the size of the frame is 800x600, the first 3 divs are out-of-view and should not be composited, and the last 2 divs should be composited. -->
+ <div class="fixed" style="top: -100px"></div>
+ <div class="fixed"></div>
+ <div class="fixed" style="top: 0px; left: 1000px"></div>
+ <div class="fixed" style="top: 0px; left: 600px"></div>
+ <div class="fixed" style="top: 0px; left: 0px"></div>
+</body>
+</html>
+
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 180f99a..9709361 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2012-12-13 Xianzhu Wang <wangxianzhu@chromium.org>
+
+ Out-of-view check of fixed position element in frame is incorrect when page is scaled
+ https://bugs.webkit.org/show_bug.cgi?id=104943
+
+ Reviewed by Simon Fraser.
+
+ Use frameScaleFactor instead of pageScaleFactor to scale the layer bounds.
+
+ Tests: compositing/layer-creation/fixed-position-out-of-view-scaled-iframe-scroll.html
+ compositing/layer-creation/fixed-position-out-of-view-scaled-iframe.html
+
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::requiresCompositingForPosition):
+
2012-12-13 Bear Travis <betravis@adobe.com>
Positioned replaced elements should resolve vertical margins against their containing
diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp
index 20f2622..25b8eab 100644
--- a/Source/WebCore/rendering/RenderLayerCompositor.cpp
+++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp
@@ -1998,7 +1998,7 @@
IntRect viewBounds = frameView->visibleContentRect();
LayoutRect layerBounds = layer->calculateLayerBounds(rootRenderLayer(), 0, RenderLayer::DefaultCalculateLayerBoundsFlags
| RenderLayer::ExcludeHiddenDescendants | RenderLayer::DontConstrainForMask | RenderLayer::IncludeCompositedDescendants);
- layerBounds.scale(pageScaleFactor());
+ layerBounds.scale(frameView->frame()->frameScaleFactor());
if (!viewBounds.intersects(enclosingIntRect(layerBounds))) {
if (fixedPositionLayerNotCompositedReason)
*fixedPositionLayerNotCompositedReason = LayerBoundsOutOfView;