diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 19:01:24 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 19:01:24 +0000 |
commit | b09f2e3b1f1c94d6698343cfef499f87715586f9 (patch) | |
tree | 3c652e290fda57a26a3dabc362a5b883c1d0c192 /webkit/plugins | |
parent | a82ade7b4f9dc2341c8848b94bfc1e0c92108cf3 (diff) | |
download | chromium_src-b09f2e3b1f1c94d6698343cfef499f87715586f9.zip chromium_src-b09f2e3b1f1c94d6698343cfef499f87715586f9.tar.gz chromium_src-b09f2e3b1f1c94d6698343cfef499f87715586f9.tar.bz2 |
Pass through PDFs from the plugin when using Skia on the Mac.
* Don't make a single PDF, the mac print workflow expects one pdf per page.
* It looks like the margin is getting applied twice, but that's another issue.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/7200040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91173 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 22 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 4 |
2 files changed, 10 insertions, 16 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 0e809c4..c166af0 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -69,8 +69,7 @@ #include "printing/metafile_impl.h" #endif -#if defined(OS_LINUX) || defined(OS_WIN) || \ - (defined(OS_MACOSX) && defined(USE_SKIA)) +#if defined(USE_SKIA) #include "printing/metafile.h" #include "printing/metafile_skia_wrapper.h" #endif @@ -903,10 +902,10 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area, if (!num_pages) return 0; current_print_settings_ = print_settings; -#if WEBKIT_USING_SKIA +#if defined(OS_LINUX) || defined(OS_WIN) canvas_ = NULL; ranges_.clear(); -#endif // WEBKIT_USING_SKIA +#endif // OS_LINUX || OS_WIN return num_pages; } @@ -914,14 +913,14 @@ bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) { DCHECK(plugin_print_interface_.get()); PP_PrintPageNumberRange_Dev page_range; page_range.first_page_number = page_range.last_page_number = page_number; -#if WEBKIT_USING_SKIA +#if defined(OS_LINUX) || defined(OS_WIN) // The canvas only has a metafile on it for print preview. if (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas)) { ranges_.push_back(page_range); canvas_ = canvas; return true; } else -#endif // WEBKIT_USING_SKIA +#endif // OS_LINUX || OS_WIN { return PrintPageHelper(&page_range, 1, canvas); } @@ -953,12 +952,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 WEBKIT_USING_SKIA +#if defined(OS_LINUX) || defined(OS_WIN) if (!ranges_.empty()) PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); canvas_ = NULL; ranges_.clear(); -#endif // WEBKIT_USING_SKIA +#endif // OS_LINUX || OS_WIN DCHECK(plugin_print_interface_.get()); if (plugin_print_interface_.get()) @@ -1073,7 +1072,7 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, #endif // defined(OS_WIN) bool ret = false; -#if defined(OS_LINUX) +#if defined(OS_LINUX) || (defined(OS_MACOSX) && defined(USE_SKIA)) // On Linux we just set the final bits in the native metafile // (NativeMetafile and PreviewMetafile must have compatible formats, // i.e. both PDF for this to work). @@ -1087,12 +1086,7 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, // Create a PDF metafile and render from there into the passed in context. if (metafile.InitFromData(mapper.data(), mapper.size())) { // Flip the transform. -#if defined(USE_SKIA) - gfx::SkiaBitLocker bit_locker(canvas); - CGContextRef cgContext = bit_locker.cgContext(); -#else CGContextRef cgContext = canvas; -#endif CGContextSaveGState(cgContext); CGContextTranslateCTM(cgContext, 0, current_print_settings_.printable_area.size.height); diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index 8cbcaa2..7a5487c 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -405,7 +405,7 @@ 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 WEBKIT_USING_SKIA +#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. @@ -418,7 +418,7 @@ class PluginInstance : public base::RefCounted<PluginInstance>, SkRefPtr<WebKit::WebCanvas> canvas_; // An array of page ranges. std::vector<PP_PrintPageNumberRange_Dev> ranges_; -#endif // WEBKIT_USING_SKIA +#endif // OS_LINUX || OS_WIN // The plugin print interface. This nested struct adds functions needed for // backwards compatibility. |