WebKit Bugzilla
Attachment 339115 Details for
Bug 185133
: [iOS] _WKWebViewPrintFormatter should return a page count of 0 for PDF documents that do not allow printing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185133-20180430093755.patch (text/plain), 3.07 KB, created by
Andy Estes
on 2018-04-30 09:37:55 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Andy Estes
Created:
2018-04-30 09:37:55 PDT
Size:
3.07 KB
patch
obsolete
>Subversion Revision: 231157 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index b45b9c8b7b0bf1893057b858c851d46fbe2c2b68..2fa35978a9319937711e2b3d31a8e0ab4b12a5d0 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,15 @@ >+2018-04-30 Andy Estes <aestes@apple.com> >+ >+ [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 NOBODY (OOPS!). >+ >+ * UIProcess/ios/WKPDFView.mm: >+ (-[WKPDFView _ensureDocumentForPrinting]): >+ (-[WKPDFView _wk_pageCountForPrintFormatter:]): >+ (-[WKPDFView _wk_printedDocument]): >+ > 2018-04-30 Andy Estes <aestes@apple.com> > > [iOS] Try to unlock PDF documents before printing them >diff --git a/Source/WebKit/UIProcess/ios/WKPDFView.mm b/Source/WebKit/UIProcess/ios/WKPDFView.mm >index 5cbe8ceaf664f287c636e9ecb14bd4b28653e27a..c46c719ee421ca9d5427fc33bf03d1d00522eb71 100644 >--- a/Source/WebKit/UIProcess/ios/WKPDFView.mm >+++ b/Source/WebKit/UIProcess/ios/WKPDFView.mm >@@ -47,6 +47,7 @@ @end > @implementation WKPDFView { > RetainPtr<WKActionSheetAssistant> _actionSheetAssistant; > RetainPtr<NSData> _data; >+ RetainPtr<CGPDFDocumentRef> _documentForPrinting; > BlockPtr<void()> _findCompletion; > RetainPtr<NSString> _findString; > NSUInteger _findStringCount; >@@ -493,9 +494,27 @@ @end > > @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; >@@ -503,11 +522,7 @@ - (NSUInteger)_wk_pageCountForPrintFormatter:(_WKWebViewPrintFormatter *)printFo > > - (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
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 185133
: 339115 |
339138