- Revision
- 244037
- Author
- [email protected]
- Date
- 2019-04-08 13:32:53 -0700 (Mon, 08 Apr 2019)
Log Message
Update touch-action region on property changes
https://bugs.webkit.org/show_bug.cgi?id=196608
Reviewed by Simon Fraser.
Source/WebCore:
Test: pointerevents/ios/touch-action-region-dynamic.html
* rendering/EventRegion.cpp:
(WebCore::EventRegion::touchActionsForPoint const):
Correctly return 'auto' when nothing is found from the regions (this code is not used yet).
* rendering/RenderElement.cpp:
(WebCore::RenderElement::styleWillChange):
React to 'touch-action' property changes, similarly to 'pointer-events'.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::invalidateEventRegion):
Test if need to invalidate.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::setContentsNeedDisplay):
(WebCore::RenderLayerBacking::setContentsNeedDisplayInRect):
Call invalidateEventRegion explicitly instead of relying on compositing update. This ensures
that we update the top level event region correctly when we have touch-actions.
LayoutTests:
* pointerevents/ios/touch-action-region-dynamic-expected.txt: Added.
* pointerevents/ios/touch-action-region-dynamic.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (244036 => 244037)
--- trunk/LayoutTests/ChangeLog 2019-04-08 20:31:05 UTC (rev 244036)
+++ trunk/LayoutTests/ChangeLog 2019-04-08 20:32:53 UTC (rev 244037)
@@ -1,3 +1,13 @@
+2019-04-08 Antti Koivisto <[email protected]>
+
+ Update touch-action region on property changes
+ https://bugs.webkit.org/show_bug.cgi?id=196608
+
+ Reviewed by Simon Fraser.
+
+ * pointerevents/ios/touch-action-region-dynamic-expected.txt: Added.
+ * pointerevents/ios/touch-action-region-dynamic.html: Added.
+
2019-04-08 Javier Fernandez <[email protected]>
Implement white-space:break-spaces value
Added: trunk/LayoutTests/pointerevents/ios/touch-action-region-dynamic-expected.txt (0 => 244037)
--- trunk/LayoutTests/pointerevents/ios/touch-action-region-dynamic-expected.txt (rev 0)
+++ trunk/LayoutTests/pointerevents/ios/touch-action-region-dynamic-expected.txt 2019-04-08 20:32:53 UTC (rev 244037)
@@ -0,0 +1,73 @@
+before
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (drawsContent 1)
+ (backgroundColor #FFFFFF)
+ (event region
+ (rect (0,0) width=800 height=183)
+ (rect (-17,183) width=817 height=100)
+ (rect (0,283) width=800 height=317)
+ (touch-action
+ (none
+ (rect (83,208) width=25 height=75)
+ (rect (8,283) width=100 height=25)
+ )
+ )
+ )
+ )
+ )
+)
+mutation 1
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 784.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 784.00)
+ (contentsOpaque 1)
+ (drawsContent 1)
+ (backgroundColor #FFFFFF)
+ (event region
+ (rect (0,0) width=800 height=183)
+ (rect (-17,183) width=817 height=100)
+ (rect (0,283) width=800 height=501)
+ (touch-action
+ (none
+ (rect (8,8) width=100 height=100)
+ (rect (83,208) width=25 height=75)
+ (rect (8,283) width=100 height=25)
+ )
+ )
+ )
+ )
+ )
+)
+mutation 2
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 1134.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 1134.00)
+ (contentsOpaque 1)
+ (drawsContent 1)
+ (backgroundColor #FFFFFF)
+ (event region
+ (rect (0,0) width=800 height=1134)
+ (touch-action
+ (none
+ (rect (8,8) width=100 height=100)
+ (rect (8,208) width=100 height=50)
+ (rect (8,258) width=50 height=50)
+ )
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/pointerevents/ios/touch-action-region-dynamic.html (0 => 244037)
--- trunk/LayoutTests/pointerevents/ios/touch-action-region-dynamic.html (rev 0)
+++ trunk/LayoutTests/pointerevents/ios/touch-action-region-dynamic.html 2019-04-08 20:32:53 UTC (rev 244037)
@@ -0,0 +1,57 @@
+<html>
+<style>
+.test {
+ width: 200px;
+ height: 200px;
+ position: relative;
+}
+.box {
+ width: 100px;
+ height: 100px;
+ background: green;
+ position: absolute;
+}
+.none {
+ touch-action:none;
+}
+
+.red {
+ background: red;
+}
+</style>
+<script>
+window._onload_ = function () {
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ results.innerText = "before\n";
+
+ if (window.internals)
+ results.innerText += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
+
+ results.innerText += "mutation 1\n";
+ document.body.offsetLeft;
+ mutation1.classList.add("none");
+
+ if (window.internals)
+ results.innerText += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
+
+ results.innerText += "mutation 2\n";
+ document.body.offsetLeft;
+ mutation2.setAttribute("style", "top:50px;left:50px;")
+
+ if (window.internals)
+ results.innerText += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION | internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
+}
+</script>
+<body>
+<div class="test">
+ <div id="mutation1" class="box red"></div>
+</div>
+<div class="test">
+ <div class="box red none"></div>
+ <div id="mutation2" class="box" style="top:-25px;left:-25px;"></div>
+</div>
+<pre id="results"></pre>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (244036 => 244037)
--- trunk/Source/WebCore/ChangeLog 2019-04-08 20:31:05 UTC (rev 244036)
+++ trunk/Source/WebCore/ChangeLog 2019-04-08 20:32:53 UTC (rev 244037)
@@ -1,3 +1,34 @@
+2019-04-08 Antti Koivisto <[email protected]>
+
+ Update touch-action region on property changes
+ https://bugs.webkit.org/show_bug.cgi?id=196608
+
+ Reviewed by Simon Fraser.
+
+ Test: pointerevents/ios/touch-action-region-dynamic.html
+
+ * rendering/EventRegion.cpp:
+ (WebCore::EventRegion::touchActionsForPoint const):
+
+ Correctly return 'auto' when nothing is found from the regions (this code is not used yet).
+
+ * rendering/RenderElement.cpp:
+ (WebCore::RenderElement::styleWillChange):
+
+ React to 'touch-action' property changes, similarly to 'pointer-events'.
+
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::invalidateEventRegion):
+
+ Test if need to invalidate.
+
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::setContentsNeedDisplay):
+ (WebCore::RenderLayerBacking::setContentsNeedDisplayInRect):
+
+ Call invalidateEventRegion explicitly instead of relying on compositing update. This ensures
+ that we update the top level event region correctly when we have touch-actions.
+
2019-04-08 Javier Fernandez <[email protected]>
Implement white-space:break-spaces value
Modified: trunk/Source/WebCore/rendering/EventRegion.cpp (244036 => 244037)
--- trunk/Source/WebCore/rendering/EventRegion.cpp 2019-04-08 20:31:05 UTC (rev 244036)
+++ trunk/Source/WebCore/rendering/EventRegion.cpp 2019-04-08 20:32:53 UTC (rev 244037)
@@ -136,6 +136,9 @@
}
}
+ if (actions.isEmpty())
+ return { TouchAction::Auto };
+
return actions;
}
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (244036 => 244037)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2019-04-08 20:31:05 UTC (rev 244036)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2019-04-08 20:32:53 UTC (rev 244037)
@@ -730,7 +730,17 @@
}
}
- if (m_style.pointerEvents() != newStyle.pointerEvents()) {
+ auto needsInvalidateEventRegion = [&] {
+ if (m_style.pointerEvents() != newStyle.pointerEvents())
+ return true;
+#if ENABLE(POINTER_EVENTS)
+ if (m_style.effectiveTouchActions() != newStyle.effectiveTouchActions())
+ return true;
+#endif
+ return false;
+ };
+
+ if (needsInvalidateEventRegion()) {
// Usually the event region gets updated as a result of paint invalidation. Here we need to request an update explicitly.
if (auto* layer = enclosingLayer())
layer->invalidateEventRegion();
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (244036 => 244037)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2019-04-08 20:31:05 UTC (rev 244036)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2019-04-08 20:32:53 UTC (rev 244037)
@@ -6685,8 +6685,28 @@
void RenderLayer::invalidateEventRegion()
{
- if (auto* compositingLayer = enclosingCompositingLayerForRepaint())
- compositingLayer->setNeedsCompositingConfigurationUpdate();
+#if PLATFORM(IOS_FAMILY)
+ auto* compositingLayer = enclosingCompositingLayerForRepaint();
+ if (!compositingLayer)
+ return;
+
+ auto maintainsEventRegion = [&] {
+ // UI side scroll overlap testing.
+ if (!compositingLayer->isRenderViewLayer())
+ return true;
+#if ENABLE(POINTER_EVENTS)
+ // UI side touch-action resolution.
+ if (renderer().document().touchActionElements())
+ return true;
+#endif
+ return false;
+ };
+
+ if (!maintainsEventRegion())
+ return;
+
+ compositingLayer->setNeedsCompositingConfigurationUpdate();
+#endif
}
TextStream& operator<<(TextStream& ts, const RenderLayer& layer)
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (244036 => 244037)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2019-04-08 20:31:05 UTC (rev 244036)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2019-04-08 20:32:53 UTC (rev 244037)
@@ -2486,6 +2486,8 @@
if (!m_owningLayer.isRenderViewLayer())
m_owningLayer.setNeedsCompositingConfigurationUpdate();
+ m_owningLayer.invalidateEventRegion();
+
auto& frameView = renderer().view().frameView();
if (m_isMainFrameRenderViewLayer && frameView.isTrackingRepaints())
frameView.addTrackedRepaintRect(owningLayer().absoluteBoundingBoxForPainting());
@@ -2524,6 +2526,8 @@
if (!m_owningLayer.isRenderViewLayer())
m_owningLayer.setNeedsCompositingConfigurationUpdate();
+ m_owningLayer.invalidateEventRegion();
+
FloatRect pixelSnappedRectForPainting = snapRectToDevicePixels(r, deviceScaleFactor());
auto& frameView = renderer().view().frameView();
if (m_isMainFrameRenderViewLayer && frameView.isTrackingRepaints())