Chromium Code Reviews| Index: components/printing/renderer/print_web_view_helper.cc |
| diff --git a/components/printing/renderer/print_web_view_helper.cc b/components/printing/renderer/print_web_view_helper.cc |
| index 9d9a87c8cc077b7437928f4763871a082e0ce68d..2370ad80c5d3fa4dbf2905536067c0c062e3751c 100644 |
| --- a/components/printing/renderer/print_web_view_helper.cc |
| +++ b/components/printing/renderer/print_web_view_helper.cc |
| @@ -1260,11 +1260,25 @@ bool PrintWebViewHelper::CreatePreviewDocument() { |
| if (source_frame->getPrintPresetOptionsForPlugin(source_node, |
| &preset_options)) { |
| if (preset_options.isPageSizeUniform) { |
| + // Figure out if the sizes have the same orientation |
| + bool rotate = ((printable_area_in_points.width() > |
|
Lei Zhang
2017/02/23 01:32:38
Please double check and see if I got this right. I
rbpotter
2017/02/23 22:26:54
Looks like this works and it is indeed more readab
|
| + printable_area_in_points.height()) && |
| + (preset_options.uniformPageSize.width < |
| + preset_options.uniformPageSize.height)) || |
| + ((printable_area_in_points.width() < |
| + printable_area_in_points.height()) && |
| + (preset_options.uniformPageSize.width > |
| + preset_options.uniformPageSize.height)); |
| + // Match orientation for computing scaling |
| + double printable_width = rotate ? printable_area_in_points.height() |
| + : printable_area_in_points.width(); |
| + double printable_height = rotate ? printable_area_in_points.width() |
| + : printable_area_in_points.height(); |
| double scale_width = |
| - static_cast<double>(printable_area_in_points.width()) / |
| + printable_width / |
| static_cast<double>(preset_options.uniformPageSize.width); |
| double scale_height = |
| - static_cast<double>(printable_area_in_points.height()) / |
| + printable_height / |
| static_cast<double>(preset_options.uniformPageSize.height); |
| fit_to_page_scale_factor = std::min(scale_width, scale_height); |
| } else { |