WebKit Bugzilla
Attachment 339035 Details for
Bug 185093
: [iOS] Present an action sheet when long-pressing on PDF links
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185093-20180427155852.patch (text/plain), 6.85 KB, created by
Andy Estes
on 2018-04-27 15:58:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Andy Estes
Created:
2018-04-27 15:58:52 PDT
Size:
6.85 KB
patch
obsolete
>Subversion Revision: 231104 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 49488361e50599bfe3f6c914fe5c8b427fe77029..c6165ec1fd37354c30b4205ed15b7332e80ee22c 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,22 @@ >+2018-04-27 Andy Estes <aestes@apple.com> >+ >+ [iOS] Present an action sheet when long-pressing on PDF links >+ https://bugs.webkit.org/show_bug.cgi?id=185093 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UIProcess/ios/WKPDFView.mm: >+ (-[WKPDFView web_initWithFrame:webView:]): >+ (-[WKPDFView pdfHostViewController:goToURL:]): >+ (-[WKPDFView pdfHostViewController:didLongPressURL:atLocation:]): >+ (-[WKPDFView pdfHostViewController:didLongPressPageIndex:atLocation:]): >+ (-[WKPDFView positionInformationForActionSheetAssistant:]): >+ (-[WKPDFView actionSheetAssistant:performAction:]): >+ (-[WKPDFView actionSheetAssistant:openElementAtLocation:]): >+ (-[WKPDFView actionSheetAssistant:shareElementWithURL:rect:]): >+ (-[WKPDFView actionSheetAssistant:shouldIncludeAppLinkActionsForElement:]): >+ (-[WKPDFView actionSheetAssistant:decideActionsForElement:defaultActions:]): >+ > 2018-04-27 Daniel Bates <dabates@apple.com> > > UIDelegate::UIClient::didResignInputElementStrongPasswordAppearance() is applicable to both Mac and iOS >diff --git a/Source/WebKit/UIProcess/ios/WKPDFView.mm b/Source/WebKit/UIProcess/ios/WKPDFView.mm >index 0d60750bf1af48a5b0cdf8923a377b84539c9022..20088123b466e0913da8795b578968e06c65a097 100644 >--- a/Source/WebKit/UIProcess/ios/WKPDFView.mm >+++ b/Source/WebKit/UIProcess/ios/WKPDFView.mm >@@ -28,20 +28,24 @@ > > #if ENABLE(WKPDFVIEW) > >+#import "APIUIClient.h" > #import "FindClient.h" >+#import "WKActionSheetAssistant.h" > #import "WKWebViewInternal.h" > #import "WeakObjCPtr.h" > #import "WebPageProxy.h" > #import "_WKWebViewPrintFormatterInternal.h" > #import <PDFKit/PDFHostViewController.h> >+#import <WebCore/WebCoreNSURLExtras.h> > #import <wtf/BlockPtr.h> > #import <wtf/MainThread.h> > #import <wtf/RetainPtr.h> > >-@interface WKPDFView () <PDFHostViewControllerDelegate> >+@interface WKPDFView () <PDFHostViewControllerDelegate, WKActionSheetAssistantDelegate> > @end > > @implementation WKPDFView { >+ RetainPtr<WKActionSheetAssistant> _actionSheetAssistant; > RetainPtr<NSData> _data; > BlockPtr<void()> _findCompletion; > RetainPtr<NSString> _findString; >@@ -53,6 +57,7 @@ @implementation WKPDFView { > RetainPtr<PDFHostViewController> _hostViewController; > CGSize _overlaidAccessoryViewsInset; > RetainPtr<UIView> _pageNumberIndicator; >+ WebKit::InteractionInformationAtPosition _positionInformation; > RetainPtr<NSString> _suggestedFilename; > WebKit::WeakObjCPtr<WKWebView> _webView; > } >@@ -79,6 +84,9 @@ - (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView > self.backgroundColor = UIColor.grayColor; > webView.scrollView.backgroundColor = UIColor.grayColor; > >+ _actionSheetAssistant = adoptNS([[WKActionSheetAssistant alloc] initWithView:self]); >+ [_actionSheetAssistant setDelegate:self]; >+ > _webView = webView; > return self; > } >@@ -364,13 +372,13 @@ - (void)pdfHostViewController:(PDFHostViewController *)controller findStringUpda > > - (void)pdfHostViewController:(PDFHostViewController *)controller goToURL:(NSURL *)url > { >- WKWebView *webView = _webView.getAutoreleased(); >- if (!webView) >+ auto page = [_webView _page]; >+ if (!page) > return; > > // FIXME: We'd use the real tap location if we knew it. > WebCore::IntPoint point; >- webView->_page->navigateToPDFLinkWithSimulatedClick(url.absoluteString, point, point); >+ page->navigateToPDFLinkWithSimulatedClick(url.absoluteString, point, point); > } > > - (void)pdfHostViewController:(PDFHostViewController *)controller goToPageIndex:(NSInteger)pageIndex withViewFrustum:(CGRect)documentViewRect >@@ -385,6 +393,78 @@ - (void)pdfHostViewController:(PDFHostViewController *)controller goToPageIndex: > webView->_page->navigateToPDFLinkWithSimulatedClick(url.absoluteString, WebCore::roundedIntPoint(documentPoint), WebCore::roundedIntPoint(screenPoint)); > } > >+- (void)pdfHostViewController:(PDFHostViewController *)controller didLongPressURL:(NSURL *)url atLocation:(CGPoint)location >+{ >+ _positionInformation.url = url; >+ [_actionSheetAssistant showLinkSheet]; >+} >+ >+- (void)pdfHostViewController:(PDFHostViewController *)controller didLongPressPageIndex:(NSInteger)pageIndex atLocation:(CGPoint)location >+{ >+ WKWebView *webView = _webView.getAutoreleased(); >+ if (!webView) >+ return; >+ >+ _positionInformation.url = [NSURL URLWithString:[NSString stringWithFormat:@"#page%ld", (long)pageIndex + 1] relativeToURL:webView.URL]; >+ [_actionSheetAssistant showLinkSheet]; >+} >+ >+#pragma mark WKActionSheetAssistantDelegate >+ >+- (std::optional<WebKit::InteractionInformationAtPosition>)positionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant >+{ >+ return _positionInformation; >+} >+ >+- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant performAction:(WebKit::SheetAction)action >+{ >+ if (action != WebKit::SheetAction::Copy) >+ return; >+ >+ NSDictionary *representations = @{ >+ (NSString *)kUTTypeUTF8PlainText : (NSString *)_positionInformation.url, >+ (NSString *)kUTTypeURL : (NSURL *)_positionInformation.url, >+ }; >+ >+ [UIPasteboard generalPasteboard].items = @[ representations ]; >+} >+ >+- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant openElementAtLocation:(CGPoint)location >+{ >+ auto page = [_webView _page]; >+ if (!page) >+ return; >+ >+ CGPoint screenPoint = [self.window convertPoint:[self convertPoint:location toView:nil] toWindow:nil]; >+ page->navigateToPDFLinkWithSimulatedClick(_positionInformation.url, WebCore::roundedIntPoint(location), WebCore::roundedIntPoint(screenPoint)); >+} >+ >+- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant shareElementWithURL:(NSURL *)url rect:(CGRect)boundingRect >+{ >+ auto selectionAssistant = adoptNS([[UIWKSelectionAssistant alloc] initWithView:self]); >+ [selectionAssistant showShareSheetFor:WebCore::userVisibleString(url) fromRect:boundingRect]; >+} >+ >+#if HAVE(APP_LINKS) >+- (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element >+{ >+ auto page = [_webView _page]; >+ if (!page) >+ return NO; >+ >+ return page->uiClient().shouldIncludeAppLinkActionsForElement(element); >+} >+#endif >+ >+- (RetainPtr<NSArray>)actionSheetAssistant:(WKActionSheetAssistant *)assistant decideActionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions >+{ >+ auto page = [_webView _page]; >+ if (!page) >+ return nil; >+ >+ return page->uiClient().actionsForElement(element, WTFMove(defaultActions)); >+} >+ > @end > > #pragma mark _WKWebViewPrintProvider
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 185093
:
339035
|
339077
|
339082