diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 20:02:27 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-14 20:02:27 +0000 |
commit | 72f966bbd75a095ef73a121e16f5713172b51d09 (patch) | |
tree | 6f7404eb02a40fa2337d59a3d5a65b2fe4368d28 /printing/printed_document_mac.cc | |
parent | d5ceb91979a8f47ca1e7e22a608eeaa7db933a14 (diff) | |
download | chromium_src-72f966bbd75a095ef73a121e16f5713172b51d09.zip chromium_src-72f966bbd75a095ef73a121e16f5713172b51d09.tar.gz chromium_src-72f966bbd75a095ef73a121e16f5713172b51d09.tar.bz2 |
Enable the RenderViewTest printing tests on the Mac.
Migrates some test APIs from wstring path names to FilePath objects, and fixes some gcc compilation issues, to allow the tests to build on Mac.
Moves rendering logic and some other pdf logic into PdfMetafile to avoid duplication with unit test code. Switches rendering from the deprecated CGContextDrawPDFDocument to the newer (but less convenient) CGContextDrawPDFPage.
Added debugging helpers to PdfMetafile: SaveTo, matching the other platform metafiles, and context retain count checking to get early warning of issues that will cause printing failure.
BUG=24750
TEST=N/A
Review URL: http://codereview.chromium.org/274052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printed_document_mac.cc')
-rw-r--r-- | printing/printed_document_mac.cc | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/printing/printed_document_mac.cc b/printing/printed_document_mac.cc index ace57f3..e9bd044 100644 --- a/printing/printed_document_mac.cc +++ b/printing/printed_document_mac.cc @@ -24,28 +24,14 @@ void PrintedDocument::RenderPrintedPage( } #endif - const printing::NativeMetafile* metafile = page.native_metafile(); - unsigned int data_length = metafile->GetDataSize(); - scoped_cftyperef<CFMutableDataRef> pdf_data( - CFDataCreateMutable(kCFAllocatorDefault, data_length)); - CFDataIncreaseLength(pdf_data, data_length); - metafile->GetData(CFDataGetMutableBytePtr(pdf_data), data_length); - scoped_cftyperef<CGDataProviderRef> pdf_data_provider( - CGDataProviderCreateWithCFData(pdf_data)); - scoped_cftyperef<CGPDFDocumentRef> pdf_doc( - CGPDFDocumentCreateWithProvider(pdf_data_provider)); - if (!pdf_doc.get()) { - NOTREACHED() << "Unable to create PDF document from print data"; - return; - } - const printing::PageSetup& page_setup( immutable_.settings_.page_setup_pixels()); CGRect target_rect = page_setup.content_area().ToCGRect(); - // Each NativeMetafile is a one-page PDF. + const printing::NativeMetafile* metafile = page.native_metafile(); + // Each NativeMetafile is a one-page PDF, and pages use 1-based indexing. const int page_number = 1; - CGContextDrawPDFDocument(context, target_rect, pdf_doc, page_number); + metafile->RenderPage(page_number, context, target_rect); // TODO(stuartmorgan): Print the header and footer. } |