- Revision
- 258005
- Author
- simon.fra...@apple.com
- Date
- 2020-03-06 10:28:58 -0800 (Fri, 06 Mar 2020)
Log Message
Put an event region on scroll container layers
https://bugs.webkit.org/show_bug.cgi?id=208684
Reviewed by Antti Koivisto.
Source/WebCore:
Hit-testing through the CALayer tree on macOS, where we don't have scroll views for overflow,
is simpler if scroll container layers have an event region that just represents the bounds of
the layer. These regions are harmless to have on iOS too.
This patch adds them for overflow scroll, and for m_clipLayer which is the scroll container
layer for scrollable subframes.
Tests: fast/scrolling/mac/event-region-scrolled-contents-layer.html
fast/scrolling/mac/event-region-subframe.html
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateEventRegion):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateScrollLayerClipping):
LayoutTests:
* fast/scrolling/ios/event-region-scrolled-contents-layer-expected.txt:
* fast/scrolling/mac/event-region-scrolled-contents-layer-expected.txt: Copied from LayoutTests/fast/scrolling/ios/event-region-scrolled-contents-layer-expected.txt.
* fast/scrolling/mac/event-region-scrolled-contents-layer.html: Added.
* fast/scrolling/mac/event-region-subframe-expected.txt: Added.
* fast/scrolling/mac/event-region-subframe.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (258004 => 258005)
--- trunk/LayoutTests/ChangeLog 2020-03-06 18:26:35 UTC (rev 258004)
+++ trunk/LayoutTests/ChangeLog 2020-03-06 18:28:58 UTC (rev 258005)
@@ -1,3 +1,16 @@
+2020-03-06 Simon Fraser <simon.fra...@apple.com>
+
+ Put an event region on scroll container layers
+ https://bugs.webkit.org/show_bug.cgi?id=208684
+
+ Reviewed by Antti Koivisto.
+
+ * fast/scrolling/ios/event-region-scrolled-contents-layer-expected.txt:
+ * fast/scrolling/mac/event-region-scrolled-contents-layer-expected.txt: Copied from LayoutTests/fast/scrolling/ios/event-region-scrolled-contents-layer-expected.txt.
+ * fast/scrolling/mac/event-region-scrolled-contents-layer.html: Added.
+ * fast/scrolling/mac/event-region-subframe-expected.txt: Added.
+ * fast/scrolling/mac/event-region-subframe.html: Added.
+
2020-03-06 Jason Lawrence <lawrenc...@apple.com>
Unreviewed, rolling out r258001.
Modified: trunk/LayoutTests/fast/scrolling/ios/event-region-scrolled-contents-layer-expected.txt (258004 => 258005)
--- trunk/LayoutTests/fast/scrolling/ios/event-region-scrolled-contents-layer-expected.txt 2020-03-06 18:26:35 UTC (rev 258004)
+++ trunk/LayoutTests/fast/scrolling/ios/event-region-scrolled-contents-layer-expected.txt 2020-03-06 18:28:58 UTC (rev 258005)
@@ -15,6 +15,9 @@
(children 1
(GraphicsLayer
(bounds 300.00 300.00)
+ (event region
+ (rect (0,0) width=300 height=300)
+ )
(children 1
(GraphicsLayer
(anchor 0.00 0.00)
Copied: trunk/LayoutTests/fast/scrolling/mac/event-region-scrolled-contents-layer-expected.txt (from rev 258004, trunk/LayoutTests/fast/scrolling/ios/event-region-scrolled-contents-layer-expected.txt) (0 => 258005)
--- trunk/LayoutTests/fast/scrolling/mac/event-region-scrolled-contents-layer-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/event-region-scrolled-contents-layer-expected.txt 2020-03-06 18:28:58 UTC (rev 258005)
@@ -0,0 +1,38 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (children 1
+ (GraphicsLayer
+ (position 8.00 8.00)
+ (bounds 300.00 300.00)
+ (event region
+ (rect (0,0) width=300 height=300)
+ )
+ (children 1
+ (GraphicsLayer
+ (bounds 285.00 285.00)
+ (event region
+ (rect (0,0) width=285 height=285)
+ )
+ (children 1
+ (GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 400.00 400.00)
+ (drawsContent 1)
+ (event region
+ (rect (0,0) width=400 height=400)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/fast/scrolling/mac/event-region-scrolled-contents-layer.html (0 => 258005)
--- trunk/LayoutTests/fast/scrolling/mac/event-region-scrolled-contents-layer.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/event-region-scrolled-contents-layer.html 2020-03-06 18:28:58 UTC (rev 258005)
@@ -0,0 +1,39 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<style>
+.scroll {
+ overflow:scroll;
+ width:300px;
+ height:300px;
+}
+.contents {
+ position:relative;
+ background-color:blue;
+ width:200px;
+ height:200px;
+}
+.offset {
+ left: 200px;
+}
+
+</style>
+<script>
+window._onload_ = () => {
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ if (window.internals)
+ results.innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION);
+}
+</script>
+<body>
+<div class=scroll>
+ <div class="contents">
+ </div>
+ <div class="contents offset">
+ </div>
+</div>
+<pre id="results"></pre>
+</body>
+</html>
+
Added: trunk/LayoutTests/fast/scrolling/mac/event-region-subframe-expected.txt (0 => 258005)
--- trunk/LayoutTests/fast/scrolling/mac/event-region-subframe-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/event-region-subframe-expected.txt 2020-03-06 18:28:58 UTC (rev 258005)
@@ -0,0 +1,59 @@
+
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (children 1
+ (GraphicsLayer
+ (position 8.00 8.00)
+ (bounds 534.00 354.00)
+ (drawsContent 1)
+ (children 1
+ (GraphicsLayer
+ (position 17.00 17.00)
+ (children 2
+ (GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 485.00 320.00)
+ (event region
+ (rect (0,0) width=485 height=320)
+ )
+ (children 1
+ (GraphicsLayer
+ (anchor 0.00 0.00)
+ (children 1
+ (GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 485.00 1016.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 485.00 1016.00)
+ (drawsContent 1)
+ (children 1
+ (GraphicsLayer
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ (GraphicsLayer
+ (position 485.00 0.00)
+ (bounds 15.00 320.00)
+ (drawsContent 1)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/fast/scrolling/mac/event-region-subframe.html (0 => 258005)
--- trunk/LayoutTests/fast/scrolling/mac/event-region-subframe.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/event-region-subframe.html 2020-03-06 18:28:58 UTC (rev 258005)
@@ -0,0 +1,32 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true internal:AsyncFrameScrollingEnabled=true ] -->
+<html>
+<style>
+ iframe {
+ width: 500px;
+ height: 320px;
+ border: 5px solid gray;
+ padding: 12px;
+ }
+
+</style>
+<script>
+window._onload_ = () => {
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ if (window.internals)
+ results.innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION);
+}
+</script>
+<body>
+ <iframe srcdoc="
+ <style>
+ body { height: 1000px; }
+ </style>
+ This is a scrollable subframe.
+ "></iframe>
+
+<pre id="results"></pre>
+</body>
+</html>
+
Modified: trunk/Source/WebCore/ChangeLog (258004 => 258005)
--- trunk/Source/WebCore/ChangeLog 2020-03-06 18:26:35 UTC (rev 258004)
+++ trunk/Source/WebCore/ChangeLog 2020-03-06 18:28:58 UTC (rev 258005)
@@ -1,3 +1,25 @@
+2020-03-06 Simon Fraser <simon.fra...@apple.com>
+
+ Put an event region on scroll container layers
+ https://bugs.webkit.org/show_bug.cgi?id=208684
+
+ Reviewed by Antti Koivisto.
+
+ Hit-testing through the CALayer tree on macOS, where we don't have scroll views for overflow,
+ is simpler if scroll container layers have an event region that just represents the bounds of
+ the layer. These regions are harmless to have on iOS too.
+
+ This patch adds them for overflow scroll, and for m_clipLayer which is the scroll container
+ layer for scrollable subframes.
+
+ Tests: fast/scrolling/mac/event-region-scrolled-contents-layer.html
+ fast/scrolling/mac/event-region-subframe.html
+
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::updateEventRegion):
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::updateScrollLayerClipping):
+
2020-03-06 Antti Koivisto <an...@apple.com>
Reduce ThreadTimers maxDurationOfFiringTimers to 16ms
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (258004 => 258005)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2020-03-06 18:26:35 UTC (rev 258004)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2020-03-06 18:28:58 UTC (rev 258005)
@@ -1635,10 +1635,18 @@
auto eventRegionContext = eventRegion.makeContext();
auto layerOffset = graphicsLayer.scrollOffset() - roundedIntSize(graphicsLayer.offsetFromRenderer());
- if (&graphicsLayer == m_scrolledContentsLayer && renderer().visibleToHitTesting()) {
- // Initialize scrolled contents layer with layer-sized event region as it can all used for scrolling.
- // This avoids generating unnecessarily complex event regions. We still need to to do the paint to capture touch-action regions.
- eventRegionContext.unite(enclosingIntRect(FloatRect(-layerOffset, graphicsLayer.size())), RenderStyle::defaultStyle());
+ if (renderer().visibleToHitTesting()) {
+ if (&graphicsLayer == m_scrollContainerLayer) {
+ eventRegionContext.unite(enclosingIntRect(FloatRect({ }, graphicsLayer.size())), RenderStyle::defaultStyle());
+ graphicsLayer.setEventRegion(WTFMove(eventRegion));
+ return;
+ }
+
+ if (&graphicsLayer == m_scrolledContentsLayer) {
+ // Initialize scrolled contents layer with layer-sized event region as it can all used for scrolling.
+ // This avoids generating unnecessarily complex event regions. We still need to to do the paint to capture touch-action regions.
+ eventRegionContext.unite(enclosingIntRect(FloatRect(-layerOffset, graphicsLayer.size())), RenderStyle::defaultStyle());
+ }
}
auto dirtyRect = enclosingIntRect(FloatRect(FloatPoint(graphicsLayer.offsetFromRenderer()), graphicsLayer.size()));
@@ -1651,6 +1659,9 @@
updateEventRegionForLayer(*m_graphicsLayer);
+ if (m_scrollContainerLayer)
+ updateEventRegionForLayer(*m_scrollContainerLayer);
+
if (m_scrolledContentsLayer)
updateEventRegionForLayer(*m_scrolledContentsLayer);
}
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (258004 => 258005)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2020-03-06 18:26:35 UTC (rev 258004)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2020-03-06 18:28:58 UTC (rev 258005)
@@ -2036,8 +2036,18 @@
if (!layerForClipping)
return;
- layerForClipping->setSize(m_renderView.frameView().sizeForVisibleContent());
+ auto layerSize = m_renderView.frameView().sizeForVisibleContent();
+ layerForClipping->setSize(layerSize);
layerForClipping->setPosition(positionForClipLayer());
+
+#if ENABLE(SCROLLING_THREAD)
+ if (layerForClipping == m_clipLayer) {
+ EventRegion eventRegion;
+ auto eventRegionContext = eventRegion.makeContext();
+ eventRegionContext.unite(IntRect({ }, layerSize), RenderStyle::defaultStyle());
+ m_clipLayer->setEventRegion(WTFMove(eventRegion));
+ }
+#endif
}
FloatPoint RenderLayerCompositor::positionForClipLayer() const