Changeset 277352 in webkit
- Timestamp:
- May 11, 2021, 8:46:21 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (modified) (6 diffs)
-
Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r277351 r277352 1 2021-05-11 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Mail compose web view doesn't scroll to reveal the selection in certain configurations 4 https://bugs.webkit.org/show_bug.cgi?id=225675 5 rdar://77095886 6 7 Reviewed by Tim Horton. 8 9 Currently when computing input view bounds upon receiving `UIKeyboardDidChangeFrameNotification`, we attempt to 10 map the on-screen bounds of the keyboard to the window's coordinate space, and save the result in an ivar in 11 `WKWebView`, `_inputViewBounds`. The keyboard frame (which corresponds to `UIKeyboardFrameEndUserInfoKey` in the 12 notification's userInfo dictionary) is given to us in screen coordinates, and we currently pass this through 13 `-convertRect:fromWindow:`, with a nil `UIWindow`. 14 15 However, this results in mapping the rect from the coordinate space of the window's `UIWindowScene` rather than 16 the window screen. In shipping Mail on iOS, this doesn't matter because the window containing the compose web 17 view shares the same coordinate space as the screen. In some other configurations of MobileMail, however, the 18 compose web view appears inside its own `UIWindow`. This causes the above coordinate conversion logic to fail, 19 since we attempt to map a rect given to us in screen coordinates from the compose web view's window scene's 20 coordinate space, instead of the screen's coordinate space. 21 22 We fix this by using `-convertRect:fromCoordinateSpace:` instead, and explicitly pass in 23 `self.window.screen.coordinateSpace`. 24 25 * UIProcess/API/Cocoa/WKWebViewInternal.h: 26 * UIProcess/API/ios/WKWebViewIOS.mm: 27 (-[WKWebView _updateScrollViewForTransaction:]): 28 (-[WKWebView _zoomToFocusRect:selectionRect:fontSize:minimumScale:maximumScale:allowScaling:forceScroll:]): 29 (-[WKWebView _contentRectForUserInteraction]): 30 (-[WKWebView _updateVisibleContentRects]): 31 (-[WKWebView _keyboardChangedWithInfo:adjustScrollView:]): 32 33 Rename `_inputViewBounds` to `_inputViewBoundsInWindow` for clarity. 34 35 * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h: 36 * UIProcess/API/ios/WKWebViewTestingIOS.mm: 37 (-[WKWebView _inputViewBoundsInWindow]): 38 (-[WKWebView _inputViewBounds]): Deleted. 39 1 40 2021-05-11 Simon Fraser <simon.fraser@apple.com> 2 41 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
r276621 r277352 158 158 Optional<CGSize> _maximumUnobscuredSizeOverride; 159 159 Optional<WebCore::FloatSize> _lastSentMaximumUnobscuredSize; 160 CGRect _inputViewBounds ;160 CGRect _inputViewBoundsInWindow; 161 161 162 162 CGFloat _viewportMetaTagWidth; -
trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
r276780 r277352 808 808 [_scrollView _setZoomEnabledInternal:layerTreeTransaction.allowsUserScaling()]; 809 809 810 bool hasDockedInputView = !CGRectIsEmpty(_inputViewBounds );810 bool hasDockedInputView = !CGRectIsEmpty(_inputViewBoundsInWindow); 811 811 bool isZoomed = layerTreeTransaction.pageScaleFactor() > layerTreeTransaction.initialScaleFactor(); 812 812 … … 1243 1243 CGRect unobscuredScrollViewRectInWebViewCoordinates = UIEdgeInsetsInsetRect([self bounds], _obscuredInsets); 1244 1244 CGRect visibleScrollViewBoundsInWebViewCoordinates = CGRectIntersection(unobscuredScrollViewRectInWebViewCoordinates, [fullScreenView convertRect:[fullScreenView bounds] toView:self]); 1245 CGRect formAssistantFrameInWebViewCoordinates = [window convertRect:_inputViewBounds toView:self];1245 CGRect formAssistantFrameInWebViewCoordinates = [window convertRect:_inputViewBoundsInWindow toView:self]; 1246 1246 CGRect intersectionBetweenScrollViewAndFormAssistant = CGRectIntersection(visibleScrollViewBoundsInWebViewCoordinates, formAssistantFrameInWebViewCoordinates); 1247 1247 CGSize visibleSize = visibleScrollViewBoundsInWebViewCoordinates.size; … … 1882 1882 // FIXME: handle split keyboard. 1883 1883 UIEdgeInsets obscuredInsets = _obscuredInsets; 1884 obscuredInsets.bottom = std::max(_obscuredInsets.bottom, _inputViewBounds .size.height);1884 obscuredInsets.bottom = std::max(_obscuredInsets.bottom, _inputViewBoundsInWindow.size.height); 1885 1885 CGRect unobscuredRect = UIEdgeInsetsInsetRect(self.bounds, obscuredInsets); 1886 1886 return [self convertRect:unobscuredRect toView:self._currentContentView]; … … 2142 2142 obscuredInsets:_obscuredInsets 2143 2143 unobscuredSafeAreaInsets:[self _computedUnobscuredSafeAreaInset] 2144 inputViewBounds:_inputViewBounds 2144 inputViewBounds:_inputViewBoundsInWindow 2145 2145 scale:scaleFactor minimumScale:[_scrollView minimumZoomScale] 2146 2146 viewStability:viewStability … … 2299 2299 return; 2300 2300 2301 auto previousInputViewBounds = _inputViewBounds ;2301 auto previousInputViewBounds = _inputViewBoundsInWindow; 2302 2302 BOOL selectionWasVisible = self._selectionRectIsFullyVisibleAndNonEmpty; 2303 2303 2304 // The keyboard rect is always in screen coordinates. In the view services case the window does not 2305 // have the interface orientation rotation transformation; its host does. So, it makes no sense to 2306 // clip the keyboard rect against its screen. 2307 if ([[self window] _isHostedInAnotherProcess]) 2308 _inputViewBounds = [self.window convertRect:[endFrameValue CGRectValue] fromWindow:nil]; 2309 else 2310 _inputViewBounds = [self.window convertRect:CGRectIntersection([endFrameValue CGRectValue], self.window.screen.bounds) fromWindow:nil]; 2311 2312 if ([[UIPeripheralHost sharedInstance] isUndocked]) 2313 _inputViewBounds = CGRectZero; 2304 _inputViewBoundsInWindow = ([&] { 2305 if (UIPeripheralHost.sharedInstance.isUndocked) 2306 return CGRectZero; 2307 2308 auto keyboardFrameInScreen = endFrameValue.CGRectValue; 2309 // The keyboard rect is always in screen coordinates. In the view services case the window does not 2310 // have the interface orientation rotation transformation; its host does. So, it makes no sense to 2311 // clip the keyboard rect against its screen. 2312 if (!self.window._isHostedInAnotherProcess) 2313 keyboardFrameInScreen = CGRectIntersection(keyboardFrameInScreen, self.window.screen.bounds); 2314 2315 return [self.window convertRect:keyboardFrameInScreen fromCoordinateSpace:self.window.screen.coordinateSpace]; 2316 })(); 2314 2317 2315 2318 if (adjustScrollView) { … … 2325 2328 } 2326 2329 2327 if (selectionWasVisible && [_contentView _hasFocusedElement] && !CGRectIsEmpty(previousInputViewBounds) && !CGRectIsEmpty(_inputViewBounds ) && !CGRectEqualToRect(previousInputViewBounds, _inputViewBounds))2330 if (selectionWasVisible && [_contentView _hasFocusedElement] && !CGRectIsEmpty(previousInputViewBounds) && !CGRectIsEmpty(_inputViewBoundsInWindow) && !CGRectEqualToRect(previousInputViewBounds, _inputViewBoundsInWindow)) 2328 2331 [self _scrollToAndRevealSelectionIfNeeded]; 2329 2332 -
trunk/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h
r276853 r277352 40 40 @property (nonatomic, readonly) NSString *formInputLabel; 41 41 @property (nonatomic, readonly) NSArray<NSValue *> *_uiTextSelectionRects; 42 @property (nonatomic, readonly) CGRect _inputViewBounds ;42 @property (nonatomic, readonly) CGRect _inputViewBoundsInWindow; 43 43 @property (nonatomic, readonly) NSString *_scrollingTreeAsText; 44 44 @property (nonatomic, readonly) NSNumber *_stableStateOverride; -
trunk/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm
r276853 r277352 204 204 } 205 205 206 - (CGRect)_inputViewBounds 207 { 208 return _inputViewBounds ;206 - (CGRect)_inputViewBoundsInWindow 207 { 208 return _inputViewBoundsInWindow; 209 209 } 210 210 -
trunk/Tools/ChangeLog
r277348 r277352 1 2021-05-11 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Mail compose web view doesn't scroll to reveal the selection in certain configurations 4 https://bugs.webkit.org/show_bug.cgi?id=225675 5 rdar://77095886 6 7 Reviewed by Tim Horton. 8 9 Rename some testing SPI. See WebKit/ChangeLog for more information. 10 11 * WebKitTestRunner/ios/UIScriptControllerIOS.mm: 12 (WTR::UIScriptControllerIOS::inputViewBounds const): 13 1 14 2021-05-11 Commit Queue <commit-queue@webkit.org> 2 15 -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
r277265 r277352 850 850 JSObjectRef UIScriptControllerIOS::inputViewBounds() const 851 851 { 852 return JSValueToObject(m_context->jsContext(), [JSValue valueWithObject:toNSDictionary(webView()._inputViewBounds ) inContext:[JSContext contextWithJSGlobalContextRef:m_context->jsContext()]].JSValueRef, nullptr);852 return JSValueToObject(m_context->jsContext(), [JSValue valueWithObject:toNSDictionary(webView()._inputViewBoundsInWindow) inContext:[JSContext contextWithJSGlobalContextRef:m_context->jsContext()]].JSValueRef, nullptr); 853 853 } 854 854
Note:
See TracChangeset
for help on using the changeset viewer.