⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259818 in webkit


Ignore:
Timestamp:
Apr 9, 2020, 1:11:24 PM (6 years ago)
Author:
Simon Fraser
Message:

Reset view navigation gesture state between tests
https://bugs.webkit.org/show_bug.cgi?id=210283

Reviewed by Tim Horton.

State in ViewGestureController could leak between tests if a test did not wait for the gesture to complete.
Specifically m_activeGestureType could be left as non-None.
Source/WebKit:

Fix by plumbing a 'reset' through from TestController::resetStateToConsistentValues().

The implementations leverage code from removeSwipeSnapshot(), but avoid the fact that removeSwipeSnapshot()
early returns in various cases by just always calling reset code, which is factored into a new resetState function.

  • UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
  • UIProcess/API/Cocoa/WKWebViewTesting.mm:

(-[WKWebView _resetNavigationGestureStateForTesting]):

  • UIProcess/ViewGestureController.cpp:

(WebKit::ViewGestureController::willBeginGesture):
(WebKit::ViewGestureController::didEndGesture):
(WebKit::ViewGestureController::PendingSwipeTracker::handleEvent):
(WebKit::ViewGestureController::PendingSwipeTracker::eventWasNotHandledByWebCore):

  • UIProcess/ViewGestureController.h:
  • UIProcess/ios/ViewGestureControllerIOS.mm:

(WebKit::ViewGestureController::removeSwipeSnapshot):
(WebKit::ViewGestureController::resetState):
(WebKit::ViewGestureController::reset):

  • UIProcess/mac/ViewGestureControllerMac.mm:

(WebKit::ViewGestureController::removeSwipeSnapshot):
(WebKit::ViewGestureController::resetState):
(WebKit::ViewGestureController::reset):

Tools:

Fix by plumbing a 'reset' through from TestController::resetStateToConsistentValues().

The implementations leverage code from removeSwipeSnapshot(), but avoid the fact that removeSwipeSnapshot()
early returns in various cases by just always calling reset code, which is factored into a new resetState function.

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::resetStateToConsistentValues):

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r259817 r259818  
     12020-04-09  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Reset view navigation gesture state between tests
     4        https://bugs.webkit.org/show_bug.cgi?id=210283
     5
     6        Reviewed by Tim Horton.
     7
     8        State in ViewGestureController could leak between tests if a test did not wait for the gesture to complete.
     9        Specifically m_activeGestureType could be left as non-None.
     10       
     11        Fix by plumbing a 'reset' through from TestController::resetStateToConsistentValues().
     12
     13        The implementations leverage code from removeSwipeSnapshot(), but avoid the fact that removeSwipeSnapshot()
     14        early returns in various cases by just always calling reset code, which is factored into a new resetState function.
     15
     16        * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
     17        * UIProcess/API/Cocoa/WKWebViewTesting.mm:
     18        (-[WKWebView _resetNavigationGestureStateForTesting]):
     19        * UIProcess/ViewGestureController.cpp:
     20        (WebKit::ViewGestureController::willBeginGesture):
     21        (WebKit::ViewGestureController::didEndGesture):
     22        (WebKit::ViewGestureController::PendingSwipeTracker::handleEvent):
     23        (WebKit::ViewGestureController::PendingSwipeTracker::eventWasNotHandledByWebCore):
     24        * UIProcess/ViewGestureController.h:
     25        * UIProcess/ios/ViewGestureControllerIOS.mm:
     26        (WebKit::ViewGestureController::removeSwipeSnapshot):
     27        (WebKit::ViewGestureController::resetState):
     28        (WebKit::ViewGestureController::reset):
     29        * UIProcess/mac/ViewGestureControllerMac.mm:
     30        (WebKit::ViewGestureController::removeSwipeSnapshot):
     31        (WebKit::ViewGestureController::resetState):
     32        (WebKit::ViewGestureController::reset):
     33
    1342020-04-09  Ryan Haddad  <ryanhaddad@apple.com>
    235
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h

    r259540 r259818  
    4646- (BOOL)_beginBackSwipeForTesting;
    4747- (BOOL)_completeBackSwipeForTesting;
     48- (void)_resetNavigationGestureStateForTesting;
    4849- (void)_setDefersLoadingForTesting:(BOOL)defersLoading;
    4950
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm

    r259540 r259818  
    144144}
    145145
     146- (void)_resetNavigationGestureStateForTesting
     147{
     148#if PLATFORM(MAC)
     149    if (auto gestureController = _impl->gestureController())
     150        gestureController->reset();
     151#else
     152    if (_gestureController)
     153        _gestureController->reset();
     154#endif
     155}
     156
    146157- (void)_setDefersLoadingForTesting:(BOOL)defersLoading
    147158{
  • trunk/Source/WebKit/UIProcess/ViewGestureController.cpp

    r254552 r259818  
    130130void ViewGestureController::willBeginGesture(ViewGestureType type)
    131131{
     132    LOG(ViewGestures, "ViewGestureController::willBeginGesture %d", (int)type);
     133
    132134    m_activeGestureType = type;
    133135    m_currentGestureID = takeNextGestureID();
     
    136138void ViewGestureController::didEndGesture()
    137139{
     140    LOG(ViewGestures, "ViewGestureController::didEndGesture");
     141
    138142    m_activeGestureType = ViewGestureType::None;
    139143    m_currentGestureID = 0;
     
    431435bool ViewGestureController::PendingSwipeTracker::handleEvent(PlatformScrollEvent event)
    432436{
     437    LOG(ViewGestures, "PendingSwipeTracker::handleEvent - state %d", (int)m_state);
     438
    433439    if (scrollEventCanEndSwipe(event)) {
    434440        reset("gesture ended");
     
    437443
    438444    if (m_state == State::None) {
     445        LOG(ViewGestures, "PendingSwipeTracker::handleEvent - scroll can become swipe %d shouldIgnorePinnedState %d, page will handle scrolls %d", scrollEventCanBecomeSwipe(event, m_direction), m_shouldIgnorePinnedState, m_webPageProxy.willHandleHorizontalScrollEvents());
     446
    439447        if (!scrollEventCanBecomeSwipe(event, m_direction))
    440448            return false;
     
    454462void ViewGestureController::PendingSwipeTracker::eventWasNotHandledByWebCore(PlatformScrollEvent event)
    455463{
     464    LOG(ViewGestures, "Swipe Start Hysteresis - WebCore didn't handle event, state %d", (int)m_state);
     465
    456466    if (m_state != State::WaitingForWebCore)
    457467        return;
    458468
    459     LOG(ViewGestures, "Swipe Start Hysteresis - WebCore didn't handle event");
    460469    m_state = State::None;
    461470    m_cumulativeDelta = FloatSize();
  • trunk/Source/WebKit/UIProcess/ViewGestureController.h

    r254552 r259818  
    163163
    164164    void removeSwipeSnapshot();
     165    void reset();
    165166
    166167    void setSwipeGestureEnabled(bool enabled) { m_swipeGestureEnabled = enabled; }
     
    185186    void willBeginGesture(ViewGestureType);
    186187    void didEndGesture();
     188    void resetState();
    187189
    188190    void didStartProvisionalOrSameDocumentLoadForMainFrame();
  • trunk/Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm

    r256933 r259818  
    419419    }
    420420
     421    resetState();
     422}
     423
     424void ViewGestureController::resetState()
     425{
    421426    [m_snapshotView removeFromSuperview];
    422427    m_snapshotView = nullptr;
     
    434439}
    435440
     441void ViewGestureController::reset()
     442{
     443    removeSwipeSnapshot();
     444    resetState();
     445}
     446
    436447bool ViewGestureController::beginSimulatedSwipeInDirectionForTesting(SwipeDirection direction)
    437448{
  • trunk/Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm

    r259085 r259818  
    610610    }
    611611
     612    resetState();
     613}
     614
     615void ViewGestureController::resetState()
     616{
    612617    if (m_currentSwipeSnapshot)
    613618        m_currentSwipeSnapshot->setVolatile(true);
     
    638643}
    639644
     645void ViewGestureController::reset()
     646{
     647    removeSwipeSnapshot();
     648    resetState();
     649    m_swipeCancellationTracker = nil; // FIXME: Move to reset state()?
     650}
     651
    640652double ViewGestureController::magnification() const
    641653{
  • trunk/Tools/ChangeLog

    r259815 r259818  
     12020-04-09  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Reset view navigation gesture state between tests
     4        https://bugs.webkit.org/show_bug.cgi?id=210283
     5
     6        Reviewed by Tim Horton.
     7
     8        State in ViewGestureController could leak between tests if a test did not wait for the gesture to complete.
     9        Specifically m_activeGestureType could be left as non-None.
     10
     11        Fix by plumbing a 'reset' through from TestController::resetStateToConsistentValues().
     12
     13        The implementations leverage code from removeSwipeSnapshot(), but avoid the fact that removeSwipeSnapshot()
     14        early returns in various cases by just always calling reset code, which is factored into a new resetState function.
     15
     16        * WebKitTestRunner/TestController.cpp:
     17        (WTR::TestController::resetStateToConsistentValues):
     18
    1192020-04-09  Aakash Jain  <aakash_jain@apple.com>
    220
  • trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

    r259516 r259818  
    278278        [platformView _setContinuousSpellCheckingEnabledForTesting:options.shouldShowSpellCheckingDots];
    279279        [platformView resetInteractionCallbacks];
     280        [platformView _resetNavigationGestureStateForTesting];
    280281    }
    281282
Note: See TracChangeset for help on using the changeset viewer.