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

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

Issue 1848443003: Revert of Print with the correct physical dimensions when specified (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@262769
Patch Set: Created 4 years, 9 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 | third_party/WebKit/LayoutTests/compositing/squashing/squashing-print-expected.png » ('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 9ee4cd9cc3c91ab72584ea76c0223434075fdbab..823c9574eb870e6f7c988d0711e63a2024992c97 100644
--- a/components/printing/renderer/print_web_view_helper.cc
+++ b/components/printing/renderer/print_web_view_helper.cc
@@ -78,9 +78,6 @@ enum PrintPreviewHelperEvents {
const double kMinDpi = 1.0;
-// Also set in third_party/WebKit/Source/core/page/PrintContext.cpp
-const float kPrintingMinimumShrinkFactor = 1.333f;
-
#if defined(ENABLE_PRINT_PREVIEW)
bool g_is_preview_enabled = true;
@@ -680,19 +677,15 @@ PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() {
void PrepareFrameAndViewForPrint::ResizeForPrinting() {
// Layout page according to printer page size. Since WebKit shrinks the
- // 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
+ // 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
// minimum (default) scaling.
- // The scaling factor 1.25 was originally chosen as a magic number that
- // was 'about right'. However per https://crbug.com/273306 1.333 seems to be
- // 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()) *
- kPrintingMinimumShrinkFactor));
+ static_cast<int>(static_cast<double>(print_layout_size.height()) * 1.25));
if (!frame())
return;
@@ -1787,12 +1780,12 @@ void PrintWebViewHelper::PrintPageInternal(
#if defined(ENABLE_PRINT_PREVIEW)
if (params.params.display_header_footer) {
- // TODO(thestig): Figure out why Linux needs this. It is almost certainly
- // |printingMinimumShrinkFactor| from Blink.
+ // TODO(thestig): Figure out why Linux needs this. The value may be
+ // |printingMinimumShrinkFactor|.
#if defined(OS_WIN)
const float fudge_factor = 1;
#else
- const float fudge_factor = kPrintingMinimumShrinkFactor;
+ const float fudge_factor = 1.25;
#endif
// |page_number| is 0-based, so 1 is added.
PrintHeaderAndFooter(canvas, params.page_number + 1,
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/compositing/squashing/squashing-print-expected.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698