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 3e77142273bf41af06906e9d9f0b6a56ea6718b5..582cf5bf25b6adb18ba6a1eae7c3f20a2dc2000c 100644 |
| --- a/components/printing/renderer/print_web_view_helper.cc |
| +++ b/components/printing/renderer/print_web_view_helper.cc |
| @@ -114,6 +114,8 @@ int GetDPI(const PrintMsg_Print_Params* print_params) { |
| #endif // defined(OS_MACOSX) |
| } |
| +constexpr double kEpsilon = 0.01f; |
|
Lei Zhang
2016/10/29 01:19:24
Sorry, I meant line 115 in the header file, that w
rbpotter
2016/10/31 16:30:24
Done.
|
| + |
| bool PrintMsg_Print_Params_IsValid(const PrintMsg_Print_Params& params) { |
| return !params.content_size.IsEmpty() && !params.page_size.IsEmpty() && |
| !params.printable_area.IsEmpty() && params.document_cookie && |
| @@ -234,7 +236,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 >= kEpsilon && (fit_to_page || params.print_to_pdf)) { |
| content_width = |
| static_cast<int>(static_cast<double>(content_width) * scale_factor); |
| content_height = |
| @@ -721,7 +723,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 >= kEpsilon) |
| scale_factor = print_params.scale_factor; |
| #endif |
| print_params = CalculatePrintParamsForCss( |
| @@ -1232,7 +1234,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 >= kEpsilon ? print_params.scale_factor : 1.0f; |
| ComputePageLayoutInPointsForCss(print_preview_context_.prepared_frame(), 0, |
| print_params, ignore_css_margins_, |
| @@ -1828,7 +1830,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 >= kEpsilon) |
| css_scale_factor = params.params.scale_factor; |
| #endif |
| ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, |