Title: [230231] trunk/Source/WebKit
- Revision
- 230231
- Author
- aes...@apple.com
- Date
- 2018-04-03 19:41:42 -0700 (Tue, 03 Apr 2018)
Log Message
[iOS] WKWebView shouldn't know about WKPDFView
https://bugs.webkit.org/show_bug.cgi?id=184283
Reviewed by Timothy Hatcher.
WKWebView shouldn't be checking if _customContentView is a particular kind of
class (e.g., WKPDFView). Instead, it should interact with the _customContentView
using the WKWebViewContentProvider protocol.
Reimplement -_isBackground, -_isDisplayingPDF, -_dataForDisplayedPDF, and
-_suggestedFilenameForDisplayedPDF using new WKWebViewContentProvider protocol
methods that WKPDFView implements.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _isBackground]):
(-[WKWebView _isDisplayingPDF]):
(-[WKWebView _dataForDisplayedPDF]):
(-[WKWebView _suggestedFilenameForDisplayedPDF]):
* UIProcess/Cocoa/WKWebViewContentProvider.h:
* UIProcess/ios/WKPDFView.h:
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView web_dataRepresentation]):
(-[WKPDFView web_suggestedFilename]):
(-[WKPDFView web_isBackground]):
(-[WKPDFView suggestedFilename]): Deleted.
(-[WKPDFView pdfDocument]): Deleted.
(-[WKPDFView isBackground]): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (230230 => 230231)
--- trunk/Source/WebKit/ChangeLog 2018-04-04 01:19:52 UTC (rev 230230)
+++ trunk/Source/WebKit/ChangeLog 2018-04-04 02:41:42 UTC (rev 230231)
@@ -1,3 +1,33 @@
+2018-04-03 Andy Estes <aes...@apple.com>
+
+ [iOS] WKWebView shouldn't know about WKPDFView
+ https://bugs.webkit.org/show_bug.cgi?id=184283
+
+ Reviewed by Timothy Hatcher.
+
+ WKWebView shouldn't be checking if _customContentView is a particular kind of
+ class (e.g., WKPDFView). Instead, it should interact with the _customContentView
+ using the WKWebViewContentProvider protocol.
+
+ Reimplement -_isBackground, -_isDisplayingPDF, -_dataForDisplayedPDF, and
+ -_suggestedFilenameForDisplayedPDF using new WKWebViewContentProvider protocol
+ methods that WKPDFView implements.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _isBackground]):
+ (-[WKWebView _isDisplayingPDF]):
+ (-[WKWebView _dataForDisplayedPDF]):
+ (-[WKWebView _suggestedFilenameForDisplayedPDF]):
+ * UIProcess/Cocoa/WKWebViewContentProvider.h:
+ * UIProcess/ios/WKPDFView.h:
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView web_dataRepresentation]):
+ (-[WKPDFView web_suggestedFilename]):
+ (-[WKPDFView web_isBackground]):
+ (-[WKPDFView suggestedFilename]): Deleted.
+ (-[WKPDFView pdfDocument]): Deleted.
+ (-[WKPDFView isBackground]): Deleted.
+
2018-04-03 Brent Fulgham <bfulg...@apple.com>
Guard against keychain/certificate access outside the network process
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (230230 => 230231)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-04-04 01:19:52 UTC (rev 230230)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-04-04 02:41:42 UTC (rev 230231)
@@ -97,6 +97,7 @@
#import <WebCore/IOSurface.h>
#import <WebCore/JSDOMBinding.h>
#import <WebCore/JSDOMExceptionHandling.h>
+#import <WebCore/MIMETypeRegistry.h>
#import <WebCore/PlatformScreen.h>
#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/SQLiteDatabaseTracker.h>
@@ -136,7 +137,6 @@
#import "UIKitSPI.h"
#import "VideoFullscreenManagerProxy.h"
#import "WKContentViewInteraction.h"
-#import "WKPDFView.h"
#import "WKPasswordView.h"
#import "WKScrollView.h"
#import "WKWebViewContentProviderRegistry.h"
@@ -1301,10 +1301,8 @@
- (BOOL)_isBackground
{
-#if ENABLE(WKPDFVIEW)
if ([self _isDisplayingPDF])
- return [(WKPDFView *)_customContentView isBackground];
-#endif
+ return [_customContentView web_isBackground];
return [_contentView isBackground];
}
@@ -5452,34 +5450,27 @@
- (BOOL)_isDisplayingPDF
{
-#if ENABLE(WKPDFVIEW)
- return [_customContentView isKindOfClass:[WKPDFView class]];
-#else
+ for (auto& mimeType : WebCore::MIMETypeRegistry::getPDFMIMETypes()) {
+ Class providerClass = [[_configuration _contentProviderRegistry] providerForMIMEType:mimeType];
+ if ([_customContentView isKindOfClass:providerClass])
+ return YES;
+ }
+
return NO;
-#endif
}
- (NSData *)_dataForDisplayedPDF
{
-#if ENABLE(WKPDFVIEW)
if (![self _isDisplayingPDF])
return nil;
- CGPDFDocumentRef pdfDocument = [(WKPDFView *)_customContentView pdfDocument];
- return [(NSData *)CGDataProviderCopyData(CGPDFDocumentGetDataProvider(pdfDocument)) autorelease];
-#else
- return nil;
-#endif
+ return [_customContentView web_dataRepresentation];
}
- (NSString *)_suggestedFilenameForDisplayedPDF
{
-#if ENABLE(WKPDFVIEW)
if (![self _isDisplayingPDF])
return nil;
- return [(WKPDFView *)_customContentView.get() suggestedFilename];
-#else
- return nil;
-#endif
+ return [_customContentView web_suggestedFilename];
}
- (_WKWebViewPrintFormatter *)_webViewPrintFormatter
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProvider.h (230230 => 230231)
--- trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProvider.h 2018-04-04 01:19:52 UTC (rev 230230)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProvider.h 2018-04-04 02:41:42 UTC (rev 230231)
@@ -55,6 +55,9 @@
@optional
- (void)web_scrollViewDidScroll:(UIScrollView *)scrollView;
+@property (nonatomic, readonly) NSData *web_dataRepresentation;
+@property (nonatomic, readonly) NSString *web_suggestedFilename;
+@property (nonatomic, readonly) BOOL web_isBackground;
@end
Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.h (230230 => 230231)
--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.h 2018-04-04 01:19:52 UTC (rev 230230)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.h 2018-04-04 02:41:42 UTC (rev 230231)
@@ -30,11 +30,6 @@
#import "WKWebViewContentProvider.h"
@interface WKPDFView : UIView <WKWebViewContentProvider, UIPDFPageViewDelegate, UIPDFAnnotationControllerDelegate, WKActionSheetAssistantDelegate>
-
-@property (nonatomic, readonly) NSString *suggestedFilename;
-@property (nonatomic, readonly) CGPDFDocumentRef pdfDocument;
-@property (nonatomic, readonly) BOOL isBackground;
-
@end
#endif // PLATFORM(IOS) && ENABLE(WKPDFVIEW)
Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm (230230 => 230231)
--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm 2018-04-04 01:19:52 UTC (rev 230230)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm 2018-04-04 02:41:42 UTC (rev 230231)
@@ -46,6 +46,7 @@
#import <WebCore/FloatRect.h>
#import <WebCore/LocalizedStrings.h>
#import <WebCore/WebCoreNSURLExtras.h>
+#import <pal/spi/cg/CoreGraphicsSPI.h>
#import <wtf/RetainPtr.h>
#import <wtf/Vector.h>
@@ -154,14 +155,14 @@
[super dealloc];
}
-- (NSString *)suggestedFilename
+- (NSString *)web_suggestedFilename
{
return _suggestedFilename.get();
}
-- (CGPDFDocumentRef)pdfDocument
+- (NSData *)web_dataRepresentation
{
- return _cgPDFDocument.get();
+ return [(NSData *)CGDataProviderCopyData(CGPDFDocumentGetDataProvider(_cgPDFDocument.get())) autorelease];
}
static void detachViewForPage(PDFPageInfo& page)
@@ -830,7 +831,7 @@
_applicationStateTracker = std::make_unique<ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationDidCreateWindowContext), @selector(_applicationDidFinishSnapshottingAfterEnteringBackground), @selector(_applicationWillEnterForeground));
}
-- (BOOL)isBackground
+- (BOOL)web_isBackground
{
if (!_applicationStateTracker)
return YES;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes