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

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

Issue 2708213003: Fix fit to page scaling display for landscape (Closed)
Patch Set: Simplify rotate check 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 b5e829ca1eeff6845049355eabb99c6d81a057b7..b2304be5fbd9f0aa471fdfc882c74528f3f79807 100644
--- a/components/printing/renderer/print_web_view_helper.cc
+++ b/components/printing/renderer/print_web_view_helper.cc
@@ -1260,11 +1260,22 @@ 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 is_printable_area_landscape = printable_area_in_points.width() >
+ printable_area_in_points.height();
+ bool is_preset_landscape = preset_options.uniformPageSize.width >
+ preset_options.uniformPageSize.height;
+ bool rotate = is_printable_area_landscape != is_preset_landscape;
+ // 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