Title: [230496] trunk/Source/WebKit
- Revision
- 230496
- Author
- [email protected]
- Date
- 2018-04-10 15:26:45 -0700 (Tue, 10 Apr 2018)
Log Message
[iOS] WKPDFView should conform to _WKWebViewPrintProvider
https://bugs.webkit.org/show_bug.cgi?id=184471
Reviewed by Dan Bernstein.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _printProvider]):
The print provider will always be either _contentView or _customContentView, but
might not be _currentContentView.
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView _wk_pageCountForPrintFormatter:]):
Asked _hostViewController for the page count, clamped to 1 if
-[_WKWebViewPrintFormatter snapshotFirstPage] is YES.
(-[WKPDFView _wk_printedDocument]):
Created a CGPDFDocumentRef from _data and returned it.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (230495 => 230496)
--- trunk/Source/WebKit/ChangeLog 2018-04-10 22:16:27 UTC (rev 230495)
+++ trunk/Source/WebKit/ChangeLog 2018-04-10 22:26:45 UTC (rev 230496)
@@ -1,3 +1,26 @@
+2018-04-10 Andy Estes <[email protected]>
+
+ [iOS] WKPDFView should conform to _WKWebViewPrintProvider
+ https://bugs.webkit.org/show_bug.cgi?id=184471
+
+ Reviewed by Dan Bernstein.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _printProvider]):
+
+ The print provider will always be either _contentView or _customContentView, but
+ might not be _currentContentView.
+
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView _wk_pageCountForPrintFormatter:]):
+
+ Asked _hostViewController for the page count, clamped to 1 if
+ -[_WKWebViewPrintFormatter snapshotFirstPage] is YES.
+
+ (-[WKPDFView _wk_printedDocument]):
+
+ Created a CGPDFDocumentRef from _data and returned it.
+
2018-04-10 Youenn Fablet <[email protected]>
Beacon redirect responses should be CORS validated
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (230495 => 230496)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-04-10 22:16:27 UTC (rev 230495)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-04-10 22:26:45 UTC (rev 230496)
@@ -6462,9 +6462,9 @@
- (id <_WKWebViewPrintProvider>)_printProvider
{
- id contentView = self._currentContentView;
- if ([contentView conformsToProtocol:@protocol(_WKWebViewPrintProvider)])
- return contentView;
+ id printProvider = _customContentView ? _customContentView.get() : _contentView.get();
+ if ([printProvider conformsToProtocol:@protocol(_WKWebViewPrintProvider)])
+ return printProvider;
return nil;
}
Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm (230495 => 230496)
--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm 2018-04-10 22:16:27 UTC (rev 230495)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm 2018-04-10 22:26:45 UTC (rev 230496)
@@ -31,6 +31,7 @@
#import "WKWebViewInternal.h"
#import "WeakObjCPtr.h"
#import "WebPageProxy.h"
+#import "_WKWebViewPrintFormatterInternal.h"
#import <PDFKit/PDFHostViewController.h>
#import <wtf/MainThread.h>
#import <wtf/RetainPtr.h>
@@ -223,4 +224,31 @@
@end
+#pragma mark _WKWebViewPrintProvider
+
+#if !ENABLE(MINIMAL_SIMULATOR)
+
+@interface WKPDFView (_WKWebViewPrintFormatter) <_WKWebViewPrintProvider>
+@end
+
+@implementation WKPDFView (_WKWebViewPrintFormatter)
+
+- (NSUInteger)_wk_pageCountForPrintFormatter:(_WKWebViewPrintFormatter *)printFormatter
+{
+ NSUInteger pageCount = std::max<NSInteger>([_hostViewController pageCount], 0);
+ if (printFormatter.snapshotFirstPage)
+ return std::min<NSUInteger>(pageCount, 1);
+ return pageCount;
+}
+
+- (CGPDFDocumentRef)_wk_printedDocument
+{
+ auto dataProvider = adoptCF(CGDataProviderCreateWithCFData((CFDataRef)_data.get()));
+ return adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get())).autorelease();
+}
+
+@end
+
+#endif // !ENABLE(MINIMAL_SIMULATOR)
+
#endif // ENABLE(WKPDFVIEW)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes