Layer with no backing store should still hit-test over a scroller
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2019 11:07:42 +0000 (11:07 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Mar 2019 11:07:42 +0000 (11:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195378
<rdar://problem/48652078>

Reviewed by Simon Fraser.

Source/WebCore:

Tests: fast/scrolling/ios/overflow-scroll-overlap-3.html
       fast/scrolling/ios/overflow-scroll-overlap-4.html

Move collecting event region from paint to compositing update time.
This solves a number of problems including regions for non-painting layers.

* platform/graphics/GraphicsLayer.h:
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintObject):

Use the existing visibleToHitTesting() helper.

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

Use flag for event region collecting, don't paint content.

(WebCore::RenderLayer::paintList):

We can bail out immediately if there is no overflow.

(WebCore::RenderLayer::paintForegroundForFragments):
(WebCore::RenderLayer::paintForegroundForFragmentsWithPhase):
(WebCore::RenderLayer::collectEventRegionForFragments):

Move to a separate function.

* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateConfiguration):

Update event region on backing configuration update. This is called after anything interesting changes on a sublayer.

(WebCore::RenderLayerBacking::updateEventRegion):
(WebCore::RenderLayerBacking::paintIntoLayer):
* rendering/RenderLayerBacking.h:

Source/WebKit:

* UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
(WebKit::RemoteLayerTreeHost::makeNode):
* UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h:
* UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
(WebKit::collectDescendantViewsAtPoint):

No need for special WKTiledBackingView, tiled views now have correct event regions.

LayoutTests:

Reorganize the tests a bit and add some new ones.

* fast/scrolling/ios/overflow-scroll-overlap-2-expected.txt:
* fast/scrolling/ios/overflow-scroll-overlap-2.html:
* fast/scrolling/ios/overflow-scroll-overlap-3-expected.txt: Added.
* fast/scrolling/ios/overflow-scroll-overlap-3.html: Added.
* fast/scrolling/ios/overflow-scroll-overlap-4-expected.txt: Added.
* fast/scrolling/ios/overflow-scroll-overlap-4.html: Added.
* fast/scrolling/ios/overflow-scroll-overlap.html:
* fast/scrolling/resources/overflow-scroll-overlap.js: Added.
(sleep):
(async.runTest):
(logScroll):
(outputCase):

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-2-expected.txt
LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-2.html
LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-3-expected.txt [new file with mode: 0644]
LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-3.html [new file with mode: 0644]
LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-4-expected.txt [new file with mode: 0644]
LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-4.html [new file with mode: 0644]
LayoutTests/fast/scrolling/ios/overflow-scroll-overlap.html
LayoutTests/fast/scrolling/resources/overflow-scroll-overlap.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm

index 387f460..8295717 100644 (file)
@@ -1,3 +1,26 @@
+2019-03-19  Antti Koivisto  <antti@apple.com>
+
+        Layer with no backing store should still hit-test over a scroller
+        https://bugs.webkit.org/show_bug.cgi?id=195378
+        <rdar://problem/48652078>
+
+        Reviewed by Simon Fraser.
+
+        Reorganize the tests a bit and add some new ones.
+
+        * fast/scrolling/ios/overflow-scroll-overlap-2-expected.txt:
+        * fast/scrolling/ios/overflow-scroll-overlap-2.html:
+        * fast/scrolling/ios/overflow-scroll-overlap-3-expected.txt: Added.
+        * fast/scrolling/ios/overflow-scroll-overlap-3.html: Added.
+        * fast/scrolling/ios/overflow-scroll-overlap-4-expected.txt: Added.
+        * fast/scrolling/ios/overflow-scroll-overlap-4.html: Added.
+        * fast/scrolling/ios/overflow-scroll-overlap.html:
+        * fast/scrolling/resources/overflow-scroll-overlap.js: Added.
+        (sleep):
+        (async.runTest):
+        (logScroll):
+        (outputCase):
+
 2019-03-18  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r243092 and r243096.
index 8f11fe5..1d37bce 100644 (file)
@@ -1,9 +1,8 @@
 Test that scrollable areas with non-trivial overlap are correctly targeted.
 
-case 1: 
-case 2: Scrollable 2 
+case 1: Scrollable 1 
+case 2: 
 case 3: Scrollable 3 
 case 4: Scrollable 4 
-case 5: Scrollable 5 
-case 6: 
+case 5: 
 
index 0c90611..45140fd 100644 (file)
@@ -33,6 +33,14 @@ body {
     height: 100px;
     background: red;
 }
+.overlapping-empty {
+    position:absolute;
+    left: 25px;
+    top: 25px;
+    width: 100px;
+    height: 100px;
+    background: blue;
+}
 .clip {
     position:absolute;
     width: 100px;
@@ -49,85 +57,7 @@ body {
 }
 </style>
 <script src="../../../resources/basic-gestures.js"></script>
-<script type="text/javascript">
-if (window.testRunner) {
-    testRunner.dumpAsText();
-    testRunner.waitUntilDone();
-    internals.settings.setAsyncFrameScrollingEnabled(true);
-    internals.settings.setAsyncOverflowScrollingEnabled(true);
-}
-
-function sleep(delay)
-{
-    return new Promise((resolve) => { setTimeout(resolve, delay); });
-}
-
-async function runTest() {
-    for (const scrollable of document.querySelectorAll('.overflowscroll')) {
-        scrollable.addEventListener('scroll', function(e) {
-            logScroll(e.target);
-        });
-    }
-
-    {
-        let i = 0;
-        for (const scrollcontent of document.querySelectorAll('.scrollcontent'))
-            scrollcontent.innerText = "Scrollable " + ++i;
-    }
-    {
-        let i = 0;
-        for (const overlapping of document.querySelectorAll('.overlapping'))
-            overlapping.insertBefore(document.createTextNode("Overlapping " + ++i), overlapping.firstChild);
-    }
-
-
-    if (!window.testRunner || !testRunner.runUIScript)
-        return;
-
-    for (const testcase of document.querySelectorAll('.case'))
-        testcase.style.display = 'none';
-
-    {
-        let i = 0;
-        for (const testcase of document.querySelectorAll('.case')) {
-            ++i;
-            testcase.style.display = 'inline-block';
-            
-            const target = testcase.querySelector('.target');
-            const rect = target.getBoundingClientRect();
-            const centerX = (rect.left + rect.right) / 2;
-            const centerY = (rect.top + rect.bottom) / 2;
-            await touchAndDragFromPointToPoint(centerX, centerY, centerX, centerY - 30);
-            await liftUpAtPoint(centerX, centerY - 30);
-            await sleep(500);
-
-            testcase.style.display = 'none';
-            outputCase(i);
-        }
-   }
-
-    for (const testcase of document.querySelectorAll('.case'))
-        testcase.style.display = 'none';
-
-    testRunner.notifyDone();
-}
-
-const scrolledElements = new Set();
-
-function logScroll(element) {
-    if (scrolledElements.has(element))
-        return;
-    scrolledElements.add(element);
-}
-
-function outputCase(i) {
-    log.innerText += "case " + i + ": ";
-    for (const scrolled of scrolledElements)
-        log.innerText += scrolled.getElementsByClassName("scrollcontent")[0].innerText + " ";
-    log.innerText += "\n";
-    scrolledElements.clear();
-}
-</script>
+<script src="../resources/overflow-scroll-overlap.js"></script>
 </head>
 <body onload="runTest()">
 <p>
@@ -137,8 +67,7 @@ Test that scrollable areas with non-trivial overlap are correctly targeted.
     <div class="overflowscroll target">
         <div class="scrollcontent"></div>
     </div>
-    <div class="overlapping" style="left: 80px">
-        <div class="overlapping" style="left: -40px; top: -30px"></div>
+    <div class="overlapping" style="visibility:hidden">
     </div>
 </div>
 
@@ -146,7 +75,7 @@ Test that scrollable areas with non-trivial overlap are correctly targeted.
     <div class="overflowscroll target">
         <div class="scrollcontent"></div>
     </div>
-    <div class="overlapping" style="box-shadow: 0px 0px 32px 32px blue; left: 60px; top: 60px">
+    <div class="overlapping-empty" style="background-color:transparent">
     </div>
 </div>
 
@@ -154,16 +83,7 @@ Test that scrollable areas with non-trivial overlap are correctly targeted.
     <div class="overflowscroll target">
         <div class="scrollcontent"></div>
     </div>
-    <div class="overlapping" style="pointer-events:none">
-    </div>
-</div>
-
-<div class="case">
-    <div class="overflowscroll target">
-        <div class="scrollcontent"></div>
-    </div>
-    <div class="overlapping" style="top:-60px">
-    Text text text text text text text text text text text text text text text text text text text text text text
+    <div class="overlapping" style="box-shadow: 0px 0px 32px 32px blue; left: 60px; top: 60px">
     </div>
 </div>
 
@@ -171,8 +91,7 @@ Test that scrollable areas with non-trivial overlap are correctly targeted.
     <div class="overflowscroll target">
         <div class="scrollcontent"></div>
     </div>
-    <div class="overlapping" style="top:-60px; padding-left:40px">
-    Text text text text text text text text text text text text text text text text text text text text text text
+    <div class="overlapping" style="pointer-events:none">
     </div>
 </div>
 
diff --git a/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-3-expected.txt b/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-3-expected.txt
new file mode 100644 (file)
index 0000000..0261016
--- /dev/null
@@ -0,0 +1,5 @@
+Test that scrollable areas with text overlap are correctly targeted.
+
+case 1: Scrollable 1 
+case 2: Scrollable 2 
+
diff --git a/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-3.html b/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-3.html
new file mode 100644 (file)
index 0000000..15780a9
--- /dev/null
@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+body {
+    touch-action: none;
+}
+.case {
+    width: 200px;
+    height: 200px;
+    display: inline-block;
+    position: relative;
+}
+.scrollcontent {
+    width: 500px;
+    height: 500px;
+    background: green;
+}
+
+.overflowscroll {
+    overflow: scroll;
+    height: 100px;
+    width: 100px;
+    position: absolute;
+    border: 2px solid black;
+}
+.overlapping {
+    position:absolute;
+    left: 25px;
+    top: 25px;
+    width: 100px;
+    height: 100px;
+    background: red;
+}
+.clip {
+    position:absolute;
+    width: 100px;
+    height: 100px;
+    overflow:hidden;
+}
+.large {
+    width: 3000px;
+    height: 150px;
+}
+#log {
+    position:relative;
+    white-space: pre;
+}
+</style>
+<script src="../../../resources/basic-gestures.js"></script>
+<script src="../resources/overflow-scroll-overlap.js"></script>
+</head>
+<body onload="runTest()">
+<p>
+Test that scrollable areas with text overlap are correctly targeted.
+</p>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="top:-60px">
+    Text text text text text text text text text text text text text text text text text text text text text text
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="top:-60px; padding-left:40px">
+    Text text text text text text text text text text text text text text text text text text text text text text
+    </div>
+</div>
+
+<div id=log></div>
+
+</body>
+</html>
diff --git a/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-4-expected.txt b/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-4-expected.txt
new file mode 100644 (file)
index 0000000..b6c4cc1
--- /dev/null
@@ -0,0 +1,9 @@
+Test that scrollable areas with overflowing overlap are correctly targeted.
+
+case 1: 
+case 2: 
+case 3: 
+case 4: 
+case 5: 
+case 6: Scrollable 6 
+
diff --git a/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-4.html b/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-4.html
new file mode 100644 (file)
index 0000000..4fdfd1b
--- /dev/null
@@ -0,0 +1,116 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+body {
+    touch-action: none;
+}
+.case {
+    width: 200px;
+    height: 200px;
+    display: inline-block;
+    position: relative;
+}
+.scrollcontent {
+    width: 500px;
+    height: 500px;
+    background: green;
+}
+
+.overflowscroll {
+    overflow: scroll;
+    height: 100px;
+    width: 100px;
+    position: absolute;
+    border: 2px solid black;
+}
+.overlapping {
+    position:absolute;
+    left: 25px;
+    top: 25px;
+    width: 100px;
+    height: 100px;
+    background: red;
+}
+.clip {
+    position:absolute;
+    width: 100px;
+    height: 100px;
+    overflow:hidden;
+}
+.large {
+    width: 3000px;
+    height: 150px;
+}
+#log {
+    position:relative;
+    white-space: pre;
+}
+</style>
+<script src="../../../resources/basic-gestures.js"></script>
+<script src="../resources/overflow-scroll-overlap.js"></script>
+</head>
+<body onload="runTest()">
+<p>
+Test that scrollable areas with overflowing overlap are correctly targeted.
+</p>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="left: 80px">
+        <div class="overlapping" style="left: -40px; top: -30px"></div>
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="left: 80px; z-index:0">
+        <div class="overlapping" style="left: -40px; top: -30px"></div>
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="left: 80px; top: 90px; z-index:0">
+        <div class="overlapping" style="left: -40px; top: -120px"></div>
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="left: 80px; top: 90px; z-index:0">
+        <div class="overlapping" style="left: -40px; top: -120px; z-index:-1"></div>
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="left: 80px; top: 90px; z-index:0">
+        <div class="overlapping" style="left: -40px; top: -120px; z-index:1"></div>
+    </div>
+</div>
+
+<div class="case">
+    <div class="overflowscroll target">
+        <div class="scrollcontent"></div>
+    </div>
+    <div class="overlapping" style="left: 80px; top: 60px; z-index:0">
+        <div class="overlapping" style="left: -40px; top: -120px"></div>
+    </div>
+</div>
+
+<div id=log></div>
+
+</body>
+</html>
index 209246e..67658de 100644 (file)
@@ -49,85 +49,7 @@ body {
 }
 </style>
 <script src="../../../resources/basic-gestures.js"></script>
-<script type="text/javascript">
-if (window.testRunner) {
-    testRunner.dumpAsText();
-    testRunner.waitUntilDone();
-    internals.settings.setAsyncFrameScrollingEnabled(true);
-    internals.settings.setAsyncOverflowScrollingEnabled(true);
-}
-
-function sleep(delay)
-{
-    return new Promise((resolve) => { setTimeout(resolve, delay); });
-}
-
-async function runTest() {
-    for (const scrollable of document.querySelectorAll('.overflowscroll')) {
-        scrollable.addEventListener('scroll', function(e) {
-            logScroll(e.target);
-        });
-    }
-
-    {
-        let i = 0;
-        for (const scrollcontent of document.querySelectorAll('.scrollcontent'))
-            scrollcontent.innerText = "Scrollable " + ++i;
-    }
-    {
-        let i = 0;
-        for (const overlapping of document.querySelectorAll('.overlapping'))
-            overlapping.innerText = "Overlapping " + ++i;
-    }
-
-
-    if (!window.testRunner || !testRunner.runUIScript)
-        return;
-
-    for (const testcase of document.querySelectorAll('.case'))
-        testcase.style.display = 'none';
-
-    {
-        let i = 0;
-        for (const testcase of document.querySelectorAll('.case')) {
-            ++i;
-            testcase.style.display = 'inline-block';
-            
-            const target = testcase.querySelector('.target');
-            const rect = target.getBoundingClientRect();
-            const centerX = (rect.left + rect.right) / 2;
-            const centerY = (rect.top + rect.bottom) / 2;
-            await touchAndDragFromPointToPoint(centerX, centerY, centerX, centerY - 30);
-            await liftUpAtPoint(centerX, centerY - 30);
-            await sleep(500);
-
-            testcase.style.display = 'none';
-            outputCase(i);
-        }
-   }
-
-    for (const testcase of document.querySelectorAll('.case'))
-        testcase.style.display = 'none';
-
-    testRunner.notifyDone();
-}
-
-const scrolledElements = new Set();
-
-function logScroll(element) {
-    if (scrolledElements.has(element))
-        return;
-    scrolledElements.add(element);
-}
-
-function outputCase(i) {
-    log.innerText += "case " + i + ": ";
-    for (const scrolled of scrolledElements)
-        log.innerText += scrolled.getElementsByClassName("scrollcontent")[0].innerText + " ";
-    log.innerText += "\n";
-    scrolledElements.clear();
-}
-</script>
+<script src="../resources/overflow-scroll-overlap.js"></script>
 </head>
 <body onload="runTest()">
 <p>
diff --git a/LayoutTests/fast/scrolling/resources/overflow-scroll-overlap.js b/LayoutTests/fast/scrolling/resources/overflow-scroll-overlap.js
new file mode 100644 (file)
index 0000000..e9c4c39
--- /dev/null
@@ -0,0 +1,78 @@
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+    internals.settings.setAsyncFrameScrollingEnabled(true);
+    internals.settings.setAsyncOverflowScrollingEnabled(true);
+}
+
+function sleep(delay)
+{
+    return new Promise((resolve) => { setTimeout(resolve, delay); });
+}
+
+async function runTest() {
+    for (const scrollable of document.querySelectorAll('.overflowscroll')) {
+        scrollable.addEventListener('scroll', function(e) {
+            logScroll(e.target);
+        });
+    }
+
+    {
+        let i = 0;
+        for (const scrollcontent of document.querySelectorAll('.scrollcontent'))
+            scrollcontent.innerText = "Scrollable " + ++i;
+    }
+    {
+        let i = 0;
+        for (const overlapping of document.querySelectorAll('.overlapping'))
+            overlapping.insertBefore(document.createTextNode("Overlapping " + ++i), overlapping.firstChild);
+    }
+
+
+    if (!window.testRunner || !testRunner.runUIScript)
+        return;
+
+    for (const testcase of document.querySelectorAll('.case'))
+        testcase.style.display = 'none';
+
+    {
+        let i = 0;
+        for (const testcase of document.querySelectorAll('.case')) {
+            ++i;
+            testcase.style.display = 'inline-block';
+
+            const target = testcase.querySelector('.target');
+            const rect = target.getBoundingClientRect();
+            const centerX = (rect.left + rect.right) / 2;
+            const centerY = (rect.top + rect.bottom) / 2;
+            await touchAndDragFromPointToPoint(centerX, centerY, centerX, centerY - 30);
+            await liftUpAtPoint(centerX, centerY - 30);
+            await sleep(500);
+
+            testcase.style.display = 'none';
+            outputCase(i);
+        }
+   }
+
+    for (const testcase of document.querySelectorAll('.case'))
+        testcase.style.display = 'none';
+
+    testRunner.notifyDone();
+}
+
+const scrolledElements = new Set();
+
+function logScroll(element) {
+    if (scrolledElements.has(element))
+        return;
+    scrolledElements.add(element);
+}
+
+function outputCase(i) {
+    log.innerText += "case " + i + ": ";
+    for (const scrolled of scrolledElements)
+        log.innerText += scrolled.getElementsByClassName("scrollcontent")[0].innerText + " ";
+    log.innerText += "\n";
+    scrolledElements.clear();
+}
index fba931a..6e2cad2 100644 (file)
@@ -1,3 +1,48 @@
+2019-03-19  Antti Koivisto  <antti@apple.com>
+
+        Layer with no backing store should still hit-test over a scroller
+        https://bugs.webkit.org/show_bug.cgi?id=195378
+        <rdar://problem/48652078>
+
+        Reviewed by Simon Fraser.
+
+        Tests: fast/scrolling/ios/overflow-scroll-overlap-3.html
+               fast/scrolling/ios/overflow-scroll-overlap-4.html
+
+        Move collecting event region from paint to compositing update time.
+        This solves a number of problems including regions for non-painting layers.
+
+        * platform/graphics/GraphicsLayer.h:
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintObject):
+
+        Use the existing visibleToHitTesting() helper.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::paintLayerContents):
+
+        Use flag for event region collecting, don't paint content.
+
+        (WebCore::RenderLayer::paintList):
+
+        We can bail out immediately if there is no overflow.
+
+        (WebCore::RenderLayer::paintForegroundForFragments):
+        (WebCore::RenderLayer::paintForegroundForFragmentsWithPhase):
+        (WebCore::RenderLayer::collectEventRegionForFragments):
+
+        Move to a separate function.
+
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateConfiguration):
+
+        Update event region on backing configuration update. This is called after anything interesting changes on a sublayer.
+
+        (WebCore::RenderLayerBacking::updateEventRegion):
+        (WebCore::RenderLayerBacking::paintIntoLayer):
+        * rendering/RenderLayerBacking.h:
+
 2019-03-18  Alex Christensen  <achristensen@webkit.org>
 
         Make WTFLogChannelState and WTFLogLevel enum classes
index c84d75f..da9ac33 100644 (file)
@@ -453,7 +453,6 @@ public:
     WindRule shapeLayerWindRule() const;
     virtual void setShapeLayerWindRule(WindRule);
 
-    // Non-null if the event sensitive region of the layer differs from the layer bounds.
     const Region& eventRegion() const { return m_eventRegion; }
     virtual void setEventRegion(Region&&);
 
index aacf9a6..b3a7378 100644 (file)
@@ -1243,7 +1243,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
     if (paintPhase == PaintPhase::EventRegion) {
         // FIXME: Handle inlines, lineboxes, SVG too.
         // FIXME: Transforms?
-        if (style().pointerEvents() != PointerEvents::None)
+        if (visibleToHitTesting())
             paintInfo.eventRegion->unite(enclosingIntRect(LayoutRect(paintOffset, size())));
 
         // No need to check descendants if we don't have overflow.
index a7e711a..778c17a 100644 (file)
@@ -4243,16 +4243,17 @@ void RenderLayer::paintLayerContents(GraphicsContext& context, const LayerPainti
     bool isPaintingCompositedForeground = paintFlags.contains(PaintLayerPaintingCompositingForegroundPhase);
     bool isPaintingCompositedBackground = paintFlags.contains(PaintLayerPaintingCompositingBackgroundPhase);
     bool isPaintingOverflowContents = paintFlags.contains(PaintLayerPaintingOverflowContents);
+    bool isCollectingEventRegion = paintFlags.contains(PaintLayerCollectingEventRegion);
     // Outline always needs to be painted even if we have no visible content. Also,
     // the outline is painted in the background phase during composited scrolling.
     // If it were painted in the foreground phase, it would move with the scrolled
     // content. When not composited scrolling, the outline is painted in the
     // foreground phase. Since scrolled contents are moved by repainting in this
     // case, the outline won't get 'dragged along'.
-    bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbars
+    bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbars && !isCollectingEventRegion
         && ((isPaintingScrollingContent && isPaintingCompositedBackground)
         || (!isPaintingScrollingContent && isPaintingCompositedForeground));
-    bool shouldPaintContent = m_hasVisibleContent && isSelfPaintingLayer && !isPaintingOverlayScrollbars;
+    bool shouldPaintContent = m_hasVisibleContent && isSelfPaintingLayer && !isPaintingOverlayScrollbars && !isCollectingEventRegion;
 
     if (localPaintFlags & PaintLayerPaintingRootBackgroundOnly && !renderer().isRenderView() && !renderer().isDocumentElementRenderer())
         return;
@@ -4323,7 +4324,7 @@ void RenderLayer::paintLayerContents(GraphicsContext& context, const LayerPainti
             paintBehavior.add(PaintBehavior::ExcludeSelection);
 
         LayoutRect paintDirtyRect = localPaintingInfo.paintDirtyRect;
-        if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
+        if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars || isCollectingEventRegion) {
             // Collect the fragments. This will compute the clip rectangles and paint offsets for each layer fragment, as well as whether or not the content of each
             // fragment should paint. If the parent's filter dictates full repaint to ensure proper filter effect,
             // use the overflow clip as dirty rect, instead of no clipping. It maintains proper clipping for overflow::scroll.
@@ -4357,6 +4358,9 @@ void RenderLayer::paintLayerContents(GraphicsContext& context, const LayerPainti
             }
         }
 
+        if (isCollectingEventRegion)
+            collectEventRegionForFragments(layerFragments, currentContext, localPaintingInfo);
+
         if (shouldPaintOutline)
             paintOutlineForFragments(layerFragments, currentContext, localPaintingInfo, paintBehavior, subtreePaintRootForRenderer);
 
@@ -4464,6 +4468,9 @@ void RenderLayer::paintList(LayerList layerIterator, GraphicsContext& context, c
     if (!hasSelfPaintingLayerDescendant())
         return;
 
+    if (paintFlags.contains(PaintLayerCollectingEventRegion) && renderBox() && !renderBox()->hasRenderOverflow())
+        return;
+
 #if !ASSERT_DISABLED
     LayerListMutationDetector mutationChecker(*this);
 #endif
@@ -4746,8 +4753,6 @@ void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragmen
         paintForegroundForFragmentsWithPhase(PaintPhase::Float, layerFragments, context, localPaintingInfo, localPaintBehavior, subtreePaintRootForRenderer);
         paintForegroundForFragmentsWithPhase(PaintPhase::Foreground, layerFragments, context, localPaintingInfo, localPaintBehavior, subtreePaintRootForRenderer);
         paintForegroundForFragmentsWithPhase(PaintPhase::ChildOutlines, layerFragments, context, localPaintingInfo, localPaintBehavior, subtreePaintRootForRenderer);
-        if (localPaintingInfo.eventRegion)
-            paintForegroundForFragmentsWithPhase(PaintPhase::EventRegion, layerFragments, context, localPaintingInfo, localPaintBehavior, subtreePaintRootForRenderer);
     }
     
     if (shouldClip)
@@ -4769,8 +4774,6 @@ void RenderLayer::paintForegroundForFragmentsWithPhase(PaintPhase phase, const L
         PaintInfo paintInfo(context, fragment.foregroundRect.rect(), phase, paintBehavior, subtreePaintRootForRenderer, nullptr, nullptr, &localPaintingInfo.rootLayer->renderer(), this, localPaintingInfo.requireSecurityOriginAccessForWidgets);
         if (phase == PaintPhase::Foreground)
             paintInfo.overlapTestRequests = localPaintingInfo.overlapTestRequests;
-        if (phase == PaintPhase::EventRegion)
-            paintInfo.eventRegion = localPaintingInfo.eventRegion;
         renderer().paint(paintInfo, toLayoutPoint(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.subpixelOffset));
         
         if (shouldClip)
@@ -4843,6 +4846,17 @@ void RenderLayer::paintOverflowControlsForFragments(const LayerFragments& layerF
     }
 }
 
+void RenderLayer::collectEventRegionForFragments(const LayerFragments& layerFragments, GraphicsContext& context, const LayerPaintingInfo& localPaintingInfo)
+{
+    ASSERT(localPaintingInfo.eventRegion);
+
+    for (const auto& fragment : layerFragments) {
+        PaintInfo paintInfo(context, fragment.foregroundRect.rect(), PaintPhase::EventRegion, { });
+        paintInfo.eventRegion = localPaintingInfo.eventRegion;
+        renderer().paint(paintInfo, toLayoutPoint(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.subpixelOffset));
+    }
+}
+
 bool RenderLayer::hitTest(const HitTestRequest& request, HitTestResult& result)
 {
     return hitTest(request, result.hitTestLocation(), result);
index 839569e..24f26f9 100644 (file)
@@ -641,8 +641,9 @@ public:
         PaintLayerPaintingRootBackgroundOnly            = 1 << 11,
         PaintLayerPaintingSkipRootBackground            = 1 << 12,
         PaintLayerPaintingChildClippingMaskPhase        = 1 << 13,
+        PaintLayerCollectingEventRegion                 = 1 << 14,
     };
-    static constexpr OptionSet<PaintLayerFlag> paintLayerPaintingCompositingAllPhasesFlags() { return { PaintLayerPaintingCompositingBackgroundPhase,  PaintLayerPaintingCompositingForegroundPhase }; }
+    static constexpr OptionSet<PaintLayerFlag> paintLayerPaintingCompositingAllPhasesFlags() { return { PaintLayerPaintingCompositingBackgroundPhase, PaintLayerPaintingCompositingForegroundPhase }; }
 
     enum class SecurityOriginPaintPolicy { AnyOrigin, AccessibleOriginOnly };
 
@@ -984,6 +985,7 @@ private:
     void paintMaskForFragments(const LayerFragments&, GraphicsContext&, const LayerPaintingInfo&, OptionSet<PaintBehavior>, RenderObject* paintingRootForRenderer);
     void paintChildClippingMaskForFragments(const LayerFragments&, GraphicsContext&, const LayerPaintingInfo&, OptionSet<PaintBehavior>, RenderObject* paintingRootForRenderer);
     void paintTransformedLayerIntoFragments(GraphicsContext&, const LayerPaintingInfo&, OptionSet<PaintLayerFlag>);
+    void collectEventRegionForFragments(const LayerFragments&, GraphicsContext&, const LayerPaintingInfo&);
 
     RenderLayer* transparentPaintingAncestor();
     void beginTransparencyLayers(GraphicsContext&, const LayerPaintingInfo&, const LayoutRect& dirtyRect);
index 35e7367..23bde13 100644 (file)
@@ -765,6 +765,8 @@ bool RenderLayerBacking::updateConfiguration()
     if (!m_owningLayer.isRenderViewLayer()) {
         bool didUpdateContentsRect = false;
         updateDirectlyCompositedBoxDecorations(contentsInfo, didUpdateContentsRect);
+
+        updateEventRegion();
     } else
         updateRootLayerConfiguration();
     
@@ -1431,6 +1433,27 @@ void RenderLayerBacking::updateDrawsContent(PaintedContentsInfo& contentsInfo)
         m_backgroundLayer->setDrawsContent(m_backgroundLayerPaintsFixedRootBackground ? hasPaintedContent : contentsInfo.paintsBoxDecorations());
 }
 
+void RenderLayerBacking::updateEventRegion()
+{
+#if PLATFORM(IOS_FAMILY)
+    if (paintsIntoCompositedAncestor())
+        return;
+
+    GraphicsContext nullContext(nullptr);
+    RenderLayer::LayerPaintingInfo paintingInfo(&m_owningLayer, compositedBounds(), { }, LayoutSize());
+
+    Region eventRegion;
+    paintingInfo.eventRegion = &eventRegion;
+
+    auto paintFlags = RenderLayer::paintLayerPaintingCompositingAllPhasesFlags() | RenderLayer::PaintLayerCollectingEventRegion;
+    m_owningLayer.paintLayerContents(nullContext, paintingInfo, paintFlags);
+
+    eventRegion.translate(roundedIntSize(contentOffsetInCompositingLayer()));
+
+    m_graphicsLayer->setEventRegion(WTFMove(eventRegion));
+#endif
+}
+
 // Return true if the layer changed.
 bool RenderLayerBacking::updateAncestorClippingLayer(bool needsAncestorClip)
 {
@@ -2586,19 +2609,8 @@ void RenderLayerBacking::paintIntoLayer(const GraphicsLayer* graphicsLayer, Grap
 
     RenderLayer::LayerPaintingInfo paintingInfo(&m_owningLayer, paintDirtyRect, paintBehavior, -m_subpixelOffsetFromRenderer);
 
-#if PLATFORM(IOS_FAMILY)
-    Region eventRegion;
-    paintingInfo.eventRegion = &eventRegion;
-#endif
-
     m_owningLayer.paintLayerContents(context, paintingInfo, paintFlags);
 
-#if PLATFORM(IOS_FAMILY)
-    paintingInfo.eventRegion = nullptr;
-    eventRegion.translate(roundedIntSize(contentOffsetInCompositingLayer()));
-    m_graphicsLayer->setEventRegion(WTFMove(eventRegion));
-#endif
-
     if (m_owningLayer.containsDirtyOverlayScrollbars())
         m_owningLayer.paintLayerContents(context, paintingInfo, paintFlags | RenderLayer::PaintLayerPaintingOverlayScrollbars);
 
index 01a6bfa..fbe2a70 100644 (file)
@@ -352,6 +352,7 @@ private:
     bool paintsContent(RenderLayer::PaintedContentRequest&) const;
 
     void updateDrawsContent(PaintedContentsInfo&);
+    void updateEventRegion();
 
     // Returns true if this compositing layer has no visible content.
     bool isSimpleContainerCompositingLayer(PaintedContentsInfo&) const;
index f909bd6..fe6b7ae 100644 (file)
@@ -1,3 +1,19 @@
+2019-03-19  Antti Koivisto  <antti@apple.com>
+
+        Layer with no backing store should still hit-test over a scroller
+        https://bugs.webkit.org/show_bug.cgi?id=195378
+        <rdar://problem/48652078>
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
+        (WebKit::RemoteLayerTreeHost::makeNode):
+        * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.h:
+        * UIProcess/RemoteLayerTree/ios/RemoteLayerTreeViews.mm:
+        (WebKit::collectDescendantViewsAtPoint):
+
+        No need for special WKTiledBackingView, tiled views now have correct event regions.
+
 2019-03-18  Alex Christensen  <achristensen@webkit.org>
 
         Make WTFLogChannelState and WTFLogLevel enum classes
index 305918f..629a9c6 100644 (file)
@@ -72,11 +72,9 @@ std::unique_ptr<RemoteLayerTreeNode> RemoteLayerTreeHost::makeNode(const RemoteL
     case PlatformCALayer::LayerTypeWebLayer:
     case PlatformCALayer::LayerTypeRootLayer:
     case PlatformCALayer::LayerTypeSimpleLayer:
-        return makeAdoptingView([[WKCompositingView alloc] init]);
-        
     case PlatformCALayer::LayerTypeTiledBackingLayer:
     case PlatformCALayer::LayerTypePageTiledBackingLayer:
-        return makeAdoptingView([[WKTiledBackingView alloc] init]);
+        return makeAdoptingView([[WKCompositingView alloc] init]);
 
     case PlatformCALayer::LayerTypeTiledBackingTileLayer:
         return RemoteLayerTreeNode::createWithPlainLayer(properties.layerID);
index cd47abb..9a58a02 100644 (file)
@@ -40,9 +40,6 @@ class WebPageProxy;
 @interface WKCompositingView : UIView
 @end
 
-@interface WKTiledBackingView : WKCompositingView
-@end
-
 @interface WKTransformView : WKCompositingView
 @end
 
index 9a4f34e..28fe543 100644 (file)
@@ -49,8 +49,6 @@ static void collectDescendantViewsAtPoint(Vector<UIView *, 16>& viewsAtPoint, UI
         auto handlesEvent = [&] {
             if (![view pointInside:subviewPoint withEvent:event])
                 return false;
-            if ([view isKindOfClass:[WKTiledBackingView class]])
-                return true;
             if (![view isKindOfClass:[WKCompositingView class]])
                 return true;
             auto* node = RemoteLayerTreeNode::forCALayer(view.layer);
@@ -115,9 +113,6 @@ static void collectDescendantViewsAtPoint(Vector<UIView *, 16>& viewsAtPoint, UI
 
 @end
 
-@implementation WKTiledBackingView
-@end
-
 @implementation WKTransformView
 
 + (Class)layerClass