Fixed position out-of-view check is incorrect when page is scaled
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 01:53:34 +0000 (01:53 +0000)
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 01:53:34 +0000 (01:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104303

Source/WebCore:

Reviewed by Kenneth Rohde Christiansen.

Test: compositing/layer-creation/fixed-position-out-of-view-scaled.html
      compositing/layer-creation/fixed-position-out-of-view-scaled-scroll.html

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingForPosition): Scale the content rect of the fixed position layer before checking out-of-view.

LayoutTests:

Test if fixed position elements are correctly composited or not composited when page is scaled up and down.

Reviewed by Kenneth Rohde Christiansen.

* compositing/layer-creation/fixed-position-out-of-view-scaled.html: Added.
* compositing/layer-creation/fixed-position-out-of-view-scaled-expected.txt: Added.
* compositing/layer-creation/fixed-position-out-of-view-scaled-scroll.html: Added.
* compositing/layer-creation/fixed-position-out-of-view-scaled-scroll-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-expected.txt [new file with mode: 0644]
LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-scroll-expected.txt [new file with mode: 0644]
LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-scroll.html [new file with mode: 0644]
LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerCompositor.cpp

index 86067a5..46e4664 100644 (file)
@@ -1,3 +1,17 @@
+2012-12-11  Xianzhu Wang  <wangxianzhu@chromium.org>
+
+        Fixed position out-of-view check is incorrect when page is scaled
+        https://bugs.webkit.org/show_bug.cgi?id=104303
+
+        Test if fixed position elements are correctly composited or not composited when page is scaled up and down.
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * compositing/layer-creation/fixed-position-out-of-view-scaled.html: Added.
+        * compositing/layer-creation/fixed-position-out-of-view-scaled-expected.txt: Added.
+        * compositing/layer-creation/fixed-position-out-of-view-scaled-scroll.html: Added.
+        * compositing/layer-creation/fixed-position-out-of-view-scaled-scroll-expected.txt: Added.
+
 2012-12-11  Chris Rogers  <crogers@google.com>
 
         Implement OfflineAudioContext constructor
diff --git a/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-expected.txt b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-expected.txt
new file mode 100644 (file)
index 0000000..0537665
--- /dev/null
@@ -0,0 +1,63 @@
+Not scaled:
+(GraphicsLayer
+  (bounds 785.00 1016.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 1016.00)
+      (children 2
+        (GraphicsLayer
+          (position 600.00 0.00)
+          (bounds 10.00 10.00)
+        )
+        (GraphicsLayer
+          (bounds 10.00 10.00)
+        )
+      )
+    )
+  )
+)
+Scale=0.5:
+(GraphicsLayer
+  (bounds 400.00 508.00)
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 800.00 1016.00)
+      (transform [0.50 0.00 0.00 0.00] [0.00 0.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
+      (children 4
+        (GraphicsLayer
+          (position 8.00 1008.00)
+          (bounds 10.00 10.00)
+        )
+        (GraphicsLayer
+          (position 1000.00 0.00)
+          (bounds 10.00 10.00)
+        )
+        (GraphicsLayer
+          (position 600.00 0.00)
+          (bounds 10.00 10.00)
+        )
+        (GraphicsLayer
+          (bounds 10.00 10.00)
+        )
+      )
+    )
+  )
+)
+Scale=1.5:
+(GraphicsLayer
+  (bounds 1272.00 1524.00)
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 848.00 1016.00)
+      (transform [1.50 0.00 0.00 0.00] [0.00 1.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
+      (children 1
+        (GraphicsLayer
+          (bounds 10.00 10.00)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-scroll-expected.txt b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-scroll-expected.txt
new file mode 100644 (file)
index 0000000..c065bb6
--- /dev/null
@@ -0,0 +1,64 @@
+Not scaled:
+(GraphicsLayer
+  (bounds 785.00 1016.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 1016.00)
+      (children 2
+        (GraphicsLayer
+          (position 600.00 100.00)
+          (bounds 10.00 10.00)
+        )
+        (GraphicsLayer
+          (position 0.00 100.00)
+          (bounds 10.00 10.00)
+        )
+      )
+    )
+  )
+)
+Scale=0.5:
+(GraphicsLayer
+  (bounds 400.00 508.00)
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 800.00 1016.00)
+      (transform [0.50 0.00 0.00 0.00] [0.00 0.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
+      (children 4
+        (GraphicsLayer
+          (position 8.00 1008.00)
+          (bounds 10.00 10.00)
+        )
+        (GraphicsLayer
+          (position 1000.00 0.00)
+          (bounds 10.00 10.00)
+        )
+        (GraphicsLayer
+          (position 600.00 0.00)
+          (bounds 10.00 10.00)
+        )
+        (GraphicsLayer
+          (bounds 10.00 10.00)
+        )
+      )
+    )
+  )
+)
+Scale=1.5:
+(GraphicsLayer
+  (bounds 1272.00 1524.00)
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 848.00 1016.00)
+      (transform [1.50 0.00 0.00 0.00] [0.00 1.50 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
+      (children 1
+        (GraphicsLayer
+          (bounds 10.00 10.00)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-scroll.html b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-scroll.html
new file mode 100644 (file)
index 0000000..9912f10
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+  .fixed {
+    position: fixed;
+    width: 10px;
+    height: 10px;
+  }
+</style>
+<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.scrollTo(100,100);
+
+      document.getElementById("layerTree").innerText = internals.layerTreeAsText(document);
+
+      window.internals.setPageScaleFactor(0.5, 0, 0);
+      setTimeout(function() {
+        document.getElementById("layerTreeScaledDown").innerText = internals.layerTreeAsText(document);
+
+        window.internals.setPageScaleFactor(1.5, 0, 0);
+        setTimeout(function() {
+          document.getElementById("layerTreeScaledUp").innerText = internals.layerTreeAsText(document);
+          testRunner.notifyDone();
+        }, 0);
+      }, 0);
+    }, false);
+  }
+</script>
+</head>
+<body>
+<div style="height: 1000px">
+  Not scaled:
+  <pre id="layerTree"></pre>
+  Scale=0.5:
+  <pre id="layerTreeScaledDown"></pre>
+  Scale=1.5:
+  <pre id="layerTreeScaledUp"></pre>
+</div>
+<!-- No layer in any case. -->
+<div class="fixed" style="top: -100px"></div>
+<!-- Has composited layer when scaled down; no layer when not scaled or scaled up. -->
+<div class="fixed"></div>
+<div class="fixed" style="top: 0px; left: 1000px"></div>
+<!-- Has composited layer when not scaled and scaled down; no layer scaled up. -->
+<div class="fixed" style="top: 0px; left: 600px"></div>
+<!-- Always has composited layer. -->
+<div class="fixed" style="top: 0px; left: 0px"></div>
+</body>
+</html>
diff --git a/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled.html b/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled.html
new file mode 100644 (file)
index 0000000..d25f7e9
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+  .fixed {
+    position: fixed;
+    width: 10px;
+    height: 10px;
+  }
+</style>
+<script>
+  if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+  }
+  if (window.internals) {
+    window.internals.settings.setEnableCompositingForFixedPosition(true);
+    window.internals.settings.setFixedPositionCreatesStackingContext(true);
+
+    addEventListener("load", function() {
+      document.getElementById("layerTree").innerText = internals.layerTreeAsText(document);
+
+      window.internals.setPageScaleFactor(0.5, 0, 0);
+      setTimeout(function() {
+        document.getElementById("layerTreeScaledDown").innerText = internals.layerTreeAsText(document);
+
+        window.internals.setPageScaleFactor(1.5, 0, 0);
+        setTimeout(function() {
+          document.getElementById("layerTreeScaledUp").innerText = internals.layerTreeAsText(document);
+          testRunner.notifyDone();
+        }, 0);
+      }, 0);
+    }, false);
+  }
+</script>
+</head>
+<body>
+<div style="height: 1000px">
+  Not scaled:
+  <pre id="layerTree"></pre>
+  Scale=0.5:
+  <pre id="layerTreeScaledDown"></pre>
+  Scale=1.5:
+  <pre id="layerTreeScaledUp"></pre>
+</div>
+<!-- No layer in any case. -->
+<div class="fixed" style="top: -100px"></div>
+<!-- Has composited layer when scaled down; no layer when not scaled or scaled up. -->
+<div class="fixed"></div>
+<div class="fixed" style="top: 0px; left: 1000px"></div>
+<!-- Has composited layer when not scaled and scaled down; no layer scaled up. -->
+<div class="fixed" style="top: 0px; left: 600px"></div>
+<!-- Always has composited layer. -->
+<div class="fixed" style="top: 0px; left: 0px"></div>
+</body>
+</html>
index f1bd0f8..ab111b7 100644 (file)
@@ -1,3 +1,16 @@
+2012-12-11  Xianzhu Wang  <wangxianzhu@chromium.org>
+
+        Fixed position out-of-view check is incorrect when page is scaled
+        https://bugs.webkit.org/show_bug.cgi?id=104303
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Test: compositing/layer-creation/fixed-position-out-of-view-scaled.html
+              compositing/layer-creation/fixed-position-out-of-view-scaled-scroll.html
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::requiresCompositingForPosition): Scale the content rect of the fixed position layer before checking out-of-view.
+
 2012-12-11  Chris Rogers  <crogers@google.com>
 
         Implement OfflineAudioContext constructor
index 37bb651..6efd5d5 100644 (file)
@@ -1989,8 +1989,9 @@ bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere
     // Fixed position elements that are invisible in the current view don't get their own layer.
     if (FrameView* frameView = m_renderView->frameView()) {
         IntRect viewBounds = frameView->visibleContentRect();
-        IntRect layerBounds = calculateCompositedBounds(layer, rootRenderLayer());
-        if (!viewBounds.intersects(layerBounds))
+        LayoutRect layerBounds = calculateCompositedBounds(layer, rootRenderLayer());
+        layerBounds.scale(pageScaleFactor());
+        if (!viewBounds.intersects(enclosingIntRect(layerBounds)))
             return false;
     }