Title: [231530] trunk/Source/WebKit
- Revision
- 231530
- Author
- [email protected]
- Date
- 2018-05-08 17:31:04 -0700 (Tue, 08 May 2018)
Log Message
[iOS] _WKWebViewPrintFormatter should return a page count of 0 for PDF documents that do not allow printing
https://bugs.webkit.org/show_bug.cgi?id=185133
Reviewed by Andreas Kling.
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView _ensureDocumentForPrinting]):
(-[WKPDFView _wk_pageCountForPrintFormatter:]):
(-[WKPDFView _wk_printedDocument]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (231529 => 231530)
--- trunk/Source/WebKit/ChangeLog 2018-05-09 00:20:18 UTC (rev 231529)
+++ trunk/Source/WebKit/ChangeLog 2018-05-09 00:31:04 UTC (rev 231530)
@@ -1,5 +1,17 @@
2018-05-08 Andy Estes <[email protected]>
+ [iOS] _WKWebViewPrintFormatter should return a page count of 0 for PDF documents that do not allow printing
+ https://bugs.webkit.org/show_bug.cgi?id=185133
+
+ Reviewed by Andreas Kling.
+
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView _ensureDocumentForPrinting]):
+ (-[WKPDFView _wk_pageCountForPrintFormatter:]):
+ (-[WKPDFView _wk_printedDocument]):
+
+2018-05-08 Andy Estes <[email protected]>
+
[iOS] WKPDFView remains in the view hierarchy after navigating away
https://bugs.webkit.org/show_bug.cgi?id=185449
<rdar://problem/39693469>
Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm (231529 => 231530)
--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm 2018-05-09 00:20:18 UTC (rev 231529)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm 2018-05-09 00:31:04 UTC (rev 231530)
@@ -47,6 +47,7 @@
@implementation WKPDFView {
RetainPtr<WKActionSheetAssistant> _actionSheetAssistant;
RetainPtr<NSData> _data;
+ RetainPtr<CGPDFDocumentRef> _documentForPrinting;
BlockPtr<void()> _findCompletion;
RetainPtr<NSString> _findString;
NSUInteger _findStringCount;
@@ -498,9 +499,27 @@
@implementation WKPDFView (_WKWebViewPrintFormatter)
+- (CGPDFDocumentRef)_ensureDocumentForPrinting
+{
+ if (_documentForPrinting)
+ return _documentForPrinting.get();
+
+ auto dataProvider = adoptCF(CGDataProviderCreateWithCFData((CFDataRef)_data.get()));
+ auto pdfDocument = adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get()));
+ if (!CGPDFDocumentIsUnlocked(pdfDocument.get()))
+ CGPDFDocumentUnlockWithPassword(pdfDocument.get(), [_password UTF8String]);
+
+ _documentForPrinting = WTFMove(pdfDocument);
+ return _documentForPrinting.get();
+}
+
- (NSUInteger)_wk_pageCountForPrintFormatter:(_WKWebViewPrintFormatter *)printFormatter
{
- NSUInteger pageCount = std::max<NSInteger>([_hostViewController pageCount], 0);
+ CGPDFDocumentRef documentForPrinting = [self _ensureDocumentForPrinting];
+ if (!CGPDFDocumentAllowsPrinting(documentForPrinting))
+ return 0;
+
+ size_t pageCount = CGPDFDocumentGetNumberOfPages(documentForPrinting);
if (printFormatter.snapshotFirstPage)
return std::min<NSUInteger>(pageCount, 1);
return pageCount;
@@ -508,11 +527,7 @@
- (CGPDFDocumentRef)_wk_printedDocument
{
- auto dataProvider = adoptCF(CGDataProviderCreateWithCFData((CFDataRef)_data.get()));
- auto pdfDocument = adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get()));
- if (!CGPDFDocumentIsUnlocked(pdfDocument.get()))
- CGPDFDocumentUnlockWithPassword(pdfDocument.get(), [_password UTF8String]);
- return pdfDocument.autorelease();
+ return [self _ensureDocumentForPrinting];
}
@end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes