Changeset 261602 in webkit


Ignore:
Timestamp:
May 13, 2020 12:10:51 AM (4 years ago)
Author:
Antti Koivisto
Message:

[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:
Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r261597 r261602  
     12020-05-13  Antti Koivisto  <antti@apple.com>
     2
     3        [Wheel event region] Add support for getting wheel event region from ScrollingTree
     4        https://bugs.webkit.org/show_bug.cgi?id=211785
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add ScrollingTree::eventListenerRegionTypesForPoint. It is not used yet.
     9
     10        * page/scrolling/ScrollingTree.cpp:
     11        (WebCore::ScrollingTree::eventListenerRegionTypesForPoint const):
     12        * page/scrolling/ScrollingTree.h:
     13        * page/scrolling/mac/ScrollingTreeMac.h:
     14        * page/scrolling/mac/ScrollingTreeMac.mm:
     15        (collectDescendantLayersAtPoint):
     16        (ScrollingTreeMac::eventListenerRegionTypesForPoint const):
     17        * platform/graphics/ca/PlatformCALayer.h:
     18        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
     19        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
     20        (WebCore::PlatformCALayerCocoa::eventRegionContainsPoint const): Deleted.
     21        * rendering/EventRegion.cpp:
     22        (WebCore::EventRegion::eventListenerRegionTypesForPoint const):
     23        * rendering/EventRegion.h:
     24
    1252020-05-12  Alex Christensen  <achristensen@webkit.org>
    226
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r261558 r261602  
    171171}
    172172
     173OptionSet<EventListenerRegionType> ScrollingTree::eventListenerRegionTypesForPoint(FloatPoint) const
     174{
     175    return { };
     176}
     177
    173178void ScrollingTree::traverseScrollingTree(VisitorFunction&& visitorFunction)
    174179{
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r261427 r261602  
    5454class ScrollingTreePositionedNode;
    5555class ScrollingTreeScrollingNode;
     56enum class EventListenerRegionType : uint8_t;
    5657
    5758class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
     
    195196
    196197    WEBCORE_EXPORT virtual RefPtr<ScrollingTreeNode> scrollingNodeForPoint(FloatPoint);
     198    WEBCORE_EXPORT virtual OptionSet<EventListenerRegionType> eventListenerRegionTypesForPoint(FloatPoint) const;
    197199    virtual void receivedWheelEvent(const PlatformWheelEvent&) { }
    198200
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.h

    r258679 r261602  
    4444
    4545    RefPtr<ScrollingTreeNode> scrollingNodeForPoint(FloatPoint) final;
     46    OptionSet<EventListenerRegionType> eventListenerRegionTypesForPoint(FloatPoint) const final;
    4647
    4748    void setWheelEventTestMonitor(RefPtr<WheelEventTestMonitor>&&) final;
     
    5657
    5758    // This lock protects the CALayer/PlatformCALayer tree.
    58     Lock m_layerHitTestMutex;
     59    mutable Lock m_layerHitTestMutex;
    5960   
    6061    RefPtr<WheelEventTestMonitor> m_wheelEventTestMonitor;
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm

    r260366 r261602  
    103103                FloatPoint boundsOrigin = layer.bounds.origin;
    104104                FloatPoint localPoint = subviewPoint - toFloatSize(boundsOrigin);
    105                 return platformCALayer->eventRegionContainsPoint(IntPoint(localPoint));
     105                auto* eventRegion = platformCALayer->eventRegion();
     106                return eventRegion && eventRegion->contains(roundedIntPoint(localPoint));
    106107            }
    107108           
     
    185186}
    186187
     188OptionSet<EventListenerRegionType> ScrollingTreeMac::eventListenerRegionTypesForPoint(FloatPoint point) const
     189{
     190    auto* rootScrollingNode = rootNode();
     191    if (!rootScrollingNode)
     192        return { };
     193
     194    LockHolder lockHolder(m_layerHitTestMutex);
     195
     196    auto rootContentsLayer = static_cast<ScrollingTreeFrameScrollingNodeMac*>(rootScrollingNode)->rootContentsLayer();
     197
     198    Vector<CALayer *, 16> layersAtPoint;
     199    collectDescendantLayersAtPoint(layersAtPoint, rootContentsLayer.get(), point);
     200
     201    if (layersAtPoint.isEmpty())
     202        return { };
     203
     204    auto *hitLayer = layersAtPoint.last();
     205    if (!hitLayer)
     206        return { };
     207
     208    auto platformCALayer = PlatformCALayer::platformCALayerForLayer((__bridge void*)hitLayer);
     209    if (!platformCALayer)
     210        return { };
     211
     212    auto* eventRegion = platformCALayer->eventRegion();
     213    if (!eventRegion)
     214        return { };
     215
     216    return eventRegion->eventListenerRegionTypesForPoint(roundedIntPoint(point));
     217}
     218
    187219void ScrollingTreeMac::lockLayersForHitTesting()
    188220{
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h

    r258006 r261602  
    236236    virtual void setShapeWindRule(WindRule) = 0;
    237237
     238    virtual const EventRegion* eventRegion() const { return nullptr; }
    238239    virtual void setEventRegion(const EventRegion&) { }
    239     virtual bool eventRegionContainsPoint(IntPoint) const { return false; }
    240240   
    241241#if ENABLE(SCROLLING_THREAD)
  • trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h

    r257949 r261602  
    169169    void updateCustomAppearance(GraphicsLayer::CustomAppearance) override;
    170170
     171    const EventRegion* eventRegion() const override { return &m_eventRegion; }
    171172    void setEventRegion(const EventRegion&) override;
    172     bool eventRegionContainsPoint(IntPoint) const override;
    173173
    174174#if ENABLE(SCROLLING_THREAD)
  • trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm

    r261210 r261602  
    10391039}
    10401040
    1041 bool PlatformCALayerCocoa::eventRegionContainsPoint(IntPoint point) const
    1042 {
    1043     return m_eventRegion.contains(point);
    1044 }
    1045 
    10461041GraphicsLayer::EmbeddedViewID PlatformCALayerCocoa::embeddedViewID() const
    10471042{
  • trunk/Source/WebCore/rendering/EventRegion.cpp

    r261279 r261602  
    230230}
    231231
     232OptionSet<EventListenerRegionType> EventRegion::eventListenerRegionTypesForPoint(const IntPoint& point) const
     233{
     234    OptionSet<EventListenerRegionType> regionTypes;
     235    if (m_wheelEventListenerRegion.contains(point))
     236        regionTypes.add(EventListenerRegionType::Wheel);
     237    if (m_nonPassiveWheelEventListenerRegion.contains(point))
     238        regionTypes.add(EventListenerRegionType::NonPassiveWheel);
     239
     240    return regionTypes;
     241}
     242
    232243#if ENABLE(EDITABLE_REGION)
    233244
  • trunk/Source/WebCore/rendering/EventRegion.h

    r261279 r261602  
    8080    const Region* regionForTouchAction(TouchAction) const;
    8181
     82    OptionSet<EventListenerRegionType> eventListenerRegionTypesForPoint(const IntPoint&) const;
     83
    8284#if ENABLE(EDITABLE_REGION)
    8385    WEBCORE_EXPORT bool containsEditableElementsInRect(const IntRect&) const;
Note: See TracChangeset for help on using the changeset viewer.