diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 21:59:34 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-27 21:59:34 +0000 |
commit | c73df9dfae8ef94e2209564e30102a0862bd7580 (patch) | |
tree | 8be4e18edf1fe8ef3f534cb2455ebbb15cd6f505 /webkit | |
parent | fce166e2029e65921ef7b066529b71db3924128c (diff) | |
download | chromium_src-c73df9dfae8ef94e2209564e30102a0862bd7580.zip chromium_src-c73df9dfae8ef94e2209564e30102a0862bd7580.tar.gz chromium_src-c73df9dfae8ef94e2209564e30102a0862bd7580.tar.bz2 |
PrintPreview: Printing preview of a PDF on Mac with Skia only previews the last page of the PDF
BUG=93145
TEST=Please refer to bug report.
Review URL: http://codereview.chromium.org/7719014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103021 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 23 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 16 |
2 files changed, 22 insertions, 17 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 4ec22da..cee7108 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -851,10 +851,10 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area, if (!num_pages) return 0; current_print_settings_ = print_settings; -#if defined(OS_LINUX) || defined(OS_WIN) +#if defined(USE_SKIA) canvas_ = NULL; ranges_.clear(); -#endif // OS_LINUX || OS_WIN +#endif // USE_SKIA return num_pages; } @@ -862,14 +862,19 @@ bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) { DCHECK(plugin_print_interface_); PP_PrintPageNumberRange_Dev page_range; page_range.first_page_number = page_range.last_page_number = page_number; -#if defined(OS_LINUX) || defined(OS_WIN) +#if defined(USE_SKIA) // The canvas only has a metafile on it for print preview. - if (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas)) { + bool save_for_later = + (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); +#if defined(OS_MACOSX) || defined(OS_WIN) + save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); +#endif + if (save_for_later) { ranges_.push_back(page_range); canvas_ = canvas; return true; } else -#endif // OS_LINUX || OS_WIN +#endif // USE_SKIA { return PrintPageHelper(&page_range, 1, canvas); } @@ -901,12 +906,12 @@ bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, void PluginInstance::PrintEnd() { // Keep a reference on the stack. See NOTE above. scoped_refptr<PluginInstance> ref(this); -#if defined(OS_LINUX) || defined(OS_WIN) +#if defined(USE_SKIA) if (!ranges_.empty()) PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); canvas_ = NULL; ranges_.clear(); -#endif // OS_LINUX || OS_WIN +#endif // USE_SKIA DCHECK(plugin_print_interface_); if (plugin_print_interface_) @@ -1061,7 +1066,7 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, // (NativeMetafile and PreviewMetafile must have compatible formats, // i.e. both PDF for this to work). printing::Metafile* metafile = - printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas); + printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); DCHECK(metafile != NULL); if (metafile) ret = metafile->InitFromData(mapper.data(), mapper.size()); @@ -1086,7 +1091,7 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, } #elif defined(OS_WIN) printing::Metafile* metafile = - printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas); + printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); if (metafile) { // We only have a metafile when doing print preview, so we just want to // pass the PDF off to preview. diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index f46301b..fdb3dce 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -466,14 +466,14 @@ class PluginInstance : public base::RefCounted<PluginInstance>, // variable to hold on to the pixels. scoped_refptr<PPB_ImageData_Impl> last_printed_page_; #endif // defined(OS_MACOSX) -#if defined(OS_LINUX) || defined(OS_WIN) - // When printing to PDF (print preview, Linux) the entire document goes into - // one metafile. However, when users print only a subset of all the pages, - // it is impossible to know if a call to PrintPage() is the last call. - // Thus in PrintPage(), just store the page number in |ranges_|. - // The hack is in PrintEnd(), where a valid |canvas_| is preserved in - // PrintWebViewHelper::PrintPages. This makes it possible to generate the - // entire PDF given the variables below: +#if defined(USE_SKIA) + // Always when printing to PDF on Linux and when printing for preview on Mac + // and Win, the entire document goes into one metafile. However, when users + // print only a subset of all the pages, it is impossible to know if a call + // to PrintPage() is the last call. Thus in PrintPage(), just store the page + // number in |ranges_|. The hack is in PrintEnd(), where a valid |canvas_| + // is preserved in PrintWebViewHelper::PrintPages. This makes it possible + // to generate the entire PDF given the variables below: // // The most recently used WebCanvas, guaranteed to be valid. SkRefPtr<WebKit::WebCanvas> canvas_; |