Changeset 269659 in webkit


Ignore:
Timestamp:
Nov 10, 2020, 4:28:59 PM (5 years ago)
Author:
Simon Fraser
Message:

Make PlatformWheelEventPhase an enum class
https://bugs.webkit.org/show_bug.cgi?id=218772

Reviewed by Tim Horton.

Change PlatformWheelEventPhase to be an enum class.

Changed code that maps between NSEventPhase and PlatformWheelEventPhase to not
treat NSEventPhase as a set of bits, since it only ever contains one of the bits.

Source/WebCore:

  • dom/WheelEvent.h:
  • page/EventHandler.cpp:

(WebCore::handleWheelEventPhaseInScrollableArea):
(WebCore::handleWheelEventInAppropriateEnclosingBox):

  • page/WheelEventTestMonitor.cpp:

(WebCore::WheelEventTestMonitor::receivedWheelEvent):

  • page/mac/EventHandlerMac.mm:

(WebCore::findEnclosingScrollableContainer):
(WebCore::EventHandler::recordWheelEventForDeltaFilter):
(WebCore::EventHandler::processWheelEventForScrollSnap):

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::willWheelEventStartSwipeGesture):

  • page/scrolling/ScrollingTreeGestureState.cpp:

(WebCore::ScrollingTreeGestureState::handleGestureCancel):
(WebCore::ScrollingTreeGestureState::nodeDidHandleEvent):

  • page/scrolling/ScrollingTreeScrollingNode.cpp:

(WebCore::ScrollingTreeScrollingNode::canHandleWheelEvent const):

  • page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:

(WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent):

  • platform/PlatformWheelEvent.cpp:

(WebCore::operator<<):

  • platform/PlatformWheelEvent.h:

(WebCore::PlatformWheelEvent::useLatchedEventElement const):
(WebCore::PlatformWheelEvent::isGestureStart const):
(WebCore::PlatformWheelEvent::isGestureContinuation const):
(WebCore::PlatformWheelEvent::shouldResetLatching const):
(WebCore::PlatformWheelEvent::isNonGestureEvent const):
(WebCore::PlatformWheelEvent::isEndOfMomentumScroll const):
(WebCore::PlatformWheelEvent::isGestureBegin const):
(WebCore::PlatformWheelEvent::isGestureCancel const):
(WebCore::PlatformWheelEvent::isEndOfNonMomentumScroll const):
(WebCore::PlatformWheelEvent::isTransitioningToMomentumScroll const):

  • platform/ScrollAnimator.cpp:

(WebCore::ScrollAnimator::handleWheelEvent):

  • platform/cocoa/ScrollController.mm:

(WebCore::ScrollController::handleWheelEvent):
(WebCore::toWheelEventStatus):

  • platform/mac/PlatformEventFactoryMac.mm:

(WebCore::phaseFromNSEventPhase):
(WebCore::momentumPhaseForEvent):
(WebCore::phaseForEvent):

  • platform/mac/ScrollAnimatorMac.mm:

(WebCore::ScrollAnimatorMac::handleWheelEventPhase):
(WebCore::newGestureIsStarting):
(WebCore::gestureShouldBeginSnap):

Source/WebKit:

  • UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm:

(WebKit::ScrollerPairMac::handleWheelEvent):

  • WebProcess/WebPage/EventDispatcher.cpp:

(WebKit::EventDispatcher::wheelEvent):

Source/WebKitLegacy/mac:

  • DOM/WebDOMOperations.mm:

(toNSEventPhase):

Location:
trunk/Source
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r269658 r269659  
     12020-11-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make PlatformWheelEventPhase an enum class
     4        https://bugs.webkit.org/show_bug.cgi?id=218772
     5
     6        Reviewed by Tim Horton.
     7
     8        Change PlatformWheelEventPhase to be an enum class.
     9
     10        Changed code that maps between NSEventPhase and PlatformWheelEventPhase to not
     11        treat NSEventPhase as a set of bits, since it only ever contains one of the bits.
     12
     13        * dom/WheelEvent.h:
     14        * page/EventHandler.cpp:
     15        (WebCore::handleWheelEventPhaseInScrollableArea):
     16        (WebCore::handleWheelEventInAppropriateEnclosingBox):
     17        * page/WheelEventTestMonitor.cpp:
     18        (WebCore::WheelEventTestMonitor::receivedWheelEvent):
     19        * page/mac/EventHandlerMac.mm:
     20        (WebCore::findEnclosingScrollableContainer):
     21        (WebCore::EventHandler::recordWheelEventForDeltaFilter):
     22        (WebCore::EventHandler::processWheelEventForScrollSnap):
     23        * page/scrolling/ScrollingTree.cpp:
     24        (WebCore::ScrollingTree::willWheelEventStartSwipeGesture):
     25        * page/scrolling/ScrollingTreeGestureState.cpp:
     26        (WebCore::ScrollingTreeGestureState::handleGestureCancel):
     27        (WebCore::ScrollingTreeGestureState::nodeDidHandleEvent):
     28        * page/scrolling/ScrollingTreeScrollingNode.cpp:
     29        (WebCore::ScrollingTreeScrollingNode::canHandleWheelEvent const):
     30        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
     31        (WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent):
     32        * platform/PlatformWheelEvent.cpp:
     33        (WebCore::operator<<):
     34        * platform/PlatformWheelEvent.h:
     35        (WebCore::PlatformWheelEvent::useLatchedEventElement const):
     36        (WebCore::PlatformWheelEvent::isGestureStart const):
     37        (WebCore::PlatformWheelEvent::isGestureContinuation const):
     38        (WebCore::PlatformWheelEvent::shouldResetLatching const):
     39        (WebCore::PlatformWheelEvent::isNonGestureEvent const):
     40        (WebCore::PlatformWheelEvent::isEndOfMomentumScroll const):
     41        (WebCore::PlatformWheelEvent::isGestureBegin const):
     42        (WebCore::PlatformWheelEvent::isGestureCancel const):
     43        (WebCore::PlatformWheelEvent::isEndOfNonMomentumScroll const):
     44        (WebCore::PlatformWheelEvent::isTransitioningToMomentumScroll const):
     45        * platform/ScrollAnimator.cpp:
     46        (WebCore::ScrollAnimator::handleWheelEvent):
     47        * platform/cocoa/ScrollController.mm:
     48        (WebCore::ScrollController::handleWheelEvent):
     49        (WebCore::toWheelEventStatus):
     50        * platform/mac/PlatformEventFactoryMac.mm:
     51        (WebCore::phaseFromNSEventPhase):
     52        (WebCore::momentumPhaseForEvent):
     53        (WebCore::phaseForEvent):
     54        * platform/mac/ScrollAnimatorMac.mm:
     55        (WebCore::ScrollAnimatorMac::handleWheelEventPhase):
     56        (WebCore::newGestureIsStarting):
     57        (WebCore::gestureShouldBeginSnap):
     58
    1592020-11-10  Geoffrey Garen  <ggaren@apple.com>
    260
  • trunk/Source/WebCore/dom/WheelEvent.h

    r250060 r269659  
    7070
    7171#if PLATFORM(MAC)
    72     PlatformWheelEventPhase phase() const { return m_underlyingPlatformEvent ? m_underlyingPlatformEvent.value().phase() : PlatformWheelEventPhaseNone; }
    73     PlatformWheelEventPhase momentumPhase() const { return m_underlyingPlatformEvent ? m_underlyingPlatformEvent.value().momentumPhase() : PlatformWheelEventPhaseNone; }
     72    PlatformWheelEventPhase phase() const { return m_underlyingPlatformEvent ? m_underlyingPlatformEvent.value().phase() : PlatformWheelEventPhase::None; }
     73    PlatformWheelEventPhase momentumPhase() const { return m_underlyingPlatformEvent ? m_underlyingPlatformEvent.value().momentumPhase() : PlatformWheelEventPhase::None; }
    7474#endif
    7575
  • trunk/Source/WebCore/page/EventHandler.cpp

    r269587 r269659  
    295295{
    296296#if PLATFORM(MAC)
    297     if (wheelEvent.phase() == PlatformWheelEventPhaseMayBegin || wheelEvent.phase() == PlatformWheelEventPhaseCancelled)
     297    if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin || wheelEvent.phase() == PlatformWheelEventPhase::Cancelled)
    298298        scrollableArea.scrollAnimator().handleWheelEventPhase(wheelEvent.phase());
    299299#else
     
    320320    bool shouldHandleEvent = wheelEvent.deltaX() || wheelEvent.deltaY();
    321321#if ENABLE(WHEEL_EVENT_LATCHING)
    322     shouldHandleEvent |= wheelEvent.phase() == PlatformWheelEventPhaseEnded;
     322    shouldHandleEvent |= wheelEvent.phase() == PlatformWheelEventPhase::Ended;
    323323#if ENABLE(CSS_SCROLL_SNAP)
    324     shouldHandleEvent |= wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded;
     324    shouldHandleEvent |= wheelEvent.momentumPhase() == PlatformWheelEventPhase::Ended;
    325325#endif
    326326#endif
  • trunk/Source/WebCore/page/WheelEventTestMonitor.cpp

    r268075 r269659  
    111111{
    112112#if ENABLE(KINETIC_SCROLLING)
    113     if (event.phase() == PlatformWheelEventPhaseEnded || event.phase() == PlatformWheelEventPhaseCancelled)
     113    if (event.phase() == PlatformWheelEventPhase::Ended || event.phase() == PlatformWheelEventPhase::Cancelled)
    114114        m_receivedWheelEndOrCancel = true;
    115115
    116     if (event.momentumPhase() == PlatformWheelEventPhaseEnded)
     116    if (event.momentumPhase() == PlatformWheelEventPhase::Ended)
    117117        m_receivedMomentumEnd = true;
    118118#endif
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r268417 r269659  
    809809            continue;
    810810
    811         if (wheelEvent.phase() == PlatformWheelEventPhaseMayBegin || wheelEvent.phase() == PlatformWheelEventPhaseCancelled)
     811        if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin || wheelEvent.phase() == PlatformWheelEventPhase::Cancelled)
    812812            return candidate;
    813813
     
    892892
    893893    switch (wheelEvent.phase()) {
    894         case PlatformWheelEventPhaseBegan:
    895             page->wheelEventDeltaFilter()->beginFilteringDeltas();
    896             break;
    897         case PlatformWheelEventPhaseEnded:
    898             page->wheelEventDeltaFilter()->endFilteringDeltas();
    899             break;
    900         default:
    901             break;
     894    case PlatformWheelEventPhase::Began:
     895        page->wheelEventDeltaFilter()->beginFilteringDeltas();
     896        break;
     897    case PlatformWheelEventPhase::Ended:
     898        page->wheelEventDeltaFilter()->endFilteringDeltas();
     899        break;
     900    default:
     901        break;
    902902    }
    903903    page->wheelEventDeltaFilter()->updateFromDelta(FloatSize(wheelEvent.deltaX(), wheelEvent.deltaY()));
     
    975975
    976976    // Special case handling for ending wheel gesture to activate snap animation:
    977     if (wheelEvent.phase() != PlatformWheelEventPhaseEnded && wheelEvent.momentumPhase() != PlatformWheelEventPhaseEnded)
     977    if (wheelEvent.phase() != PlatformWheelEventPhase::Ended && wheelEvent.momentumPhase() != PlatformWheelEventPhase::Ended)
    978978        return;
    979979
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r269561 r269659  
    618618bool ScrollingTree::willWheelEventStartSwipeGesture(const PlatformWheelEvent& wheelEvent)
    619619{
    620     if (wheelEvent.phase() != PlatformWheelEventPhaseBegan)
     620    if (wheelEvent.phase() != PlatformWheelEventPhase::Began)
    621621        return false;
    622622
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeGestureState.cpp

    r261431 r269659  
    5252    if (event.isGestureCancel()) {
    5353        if (m_mayBeginNodeID)
    54             m_scrollingTree.handleWheelEventPhase(*m_mayBeginNodeID, PlatformWheelEventPhaseCancelled);
     54            m_scrollingTree.handleWheelEventPhase(*m_mayBeginNodeID, PlatformWheelEventPhase::Cancelled);
    5555        return true;
    5656    }
     
    6262{
    6363    switch (event.phase()) {
    64     case PlatformWheelEventPhaseMayBegin:
     64    case PlatformWheelEventPhase::MayBegin:
    6565        m_mayBeginNodeID = nodeID;
    6666        m_scrollingTree.handleWheelEventPhase(nodeID, event.phase());
    6767        break;
    68     case PlatformWheelEventPhaseCancelled:
     68    case PlatformWheelEventPhase::Cancelled:
    6969        // handleGestureCancel() should have been called first.
    7070        ASSERT_NOT_REACHED();
    7171        break;
    72     case PlatformWheelEventPhaseBegan:
     72    case PlatformWheelEventPhase::Began:
    7373        m_activeNodeID = nodeID;
    7474        m_scrollingTree.handleWheelEventPhase(nodeID, event.phase());
    7575        break;
    76     case PlatformWheelEventPhaseEnded:
     76    case PlatformWheelEventPhase::Ended:
    7777        if (m_activeNodeID)
    7878            m_scrollingTree.handleWheelEventPhase(*m_activeNodeID, event.phase());
    7979        break;
    80     case PlatformWheelEventPhaseChanged:
    81     case PlatformWheelEventPhaseStationary:
    82     case PlatformWheelEventPhaseNone:
     80    case PlatformWheelEventPhase::Changed:
     81    case PlatformWheelEventPhase::Stationary:
     82    case PlatformWheelEventPhase::None:
    8383        break;
    8484    }
    8585
    8686    switch (event.momentumPhase()) {
    87     case PlatformWheelEventPhaseMayBegin:
    88     case PlatformWheelEventPhaseCancelled:
     87    case PlatformWheelEventPhase::MayBegin:
     88    case PlatformWheelEventPhase::Cancelled:
    8989        ASSERT_NOT_REACHED();
    9090        break;
    91     case PlatformWheelEventPhaseBegan:
     91    case PlatformWheelEventPhase::Began:
    9292        m_activeNodeID = nodeID;
    9393        m_scrollingTree.handleWheelEventPhase(nodeID, event.momentumPhase());
    9494        break;
    95     case PlatformWheelEventPhaseEnded:
     95    case PlatformWheelEventPhase::Ended:
    9696        if (m_activeNodeID)
    9797            m_scrollingTree.handleWheelEventPhase(*m_activeNodeID, event.momentumPhase());
    9898        break;
    99     case PlatformWheelEventPhaseChanged:
    100     case PlatformWheelEventPhaseStationary:
    101     case PlatformWheelEventPhaseNone:
     99    case PlatformWheelEventPhase::Changed:
     100    case PlatformWheelEventPhase::Stationary:
     101    case PlatformWheelEventPhase::None:
    102102        break;
    103103    }
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

    r269559 r269659  
    141141
    142142    // MayBegin is used to flash scrollbars; if this node is scrollable, it can handle it.
    143     if (wheelEvent.phase() == PlatformWheelEventPhaseMayBegin)
     143    if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin)
    144144        return true;
    145145
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm

    r269559 r269659  
    125125    bool wasInMomentumPhase = m_inMomentumPhase;
    126126
    127     if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseBegan)
     127    if (wheelEvent.momentumPhase() == PlatformWheelEventPhase::Began)
    128128        m_inMomentumPhase = true;
    129     else if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded || wheelEvent.momentumPhase() == PlatformWheelEventPhaseCancelled)
     129    else if (wheelEvent.momentumPhase() == PlatformWheelEventPhase::Ended || wheelEvent.momentumPhase() == PlatformWheelEventPhase::Cancelled)
    130130        m_inMomentumPhase = false;
    131131   
     
    146146        scrollingNode().setUserScrollInProgress(isInUserScroll);
    147147
    148     // PlatformWheelEventPhaseMayBegin fires when two fingers touch the trackpad, and is used to flash overlay scrollbars.
     148    // PlatformWheelEventPhase::MayBegin fires when two fingers touch the trackpad, and is used to flash overlay scrollbars.
    149149    // We know we're scrollable at this point, so handle the event.
    150     if (wheelEvent.phase() == PlatformWheelEventPhaseMayBegin)
     150    if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin)
    151151        return true;
    152152
  • trunk/Source/WebCore/platform/PlatformWheelEvent.cpp

    r268417 r269659  
    3636{
    3737    switch (phase) {
    38     case PlatformWheelEventPhaseNone: ts << "none"; break;
    39     case PlatformWheelEventPhaseBegan: ts << "began"; break;
    40     case PlatformWheelEventPhaseStationary: ts << "stationary"; break;
    41     case PlatformWheelEventPhaseChanged: ts << "changed"; break;
    42     case PlatformWheelEventPhaseEnded: ts << "ended"; break;
    43     case PlatformWheelEventPhaseCancelled: ts << "cancelled"; break;
    44     case PlatformWheelEventPhaseMayBegin: ts << "mayBegin"; break;
     38    case PlatformWheelEventPhase::None: ts << "none"; break;
     39    case PlatformWheelEventPhase::Began: ts << "began"; break;
     40    case PlatformWheelEventPhase::Stationary: ts << "stationary"; break;
     41    case PlatformWheelEventPhase::Changed: ts << "changed"; break;
     42    case PlatformWheelEventPhase::Ended: ts << "ended"; break;
     43    case PlatformWheelEventPhase::Cancelled: ts << "cancelled"; break;
     44    case PlatformWheelEventPhase::MayBegin: ts << "mayBegin"; break;
    4545    }
    4646    return ts;
  • trunk/Source/WebCore/platform/PlatformWheelEvent.h

    r269143 r269659  
    5757#if ENABLE(KINETIC_SCROLLING)
    5858
    59 enum PlatformWheelEventPhase : uint8_t {
    60     PlatformWheelEventPhaseNone = 0,
    61     PlatformWheelEventPhaseBegan = 1 << 0,
    62     PlatformWheelEventPhaseStationary = 1 << 1,
    63     PlatformWheelEventPhaseChanged = 1 << 2,
    64     PlatformWheelEventPhaseEnded = 1 << 3,
    65     PlatformWheelEventPhaseCancelled = 1 << 4,
    66     PlatformWheelEventPhaseMayBegin = 1 << 5,
     59enum class PlatformWheelEventPhase : uint8_t {
     60    None        = 0,
     61    Began      = 1 << 0,
     62    Stationary = 1 << 1,
     63    Changed    = 1 << 2,
     64    Ended      = 1 << 3,
     65    Cancelled  = 1 << 4,
     66    MayBegin    = 1 << 5,
    6767};
    6868
     
    184184
    185185#if ENABLE(KINETIC_SCROLLING)
    186     PlatformWheelEventPhase m_phase { PlatformWheelEventPhaseNone };
    187     PlatformWheelEventPhase m_momentumPhase { PlatformWheelEventPhaseNone };
     186    PlatformWheelEventPhase m_phase { PlatformWheelEventPhase::None };
     187    PlatformWheelEventPhase m_momentumPhase { PlatformWheelEventPhase::None };
    188188#endif
    189189    bool m_hasPreciseScrollingDeltas { false };
     
    199199inline bool PlatformWheelEvent::useLatchedEventElement() const
    200200{
    201     return m_phase == PlatformWheelEventPhaseBegan
    202         || m_phase == PlatformWheelEventPhaseChanged
    203         || m_momentumPhase == PlatformWheelEventPhaseBegan
    204         || m_momentumPhase == PlatformWheelEventPhaseChanged
    205         || (m_phase == PlatformWheelEventPhaseEnded && m_momentumPhase == PlatformWheelEventPhaseNone);
     201    return m_phase == PlatformWheelEventPhase::Began
     202        || m_phase == PlatformWheelEventPhase::Changed
     203        || m_momentumPhase == PlatformWheelEventPhase::Began
     204        || m_momentumPhase == PlatformWheelEventPhase::Changed
     205        || (m_phase == PlatformWheelEventPhase::Ended && m_momentumPhase == PlatformWheelEventPhase::None);
    206206}
    207207
    208208inline bool PlatformWheelEvent::isGestureStart() const
    209209{
    210     return m_phase == PlatformWheelEventPhaseBegan || m_phase == PlatformWheelEventPhaseMayBegin;
     210    return m_phase == PlatformWheelEventPhase::Began || m_phase == PlatformWheelEventPhase::MayBegin;
    211211}
    212212
    213213inline bool PlatformWheelEvent::isGestureContinuation() const
    214214{
    215     return m_phase == PlatformWheelEventPhaseChanged;
     215    return m_phase == PlatformWheelEventPhase::Changed;
    216216}
    217217
    218218inline bool PlatformWheelEvent::shouldResetLatching() const
    219219{
    220     return m_phase == PlatformWheelEventPhaseCancelled || m_phase == PlatformWheelEventPhaseMayBegin || (m_phase == PlatformWheelEventPhaseNone && m_momentumPhase == PlatformWheelEventPhaseNone) || isEndOfMomentumScroll();
     220    return m_phase == PlatformWheelEventPhase::Cancelled || m_phase == PlatformWheelEventPhase::MayBegin || (m_phase == PlatformWheelEventPhase::None && m_momentumPhase == PlatformWheelEventPhase::None) || isEndOfMomentumScroll();
    221221}
    222222
    223223inline bool PlatformWheelEvent::isNonGestureEvent() const
    224224{
    225     return m_phase == PlatformWheelEventPhaseNone && m_momentumPhase == PlatformWheelEventPhaseNone;
     225    return m_phase == PlatformWheelEventPhase::None && m_momentumPhase == PlatformWheelEventPhase::None;
    226226}
    227227
    228228inline bool PlatformWheelEvent::isEndOfMomentumScroll() const
    229229{
    230     return m_phase == PlatformWheelEventPhaseNone && m_momentumPhase == PlatformWheelEventPhaseEnded;
     230    return m_phase == PlatformWheelEventPhase::None && m_momentumPhase == PlatformWheelEventPhase::Ended;
    231231}
    232232
     
    237237inline bool PlatformWheelEvent::isGestureBegin() const
    238238{
    239     return m_phase == PlatformWheelEventPhaseMayBegin
    240         || m_phase == PlatformWheelEventPhaseBegan;
     239    return m_phase == PlatformWheelEventPhase::MayBegin
     240        || m_phase == PlatformWheelEventPhase::Began;
    241241}
    242242
    243243inline bool PlatformWheelEvent::isGestureCancel() const
    244244{
    245     return m_phase == PlatformWheelEventPhaseCancelled;
     245    return m_phase == PlatformWheelEventPhase::Cancelled;
    246246}
    247247
    248248inline bool PlatformWheelEvent::isEndOfNonMomentumScroll() const
    249249{
    250     return m_phase == PlatformWheelEventPhaseEnded && m_momentumPhase == PlatformWheelEventPhaseNone;
     250    return m_phase == PlatformWheelEventPhase::Ended && m_momentumPhase == PlatformWheelEventPhase::None;
    251251}
    252252
    253253inline bool PlatformWheelEvent::isTransitioningToMomentumScroll() const
    254254{
    255     return m_phase == PlatformWheelEventPhaseNone && m_momentumPhase == PlatformWheelEventPhaseBegan;
     255    return m_phase == PlatformWheelEventPhase::None && m_momentumPhase == PlatformWheelEventPhase::Began;
    256256}
    257257
  • trunk/Source/WebCore/platform/ScrollAnimator.cpp

    r269559 r269659  
    147147#endif
    148148#if PLATFORM(COCOA)
    149     // Events in the PlatformWheelEventPhaseMayBegin phase have no deltas, and therefore never passes through the scroll handling logic below.
     149    // Events in the PlatformWheelEventPhase::MayBegin phase have no deltas, and therefore never passes through the scroll handling logic below.
    150150    // This causes us to return with an 'unhandled' return state, even though this event was successfully processed.
    151151    //
    152     // We receive at least one PlatformWheelEventPhaseMayBegin when starting main-thread scrolling (see FrameView::wheelEvent), which can
     152    // We receive at least one PlatformWheelEventPhase::MayBegin when starting main-thread scrolling (see FrameView::wheelEvent), which can
    153153    // fool the scrolling thread into attempting to handle the scroll, unless we treat the event as handled here.
    154     if (e.phase() == PlatformWheelEventPhaseMayBegin)
     154    if (e.phase() == PlatformWheelEventPhase::MayBegin)
    155155        return true;
    156156#endif
  • trunk/Source/WebCore/platform/cocoa/ScrollController.mm

    r269559 r269659  
    124124        return false; // FIXME: Why don't we report that we handled it?
    125125#endif
    126     if (wheelEvent.phase() == PlatformWheelEventPhaseMayBegin || wheelEvent.phase() == PlatformWheelEventPhaseCancelled)
     126    if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin || wheelEvent.phase() == PlatformWheelEventPhase::Cancelled)
    127127        return false;
    128128
    129     if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) {
     129    if (wheelEvent.phase() == PlatformWheelEventPhase::Began) {
    130130        // FIXME: Trying to decide if a gesture is horizontal or vertical at the "began" phase is very error-prone.
    131131        auto direction = directionFromEvent(wheelEvent, ScrollEventAxis::Horizontal);
     
    153153    }
    154154
    155     if (wheelEvent.phase() == PlatformWheelEventPhaseEnded) {
     155    if (wheelEvent.phase() == PlatformWheelEventPhase::Ended) {
    156156        snapRubberBand();
    157157        updateRubberBandingState();
     
    159159    }
    160160
    161     bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone);
     161    bool isMomentumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhase::None);
    162162    if (m_ignoreMomentumScrolls && (isMomentumScrollEvent || m_snapRubberbandTimer)) {
    163         if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded) {
     163        if (wheelEvent.momentumPhase() == PlatformWheelEventPhase::Ended) {
    164164            m_ignoreMomentumScrolls = false;
    165165            return true;
     
    208208
    209209    // If we are starting momentum scrolling then do some setup.
    210     if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhaseBegan || momentumPhase == PlatformWheelEventPhaseChanged))
     210    if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhase::Began || momentumPhase == PlatformWheelEventPhase::Changed))
    211211        m_momentumScrollInProgress = true;
    212212
     
    317317    }
    318318
    319     if (m_momentumScrollInProgress && momentumPhase == PlatformWheelEventPhaseEnded) {
     319    if (m_momentumScrollInProgress && momentumPhase == PlatformWheelEventPhase::Ended) {
    320320        m_momentumScrollInProgress = false;
    321321        m_ignoreMomentumScrolls = false;
     
    613613static inline WheelEventStatus toWheelEventStatus(PlatformWheelEventPhase phase, PlatformWheelEventPhase momentumPhase)
    614614{
    615     if (phase == PlatformWheelEventPhaseNone) {
     615    if (phase == PlatformWheelEventPhase::None) {
    616616        switch (momentumPhase) {
    617         case PlatformWheelEventPhaseBegan:
     617        case PlatformWheelEventPhase::Began:
    618618            return WheelEventStatus::MomentumScrollBegin;
    619619               
    620         case PlatformWheelEventPhaseChanged:
     620        case PlatformWheelEventPhase::Changed:
    621621            return WheelEventStatus::MomentumScrolling;
    622622               
    623         case PlatformWheelEventPhaseEnded:
     623        case PlatformWheelEventPhase::Ended:
    624624            return WheelEventStatus::MomentumScrollEnd;
    625625
    626         case PlatformWheelEventPhaseNone:
     626        case PlatformWheelEventPhase::None:
    627627            return WheelEventStatus::StatelessScrollEvent;
    628628
     
    631631        }
    632632    }
    633     if (momentumPhase == PlatformWheelEventPhaseNone) {
     633    if (momentumPhase == PlatformWheelEventPhase::None) {
    634634        switch (phase) {
    635         case PlatformWheelEventPhaseBegan:
    636         case PlatformWheelEventPhaseMayBegin:
     635        case PlatformWheelEventPhase::Began:
     636        case PlatformWheelEventPhase::MayBegin:
    637637            return WheelEventStatus::UserScrollBegin;
    638638               
    639         case PlatformWheelEventPhaseChanged:
     639        case PlatformWheelEventPhase::Changed:
    640640            return WheelEventStatus::UserScrolling;
    641641               
    642         case PlatformWheelEventPhaseEnded:
    643         case PlatformWheelEventPhaseCancelled:
     642        case PlatformWheelEventPhase::Ended:
     643        case PlatformWheelEventPhase::Cancelled:
    644644            return WheelEventStatus::UserScrollEnd;
    645645               
  • trunk/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm

    r260366 r269659  
    170170}
    171171
     172static PlatformWheelEventPhase phaseFromNSEventPhase(NSEventPhase eventPhase)
     173{
     174    switch (eventPhase) {
     175    case NSEventPhaseNone:
     176        return PlatformWheelEventPhase::None;
     177    case NSEventPhaseBegan:
     178        return PlatformWheelEventPhase::Began;
     179    case NSEventPhaseStationary:
     180        return PlatformWheelEventPhase::Stationary;
     181    case NSEventPhaseChanged:
     182        return PlatformWheelEventPhase::Changed;
     183    case NSEventPhaseEnded:
     184        return PlatformWheelEventPhase::Ended;
     185    case NSEventPhaseCancelled:
     186        return PlatformWheelEventPhase::Cancelled;
     187    case NSEventPhaseMayBegin:
     188        return PlatformWheelEventPhase::MayBegin;
     189    }
     190
     191    return PlatformWheelEventPhase::None;
     192}
     193
    172194static PlatformWheelEventPhase momentumPhaseForEvent(NSEvent *event)
    173195{
    174     uint32_t phase = PlatformWheelEventPhaseNone;
    175 
    176     if ([event momentumPhase] & NSEventPhaseBegan)
    177         phase |= PlatformWheelEventPhaseBegan;
    178     if ([event momentumPhase] & NSEventPhaseStationary)
    179         phase |= PlatformWheelEventPhaseStationary;
    180     if ([event momentumPhase] & NSEventPhaseChanged)
    181         phase |= PlatformWheelEventPhaseChanged;
    182     if ([event momentumPhase] & NSEventPhaseEnded)
    183         phase |= PlatformWheelEventPhaseEnded;
    184     if ([event momentumPhase] & NSEventPhaseCancelled)
    185         phase |= PlatformWheelEventPhaseCancelled;
    186 
    187     return static_cast<PlatformWheelEventPhase>(phase);
     196    return phaseFromNSEventPhase([event momentumPhase]);
    188197}
    189198
    190199static PlatformWheelEventPhase phaseForEvent(NSEvent *event)
    191200{
    192     uint32_t phase = PlatformWheelEventPhaseNone;
    193     if ([event phase] & NSEventPhaseBegan)
    194         phase |= PlatformWheelEventPhaseBegan;
    195     if ([event phase] & NSEventPhaseStationary)
    196         phase |= PlatformWheelEventPhaseStationary;
    197     if ([event phase] & NSEventPhaseChanged)
    198         phase |= PlatformWheelEventPhaseChanged;
    199     if ([event phase] & NSEventPhaseEnded)
    200         phase |= PlatformWheelEventPhaseEnded;
    201     if ([event phase] & NSEventPhaseCancelled)
    202         phase |= PlatformWheelEventPhaseCancelled;
    203     if ([event momentumPhase] & NSEventPhaseMayBegin)
    204         phase |= PlatformWheelEventPhaseMayBegin;
    205 
    206     return static_cast<PlatformWheelEventPhase>(phase);
     201    return phaseFromNSEventPhase([event phase]);
    207202}
    208203
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r269373 r269659  
    12471247    m_haveScrolledSincePageLoad = true;
    12481248
    1249 // FIXME: Need to ensure we get PlatformWheelEventPhaseEnded.
    1250     if (phase == PlatformWheelEventPhaseBegan)
     1249    // FIXME: Need to ensure we get PlatformWheelEventPhase::Ended.
     1250    if (phase == PlatformWheelEventPhase::Began)
    12511251        didBeginScrollGesture();
    1252     else if (phase == PlatformWheelEventPhaseEnded || phase == PlatformWheelEventPhaseCancelled)
     1252    else if (phase == PlatformWheelEventPhase::Ended || phase == PlatformWheelEventPhase::Cancelled)
    12531253        didEndScrollGesture();
    1254     else if (phase == PlatformWheelEventPhaseMayBegin)
     1254    else if (phase == PlatformWheelEventPhase::MayBegin)
    12551255        mayBeginScrollGesture();
    12561256}
     
    13291329static bool newGestureIsStarting(const PlatformWheelEvent& wheelEvent)
    13301330{
    1331     return wheelEvent.phase() == PlatformWheelEventPhaseMayBegin || wheelEvent.phase() == PlatformWheelEventPhaseBegan;
     1331    return wheelEvent.phase() == PlatformWheelEventPhase::MayBegin || wheelEvent.phase() == PlatformWheelEventPhase::Began;
    13321332}
    13331333
     
    13511351        return false;
    13521352   
    1353     if (wheelEvent.phase() != PlatformWheelEventPhaseEnded && !wheelEvent.isEndOfMomentumScroll())
     1353    if (wheelEvent.phase() != PlatformWheelEventPhase::Ended && !wheelEvent.isEndOfMomentumScroll())
    13541354        return false;
    13551355
  • trunk/Source/WebKit/ChangeLog

    r269657 r269659  
     12020-11-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make PlatformWheelEventPhase an enum class
     4        https://bugs.webkit.org/show_bug.cgi?id=218772
     5
     6        Reviewed by Tim Horton.
     7
     8        Change PlatformWheelEventPhase to be an enum class.
     9
     10        Changed code that maps between NSEventPhase and PlatformWheelEventPhase to not
     11        treat NSEventPhase as a set of bits, since it only ever contains one of the bits.
     12
     13        * UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm:
     14        (WebKit::ScrollerPairMac::handleWheelEvent):
     15        * WebProcess/WebPage/EventDispatcher.cpp:
     16        (WebKit::EventDispatcher::wheelEvent):
     17
    1182020-11-10  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollerPairMac.mm

    r260366 r269659  
    145145{
    146146    switch (event.phase()) {
    147     case WebCore::PlatformWheelEventPhaseBegan:
     147    case WebCore::PlatformWheelEventPhase::Began:
    148148        [m_scrollerImpPair beginScrollGesture];
    149149        break;
    150     case WebCore::PlatformWheelEventPhaseEnded:
    151     case WebCore::PlatformWheelEventPhaseCancelled:
     150    case WebCore::PlatformWheelEventPhase::Ended:
     151    case WebCore::PlatformWheelEventPhase::Cancelled:
    152152        [m_scrollerImpPair endScrollGesture];
    153153        break;
    154     case WebCore::PlatformWheelEventPhaseMayBegin:
     154    case WebCore::PlatformWheelEventPhase::MayBegin:
    155155        [m_scrollerImpPair beginScrollGesture];
    156156        [m_scrollerImpPair contentAreaScrolled];
  • trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp

    r268664 r269659  
    135135        // scrolling tree can be notified.
    136136        // We only need to do this at the beginning of the gesture.
    137         if (platformWheelEvent.phase() == PlatformWheelEventPhaseBegan)
     137        if (platformWheelEvent.phase() == PlatformWheelEventPhase::Began)
    138138            scrollingTree->setMainFrameCanRubberBand({ canRubberBandAtTop, canRubberBandAtRight, canRubberBandAtBottom, canRubberBandAtLeft });
    139139
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r269648 r269659  
     12020-11-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make PlatformWheelEventPhase an enum class
     4        https://bugs.webkit.org/show_bug.cgi?id=218772
     5
     6        Reviewed by Tim Horton.
     7
     8        Change PlatformWheelEventPhase to be an enum class.
     9
     10        Changed code that maps between NSEventPhase and PlatformWheelEventPhase to not
     11        treat NSEventPhase as a set of bits, since it only ever contains one of the bits.
     12
     13        * DOM/WebDOMOperations.mm:
     14        (toNSEventPhase):
     15
    1162020-11-10  Said Abou-Hallawa  <said@apple.com>
    217
  • trunk/Source/WebKitLegacy/mac/DOM/WebDOMOperations.mm

    r266295 r269659  
    252252static NSEventPhase toNSEventPhase(PlatformWheelEventPhase platformPhase)
    253253{
    254     uint32_t phase = PlatformWheelEventPhaseNone;
    255     if (platformPhase & PlatformWheelEventPhaseBegan)
    256         phase |= NSEventPhaseBegan;
    257     if (platformPhase & PlatformWheelEventPhaseStationary)
    258         phase |= NSEventPhaseStationary;
    259     if (platformPhase & PlatformWheelEventPhaseChanged)
    260         phase |= NSEventPhaseChanged;
    261     if (platformPhase & PlatformWheelEventPhaseEnded)
    262         phase |= NSEventPhaseEnded;
    263     if (platformPhase & PlatformWheelEventPhaseCancelled)
    264         phase |= NSEventPhaseCancelled;
    265     if (platformPhase & PlatformWheelEventPhaseMayBegin)
    266         phase |= NSEventPhaseMayBegin;
    267 
    268     return static_cast<NSEventPhase>(phase);
     254    switch (platformPhase) {
     255    case PlatformWheelEventPhase::None:
     256        return NSEventPhaseNone;
     257    case PlatformWheelEventPhase::Began:
     258        return NSEventPhaseBegan;
     259    case PlatformWheelEventPhase::Stationary:
     260        return NSEventPhaseStationary;
     261    case PlatformWheelEventPhase::Changed:
     262        return NSEventPhaseChanged;
     263    case PlatformWheelEventPhase::Ended:
     264        return NSEventPhaseEnded;
     265    case PlatformWheelEventPhase::Cancelled:
     266        return NSEventPhaseCancelled;
     267    case PlatformWheelEventPhase::MayBegin:
     268        return NSEventPhaseMayBegin;
     269    }
     270
     271    return NSEventPhaseNone;
    269272}
    270273
Note: See TracChangeset for help on using the changeset viewer.