WebKit Bugzilla
Attachment 348447 Details for
Bug 189114
: Long press on picture/link show menu obscured by keyboard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189114-20180829164621.patch (text/plain), 8.47 KB, created by
James Savage
on 2018-08-29 16:46:22 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
James Savage
Created:
2018-08-29 16:46:22 PDT
Size:
8.47 KB
patch
obsolete
>Subversion Revision: 235452 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index dc7c6c731c3bf075e5b37877668bf889c99c3e62..7bcb567ae3cf7b0ea04119d87c341ed4818fc49c 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,31 @@ >+2018-08-29 James Savage <james.savage@apple.com> >+ >+ Long press on picture/link show menu obscured by keyboard. >+ https://bugs.webkit.org/show_bug.cgi?id=189114. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Factor the visible bounds of the window into decisions about the presentation >+ style for WKActionSheet. This handles occlusion by the keyboard, other bars, >+ and other overlapping content, rather than assuming the popover will be free to >+ present from anywhere. >+ >+ Technically, we only need to account for overlapping geometry that also affects >+ popovers, but there isn't an easy way to get that information. This will result >+ in presentations favoring "from touch" somewhat more often than previously. >+ >+ * UIProcess/ios/WKActionSheetAssistant.h: Declare a new delegate method to ask >+ about occlusion geometry. >+ * UIProcess/ios/WKActionSheetAssistant.mm: >+ (-[WKActionSheetAssistant showImageSheet]): Use new delegate method. >+ (-[WKActionSheetAssistant showLinkSheet]): Ditto. >+ (presentationStyleForView): Replace window bounds with the new unoccluded rect >+ provided by delegate. If none was provided, fall-back to window bounds. >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView unoccludedWindowBoundsForActionSheetAssistant:]): >+ Calculate the unoccluded rect using -[UIScrollView adjustedContentInset], which >+ factors in client specified insets and system insets (such as the keyboard). >+ > 2018-08-28 Wenson Hsieh <wenson_hsieh@apple.com> > > Work towards: [iOS] Consolidate the implementations of readString, stringForType, and readURL in PlatformPasteboardIOS.mm >diff --git a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h >index 25677e8b1c6a82048f1c37bb60ce599ce16cfc71..78915f6a619e997a8a0e7ea0f6978191d11a1c98 100644 >--- a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h >+++ b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h >@@ -54,6 +54,7 @@ struct InteractionInformationAtPosition; > @optional > - (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant showCustomSheetForElement:(_WKActivatedElementInfo *)element; > - (void)updatePositionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant; >+- (CGRect)unoccludedWindowBoundsForActionSheetAssistant:(WKActionSheetAssistant *)assistant; > - (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant willStartInteractionWithElement:(_WKActivatedElementInfo *)element; > - (void)actionSheetAssistantDidStopInteraction:(WKActionSheetAssistant *)assistant; > - (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant; >diff --git a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm >index 6f748b4c1401781538f243a8726d810848e0f0fd..c6a4d5401b875625d4e6e79058a441a3fd843a62 100644 >--- a/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm >+++ b/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm >@@ -370,9 +370,13 @@ - (void)showImageSheet > if (!_interactionSheet) > return; > >+ CGRect visibleRect = CGRectNull; >+ if ([delegate respondsToSelector:@selector(unoccludedWindowBoundsForActionSheetAssistant:)]) >+ visibleRect = [delegate unoccludedWindowBoundsForActionSheetAssistant:self]; >+ > _elementInfo = WTFMove(elementInfo); > >- if (![_interactionSheet presentSheet:presentationStyleForView(_view.getAutoreleased(), _positionInformation.value(), _elementInfo.get())]) >+ if (![_interactionSheet presentSheet:presentationStyleForView(_view.getAutoreleased(), visibleRect, _positionInformation.value(), _elementInfo.get())]) > [self cleanupSheet]; > }; > >@@ -394,24 +398,29 @@ - (void)showImageSheet > showImageSheetWithAlternateURLBlock(nil, nil); > } > >-static WKActionSheetPresentationStyle presentationStyleForView(UIView *view, const WebKit::InteractionInformationAtPosition& positionInfo, _WKActivatedElementInfo *elementInfo) >+static WKActionSheetPresentationStyle presentationStyleForView(UIView *view, CGRect unoccludedWindowBounds, const WebKit::InteractionInformationAtPosition& positionInfo, _WKActivatedElementInfo *elementInfo) > { > auto apparentElementRect = [view convertRect:positionInfo.bounds toView:view.window]; > if (CGRectIsEmpty(apparentElementRect)) > return WKActionSheetPresentAtTouchLocation; > >- auto windowRect = view.window.bounds; >- apparentElementRect = CGRectIntersection(apparentElementRect, windowRect); >+ CGRect visibleRect; >+ if (!CGRectEqualToRect(CGRectNull, unoccludedWindowBounds)) >+ visibleRect = unoccludedWindowBounds; >+ else >+ visibleRect = view.window.bounds; > >- auto leftInset = CGRectGetMinX(apparentElementRect) - CGRectGetMinX(windowRect); >- auto topInset = CGRectGetMinY(apparentElementRect) - CGRectGetMinY(windowRect); >- auto rightInset = CGRectGetMaxX(windowRect) - CGRectGetMaxX(apparentElementRect); >- auto bottomInset = CGRectGetMaxY(windowRect) - CGRectGetMaxY(apparentElementRect); >+ apparentElementRect = CGRectIntersection(apparentElementRect, visibleRect); >+ >+ auto leftInset = CGRectGetMinX(apparentElementRect) - CGRectGetMinX(visibleRect); >+ auto topInset = CGRectGetMinY(apparentElementRect) - CGRectGetMinY(visibleRect); >+ auto rightInset = CGRectGetMaxX(visibleRect) - CGRectGetMaxX(apparentElementRect); >+ auto bottomInset = CGRectGetMaxY(visibleRect) - CGRectGetMaxY(apparentElementRect); > > // If at least this much of the window is available for the popover to draw in, then target the element rect when presenting the action menu popover. > // Otherwise, there is not enough space to position the popover around the element, so revert to using the touch location instead. > static const CGFloat minimumAvailableWidthOrHeightRatio = 0.4; >- if (std::max(leftInset, rightInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetWidth(windowRect) && std::max(topInset, bottomInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetHeight(windowRect)) >+ if (std::max(leftInset, rightInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetWidth(visibleRect) && std::max(topInset, bottomInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetHeight(visibleRect)) > return WKActionSheetPresentAtTouchLocation; > > if (elementInfo.type == _WKActivatedElementTypeLink && positionInfo.linkIndicator.textRectsInBoundingRectCoordinates.size()) >@@ -537,9 +546,13 @@ - (void)showLinkSheet > return; > } > >+ CGRect visibleRect = CGRectNull; >+ if ([delegate respondsToSelector:@selector(unoccludedWindowBoundsForActionSheetAssistant:)]) >+ visibleRect = [delegate unoccludedWindowBoundsForActionSheetAssistant:self]; >+ > _elementInfo = WTFMove(elementInfo); > >- if (![_interactionSheet presentSheet:presentationStyleForView(_view.getAutoreleased(), _positionInformation.value(), _elementInfo.get())]) >+ if (![_interactionSheet presentSheet:presentationStyleForView(_view.getAutoreleased(), visibleRect, _positionInformation.value(), _elementInfo.get())]) > [self cleanupSheet]; > } > >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 216e59c22fc0fb92c4141ba9cb7d222cb247ccc0..889e9a57c004d213c52746e8d7042e72483470f7 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -4817,6 +4817,15 @@ - (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant showCustomSheet > return NO; > } > >+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 >+- (CGRect)unoccludedWindowBoundsForActionSheetAssistant:(WKActionSheetAssistant *)assistant >+{ >+ UIEdgeInsets contentInset = [[_webView scrollView] adjustedContentInset]; >+ CGRect rect = UIEdgeInsetsInsetRect([_webView bounds], contentInset); >+ return [_webView convertRect:rect toView:[self window]]; >+} >+#endif >+ > - (RetainPtr<NSArray>)actionSheetAssistant:(WKActionSheetAssistant *)assistant decideActionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions > { > return _page->uiClient().actionsForElement(element, WTFMove(defaultActions));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189114
:
348447
|
348579