Fix disappearing position:fixed elements in fixed layout mode
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jul 2015 21:54:06 +0000 (21:54 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jul 2015 21:54:06 +0000 (21:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147019

Reviewed by Tim Horton.
Source/WebCore:

Test: compositing/fixed-with-fixed-layout.html

When in fixed layout mode, and being scaled down, viewportConstrainedVisibleContentRect() is
the wrong thing to use to determine if position:fixed elements are clipped out. In this case,
use the simpler document bounds (before scaling).

In the long term,  there needs to be an equivalent of viewportConstrainedVisibleContentRect()
that gives an appropriate rect that can be used here.

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingForPosition):

LayoutTests:

Test with four fixed elements in fixed layout mode.

* compositing/fixed-with-fixed-layout-expected.txt: Added.
* compositing/fixed-with-fixed-layout.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/compositing/fixed-with-fixed-layout-expected.txt [new file with mode: 0644]
LayoutTests/compositing/fixed-with-fixed-layout.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerCompositor.cpp

index ef9a0f4..265583c 100644 (file)
@@ -1,3 +1,15 @@
+2015-07-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Fix disappearing position:fixed elements in fixed layout mode
+        https://bugs.webkit.org/show_bug.cgi?id=147019
+
+        Reviewed by Tim Horton.
+        
+        Test with four fixed elements in fixed layout mode.
+
+        * compositing/fixed-with-fixed-layout-expected.txt: Added.
+        * compositing/fixed-with-fixed-layout.html: Added.
+
 2015-07-16  Filip Pizlo  <fpizlo@apple.com>
 
         Unreviewed, roll out http://trac.webkit.org/changeset/186903. It broke the build.
diff --git a/LayoutTests/compositing/fixed-with-fixed-layout-expected.txt b/LayoutTests/compositing/fixed-with-fixed-layout-expected.txt
new file mode 100644 (file)
index 0000000..8042bd5
--- /dev/null
@@ -0,0 +1,35 @@
+Top Left Right bottom
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 806.00 1616.00)
+  (children 1
+    (GraphicsLayer
+      (anchor 0.00 0.00)
+      (bounds 1008.00 2021.00)
+      (contentsOpaque 1)
+      (transform [0.80 0.00 0.00 0.00] [0.00 0.80 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
+      (children 4
+        (GraphicsLayer
+          (bounds 1000.00 100.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 0.00 200.00)
+          (bounds 100.00 100.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 900.00 200.00)
+          (bounds 100.00 100.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 0.00 1900.00)
+          (bounds 1000.00 100.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/compositing/fixed-with-fixed-layout.html b/LayoutTests/compositing/fixed-with-fixed-layout.html
new file mode 100644 (file)
index 0000000..9c06712
--- /dev/null
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            height: 2000px;
+            width: 1000px;
+        }
+        
+        .fixed {
+            position: fixed;
+            height: 100px;
+            width: 100px;
+            background-color: rgba(0, 0, 0, 0.5);
+        }
+        
+        .top, .bottom {
+            left: 0;
+            width: 100%;
+        }
+        
+        .left, .right {
+            top: 200px;
+        }
+        
+        .top {
+            top: 0;
+        }
+        
+        .bottom {
+            bottom: 0;
+        }
+        .left {
+            left: 0;
+        }
+        .right {
+            right: 0;
+        }
+    </style>
+    <script>
+        
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        if (window.internals) {
+            internals.settings.setAcceleratedCompositingForFixedPositionEnabled(true);
+            internals.setUseFixedLayout(true);
+            internals.setFixedLayoutSize(1000, 2000);
+            var scale = 800 / 1000;
+            eventSender.scalePageBy(scale, scale);
+        }
+        
+        function doTest()
+        {
+            window.setTimeout(function() {
+                document.getElementById("layerTree").innerText = window.internals.layerTreeAsText(document);
+                testRunner.notifyDone();
+            }, 0);
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<div class="top fixed">
+    Top
+</div>
+
+<div class="left fixed">
+    Left
+</div>
+
+<div class="right fixed">
+    Right
+</div>
+
+<div class="bottom fixed">
+    bottom
+</div>
+
+<pre id="layerTree"></pre>
+</body>
+</html>
index acc51bd..3b6c2c1 100644 (file)
@@ -1,3 +1,22 @@
+2015-07-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Fix disappearing position:fixed elements in fixed layout mode
+        https://bugs.webkit.org/show_bug.cgi?id=147019
+
+        Reviewed by Tim Horton.
+
+        Test: compositing/fixed-with-fixed-layout.html
+        
+        When in fixed layout mode, and being scaled down, viewportConstrainedVisibleContentRect() is
+        the wrong thing to use to determine if position:fixed elements are clipped out. In this case,
+        use the simpler document bounds (before scaling).
+        
+        In the long term,  there needs to be an equivalent of viewportConstrainedVisibleContentRect()
+        that gives an appropriate rect that can be used here.
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::requiresCompositingForPosition):
+
 2015-07-16  Benjamin Poulain  <bpoulain@apple.com>
 
         [Content extensions] Combine suffixes when generating NFAs
index b9e062a..043a24a 100644 (file)
@@ -2739,7 +2739,12 @@ bool RenderLayerCompositor::requiresCompositingForPosition(RenderLayerModelObjec
     }
 
     // Fixed position elements that are invisible in the current view don't get their own layer.
-    LayoutRect viewBounds = m_renderView.frameView().viewportConstrainedVisibleContentRect();
+    // FIXME: We shouldn't have to check useFixedLayout() here; one of the viewport rects needs to give the correct answer.
+    LayoutRect viewBounds;
+    if (m_renderView.frameView().useFixedLayout())
+        viewBounds = m_renderView.unscaledDocumentRect();
+    else
+        viewBounds = m_renderView.frameView().viewportConstrainedVisibleContentRect();
     LayoutRect layerBounds = layer.calculateLayerBounds(&layer, LayoutSize(), RenderLayer::UseLocalClipRectIfPossible | RenderLayer::IncludeLayerFilterOutsets | RenderLayer::UseFragmentBoxesExcludingCompositing
         | RenderLayer::ExcludeHiddenDescendants | RenderLayer::DontConstrainForMask | RenderLayer::IncludeCompositedDescendants);
     // Map to m_renderView to ignore page scale.