Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 43f0c7bee73462d78424d868f5f31ec04d8c4458
      
https://github.com/WebKit/WebKit/commit/43f0c7bee73462d78424d868f5f31ec04d8c4458
  Author: Wenson Hsieh <[email protected]>
  Date:   2023-05-12 (Fri, 12 May 2023)

  Changed paths:
    M Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/ios/GestureRecognizerTests.mm

  Log Message:
  -----------
  [iOS] Click events are triggered unexpectedly when scrolling in reflowable 
EPUBs in Books
https://bugs.webkit.org/show_bug.cgi?id=256682
rdar://108527387

Reviewed by Aditya Keerthi.

When reading certain types of EPUBs in the Books app, the app creates a 
`UIScrollView` *behind* the
web view, but then adds the built-in scroll view pan gesture from this scroll 
view to a container
view that's an ancestor of the web view. This means that panning over the 
(otherwise-unscrollable)
web view will scroll the `UIScrollView` behind it. Books then replays any 
scrolling that happens in
this hidden scroll view back to the web view, adjusting its offset.

This means that our current logic for avoiding synthetic clicks when stopping 
scroll deceleration —
which walks up the view hierarchy in search of a scroll view that 
`-_isInterruptingDeceleration` —
won't work since the relevant scroll view in question isn't even an ancestor of 
the web view.

To mitigate this case, we can avoid allowing simultaneous recognition with tap 
gestures when the
built-in scroll view pan gesture's view isn't even a scroll view to begin with.

* Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm:
(-[WKWebView _singleTapGestureRecognizer]):

Add a read-only testing hook to expose the synthetic tap gesture recognizer on 
the content view.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView 
gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):

Additionally constrain this to built-in scroll view pan gestures that are 
connected to an actual
scroll view.

(-[WKContentView singleTapGestureRecognizer]):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/ios/GestureRecognizerTests.mm: Added.

Add an API test that sets up the view hierarchy in the same way as in Books 
(for this specific type
of reflowable EPUB), and checks that click gestures can recognize 
simultaneously alongside the
`WKWebView`'s scroll view's pan gesture, but not a built-in scroll view pan 
gesture that has been
migrated out of `UIScrollView`.

Canonical link: https://commits.webkit.org/264009@main


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to