Remove redundant fields from WebPrintParams.
paper_size_in_css_pixels can be removed because default_page_description already contains the page box size. print_content_area_in_css_pixels can be removed because the page area can be deduced by subtracting the margins in default_page_description from the page box size. The page area offset part of this field was always set to 0,0 in PrintRenderFrameHelper, by the way. Change-Id: Ib0d32b1089ff0e3e699fafa453f48b1228959c36 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4858744 Reviewed-by: Kent Tamura <tkent@chromium.org> Reviewed-by: Derek Schuff <dschuff@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Morten Stenshorne <mstensho@chromium.org> Cr-Commit-Position: refs/heads/main@{#1195892}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
5b12af375d
commit
d2ff80eb8d
components/printing/renderer
content/renderer/pepper
pdf/pdfium
third_party/blink/public/web
@ -368,11 +368,6 @@ blink::WebPrintParams ComputeWebKitPrintParamsInDesiredDpi(
|
||||
webkit_print_params.rasterize_pdf = print_params.rasterize_pdf;
|
||||
webkit_print_params.print_scaling_option = print_params.print_scaling_option;
|
||||
|
||||
webkit_print_params.print_content_area_in_css_pixels.set_size(gfx::SizeF(
|
||||
ConvertUnitFloat(print_params.content_size.width(), dpi, kPixelsPerInch),
|
||||
ConvertUnitFloat(print_params.content_size.height(), dpi,
|
||||
kPixelsPerInch)));
|
||||
|
||||
webkit_print_params.printable_area_in_css_pixels = gfx::RectF(
|
||||
ConvertUnitFloat(print_params.printable_area.x(), dpi, kPixelsPerInch),
|
||||
ConvertUnitFloat(print_params.printable_area.y(), dpi, kPixelsPerInch),
|
||||
@ -381,10 +376,6 @@ blink::WebPrintParams ComputeWebKitPrintParamsInDesiredDpi(
|
||||
ConvertUnitFloat(print_params.printable_area.height(), dpi,
|
||||
kPixelsPerInch));
|
||||
|
||||
webkit_print_params.paper_size_in_css_pixels = gfx::SizeF(
|
||||
ConvertUnitFloat(print_params.page_size.width(), dpi, kPixelsPerInch),
|
||||
ConvertUnitFloat(print_params.page_size.height(), dpi, kPixelsPerInch));
|
||||
|
||||
// The following settings is for N-up mode.
|
||||
webkit_print_params.pages_per_sheet = print_params.pages_per_sheet;
|
||||
|
||||
|
@ -1609,13 +1609,22 @@ int PepperPluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const blink::WebPrintPageDescription& description =
|
||||
print_params.default_page_description;
|
||||
gfx::SizeF page_area_size = description.size;
|
||||
page_area_size.set_width(std::max(0.0f, page_area_size.width() -
|
||||
description.margin_left -
|
||||
description.margin_right));
|
||||
page_area_size.set_height(std::max(0.0f, page_area_size.height() -
|
||||
description.margin_top -
|
||||
description.margin_bottom));
|
||||
|
||||
PP_PrintSettings_Dev print_settings;
|
||||
print_settings.printable_area =
|
||||
CSSPixelsToPoints(print_params.printable_area_in_css_pixels);
|
||||
print_settings.content_area =
|
||||
CSSPixelsToPoints(print_params.print_content_area_in_css_pixels);
|
||||
print_settings.paper_size =
|
||||
CSSPixelsToPoints(print_params.paper_size_in_css_pixels);
|
||||
print_settings.content_area.point = PP_Point();
|
||||
print_settings.content_area.size = CSSPixelsToPoints(page_area_size);
|
||||
print_settings.paper_size = CSSPixelsToPoints(description.size);
|
||||
print_settings.dpi = print_params.printer_dpi;
|
||||
print_settings.orientation = PP_PRINTORIENTATION_NORMAL;
|
||||
print_settings.grayscale = PP_FALSE;
|
||||
|
@ -339,8 +339,8 @@ ScopedFPDFDocument PDFiumPrint::CreatePrintPdf(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gfx::Size int_paper_size =
|
||||
ToFlooredSize(CSSPixelsToPoints(print_params.paper_size_in_css_pixels));
|
||||
gfx::Size int_paper_size = ToFlooredSize(
|
||||
CSSPixelsToPoints(print_params.default_page_description.size));
|
||||
gfx::Rect int_printable_area = ToEnclosedRect(
|
||||
CSSPixelsToPoints(print_params.printable_area_in_css_pixels));
|
||||
|
||||
|
@ -54,9 +54,8 @@ base::FilePath GetReferenceFilePath(base::StringPiece test_filename) {
|
||||
|
||||
blink::WebPrintParams GetDefaultPrintParams() {
|
||||
blink::WebPrintParams params;
|
||||
params.print_content_area_in_css_pixels = kUSLetterRect;
|
||||
params.default_page_description.size = kUSLetterSize;
|
||||
params.printable_area_in_css_pixels = kUSLetterRect;
|
||||
params.paper_size_in_css_pixels = kUSLetterSize;
|
||||
params.print_scaling_option = printing::mojom::PrintScalingOption::kNone;
|
||||
return params;
|
||||
}
|
||||
|
14
third_party/blink/public/web/web_print_params.h
vendored
14
third_party/blink/public/web/web_print_params.h
vendored
@ -39,20 +39,14 @@
|
||||
namespace blink {
|
||||
|
||||
struct WebPrintParams {
|
||||
// Specifies printable content rect in CSS pixels (a CSS pixel is 1/96 of an
|
||||
// inch).
|
||||
gfx::RectF print_content_area_in_css_pixels;
|
||||
|
||||
// Specifies the selected printer default printable area details in
|
||||
// pixels.
|
||||
// in CSS pixels (a CSS pixel is 1/96 of an inch).
|
||||
gfx::RectF printable_area_in_css_pixels;
|
||||
|
||||
// Specifies the selected printer default paper size in pixels.
|
||||
gfx::SizeF paper_size_in_css_pixels;
|
||||
|
||||
// The page size and margins as provided by the system / user. This will be
|
||||
// used as a base when handling @page rules, to fill in the blanks (rules may
|
||||
// provide or omit declarations for the page size and/or any margin side).
|
||||
// In CSS pixels.
|
||||
WebPrintPageDescription default_page_description;
|
||||
|
||||
// Specifies user selected DPI for printing.
|
||||
@ -81,9 +75,7 @@ struct WebPrintParams {
|
||||
: WebPrintParams(paper_size, true) {}
|
||||
|
||||
WebPrintParams(const gfx::SizeF& paper_size, bool use_printing_layout)
|
||||
: print_content_area_in_css_pixels(paper_size),
|
||||
printable_area_in_css_pixels(paper_size),
|
||||
paper_size_in_css_pixels(paper_size),
|
||||
: printable_area_in_css_pixels(paper_size),
|
||||
default_page_description(paper_size),
|
||||
print_scaling_option(printing::mojom::PrintScalingOption::kSourceSize),
|
||||
use_printing_layout(use_printing_layout) {}
|
||||
|
Reference in New Issue
Block a user