Diff
Modified: trunk/Source/WebCore/ChangeLog (261601 => 261602)
--- trunk/Source/WebCore/ChangeLog 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/ChangeLog 2020-05-13 07:10:51 UTC (rev 261602)
@@ -1,3 +1,27 @@
+2020-05-13 Antti Koivisto <an...@apple.com>
+
+ [Wheel event region] Add support for getting wheel event region from ScrollingTree
+ https://bugs.webkit.org/show_bug.cgi?id=211785
+
+ Reviewed by Simon Fraser.
+
+ Add ScrollingTree::eventListenerRegionTypesForPoint. It is not used yet.
+
+ * page/scrolling/ScrollingTree.cpp:
+ (WebCore::ScrollingTree::eventListenerRegionTypesForPoint const):
+ * page/scrolling/ScrollingTree.h:
+ * page/scrolling/mac/ScrollingTreeMac.h:
+ * page/scrolling/mac/ScrollingTreeMac.mm:
+ (collectDescendantLayersAtPoint):
+ (ScrollingTreeMac::eventListenerRegionTypesForPoint const):
+ * platform/graphics/ca/PlatformCALayer.h:
+ * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
+ * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
+ (WebCore::PlatformCALayerCocoa::eventRegionContainsPoint const): Deleted.
+ * rendering/EventRegion.cpp:
+ (WebCore::EventRegion::eventListenerRegionTypesForPoint const):
+ * rendering/EventRegion.h:
+
2020-05-12 Alex Christensen <achristen...@webkit.org>
Give some NetworkLoadMetrics to WebCoreNSURLSession's delegate
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (261601 => 261602)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2020-05-13 07:10:51 UTC (rev 261602)
@@ -170,6 +170,11 @@
return m_rootNode;
}
+OptionSet<EventListenerRegionType> ScrollingTree::eventListenerRegionTypesForPoint(FloatPoint) const
+{
+ return { };
+}
+
void ScrollingTree::traverseScrollingTree(VisitorFunction&& visitorFunction)
{
LockHolder locker(m_treeMutex);
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (261601 => 261602)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2020-05-13 07:10:51 UTC (rev 261602)
@@ -53,6 +53,7 @@
class ScrollingTreeOverflowScrollProxyNode;
class ScrollingTreePositionedNode;
class ScrollingTreeScrollingNode;
+enum class EventListenerRegionType : uint8_t;
class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
friend class ScrollingTreeLatchingController;
@@ -194,6 +195,7 @@
void traverseScrollingTreeRecursive(ScrollingTreeNode&, const VisitorFunction&);
WEBCORE_EXPORT virtual RefPtr<ScrollingTreeNode> scrollingNodeForPoint(FloatPoint);
+ WEBCORE_EXPORT virtual OptionSet<EventListenerRegionType> eventListenerRegionTypesForPoint(FloatPoint) const;
virtual void receivedWheelEvent(const PlatformWheelEvent&) { }
Lock m_treeMutex; // Protects the scrolling tree.
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.h (261601 => 261602)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.h 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.h 2020-05-13 07:10:51 UTC (rev 261602)
@@ -43,6 +43,7 @@
Ref<ScrollingTreeNode> createScrollingTreeNode(ScrollingNodeType, ScrollingNodeID) final;
RefPtr<ScrollingTreeNode> scrollingNodeForPoint(FloatPoint) final;
+ OptionSet<EventListenerRegionType> eventListenerRegionTypesForPoint(FloatPoint) const final;
void setWheelEventTestMonitor(RefPtr<WheelEventTestMonitor>&&) final;
@@ -55,7 +56,7 @@
void unlockLayersForHitTesting() final;
// This lock protects the CALayer/PlatformCALayer tree.
- Lock m_layerHitTestMutex;
+ mutable Lock m_layerHitTestMutex;
RefPtr<WheelEventTestMonitor> m_wheelEventTestMonitor;
};
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm (261601 => 261602)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm 2020-05-13 07:10:51 UTC (rev 261602)
@@ -102,7 +102,8 @@
// Scrolling changes boundsOrigin on the scroll container layer, but we computed its event region ignoring scroll position, so factor out bounds origin.
FloatPoint boundsOrigin = layer.bounds.origin;
FloatPoint localPoint = subviewPoint - toFloatSize(boundsOrigin);
- return platformCALayer->eventRegionContainsPoint(IntPoint(localPoint));
+ auto* eventRegion = platformCALayer->eventRegion();
+ return eventRegion && eventRegion->contains(roundedIntPoint(localPoint));
}
return false;
@@ -184,6 +185,37 @@
return rootScrollingNode;
}
+OptionSet<EventListenerRegionType> ScrollingTreeMac::eventListenerRegionTypesForPoint(FloatPoint point) const
+{
+ auto* rootScrollingNode = rootNode();
+ if (!rootScrollingNode)
+ return { };
+
+ LockHolder lockHolder(m_layerHitTestMutex);
+
+ auto rootContentsLayer = static_cast<ScrollingTreeFrameScrollingNodeMac*>(rootScrollingNode)->rootContentsLayer();
+
+ Vector<CALayer *, 16> layersAtPoint;
+ collectDescendantLayersAtPoint(layersAtPoint, rootContentsLayer.get(), point);
+
+ if (layersAtPoint.isEmpty())
+ return { };
+
+ auto *hitLayer = layersAtPoint.last();
+ if (!hitLayer)
+ return { };
+
+ auto platformCALayer = PlatformCALayer::platformCALayerForLayer((__bridge void*)hitLayer);
+ if (!platformCALayer)
+ return { };
+
+ auto* eventRegion = platformCALayer->eventRegion();
+ if (!eventRegion)
+ return { };
+
+ return eventRegion->eventListenerRegionTypesForPoint(roundedIntPoint(point));
+}
+
void ScrollingTreeMac::lockLayersForHitTesting()
{
m_layerHitTestMutex.lock();
Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (261601 => 261602)
--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h 2020-05-13 07:10:51 UTC (rev 261602)
@@ -235,8 +235,8 @@
virtual WindRule shapeWindRule() const = 0;
virtual void setShapeWindRule(WindRule) = 0;
+ virtual const EventRegion* eventRegion() const { return nullptr; }
virtual void setEventRegion(const EventRegion&) { }
- virtual bool eventRegionContainsPoint(IntPoint) const { return false; }
#if ENABLE(SCROLLING_THREAD)
virtual ScrollingNodeID scrollingNodeID() const { return 0; }
Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h (261601 => 261602)
--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h 2020-05-13 07:10:51 UTC (rev 261602)
@@ -168,8 +168,8 @@
GraphicsLayer::CustomAppearance customAppearance() const override { return m_customAppearance; }
void updateCustomAppearance(GraphicsLayer::CustomAppearance) override;
+ const EventRegion* eventRegion() const override { return &m_eventRegion; }
void setEventRegion(const EventRegion&) override;
- bool eventRegionContainsPoint(IntPoint) const override;
#if ENABLE(SCROLLING_THREAD)
ScrollingNodeID scrollingNodeID() const override { return m_scrollingNodeID; }
Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm (261601 => 261602)
--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm 2020-05-13 07:10:51 UTC (rev 261602)
@@ -1038,11 +1038,6 @@
m_eventRegion = eventRegion;
}
-bool PlatformCALayerCocoa::eventRegionContainsPoint(IntPoint point) const
-{
- return m_eventRegion.contains(point);
-}
-
GraphicsLayer::EmbeddedViewID PlatformCALayerCocoa::embeddedViewID() const
{
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/rendering/EventRegion.cpp (261601 => 261602)
--- trunk/Source/WebCore/rendering/EventRegion.cpp 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/rendering/EventRegion.cpp 2020-05-13 07:10:51 UTC (rev 261602)
@@ -229,6 +229,17 @@
m_nonPassiveWheelEventListenerRegion.unite(region);
}
+OptionSet<EventListenerRegionType> EventRegion::eventListenerRegionTypesForPoint(const IntPoint& point) const
+{
+ OptionSet<EventListenerRegionType> regionTypes;
+ if (m_wheelEventListenerRegion.contains(point))
+ regionTypes.add(EventListenerRegionType::Wheel);
+ if (m_nonPassiveWheelEventListenerRegion.contains(point))
+ regionTypes.add(EventListenerRegionType::NonPassiveWheel);
+
+ return regionTypes;
+}
+
#if ENABLE(EDITABLE_REGION)
bool EventRegion::containsEditableElementsInRect(const IntRect& rect) const
Modified: trunk/Source/WebCore/rendering/EventRegion.h (261601 => 261602)
--- trunk/Source/WebCore/rendering/EventRegion.h 2020-05-13 07:08:13 UTC (rev 261601)
+++ trunk/Source/WebCore/rendering/EventRegion.h 2020-05-13 07:10:51 UTC (rev 261602)
@@ -79,6 +79,8 @@
WEBCORE_EXPORT OptionSet<TouchAction> touchActionsForPoint(const IntPoint&) const;
const Region* regionForTouchAction(TouchAction) const;
+ OptionSet<EventListenerRegionType> eventListenerRegionTypesForPoint(const IntPoint&) const;
+
#if ENABLE(EDITABLE_REGION)
WEBCORE_EXPORT bool containsEditableElementsInRect(const IntRect&) const;
Vector<IntRect, 1> rectsForEditableElements() const { return m_editableRegion.rects(); }