Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Unified Diff: components/printing/renderer/print_web_view_helper.cc

Issue 2708213003: Fix fit to page scaling display for landscape (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698