Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 26bb7484b4f6853b76ff5d3b2b843668f38ab019
https://github.com/WebKit/WebKit/commit/26bb7484b4f6853b76ff5d3b2b843668f38ab019
Author: Wenson Hsieh <[email protected]>
Date: 2024-08-05 (Mon, 05 Aug 2024)
Changed paths:
A LayoutTests/fast/forms/ios/dismiss-keyboard-after-tapping-expected.txt
A LayoutTests/fast/forms/ios/dismiss-keyboard-after-tapping.html
M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
M Source/WebKit/SourcesCocoa.txt
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
A Source/WebKit/UIProcess/ios/WKScrollViewTrackingTapGestureRecognizer.h
A Source/WebKit/UIProcess/ios/WKScrollViewTrackingTapGestureRecognizer.mm
M Source/WebKit/UIProcess/ios/WKSyntheticTapGestureRecognizer.h
M Source/WebKit/UIProcess/ios/WKSyntheticTapGestureRecognizer.mm
M Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M Source/WebKit/WebProcess/WebPage/WebPage.h
M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Log Message:
-----------
[iOS] Add an internal setting to allow the keyboard to dismiss after tapping
https://bugs.webkit.org/show_bug.cgi?id=277551
rdar://130552664
Reviewed by Aditya Keerthi.
Add an internal setting to make it possible to dismiss the keyboard by tapping
over the page,
regardless of whether the page prevents default on touch, mouse or click
events. See below for more
details.
Test: fast/forms/ios/dismiss-keyboard-after-tapping.html
* LayoutTests/fast/forms/ios/dismiss-keyboard-after-tapping-expected.txt: Added.
* LayoutTests/fast/forms/ios/dismiss-keyboard-after-tapping.html: Added.
Add a test case to verify that after focusing a text field with the new flag
enabled:
1. Tapping within the focused field does not dismiss the keyboard.
2. Tapping another text field keeps the keyboard up.
3. Tapping an empty part of the page that prevents `touchend`, `mousedown` and
`click` dismisses
the keyboard.
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _createAndConfigureDoubleTapGestureRecognizer]):
(-[WKContentView setUpInteraction]):
(-[WKContentView cleanUpInteraction]):
Add a new gesture, `_keyboardDismissalGestureRecognizer`, that's only enabled
when the new setting
is enabled, and whose only purpose is to drive keyboard dismissal. This is a
new gesture recognizer
because:
a. We should recognize a tap regardless of whether default was prevented, so
we can't key off of
the synthetic click gesture.
b. We should not recognize in the case where the user is double tapping the
page to zoom out (i.e.
single tap recognition should be delayed by double tap).
(-[WKContentView _removeDefaultGestureRecognizers]):
(-[WKContentView _addDefaultGestureRecognizers]):
(-[WKContentView
gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
(-[WKContentView gestureRecognizerShouldBegin:]):
Bail early from the keyboard dismissal gesture if any of the following are true:
1. The keyboard is not shown.
2. The tap is inside of the focused element.
3. A hidden contenteditable element has focus.
4. The tap gesture is used to stop momentum scrolling.
(-[WKContentView _keyboardDismissalGestureRecognized:]):
Asynchronously check if a tap at this location should result in keyboard
dismissal using
`shouldDismissKeyboardAfterTapAtPoint` (see below).
(-[WKContentView
deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
* Source/WebKit/UIProcess/ios/WKScrollViewTrackingTapGestureRecognizer.h:
Copied from Source/WebKit/UIProcess/ios/WKSyntheticTapGestureRecognizer.h.
* Source/WebKit/UIProcess/ios/WKScrollViewTrackingTapGestureRecognizer.mm:
Copied from Source/WebKit/UIProcess/ios/WKSyntheticTapGestureRecognizer.h.
(-[WKScrollViewTrackingTapGestureRecognizer reset]):
(-[WKScrollViewTrackingTapGestureRecognizer touchesBegan:withEvent:]):
Split out logic to keep track of the last touched scroll view out into a
separate class, which we
use for the new gesture recognizer. This allows us to check whether the
keyboard dismissal tap
gesture was recognized while momentum scrolling, in which case we don't allow
it to recognize.
* Source/WebKit/UIProcess/ios/WKSyntheticTapGestureRecognizer.h:
* Source/WebKit/UIProcess/ios/WKSyntheticTapGestureRecognizer.mm:
(-[WKSyntheticTapGestureRecognizer reset]):
(-[WKSyntheticTapGestureRecognizer touchesBegan:withEvent:]): Deleted.
(-[WKSyntheticTapGestureRecognizer lastTouchedScrollView]): Deleted.
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::shouldDismissKeyboardAfterTapAtPoint):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::shouldDismissKeyboardAfterTapAtPoint):
Only dismiss the keyboard if the tap is either:
- Over a very large element responding to click events, or
- Not over an element responding to click events.
This makes it likely that the user will be able to dismiss the keyboard by
tapping over blank areas
of the page, even if the page installs click handlers over a large container
element, while making
it unlikely that the keyboard would unintentionally dismiss when tapping (for
instance) a small,
text editing control to bold or italicize text.
Canonical link: https://commits.webkit.org/281844@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes