- Revision
- 233966
- Author
- [email protected]
- Date
- 2018-07-18 19:00:41 -0700 (Wed, 18 Jul 2018)
Log Message
Cherry-pick r233905. rdar://problem/42345236
REGRESSION (iOS 12): Can't scroll to the bottom of the page in WKWebView while keyboard is up on pages with viewport-fit=cover
https://bugs.webkit.org/show_bug.cgi?id=187743
<rdar://problem/41651546>
Reviewed by Simon Fraser.
UIScrollView's _systemContentInset no longer includes keyboard insets
in apps linked on iOS 12+ when contentInsetAdjustmentBehavior is None.
We use contentInsetAdjustmentBehavior to control adjustment of other
sources of insets, but expect the keyboard inset to always be applied.
For now, barring a more comprehensive way to separate insets, re-add
the keyboard inset in cases where UIKit does not.
* Platform/spi/ios/UIKitSPI.h:
Move some IPI to the SPI header.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _haveSetObscuredInsets]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
Make it possible for WKScrollView to check whether the client is overriding insets.
* UIProcess/Cocoa/VersionChecks.h:
Add a linkedOnOrAfter() version for this new UIScrollView behavior.
* UIProcess/ios/WKScrollView.mm:
(-[WKScrollView initWithFrame:]):
Force WKScrollView's scroll indicator to always respect insets. We always
want the scroll bars in a sensible place, even if the page sets
viewport-fit=cover.
(-[WKScrollView _adjustForAutomaticKeyboardInfo:animated:lastAdjustment:]):
Store the bottom inset due to the keyboard.
(-[WKScrollView _systemContentInset]):
Add the bottom inset due to the keyboard to the systemContentInset
in all cases where UIKit does not. Also avoid adding it if the client takes
full control of the insets, because the only client that does (MobileSafari)
includes insets-due-to-keyboard in their custom insets.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233905 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-606-branch/Source/WebKit/ChangeLog (233965 => 233966)
--- branches/safari-606-branch/Source/WebKit/ChangeLog 2018-07-19 02:00:37 UTC (rev 233965)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog 2018-07-19 02:00:41 UTC (rev 233966)
@@ -1,5 +1,96 @@
2018-07-18 Babak Shafiei <[email protected]>
+ Cherry-pick r233905. rdar://problem/42345236
+
+ REGRESSION (iOS 12): Can't scroll to the bottom of the page in WKWebView while keyboard is up on pages with viewport-fit=cover
+ https://bugs.webkit.org/show_bug.cgi?id=187743
+ <rdar://problem/41651546>
+
+ Reviewed by Simon Fraser.
+
+ UIScrollView's _systemContentInset no longer includes keyboard insets
+ in apps linked on iOS 12+ when contentInsetAdjustmentBehavior is None.
+
+ We use contentInsetAdjustmentBehavior to control adjustment of other
+ sources of insets, but expect the keyboard inset to always be applied.
+
+ For now, barring a more comprehensive way to separate insets, re-add
+ the keyboard inset in cases where UIKit does not.
+
+ * Platform/spi/ios/UIKitSPI.h:
+ Move some IPI to the SPI header.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _haveSetObscuredInsets]):
+ * UIProcess/API/Cocoa/WKWebViewInternal.h:
+ Make it possible for WKScrollView to check whether the client is overriding insets.
+
+ * UIProcess/Cocoa/VersionChecks.h:
+ Add a linkedOnOrAfter() version for this new UIScrollView behavior.
+
+ * UIProcess/ios/WKScrollView.mm:
+ (-[WKScrollView initWithFrame:]):
+ Force WKScrollView's scroll indicator to always respect insets. We always
+ want the scroll bars in a sensible place, even if the page sets
+ viewport-fit=cover.
+
+ (-[WKScrollView _adjustForAutomaticKeyboardInfo:animated:lastAdjustment:]):
+ Store the bottom inset due to the keyboard.
+
+ (-[WKScrollView _systemContentInset]):
+ Add the bottom inset due to the keyboard to the systemContentInset
+ in all cases where UIKit does not. Also avoid adding it if the client takes
+ full control of the insets, because the only client that does (MobileSafari)
+ includes insets-due-to-keyboard in their custom insets.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233905 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2018-07-17 Tim Horton <[email protected]>
+
+ REGRESSION (iOS 12): Can't scroll to the bottom of the page in WKWebView while keyboard is up on pages with viewport-fit=cover
+ https://bugs.webkit.org/show_bug.cgi?id=187743
+ <rdar://problem/41651546>
+
+ Reviewed by Simon Fraser.
+
+ UIScrollView's _systemContentInset no longer includes keyboard insets
+ in apps linked on iOS 12+ when contentInsetAdjustmentBehavior is None.
+
+ We use contentInsetAdjustmentBehavior to control adjustment of other
+ sources of insets, but expect the keyboard inset to always be applied.
+
+ For now, barring a more comprehensive way to separate insets, re-add
+ the keyboard inset in cases where UIKit does not.
+
+ * Platform/spi/ios/UIKitSPI.h:
+ Move some IPI to the SPI header.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _haveSetObscuredInsets]):
+ * UIProcess/API/Cocoa/WKWebViewInternal.h:
+ Make it possible for WKScrollView to check whether the client is overriding insets.
+
+ * UIProcess/Cocoa/VersionChecks.h:
+ Add a linkedOnOrAfter() version for this new UIScrollView behavior.
+
+ * UIProcess/ios/WKScrollView.mm:
+ (-[WKScrollView initWithFrame:]):
+ Force WKScrollView's scroll indicator to always respect insets. We always
+ want the scroll bars in a sensible place, even if the page sets
+ viewport-fit=cover.
+
+ (-[WKScrollView _adjustForAutomaticKeyboardInfo:animated:lastAdjustment:]):
+ Store the bottom inset due to the keyboard.
+
+ (-[WKScrollView _systemContentInset]):
+ Add the bottom inset due to the keyboard to the systemContentInset
+ in all cases where UIKit does not. Also avoid adding it if the client takes
+ full control of the insets, because the only client that does (MobileSafari)
+ includes insets-due-to-keyboard in their custom insets.
+
+2018-07-18 Babak Shafiei <[email protected]>
+
Cherry-pick r233904. rdar://problem/42345140
RELEASE_ASSERT() under IPC::Connection::sendSync() from PluginProxy::supportsSnapshotting()
Modified: branches/safari-606-branch/Source/WebKit/Platform/spi/ios/UIKitSPI.h (233965 => 233966)
--- branches/safari-606-branch/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2018-07-19 02:00:37 UTC (rev 233965)
+++ branches/safari-606-branch/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2018-07-19 02:00:41 UTC (rev 233966)
@@ -315,6 +315,12 @@
@property (nonatomic, readonly, retain) FBSDisplayConfiguration *displayConfiguration;
@end
+typedef NS_ENUM(NSInteger, UIScrollViewIndicatorInsetAdjustmentBehavior) {
+ UIScrollViewIndicatorInsetAdjustmentAutomatic,
+ UIScrollViewIndicatorInsetAdjustmentAlways,
+ UIScrollViewIndicatorInsetAdjustmentNever
+};
+
@interface UIScrollView ()
- (void)_stopScrollingAndZoomingAnimations;
- (void)_zoomToCenter:(CGPoint)center scale:(CGFloat)scale duration:(CFTimeInterval)duration force:(BOOL)force;
@@ -326,6 +332,7 @@
@property (nonatomic) CGFloat verticalScrollDecelerationFactor;
@property (nonatomic, readonly) BOOL _isInterruptingDeceleration;
@property (nonatomic, getter=_contentScrollInset, setter=_setContentScrollInset:) UIEdgeInsets contentScrollInset;
+@property (nonatomic, getter=_indicatorInsetAdjustmentBehavior, setter=_setIndicatorInsetAdjustmentBehavior:) UIScrollViewIndicatorInsetAdjustmentBehavior indicatorInsetAdjustmentBehavior;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
@property (nonatomic, readonly) UIEdgeInsets _systemContentInset;
#endif
@@ -976,10 +983,18 @@
- (UIRectEdge)_edgesApplyingSafeAreaInsetsToContentInset;
@end
+@interface UIScrollView (IPI)
+- (CGFloat)_rubberBandOffsetForOffset:(CGFloat)newOffset maxOffset:(CGFloat)maxOffset minOffset:(CGFloat)minOffset range:(CGFloat)range outside:(BOOL *)outside;
+- (void)_adjustForAutomaticKeyboardInfo:(NSDictionary *)info animated:(BOOL)animated lastAdjustment:(CGFloat*)lastAdjustment;
+- (BOOL)_isScrollingToTop;
+- (CGPoint)_animatedTargetOffset;
+@end
+
@interface UIPeripheralHost (IPI)
- (void)_beginIgnoringReloadInputViews;
- (int)_endIgnoringReloadInputViews;
- (void)forceReloadInputViews;
+- (CGFloat)getVerticalOverlapForView:(UIView *)view usingKeyboardInfo:(NSDictionary *)info;
@end
#if __has_include(<UIKit/UITextInputMultiDocument.h>)
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (233965 => 233966)
--- branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-07-19 02:00:37 UTC (rev 233965)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-07-19 02:00:41 UTC (rev 233966)
@@ -154,16 +154,6 @@
#define RELEASE_LOG_IF_ALLOWED(...) RELEASE_LOG_IF(_page && _page->isAlwaysOnLoggingAllowed(), ViewState, __VA_ARGS__)
-@interface UIScrollView (UIScrollViewInternal)
-- (void)_adjustForAutomaticKeyboardInfo:(NSDictionary*)info animated:(BOOL)animated lastAdjustment:(CGFloat*)lastAdjustment;
-- (BOOL)_isScrollingToTop;
-- (CGPoint)_animatedTargetOffset;
-@end
-
-@interface UIPeripheralHost(UIKitInternal)
-- (CGFloat)getVerticalOverlapForView:(UIView *)view usingKeyboardInfo:(NSDictionary *)info;
-@end
-
@interface UIView (UIViewInternal)
- (UIViewController *)_viewControllerForAncestor;
@end
@@ -3176,6 +3166,11 @@
[uiDelegate _webView:self didChangeSafeAreaShouldAffectObscuredInsets:avoidsUnsafeArea];
}
+- (BOOL)_haveSetObscuredInsets
+{
+ return _haveSetObscuredInsets;
+}
+
#endif // PLATFORM(IOS)
#if ENABLE(ACCESSIBILITY_EVENTS)
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h (233965 => 233966)
--- branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2018-07-19 02:00:37 UTC (rev 233965)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2018-07-19 02:00:41 UTC (rev 233966)
@@ -147,6 +147,7 @@
@property (nonatomic, readonly) WKSelectionGranularity _selectionGranularity;
@property (nonatomic, readonly) BOOL _allowsDoubleTapGestures;
+@property (nonatomic, readonly) BOOL _haveSetObscuredInsets;
@property (nonatomic, readonly) UIEdgeInsets _computedObscuredInset;
@property (nonatomic, readonly) UIEdgeInsets _computedUnobscuredSafeAreaInset;
#endif
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/VersionChecks.h (233965 => 233966)
--- branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/VersionChecks.h 2018-07-19 02:00:37 UTC (rev 233965)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/VersionChecks.h 2018-07-19 02:00:41 UTC (rev 233966)
@@ -39,6 +39,7 @@
FirstThatDisallowsSettingAnyXHRHeaderFromFileURLs = DYLD_IOS_VERSION_11_3,
FirstThatDefaultsToPassiveTouchListenersOnDocument = DYLD_IOS_VERSION_11_3,
FirstWhereScrollViewContentInsetsAreNotObscuringInsets = DYLD_IOS_VERSION_12_0,
+ FirstWhereUIScrollViewDoesNotApplyKeyboardInsetsUnconditionally = DYLD_IOS_VERSION_12_0,
#elif PLATFORM(MAC)
FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_13,
Modified: branches/safari-606-branch/Source/WebKit/UIProcess/ios/WKScrollView.mm (233965 => 233966)
--- branches/safari-606-branch/Source/WebKit/UIProcess/ios/WKScrollView.mm 2018-07-19 02:00:37 UTC (rev 233965)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/ios/WKScrollView.mm 2018-07-19 02:00:41 UTC (rev 233966)
@@ -28,6 +28,8 @@
#if PLATFORM(IOS)
+#import "UIKitSPI.h"
+#import "VersionChecks.h"
#import "WKWebViewInternal.h"
#import <pal/spi/cg/CoreGraphicsSPI.h>
#import <wtf/WeakObjCPtr.h>
@@ -38,10 +40,6 @@
using namespace WebKit;
-@interface UIScrollView (UIScrollViewInternalHack)
-- (CGFloat)_rubberBandOffsetForOffset:(CGFloat)newOffset maxOffset:(CGFloat)maxOffset minOffset:(CGFloat)minOffset range:(CGFloat)range outside:(BOOL *)outside;
-@end
-
@interface WKScrollViewDelegateForwarder : NSObject <UIScrollViewDelegate>
- (instancetype)initWithInternalDelegate:(WKWebView *)internalDelegate externalDelegate:(id <UIScrollViewDelegate>)externalDelegate;
@@ -133,6 +131,7 @@
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
BOOL _contentInsetAdjustmentBehaviorWasExternallyOverridden;
#endif
+ CGFloat _keyboardBottomInsetAdjustment;
}
- (id)initWithFrame:(CGRect)frame
@@ -144,6 +143,7 @@
self.alwaysBounceVertical = YES;
self.directionalLockEnabled = YES;
+ [self _setIndicatorInsetAdjustmentBehavior:UIScrollViewIndicatorInsetAdjustmentAlways];
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
_contentInsetAdjustmentBehaviorWasExternallyOverridden = (self.contentInsetAdjustmentBehavior != UIScrollViewContentInsetAdjustmentAutomatic);
@@ -330,6 +330,32 @@
[self _restoreContentOffsetWithRubberbandAmount:rubberbandAmount];
}
+- (void)_adjustForAutomaticKeyboardInfo:(NSDictionary *)info animated:(BOOL)animated lastAdjustment:(CGFloat*)lastAdjustment
+{
+ [super _adjustForAutomaticKeyboardInfo:info animated:animated lastAdjustment:lastAdjustment];
+
+ _keyboardBottomInsetAdjustment = [[UIPeripheralHost sharedInstance] getVerticalOverlapForView:self usingKeyboardInfo:info];
+}
+
+- (UIEdgeInsets)_systemContentInset
+{
+ UIEdgeInsets systemContentInset = [super _systemContentInset];
+
+ // Internal clients who use setObscuredInsets include the keyboard height in their
+ // manually overriden insets, so we don't need to re-add it here.
+ if (_internalDelegate._haveSetObscuredInsets)
+ return systemContentInset;
+
+ // Match the inverse of the condition that UIScrollView uses to decide whether
+ // to include keyboard insets in the systemContentInset. We always want
+ // keyboard insets applied, even when web content has chosen to disable automatic
+ // safe area inset adjustment.
+ if (linkedOnOrAfter(SDKVersion::FirstWhereUIScrollViewDoesNotApplyKeyboardInsetsUnconditionally) && self.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentNever)
+ systemContentInset.bottom += _keyboardBottomInsetAdjustment;
+
+ return systemContentInset;
+}
+
#if PLATFORM(WATCHOS)
- (void)addGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer