Content can disappear with a combination of <video> with controls and clipping
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2019 20:11:32 +0000 (20:11 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2019 20:11:32 +0000 (20:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203834
Source/WebCore:

rdar://problem/56559648

Reviewed by Zalan Bujtas.

<video> with controls triggered a bug where a backing-sharing layer also claimed
that it didn't need any backing store. RenderLayerCompositor::requiresOwnBackingStore()
could early-return with 'false' if a layer had an indirect compositing reason of "Clipping",
while also backing-sharing. We need to check for backing-sharing first.

Test: compositing/shared-backing/clipping-and-shared-backing.html

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::setBackingSharingLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresOwnBackingStore const):

LayoutTests:

Reviewed by Zalan Bujtas.

* compositing/shared-backing/clipping-and-shared-backing-expected.html: Added.
* compositing/shared-backing/clipping-and-shared-backing.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/compositing/shared-backing/clipping-and-shared-backing-expected.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/clipping-and-shared-backing.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp

index 4d945a5..523c76a 100644 (file)
@@ -1,3 +1,13 @@
+2019-11-05  Simon Fraser  <simon.fraser@apple.com>
+
+        Content can disappear with a combination of <video> with controls and clipping
+        https://bugs.webkit.org/show_bug.cgi?id=203834
+
+        Reviewed by Zalan Bujtas.
+
+        * compositing/shared-backing/clipping-and-shared-backing-expected.html: Added.
+        * compositing/shared-backing/clipping-and-shared-backing.html: Added.
+
 2019-11-05  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Disabled SVG shapes should not be hit
diff --git a/LayoutTests/compositing/shared-backing/clipping-and-shared-backing-expected.html b/LayoutTests/compositing/shared-backing/clipping-and-shared-backing-expected.html
new file mode 100644 (file)
index 0000000..1899f73
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        .wrapper {
+            overflow-x: hidden;
+            margin: 20px 50px;
+        }
+        
+        .video {
+            width: 300px;
+            height: 100px;
+            will-change: transform;
+        }
+        
+        .obscurer {
+            position: absolute;
+            top: 18px;
+            left: 48px;
+            width: 320px;
+            height: 120px;
+            background-color: gray;
+        }
+        
+        .test {
+            position: relative;
+            width: 100%;
+            height: 300px;
+            background-color: green;
+        }
+    </style>
+</head>
+<body>
+    <section class="wrapper">
+        <div class="video"></div>
+        <div class="test">Some text here</div>
+    </section>
+    <!--Hide the video; we just want its side-effects -->
+    <div class="obscurer"></div>
+
+</body>
+</html>
diff --git a/LayoutTests/compositing/shared-backing/clipping-and-shared-backing.html b/LayoutTests/compositing/shared-backing/clipping-and-shared-backing.html
new file mode 100644 (file)
index 0000000..1bd27a9
--- /dev/null
@@ -0,0 +1,59 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <style>
+        .wrapper {
+            overflow-x: hidden;
+            margin: 20px 50px;
+        }
+        
+        video {
+            display: block;
+            width: 300px;
+            height: 100px;
+        }
+        
+        .obscurer {
+            position: absolute;
+            top: 18px;
+            left: 48px;
+            width: 320px;
+            height: 120px;
+            background-color: gray;
+        }
+        
+        .test {
+            position: relative;
+            width: 100%;
+            height: 300px;
+            background-color: green;
+        }
+    </style>
+    <script src="../resources/media-testing.js"></script>
+    <script src="../../media/media-file.js"></script>
+    <script>
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+
+        function setupTest()
+        {
+            var video = document.getElementsByTagName('video')[0];
+            setupVideo(video, '../resources/video', null, () => {
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            });
+        }
+        
+        window.addEventListener('load', setupTest, false);
+    </script>
+</head>
+<body>
+    <section class="wrapper">
+        <video ></video>
+        <div class="test">Some text here</div>
+    </section>
+    <!--Hide the video; we just want its side-effects -->
+    <div class="obscurer"></div>
+
+</body>
+</html>
index 0c35ff4..6a8005f 100644 (file)
@@ -1,3 +1,23 @@
+2019-11-05  Simon Fraser  <simon.fraser@apple.com>
+
+        Content can disappear with a combination of <video> with controls and clipping
+        https://bugs.webkit.org/show_bug.cgi?id=203834
+        rdar://problem/56559648
+
+        Reviewed by Zalan Bujtas.
+        
+        <video> with controls triggered a bug where a backing-sharing layer also claimed
+        that it didn't need any backing store. RenderLayerCompositor::requiresOwnBackingStore()
+        could early-return with 'false' if a layer had an indirect compositing reason of "Clipping",
+        while also backing-sharing. We need to check for backing-sharing first.
+
+        Test: compositing/shared-backing/clipping-and-shared-backing.html
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::setBackingSharingLayers):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::requiresOwnBackingStore const):
+
 2019-11-05  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Disabled SVG shapes should not be hit
index 7d9978f..46e97ad 100644 (file)
@@ -294,8 +294,11 @@ void RenderLayerBacking::setBackingSharingLayers(Vector<WeakPtr<RenderLayer>>&&
 
     clearBackingSharingLayerProviders(m_backingSharingLayers);
 
-    if (sharingLayers != m_backingSharingLayers)
+    if (sharingLayers != m_backingSharingLayers) {
+        if (sharingLayers.size())
+            setRequiresOwnBackingStore(true);
         setContentsNeedDisplay(); // This could be optimized to only repaint rects for changed layers.
+    }
 
     auto oldSharingLayers = WTFMove(m_backingSharingLayers);
     m_backingSharingLayers = WTFMove(sharingLayers);
index f235ce1..e9a9133 100644 (file)
@@ -2422,6 +2422,9 @@ bool RenderLayerCompositor::requiresOwnBackingStore(const RenderLayer& layer, co
         || renderer.hasBackdropFilter())
         return true;
 
+    if (layer.isComposited() && layer.backing()->hasBackingSharingLayers())
+        return true;
+
     if (layer.mustCompositeForIndirectReasons()) {
         IndirectCompositingReason reason = layer.indirectCompositingReason();
         return reason == IndirectCompositingReason::Overlap
@@ -2432,12 +2435,10 @@ bool RenderLayerCompositor::requiresOwnBackingStore(const RenderLayer& layer, co
             || reason == IndirectCompositingReason::Preserve3D; // preserve-3d has to create backing store to ensure that 3d-transformed elements intersect.
     }
 
+    // FIXME: We really need to keep track of the ancestor layer that has its own backing store.
     if (!ancestorCompositedBounds.contains(layerCompositedBoundsInAncestor))
         return true;
 
-    if (layer.isComposited() && layer.backing()->hasBackingSharingLayers())
-        return true;
-
     return false;
 }