Overflow scroll that becomes non-scrollable should stop being composited
https://bugs.webkit.org/show_bug.cgi?id=197817
<rdar://problem/50697290>

Reviewed by Antti Koivisto.

Source/WebCore:

Remove the iOS-specific #ifdef around code that triggers a compositing re-evaluation
when scrolling state changes.

Test: compositing/scrolling/async-overflow-scrolling/become-non-scrollable.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateScrollInfoAfterLayout):

LayoutTests:

Put in a compositing/scrolling/async-overflow-scrolling dir so we can enable it only
for platforms that have async overflow scrolling.

* TestExpectations:
* compositing/scrolling/async-overflow-scrolling/become-non-scrollable-expected.txt: Added.
* compositing/scrolling/async-overflow-scrolling/become-non-scrollable.html: Added.
* platform/ios-wk2/TestExpectations:
* platform/mac-wk2/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@245212 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5888a1f..1885fbe 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2019-05-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Overflow scroll that becomes non-scrollable should stop being composited
+        https://bugs.webkit.org/show_bug.cgi?id=197817
+        <rdar://problem/50697290>
+
+        Reviewed by Antti Koivisto.
+
+        Put in a compositing/scrolling/async-overflow-scrolling dir so we can enable it only
+        for platforms that have async overflow scrolling.
+
+        * TestExpectations:
+        * compositing/scrolling/async-overflow-scrolling/become-non-scrollable-expected.txt: Added.
+        * compositing/scrolling/async-overflow-scrolling/become-non-scrollable.html: Added.
+        * platform/ios-wk2/TestExpectations:
+        * platform/mac-wk2/TestExpectations:
+
 2019-05-11  Alexey Proskuryakov  <ap@apple.com>
 
         Cleaning up results for legacy-animation-engine tests
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index 5650727..18521e1 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -61,6 +61,7 @@
 
 # Requires async overflow scrolling
 compositing/shared-backing/overflow-scroll [ Skip ]
+compositing/scrolling/async-overflow-scrolling [ Skip ]
 
 # WebKit2 only.
 printing/printing-events.html [ Skip ]
diff --git a/LayoutTests/compositing/scrolling/async-overflow-scrolling/become-non-scrollable-expected.txt b/LayoutTests/compositing/scrolling/async-overflow-scrolling/become-non-scrollable-expected.txt
new file mode 100644
index 0000000..cf04ad6
--- /dev/null
+++ b/LayoutTests/compositing/scrolling/async-overflow-scrolling/become-non-scrollable-expected.txt
@@ -0,0 +1,3 @@
+There should be no layers.
+
+
diff --git a/LayoutTests/compositing/scrolling/async-overflow-scrolling/become-non-scrollable.html b/LayoutTests/compositing/scrolling/async-overflow-scrolling/become-non-scrollable.html
new file mode 100644
index 0000000..a5ab81e
--- /dev/null
+++ b/LayoutTests/compositing/scrolling/async-overflow-scrolling/become-non-scrollable.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <title>Tests an overflow scroll stops compositing if its content shrinks</title>
+    <style>
+        .scrollable {
+            overflow-y: scroll;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+    
+        .contents {
+            height: 500px;
+            width: 20px;
+            background-color: silver;
+        }
+        
+        .contents.changed {
+            height: 100px;
+        }
+    </style>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        window.addEventListener('load', () => {
+            setTimeout(() => {
+                document.querySelector('.contents').classList.add('changed');
+
+                if (window.internals)
+                    document.getElementById('layers').innerText = window.internals.layerTreeAsText(document);
+
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            }, 0);
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="scrollable">
+        <div class="contents"></div>
+    </div>
+<p>There should be no layers.</p>
+<pre id="layers"></pre>
+</body>
+</html>
+
diff --git a/LayoutTests/platform/ios-wk2/TestExpectations b/LayoutTests/platform/ios-wk2/TestExpectations
index b5383e1..a0f1cb5 100644
--- a/LayoutTests/platform/ios-wk2/TestExpectations
+++ b/LayoutTests/platform/ios-wk2/TestExpectations
@@ -8,6 +8,7 @@
 
 compositing/ios [ Pass ]
 compositing/shared-backing/overflow-scroll [ Pass ]
+compositing/scrolling/async-overflow-scrolling [ Pass ]
 fast/device-orientation [ Pass ]
 fast/history/ios [ Pass ]
 fast/scrolling/ios [ Pass ]
diff --git a/LayoutTests/platform/mac-wk2/TestExpectations b/LayoutTests/platform/mac-wk2/TestExpectations
index 450afa4..392053d 100644
--- a/LayoutTests/platform/mac-wk2/TestExpectations
+++ b/LayoutTests/platform/mac-wk2/TestExpectations
@@ -6,6 +6,7 @@
 #//////////////////////////////////////////////////////////////////////////////////////////
 
 compositing/shared-backing/overflow-scroll [ Pass ]
+compositing/scrolling/async-overflow-scrolling [ Pass ]
 editing/find [ Pass ]
 editing/undo-manager [ Pass ]
 fast/forms/select/mac-wk2 [ Pass ]
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index c7c8dca..626c55f 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,5 +1,21 @@
 2019-05-11  Simon Fraser  <simon.fraser@apple.com>
 
+        Overflow scroll that becomes non-scrollable should stop being composited
+        https://bugs.webkit.org/show_bug.cgi?id=197817
+        <rdar://problem/50697290>
+
+        Reviewed by Antti Koivisto.
+
+        Remove the iOS-specific #ifdef around code that triggers a compositing re-evaluation
+        when scrolling state changes.
+
+        Test: compositing/scrolling/async-overflow-scrolling/become-non-scrollable.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateScrollInfoAfterLayout):
+
+2019-05-11  Simon Fraser  <simon.fraser@apple.com>
+
         Layer bounds are incorrect for sharing layers that paint with transforms
         https://bugs.webkit.org/show_bug.cgi?id=197768
         <rdar://problem/50695493>
diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp
index 185a875..7aa11aa 100644
--- a/Source/WebCore/rendering/RenderLayer.cpp
+++ b/Source/WebCore/rendering/RenderLayer.cpp
@@ -3709,10 +3709,8 @@
         setNeedsCompositingConfigurationUpdate();
     }
 
-#if PLATFORM(IOS_FAMILY)
     if (canUseCompositedScrolling())
         setNeedsPostLayoutCompositingUpdate();
-#endif
 
     updateScrollSnapState();
 }