WebKit Bugzilla
Attachment 371786 Details for
Bug 198731
: [iOS] Use PDFKit SPI for taking snapshots when the hosting app is not entitled for global capture
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198731-20190610154049.patch (text/plain), 10.14 KB, created by
Andy Estes
on 2019-06-10 15:40:49 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Andy Estes
Created:
2019-06-10 15:40:49 PDT
Size:
10.14 KB
patch
obsolete
>Subversion Revision: 246240 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index a3d4c99696c5aa2e164199591da7039deeb895fb..4681d2362641d5b1a2f44b0faf35407213b455f7 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,13 @@ >+2019-06-10 Andy Estes <aestes@apple.com> >+ >+ [iOS] Use PDFKit SPI for taking snapshots when the hosting app is not entitled for global capture >+ https://bugs.webkit.org/show_bug.cgi?id=198731 >+ <rdar://problem/46215174> >+ >+ Reviewed by Tim Horton. >+ >+ * wtf/FeatureDefines.h: >+ > 2019-06-08 Andy Estes <aestes@apple.com> > > [Apple Pay] If we have a bound interface identifier, set it on new PKPaymentRequests >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index caffdadc064c5c777f7d8171ac8fb38000f48ad1..002ea5141eaf2c953e4ebe2c344a28718124d914 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,30 @@ >+2019-06-10 Andy Estes <aestes@apple.com> >+ >+ [iOS] Use PDFKit SPI for taking snapshots when the hosting app is not entitled for global capture >+ https://bugs.webkit.org/show_bug.cgi?id=198731 >+ <rdar://problem/46215174> >+ >+ Reviewed by Tim Horton. >+ >+ PDFHostViewController renders PDF contents in a view service, and apps are unable to >+ snapshot views rendered out-of-process without an entitlement. >+ >+ When an app is missing this entitlement and calls WKWebView's >+ takeSnapshotWithConfiguration: API when a PDF is displayed, fall back to calling >+ PDFHostViewController's snapshotting SPI. >+ >+ Testing is blocked by <https://webkit.org/b/175204>. >+ >+ * Platform/spi/ios/PDFKitSPI.h: >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]): >+ * UIProcess/Cocoa/WKWebViewContentProvider.h: >+ * UIProcess/ios/WKPDFView.mm: >+ (+[WKPDFView web_requiresCustomSnapshotting]): >+ (-[WKPDFView web_snapshotRectInContentViewCoordinates:snapshotWidth:completionHandler:]): >+ * UIProcess/ios/WKSystemPreviewView.mm: >+ (+[WKSystemPreviewView web_requiresCustomSnapshotting]): >+ > 2019-06-08 Dean Jackson <dino@apple.com> > > Drag starting state can get stuck even though the drag has ended >diff --git a/Source/WTF/wtf/FeatureDefines.h b/Source/WTF/wtf/FeatureDefines.h >index 4cd4df558cc27bda62b40ced373ae09b43544bf1..cd9c83ae56ee91ab5e8ea2b12578c9b1cfd5d370 100644 >--- a/Source/WTF/wtf/FeatureDefines.h >+++ b/Source/WTF/wtf/FeatureDefines.h >@@ -172,11 +172,17 @@ the public iOS SDK. See <https://webkit.org/b/179167>. */ > #endif > > #if !defined(ENABLE_WKPDFVIEW) >-#if PLATFORM(IOS_FAMILY) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) && !PLATFORM(IOSMAC) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000 >+#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) && !PLATFORM(IOSMAC) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000 > #define ENABLE_WKPDFVIEW 1 > #endif > #endif > >+#if !defined(HAVE_PDFHOSTVIEWCONTROLLER_SNAPSHOTTING) >+#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) && !PLATFORM(IOSMAC) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000 >+#define HAVE_PDFHOSTVIEWCONTROLLER_SNAPSHOTTING 1 >+#endif >+#endif >+ > #if !defined(HAVE_VISIBILITY_PROPAGATION_VIEW) > #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000 > #define HAVE_VISIBILITY_PROPAGATION_VIEW 1 >diff --git a/Source/WebKit/Platform/spi/ios/PDFKitSPI.h b/Source/WebKit/Platform/spi/ios/PDFKitSPI.h >index 93b0105685053e62af32d17e2f0e3ea071aa1327..fac63789ca3f05fcb3458a9a59d11178cac6c419 100644 >--- a/Source/WebKit/Platform/spi/ios/PDFKitSPI.h >+++ b/Source/WebKit/Platform/spi/ios/PDFKitSPI.h >@@ -57,6 +57,10 @@ > - (void) beginPDFViewRotation; > - (void) endPDFViewRotation; > >+#if HAVE(PDFHOSTVIEWCONTROLLER_SNAPSHOTTING) >+- (void) snapshotViewRect: (CGRect) rect snapshotWidth: (NSNumber*) width afterScreenUpdates: (BOOL) afterScreenUpdates withResult: (void (^)(UIImage* image)) completion; >+#endif >+ > @end > > #endif >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >index b2bf98f73edb30ee6f41935a89979aaeeedd0418..48ba322f97da7411b285149edb4362497a9a69c6 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >@@ -6188,6 +6188,11 @@ - (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)im > CGFloat imageHeight = imageScale * snapshotRectInContentCoordinates.size.height; > CGSize imageSize = CGSizeMake(imageWidth, imageHeight); > >+ if ([[_customContentView class] web_requiresCustomSnapshotting]) { >+ [_customContentView web_snapshotRectInContentViewCoordinates:snapshotRectInContentCoordinates snapshotWidth:imageWidth completionHandler:completionHandler]; >+ return; >+ } >+ > #if HAVE(CORE_ANIMATION_RENDER_SERVER) && HAVE(IOSURFACE) > // If we are parented and thus won't incur a significant penalty from paging in tiles, snapshot the view hierarchy directly. > if (NSString *displayName = self.window.screen.displayConfiguration.name) { >@@ -6206,6 +6211,7 @@ - (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)im > #endif > > if (_customContentView) { >+ ASSERT(![[_customContentView class] web_requiresCustomSnapshotting]); > UIGraphicsBeginImageContextWithOptions(imageSize, YES, 1); > > UIView *customContentView = _customContentView.get(); >diff --git a/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProvider.h b/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProvider.h >index 0a3b1c94e97632f6d43409ecd7c67b836f20cfd5..8d8a94273748219cf4737e9a17272ce6bccbee74 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProvider.h >+++ b/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProvider.h >@@ -52,6 +52,7 @@ struct UIEdgeInsets; > - (void)web_findString:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount; > - (void)web_hideFindUI; > @property (nonatomic, readonly) UIView *web_contentView; >+@property (nonatomic, readonly, class) BOOL web_requiresCustomSnapshotting; > > @optional > - (void)web_scrollViewDidScroll:(UIScrollView *)scrollView; >@@ -60,6 +61,7 @@ struct UIEdgeInsets; > - (void)web_scrollViewDidZoom:(UIScrollView *)scrollView; > - (void)web_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock; > - (BOOL)web_handleKeyEvent:(UIEvent *)event; >+- (void)web_snapshotRectInContentViewCoordinates:(CGRect)contentViewCoordinates snapshotWidth:(CGFloat)snapshotWidth completionHandler:(void (^)(CGImageRef))completionHandler; > @property (nonatomic, readonly) NSData *web_dataRepresentation; > @property (nonatomic, readonly) NSString *web_suggestedFilename; > @property (nonatomic, readonly) BOOL web_isBackground; >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index ca87bf3d2e6baf129c3f2191553d83551a7f8a16..25d40f766d628a302cace87faba71e6dda4a78b6 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -7565,9 +7565,11 @@ - (UIViewController *)_presentedViewControllerForPreviewItemController:(UIPrevie > if ([uiDelegate respondsToSelector:@selector(webView:previewingViewControllerForElement:defaultActions:)]) { > auto previewActions = adoptNS([[NSMutableArray alloc] init]); > for (_WKElementAction *elementAction in actions.get()) { >+ ALLOW_DEPRECATED_DECLARATIONS_BEGIN > WKPreviewAction *previewAction = [WKPreviewAction actionWithIdentifier:previewIdentifierForElementAction(elementAction) title:[elementAction title] style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *, UIViewController *) { > [elementAction runActionWithElementInfo:elementInfo.get()]; > }]; >+ ALLOW_DEPRECATED_DECLARATIONS_END > [previewActions addObject:previewAction]; > } > ALLOW_DEPRECATED_DECLARATIONS_BEGIN >diff --git a/Source/WebKit/UIProcess/ios/WKPDFView.mm b/Source/WebKit/UIProcess/ios/WKPDFView.mm >index 6c500fdad47d532103021f91b0df31b63cbade74..025701da65f513d64da198df05b0e4e4ba2f7567 100644 >--- a/Source/WebKit/UIProcess/ios/WKPDFView.mm >+++ b/Source/WebKit/UIProcess/ios/WKPDFView.mm >@@ -45,6 +45,7 @@ > #import <wtf/MainThread.h> > #import <wtf/RetainPtr.h> > #import <wtf/WeakObjCPtr.h> >+#import <wtf/cocoa/Entitlements.h> > #import <wtf/cocoa/NSURLExtras.h> > > @interface WKPDFView () <PDFHostViewControllerDelegate, WKActionSheetAssistantDelegate> >@@ -357,6 +358,16 @@ - (UIView *)web_contentView > return self._contentView; > } > >++ (BOOL)web_requiresCustomSnapshotting >+{ >+#if HAVE(PDFHOSTVIEWCONTROLLER_SNAPSHOTTING) >+ static bool hasGlobalCaptureEntitlement = WTF::processHasEntitlement("com.apple.QuartzCore.global-capture"); >+ return !hasGlobalCaptureEntitlement; >+#else >+ return false; >+#endif >+} >+ > - (void)web_scrollViewDidScroll:(UIScrollView *)scrollView > { > [_hostViewController updatePDFViewLayout]; >@@ -384,6 +395,16 @@ - (void)web_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock > [_hostViewController endPDFViewRotation]; > } > >+- (void)web_snapshotRectInContentViewCoordinates:(CGRect)rectInContentViewCoordinates snapshotWidth:(CGFloat)snapshotWidth completionHandler:(void (^)(CGImageRef))completionHandler >+{ >+#if HAVE(PDFHOSTVIEWCONTROLLER_SNAPSHOTTING) >+ CGRect rectInHostViewCoordinates = [self._contentView convertRect:rectInContentViewCoordinates toView:[_hostViewController view]]; >+ [_hostViewController snapshotViewRect:rectInHostViewCoordinates snapshotWidth:@(snapshotWidth) afterScreenUpdates:NO withResult:^(UIImage *image) { >+ completionHandler(image.CGImage); >+ }]; >+#endif >+} >+ > - (NSData *)web_dataRepresentation > { > return _data.get(); >diff --git a/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm b/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm >index ba2e6da011f37851c2126d7a40ec3b5547aabf9f..14f04b995bc97a6482f9b91ed1790d5321928035 100644 >--- a/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm >+++ b/Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm >@@ -144,6 +144,11 @@ - (UIView *)web_contentView > return self; > } > >++ (BOOL)web_requiresCustomSnapshotting >+{ >+ return false; >+} >+ > - (void)web_setMinimumSize:(CGSize)size > { > }
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 198731
:
371781
| 371786