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

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

Issue 2454293004: Printing: Fix undefined behavior for near 0 scaling (Closed)
Patch Set: Created 4 years, 2 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 | components/printing/renderer/print_web_view_helper_mac.mm » ('j') | 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 3e77142273bf41af06906e9d9f0b6a56ea6718b5..70198bfc77afbac453930f708b6240755b8205be 100644
--- a/components/printing/renderer/print_web_view_helper.cc
+++ b/components/printing/renderer/print_web_view_helper.cc
@@ -234,7 +234,7 @@ void CalculatePageLayoutFromPrintParams(
int content_height = params.content_size.height();
// Scale the content to its normal size for purpose of computing page layout.
// Otherwise we will get negative margins.
- if (scale_factor > 0 && (fit_to_page || params.print_to_pdf)) {
+ if (scale_factor >= 0.01f && (fit_to_page || params.print_to_pdf)) {
Lei Zhang 2016/10/29 00:26:53 Add a constexpr double kEpsilon constant and use t
rbpotter 2016/10/29 00:41:53 Done.
content_width =
static_cast<int>(static_cast<double>(content_width) * scale_factor);
content_height =
@@ -721,7 +721,7 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
frame->printBegin(web_print_params_, node_to_print_);
double scale_factor = 1.0f;
#if defined(ENABLE_PRINT_PREVIEW)
- if (print_params.scale_factor > 0)
+ if (print_params.scale_factor >= 0.01f)
scale_factor = print_params.scale_factor;
#endif
print_params = CalculatePrintParamsForCss(
@@ -1232,7 +1232,7 @@ bool PrintWebViewHelper::CreatePreviewDocument() {
PageSizeMargins default_page_layout;
double scale_factor =
- print_params.scale_factor > 0 ? print_params.scale_factor : 1.0f;
+ print_params.scale_factor >= 0.01f ? print_params.scale_factor : 1.0f;
ComputePageLayoutInPointsForCss(print_preview_context_.prepared_frame(), 0,
print_params, ignore_css_margins_,
@@ -1828,7 +1828,7 @@ void PrintWebViewHelper::PrintPageInternal(
double css_scale_factor = 1.0f;
#if defined(ENABLE_PRINT_PREVIEW)
- if (params.params.scale_factor > 0)
+ if (params.params.scale_factor >= 0.01f)
css_scale_factor = params.params.scale_factor;
#endif
ComputePageLayoutInPointsForCss(frame, params.page_number, params.params,
« no previous file with comments | « no previous file | components/printing/renderer/print_web_view_helper_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698