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

Unified Diff: third_party/WebKit/Source/core/page/PrintContext.cpp

Issue 1817873002: Print with the correct physical dimensions when specified (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@262769
Patch Set: Updated 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
Index: third_party/WebKit/Source/core/page/PrintContext.cpp
diff --git a/third_party/WebKit/Source/core/page/PrintContext.cpp b/third_party/WebKit/Source/core/page/PrintContext.cpp
index 885a9f45fdf738423f0d12f290d607f6a148e051..1eb1dcc44e94d952f29b3381d89ea096e3e0de75 100644
--- a/third_party/WebKit/Source/core/page/PrintContext.cpp
+++ b/third_party/WebKit/Source/core/page/PrintContext.cpp
@@ -27,17 +27,17 @@
namespace blink {
-// By imaging to a width a little wider than the available pixels,
-// thin pages will be scaled down a little, matching the way they
-// print in IE and Camino. This lets them use fewer sheets than they
-// would otherwise, which is presumably why other browsers do this.
+// By shrinking to a width of 75% (1.333f) we will render the correct physical
+// dimensions in paged media (i.e. cm, pt,). The shrinkage used
+// to be 80% (1.25f) to match other browsers - they have since moved on.
// Wide pages will be scaled down more than this.
-const float printingMinimumShrinkFactor = 1.25f;
+const float printingMinimumShrinkFactor = 1.333f;
// This number determines how small we are willing to reduce the page content
// in order to accommodate the widest line. If the page would have to be
// reduced smaller to make the widest line fit, we just clip instead (this
-// behavior matches MacIE and Mozilla, at least)
+// behavior matches MacIE and Mozilla, at least).
+// TODO(rhogan): Decide if this quirk is still required.
const float printingMaximumShrinkFactor = 2;
PrintContext::PrintContext(LocalFrame* frame)
@@ -99,7 +99,10 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz
IntRect docRect = view->documentRect();
int pageWidth = pageSizeInPixels.width();
- int pageHeight = pageSizeInPixels.height();
+ // We scaled with floating point arithmetic and need to ensure results like 13329.99
+ // are treated as 13330 so that we don't mistakenly assign an extra page for the
+ // stray pixel.
+ int pageHeight = pageSizeInPixels.height() + LayoutUnit::epsilon();
bool isHorizontal = view->style()->isHorizontalWritingMode();

Powered by Google App Engine
This is Rietveld 408576698