Diff
Modified: branches/safari-613.2.4.1-branch/LayoutTests/ChangeLog (292112 => 292113)
--- branches/safari-613.2.4.1-branch/LayoutTests/ChangeLog 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/LayoutTests/ChangeLog 2022-03-30 18:46:48 UTC (rev 292113)
@@ -2143,10 +2143,6 @@
2022-03-01 Russell Epstein <[email protected]>
- Revert r289282. rdar://problem/88876661
-
-2022-03-01 Russell Epstein <[email protected]>
-
Cherry-pick r290087. rdar://problem/88713302
Source/ThirdParty/ANGLE:
Added: branches/safari-613.2.4.1-branch/LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled-expected.txt (0 => 292113)
--- branches/safari-613.2.4.1-branch/LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled-expected.txt (rev 0)
+++ branches/safari-613.2.4.1-branch/LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled-expected.txt 2022-03-30 18:46:48 UTC (rev 292113)
@@ -0,0 +1,10 @@
+This test verifies that focusing an editable element causes us to scroll to reveal the selection, even if first responder keyboard avoidance is disabled on the web view's scroller. This test requires WebKitTestRunner.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.scrollingElement.scrollTop became different from 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-613.2.4.1-branch/LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled.html (0 => 292113)
--- branches/safari-613.2.4.1-branch/LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled.html (rev 0)
+++ branches/safari-613.2.4.1-branch/LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled.html 2022-03-30 18:46:48 UTC (rev 292113)
@@ -0,0 +1,34 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<script src=""
+<script src=""
+<script>
+jsTestIsAsync = true;
+
+addEventListener("load", async () => {
+ document.designMode = "on";
+ description("This test verifies that focusing an editable element causes us to scroll to reveal the selection, even if first responder keyboard avoidance is disabled on the web view's scroller. This test requires WebKitTestRunner.");
+
+ await UIHelper.setScrollViewKeyboardAvoidanceEnabled(false);
+ await UIHelper.setHardwareKeyboardAttached(false);
+ await UIHelper.activateAndWaitForInputSessionAt(160, innerHeight - 50);
+
+ shouldBecomeDifferent("document.scrollingElement.scrollTop", "0", () => {
+ document.getElementById("content").remove();
+ finishJSTest();
+ });
+});
+</script>
+</head>
+<body>
+<pre id="console"></pre>
+<div id="content" style="font-size: 24px;">
+ <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
+ <p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
+ <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
+ <p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
+</div>
+</body>
+</html>
\ No newline at end of file
Modified: branches/safari-613.2.4.1-branch/LayoutTests/resources/ui-helper.js (292112 => 292113)
--- branches/safari-613.2.4.1-branch/LayoutTests/resources/ui-helper.js 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/LayoutTests/resources/ui-helper.js 2022-03-30 18:46:48 UTC (rev 292113)
@@ -1157,6 +1157,14 @@
return new Promise(resolve => testRunner.runUIScript(`uiController.setViewScale(${scale})`, resolve));
}
+ static setScrollViewKeyboardAvoidanceEnabled(enabled)
+ {
+ if (!this.isWebKit2())
+ return Promise.resolve();
+
+ return new Promise(resolve => testRunner.runUIScript(`uiController.setScrollViewKeyboardAvoidanceEnabled(${enabled})`, resolve));
+ }
+
static resignFirstResponder()
{
if (!this.isWebKit2())
Modified: branches/safari-613.2.4.1-branch/Source/WebKit/ChangeLog (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Source/WebKit/ChangeLog 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Source/WebKit/ChangeLog 2022-03-30 18:46:48 UTC (rev 292113)
@@ -1938,10 +1938,6 @@
2022-03-01 Russell Epstein <[email protected]>
- Revert r289282. rdar://problem/88876661
-
-2022-03-01 Russell Epstein <[email protected]>
-
Cherry-pick r290066. rdar://problem/89072361
[macOS][WP] Add required syscall to sandbox
Modified: branches/safari-613.2.4.1-branch/Source/WebKit/Platform/spi/ios/UIKitSPI.h (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2022-03-30 18:46:48 UTC (rev 292113)
@@ -515,6 +515,7 @@
@property (nonatomic, readonly) UIEdgeInsets _systemContentInset;
@property (nonatomic, readonly) UIEdgeInsets _effectiveContentInset;
@property (nonatomic, getter=_allowsAsyncScrollEvent, setter=_setAllowsAsyncScrollEvent:) BOOL _allowsAsyncScrollEvent;
+@property (nonatomic, getter=_isFirstResponderKeyboardAvoidanceEnabled, setter=_setFirstResponderKeyboardAvoidanceEnabled:) BOOL firstResponderKeyboardAvoidanceEnabled;
@end
typedef NS_ENUM(NSUInteger, UIScrollPhase) {
Modified: branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2022-03-30 18:46:48 UTC (rev 292113)
@@ -2492,6 +2492,7 @@
- (void)_keyboardDidShow:(NSNotification *)notification
{
_page->setIsKeyboardAnimatingIn(false);
+ [_contentView _keyboardDidShow];
}
- (void)_keyboardWillHide:(NSNotification *)notification
Modified: branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/WebPageProxy.h (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/WebPageProxy.h 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/WebPageProxy.h 2022-03-30 18:46:48 UTC (rev 292113)
@@ -1619,6 +1619,7 @@
#if PLATFORM(IOS_FAMILY)
void setIsKeyboardAnimatingIn(bool isKeyboardAnimatingIn) { m_isKeyboardAnimatingIn = isKeyboardAnimatingIn; }
+ bool isKeyboardAnimatingIn() const { return m_isKeyboardAnimatingIn; }
void setWaitingForPostLayoutEditorStateUpdateAfterFocusingElement(bool waitingForPostLayoutEditorStateUpdateAfterFocusingElement) { m_waitingForPostLayoutEditorStateUpdateAfterFocusingElement = waitingForPostLayoutEditorStateUpdateAfterFocusingElement; }
bool waitingForPostLayoutEditorStateUpdateAfterFocusingElement() const { return m_waitingForPostLayoutEditorStateUpdateAfterFocusingElement; }
Modified: branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2022-03-30 18:46:48 UTC (rev 292113)
@@ -462,6 +462,7 @@
BOOL _isRelinquishingFirstResponderToFocusedElement;
BOOL _unsuppressSoftwareKeyboardAfterNextAutocorrectionContextUpdate;
BOOL _isUnsuppressingSoftwareKeyboardUsingLastAutocorrectionContext;
+ BOOL _shouldZoomToFocusRectAfterShowingKeyboard;
BOOL _focusRequiresStrongPasswordAssistance;
BOOL _waitingForEditDragSnapshot;
@@ -600,6 +601,8 @@
- (BOOL)_hasFocusedElement;
- (void)_zoomToRevealFocusedElement;
+- (void)_keyboardDidShow;
+
- (void)cancelPointersForGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer;
- (std::optional<unsigned>)activeTouchIdentifierForGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer;
Modified: branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2022-03-30 18:46:48 UTC (rev 292113)
@@ -1216,6 +1216,8 @@
_pointerInteraction = nil;
#endif
+ [self resetShouldZoomToFocusRectAfterShowingKeyboard];
+
#if HAVE(PENCILKIT_TEXT_INPUT)
[self cleanUpScribbleInteraction];
#endif
@@ -2344,6 +2346,22 @@
return boundingRect;
}
+- (void)_keyboardDidShow
+{
+ if (!_shouldZoomToFocusRectAfterShowingKeyboard)
+ return;
+
+ // FIXME: This deferred call to -_zoomToRevealFocusedElement works around the fact that Mail compose
+ // disables automatic content inset adjustment using the keyboard height, and instead has logic to
+ // explicitly set WKScrollView's contentScrollInset after receiving UIKeyboardDidShowNotification.
+ // This means that if we -_zoomToRevealFocusedElement immediately after focusing the body field in
+ // Mail, we won't take the keyboard height into account when scrolling.
+ // Mitigate this by deferring the call to -_zoomToRevealFocusedElement in this case until after the
+ // keyboard has finished animating. We can revert this once rdar://87733414 is fixed.
+ [self resetShouldZoomToFocusRectAfterShowingKeyboard];
+ [self performSelector:@selector(_zoomToRevealFocusedElement) withObject:nil afterDelay:0];
+}
+
- (void)_zoomToRevealFocusedElement
{
if (_focusedElementInformation.preventScroll)
@@ -2352,6 +2370,11 @@
if (_suppressSelectionAssistantReasons || _activeTextInteractionCount)
return;
+ if (!self._scroller.firstResponderKeyboardAvoidanceEnabled && _page->isKeyboardAnimatingIn()) {
+ _shouldZoomToFocusRectAfterShowingKeyboard = YES;
+ return;
+ }
+
// In case user scaling is force enabled, do not use that scaling when zooming in with an input field.
// Zooming above the page's default scale factor should only happen when the user performs it.
[self _zoomToFocusRect:_focusedElementInformation.interactionRect
@@ -2363,6 +2386,12 @@
forceScroll:[self requiresAccessoryView]];
}
+- (void)resetShouldZoomToFocusRectAfterShowingKeyboard
+{
+ _shouldZoomToFocusRectAfterShowingKeyboard = NO;
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_zoomToRevealFocusedElement) object:nil];
+}
+
- (UIView *)inputView
{
return [_webView inputView];
@@ -6579,6 +6608,8 @@
_focusRequiresStrongPasswordAssistance = NO;
_additionalContextForStrongPasswordAssistance = nil;
+ [self resetShouldZoomToFocusRectAfterShowingKeyboard];
+
// When defocusing an editable element reset a seen keydown before calling -_hideKeyboard so that we
// re-evaluate whether we still need a keyboard when UIKit calls us back in -_requiresKeyboardWhenFirstResponder.
if (editableChanged)
Modified: branches/safari-613.2.4.1-branch/Tools/ChangeLog (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Tools/ChangeLog 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Tools/ChangeLog 2022-03-30 18:46:48 UTC (rev 292113)
@@ -358,10 +358,6 @@
(verifyCertificateAndPublicKey):
(TestWebKitAPI::TEST):
-2022-03-01 Russell Epstein <[email protected]>
-
- Revert r289282. rdar://problem/88876661
-
2022-02-28 Russell Epstein <[email protected]>
Cherry-pick r289502. rdar://problem/88528286
Modified: branches/safari-613.2.4.1-branch/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl 2022-03-30 18:46:48 UTC (rev 292113)
@@ -285,6 +285,8 @@
undefined setMinimumEffectiveWidth(double effectiveWidth);
undefined setAllowsViewportShrinkToFit(boolean allows);
+ undefined setScrollViewKeyboardAvoidanceEnabled(boolean enabled);
+
undefined becomeFirstResponder();
undefined resignFirstResponder();
readonly attribute boolean isPresentingModally;
Modified: branches/safari-613.2.4.1-branch/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2022-03-30 18:46:48 UTC (rev 292113)
@@ -97,6 +97,8 @@
virtual void setMinimumEffectiveWidth(double) { notImplemented(); }
virtual void setAllowsViewportShrinkToFit(bool) { notImplemented(); }
+ virtual void setScrollViewKeyboardAvoidanceEnabled(bool) { notImplemented(); }
+
virtual std::optional<bool> stableStateOverride() const { notImplemented(); return std::nullopt; }
virtual void setStableStateOverride(std::optional<bool>) { notImplemented(); }
Modified: branches/safari-613.2.4.1-branch/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2022-03-30 18:46:48 UTC (rev 292113)
@@ -227,6 +227,7 @@
UIScrollView *scrollView = webView.scrollView;
[scrollView _removeAllAnimations:YES];
[scrollView setZoomScale:1 animated:NO];
+ scrollView.firstResponderKeyboardAvoidanceEnabled = YES;
auto currentContentInset = scrollView.contentInset;
auto contentInsetTop = options.contentInsetTop();
Modified: branches/safari-613.2.4.1-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h 2022-03-30 18:46:48 UTC (rev 292113)
@@ -146,6 +146,7 @@
void copyText(JSStringRef) override;
void installTapGestureOnWindow(JSValueRef) override;
void setSpellCheckerResults(JSValueRef) override { }
+ void setScrollViewKeyboardAvoidanceEnabled(bool) override;
bool mayContainEditableElementsInRect(unsigned x, unsigned y, unsigned width, unsigned height) override;
Modified: branches/safari-613.2.4.1-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (292112 => 292113)
--- branches/safari-613.2.4.1-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2022-03-30 18:44:17 UTC (rev 292112)
+++ branches/safari-613.2.4.1-branch/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2022-03-30 18:46:48 UTC (rev 292113)
@@ -1272,6 +1272,11 @@
webView()._allowsViewportShrinkToFit = allows;
}
+void UIScriptControllerIOS::setScrollViewKeyboardAvoidanceEnabled(bool enabled)
+{
+ webView().scrollView.firstResponderKeyboardAvoidanceEnabled = enabled;
+}
+
void UIScriptControllerIOS::doAfterDoubleTapDelay(JSValueRef callback)
{
unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);