Commit b14cbef8 authored by rbpotter's avatar rbpotter Committed by Commit Bot

PrintRenderFrameHelper: Don't let fit to page scaling be undefined

If the preset options contain a zero width or height page size,
computing the fit to page width or height will result in a division
by zero and these values will be undefined. Use 0.0f, indicating
an unknown/unavailable fit to page scaling, in this case.

Bug: 859230
Change-Id: Ib5b36786da9ba82b1ba1642a5d9ff9c086342fee
Reviewed-on: https://chromium-review.googlesource.com/1135785Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575008}
parent b658d754
...@@ -1280,13 +1280,20 @@ bool PrintRenderFrameHelper::CreatePreviewDocument() { ...@@ -1280,13 +1280,20 @@ bool PrintRenderFrameHelper::CreatePreviewDocument() {
: printable_area_in_points.width(); : printable_area_in_points.width();
double printable_height = rotate ? printable_area_in_points.width() double printable_height = rotate ? printable_area_in_points.width()
: printable_area_in_points.height(); : printable_area_in_points.height();
double scale_width =
printable_width / // Ensure we do not divide by 0.
static_cast<double>(preset_options.uniform_page_size.width); if (preset_options.uniform_page_size.width == 0 ||
double scale_height = preset_options.uniform_page_size.height == 0) {
printable_height / fit_to_page_scale_factor = 0.0f;
static_cast<double>(preset_options.uniform_page_size.height); } else {
fit_to_page_scale_factor = std::min(scale_width, scale_height); double scale_width =
printable_width /
static_cast<double>(preset_options.uniform_page_size.width);
double scale_height =
printable_height /
static_cast<double>(preset_options.uniform_page_size.height);
fit_to_page_scale_factor = std::min(scale_width, scale_height);
}
} else { } else {
fit_to_page_scale_factor = 0.0f; fit_to_page_scale_factor = 0.0f;
} }
......
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