Bug 183648 - [iOS WK2] Hit-testing fails when specifying a large top content inset
Summary: [iOS WK2] Hit-testing fails when specifying a large top content inset
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
Keywords: InRadar
: 153439 (view as bug list)
Depends on:
Reported: 2018-03-14 16:54 PDT by Wenson Hsieh
Modified: 2019-08-21 17:09 PDT (History)
8 users (show)

See Also:

Patch (28.82 KB, patch)
2018-03-14 20:28 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2018-03-14 16:54:15 PDT
To reproduce:

- Make a WKWebView
- Set the WKWebView's scrollView's contentInset to something like UIEdgeInsetsMake(500, 0, 0, 0)
- Load a page with clickable elements, such as links or buttons
- Scroll so that the links or buttons are in view
- Try to tap on them

Expected: elements should be clicked
Observed: elements are not clicked

Tested on latest iOS 11.3 beta.
Comment 1 Wenson Hsieh 2018-03-14 18:09:48 PDT
WKWebView conflates obscured insets (which cover parts of the viewport) with content insets (which allow scrolling beyond content bounds in a scroll view).

This manifests in incorrect behavior when computing the unobscured content rect if the web view's scrollview has a top content inset, since we'll think that there's a region as tall as the content inset that obscures the viewport, when in fact, the viewport isn't obscured.

This causes all hit-testing in this region to fail because FrameView::visibleContentRect is wrong.
Comment 2 Wenson Hsieh 2018-03-14 18:18:49 PDT
It appears this bug has existed since the early days of WebKit2 (see: <http://trac.webkit.org/changeset/170361>).

It also seems others have also run into this before: https://stackoverflow.com/questions/27755251/wkwebview-isnt-clickable-outside-its-contentinset
Comment 3 Wenson Hsieh 2018-03-14 18:25:19 PDT
Comment 4 Wenson Hsieh 2018-03-14 20:28:37 PDT
Created attachment 335827 [details]
Comment 5 Wenson Hsieh 2018-03-15 13:24:54 PDT
Comment on attachment 335827 [details]

Thanks for the review!
Comment 6 WebKit Commit Bot 2018-03-15 13:50:08 PDT
Comment on attachment 335827 [details]

Clearing flags on attachment: 335827

Committed r229641: <https://trac.webkit.org/changeset/229641>
Comment 7 WebKit Commit Bot 2018-03-15 13:50:09 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 BJ Burg 2018-03-20 13:23:25 PDT
Comment 9 Brady Eidson 2019-08-21 17:09:48 PDT
*** Bug 153439 has been marked as a duplicate of this bug. ***