Commit 62e2df93 authored by Alan Screen's avatar Alan Screen Committed by Commit Bot

Revert "Uncouple PDF printing metafile usage from plugin"

This reverts commit 5eb76db1.

Reason for revert: regression as reported in crbug.com/1107297

Original change's description:
> 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/+/2298036
> Reviewed-by: Stefan Zager <szager@chromium.org>
> Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
> Commit-Queue: Alan Screen <awscreen@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#789239}

TBR=szager@chromium.org,awscreen@chromium.org,dhoss@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1098860
Change-Id: Ibe61026c24800742ee6810ca681243caa19976f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2306920
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790081}
parent 5ca5d1db
...@@ -1956,22 +1956,18 @@ void PepperPluginInstanceImpl::PrintPage(int page_number, ...@@ -1956,22 +1956,18 @@ void PepperPluginInstanceImpl::PrintPage(int page_number,
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
DCHECK(plugin_print_interface_); DCHECK(plugin_print_interface_);
// When compositing to PDF output, the |canvas| metafile is not the // |canvas| should always have an associated metafile.
// document metafile, and cannot be used for getting the final PDF. auto* metafile = canvas->GetPrintingMetafile();
if (current_print_settings_.format != PP_PRINTOUTPUTFORMAT_PDF) { DCHECK(metafile);
// |canvas| should always have an associated metafile.
auto* metafile = canvas->GetPrintingMetafile(); // |ranges_| should be empty IFF |metafile_| is not set.
DCHECK(metafile); DCHECK_EQ(ranges_.empty(), !metafile_);
if (metafile_) {
// |ranges_| should be empty IFF |metafile_| is not set. // The metafile should be the same across all calls for a given print job.
DCHECK_EQ(ranges_.empty(), !metafile_); DCHECK_EQ(metafile_, metafile);
if (metafile_) { } else {
// The metafile should be the same across all calls for a given print job. // Store |metafile| on the first call.
DCHECK_EQ(metafile_, metafile); metafile_ = metafile;
} else {
// Store |metafile| on the first call.
metafile_ = metafile;
}
} }
PP_PrintPageNumberRange_Dev page_range = {page_number, page_number}; PP_PrintPageNumberRange_Dev page_range = {page_number, page_number};
...@@ -1988,7 +1984,8 @@ void PepperPluginInstanceImpl::PrintEnd() { ...@@ -1988,7 +1984,8 @@ void PepperPluginInstanceImpl::PrintEnd() {
PP_Resource print_output = plugin_print_interface_->PrintPages( PP_Resource print_output = plugin_print_interface_->PrintPages(
pp_instance(), ranges_.data(), ranges_.size()); pp_instance(), ranges_.data(), ranges_.size());
if (print_output) { if (print_output) {
if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER) { if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF ||
current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER) {
PrintPDFOutput(print_output, metafile_); 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