Commit 5eb76db1 authored by Alan Screen's avatar Alan Screen Committed by Commit Bot

Uncouple PDF printing metafile usage from plugin

Printing from within the context of a pepper plugin for a Flash object
started crashing once the print composite usage stopped the inefficient
practice of generating metafiles for both individual pages and the full
document, in r751614.

Even though this issue of printing a Flash object is not of much
interest because of Flash being near end-of-life, we can at least not
crash the tab on users who happen to invoke such a print.

This restores ability of print preview to complete and provide page
images, although the content of the Flash object is empty.  This at
least matches the behavior prior to r751614.

Bug: 1098860
Change-Id: I86f7030ade0f126d6994b810f26775bf8cfe2693
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2298036Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789239}
parent 0700788a
......@@ -1956,18 +1956,22 @@ void PepperPluginInstanceImpl::PrintPage(int page_number,
#if BUILDFLAG(ENABLE_PRINTING)
DCHECK(plugin_print_interface_);
// |canvas| should always have an associated metafile.
auto* metafile = canvas->GetPrintingMetafile();
DCHECK(metafile);
// |ranges_| should be empty IFF |metafile_| is not set.
DCHECK_EQ(ranges_.empty(), !metafile_);
if (metafile_) {
// The metafile should be the same across all calls for a given print job.
DCHECK_EQ(metafile_, metafile);
} else {
// Store |metafile| on the first call.
metafile_ = metafile;
// When compositing to PDF output, the |canvas| metafile is not the
// document metafile, and cannot be used for getting the final PDF.
if (current_print_settings_.format != PP_PRINTOUTPUTFORMAT_PDF) {
// |canvas| should always have an associated metafile.
auto* metafile = canvas->GetPrintingMetafile();
DCHECK(metafile);
// |ranges_| should be empty IFF |metafile_| is not set.
DCHECK_EQ(ranges_.empty(), !metafile_);
if (metafile_) {
// The metafile should be the same across all calls for a given print job.
DCHECK_EQ(metafile_, metafile);
} else {
// Store |metafile| on the first call.
metafile_ = metafile;
}
}
PP_PrintPageNumberRange_Dev page_range = {page_number, page_number};
......@@ -1984,8 +1988,7 @@ void PepperPluginInstanceImpl::PrintEnd() {
PP_Resource print_output = plugin_print_interface_->PrintPages(
pp_instance(), ranges_.data(), ranges_.size());
if (print_output) {
if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF ||
current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER) {
if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER) {
PrintPDFOutput(print_output, metafile_);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment