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 823c9574eb870e6f7c988d0711e63a2024992c97..07b668cc9da083f4e659a82f3db38c6448255d34 100644 |
--- a/components/printing/renderer/print_web_view_helper.cc |
+++ b/components/printing/renderer/print_web_view_helper.cc |
@@ -77,6 +77,7 @@ enum PrintPreviewHelperEvents { |
}; |
const double kMinDpi = 1.0; |
+const float kPrintingMinimumShrinkFactor = 1.333f; |
Lei Zhang
2016/03/29 01:00:46
Can you reference third_party/WebKit/Source/core/p
|
#if defined(ENABLE_PRINT_PREVIEW) |
bool g_is_preview_enabled = true; |
@@ -677,15 +678,19 @@ PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() { |
void PrepareFrameAndViewForPrint::ResizeForPrinting() { |
// Layout page according to printer page size. Since WebKit shrinks the |
- // size of the page automatically (from 125% to 200%) we trick it to |
- // think the page is 125% larger so the size of the page is correct for |
+ // size of the page automatically (from 133.3% to 200%) we trick it to |
+ // think the page is 133.3% larger so the size of the page is correct for |
// minimum (default) scaling. |
+ // The scaling factor 1.25 was originally chosen as a magic number that |
+ // was 'about right'. However per crbug.com/273306 1.333 seems to be |
Lei Zhang
2016/03/29 01:00:46
https://crbug.com/...
|
+ // the number that produces output with the correct physical size for elements |
+ // that are specified in cm, mm, pt etc. |
// This is important for sites that try to fill the page. |
- // The 1.25 value is |printingMinimumShrinkFactor|. |
gfx::Size print_layout_size(web_print_params_.printContentArea.width, |
web_print_params_.printContentArea.height); |
print_layout_size.set_height( |
- static_cast<int>(static_cast<double>(print_layout_size.height()) * 1.25)); |
+ static_cast<int>(static_cast<double>(print_layout_size.height()) * |
+ kPrintingMinimumShrinkFactor)); |
if (!frame()) |
return; |
@@ -1780,12 +1785,12 @@ void PrintWebViewHelper::PrintPageInternal( |
#if defined(ENABLE_PRINT_PREVIEW) |
if (params.params.display_header_footer) { |
- // TODO(thestig): Figure out why Linux needs this. The value may be |
- // |printingMinimumShrinkFactor|. |
+ // TODO(thestig): Figure out why Linux needs this. It is almost certainly |
+ // |printingMinimumShrinkFactor| from Blink. |
#if defined(OS_WIN) |
const float fudge_factor = 1; |
#else |
- const float fudge_factor = 1.25; |
+ const float fudge_factor = kPrintingMinimumShrinkFactor; |
#endif |
// |page_number| is 0-based, so 1 is added. |
PrintHeaderAndFooter(canvas, params.page_number + 1, |