From 72f966bbd75a095ef73a121e16f5713172b51d09 Mon Sep 17 00:00:00 2001 From: "stuartmorgan@chromium.org" Date: Wed, 14 Oct 2009 20:02:27 +0000 Subject: 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 --- printing/printed_document_mac.cc | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'printing/printed_document_mac.cc') 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 pdf_data( - CFDataCreateMutable(kCFAllocatorDefault, data_length)); - CFDataIncreaseLength(pdf_data, data_length); - metafile->GetData(CFDataGetMutableBytePtr(pdf_data), data_length); - scoped_cftyperef pdf_data_provider( - CGDataProviderCreateWithCFData(pdf_data)); - scoped_cftyperef 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. } -- cgit v1.1