Compute accurate regions for touch-action
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2019 20:28:46 +0000 (20:28 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2019 20:28:46 +0000 (20:28 +0000)
commitda5c580bf5f269b062e83a8203687af1a867c94b
tree0e1ee2b0af000523ece7b3a585df833a560d2b84
parent91cf45168600a69441a37833220d15950bec1dc7
Compute accurate regions for touch-action
https://bugs.webkit.org/show_bug.cgi?id=196536
<rdar://problem/49516022>

Reviewed by Simon Fraser.

Source/WebCore:

Tests: pointerevents/ios/touch-action-region-basic.html
       pointerevents/ios/touch-action-region-layers.html
       pointerevents/ios/touch-action-region-pan-x-y.html

- Use style system to compute effective touch-action without additional tree walks.
- Compute touch-action region in a fake paint, at the same time with the event region.

This patch doesn't yet use the computed region for anything except test output.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/StyleResolver.cpp:
(WebCore::computeEffectiveTouchActions):
(WebCore::StyleResolver::adjustRenderStyle):

Update RenderStyle::effectiveTouchAction.

* dom/Element.cpp:
(WebCore::Element::computedTouchActions const):

Just get it from the style.

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::setEventRegion):
(WebCore::GraphicsLayer::setTouchActionRegion):
(WebCore::GraphicsLayer::dumpProperties const):
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::touchActionRegion const):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::setTouchActionRegion):
* platform/graphics/ca/GraphicsLayerCA.h:
* rendering/PaintInfo.h:
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintObject):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::collectEventRegionForFragments):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateConfiguration):

Need to do this for the top compositing layer too.

(WebCore::RenderLayerBacking::updateEventRegion):

Compute touch-action region too.
As a basic optimization avoid doing any extra work if there are no elements with non-default touch-action property.

* rendering/TouchActionRegion.cpp: Added.
(WebCore::toIndex):
(WebCore::toTouchAction):
(WebCore::toString):
(WebCore::TouchActionRegion::unite):
(WebCore::TouchActionRegion::actionsForPoint const):
(WebCore::TouchActionRegion::translate):
(WebCore::operator<<):
* rendering/TouchActionRegion.h: Added.

Class for collecting and maintaining touch-action region.

(WebCore::TouchActionRegion::isEmpty const):
(WebCore::TouchActionRegion::operator== const):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::effectiveTouchActions const):
(WebCore::RenderStyle::setEffectiveTouchActions):

Implement as inherited property for efficiency (touch-action itself is non-inherited).

* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator== const):
* rendering/style/StyleRareInheritedData.h:

LayoutTests:

* pointerevents/ios/touch-action-region-basic-expected.txt: Added.
* pointerevents/ios/touch-action-region-basic.html: Added.
* pointerevents/ios/touch-action-region-layers-expected.txt: Added.
* pointerevents/ios/touch-action-region-layers.html: Added.
* pointerevents/ios/touch-action-region-pan-x-y-expected.txt: Added.
* pointerevents/ios/touch-action-region-pan-x-y.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243893 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/pointerevents/ios/touch-action-region-basic-expected.txt [new file with mode: 0644]
LayoutTests/pointerevents/ios/touch-action-region-basic.html [new file with mode: 0644]
LayoutTests/pointerevents/ios/touch-action-region-layers-expected.txt [new file with mode: 0644]
LayoutTests/pointerevents/ios/touch-action-region-layers.html [new file with mode: 0644]
LayoutTests/pointerevents/ios/touch-action-region-pan-x-y-expected.txt [new file with mode: 0644]
LayoutTests/pointerevents/ios/touch-action-region-pan-x-y.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/platform/TouchAction.h
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/rendering/PaintInfo.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/TouchActionRegion.cpp [new file with mode: 0644]
Source/WebCore/rendering/TouchActionRegion.h [new file with mode: 0644]
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.h