Title: [201884] trunk/Source
Revision
201884
Author
[email protected]
Date
2016-06-09 14:34:25 -0700 (Thu, 09 Jun 2016)

Log Message

Define printing{Minimum,Maximum}ShrinkFactor in only one place
https://bugs.webkit.org/show_bug.cgi?id=158580

Reviewed by Tim Horton.

Source/WebCore:

* page/PrintContext.cpp: Removed printingMinimumShrinkFactor and printingMaximumShrinkFactor.
(WebCore::PrintContext::begin): Used minimumShrinkFactor() and maximumShrinkFactor() instead
of printingMinimumShrinkFactor and printingMaximumShrinkFactor.
(WebCore::PrintContext::computeAutomaticScaleFactor): Ditto.
* page/PrintContext.h:
(WebCore::PrintContext::minimumShrinkFactor): Added to return the same value as
printingMinimumShrinkFactor.
(WebCore::PrintContext::maximumShrinkFactor): Added to return the same value as
printingMaximumShrinkFactor.

Source/WebKit/mac:

* WebView/WebHTMLView.mm: Initialized _WebHTMLViewPrintingMinimumShrinkFactor and
_WebHTMLViewPrintingMaximumShrinkFactor with PrintContext::minimumShrinkFactor() and
PrintContext::maximumShrinkFactor() instead of with duplicated float literals.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (201883 => 201884)


--- trunk/Source/WebCore/ChangeLog	2016-06-09 21:30:35 UTC (rev 201883)
+++ trunk/Source/WebCore/ChangeLog	2016-06-09 21:34:25 UTC (rev 201884)
@@ -1,3 +1,20 @@
+2016-06-09  Andy Estes  <[email protected]>
+
+        Define printing{Minimum,Maximum}ShrinkFactor in only one place
+        https://bugs.webkit.org/show_bug.cgi?id=158580
+
+        Reviewed by Tim Horton.
+
+        * page/PrintContext.cpp: Removed printingMinimumShrinkFactor and printingMaximumShrinkFactor.
+        (WebCore::PrintContext::begin): Used minimumShrinkFactor() and maximumShrinkFactor() instead
+        of printingMinimumShrinkFactor and printingMaximumShrinkFactor.
+        (WebCore::PrintContext::computeAutomaticScaleFactor): Ditto.
+        * page/PrintContext.h:
+        (WebCore::PrintContext::minimumShrinkFactor): Added to return the same value as
+        printingMinimumShrinkFactor.
+        (WebCore::PrintContext::maximumShrinkFactor): Added to return the same value as
+        printingMaximumShrinkFactor.
+
 2016-06-09  Eric Carlson  <[email protected]>
 
         Don't show the caption menu if a video has only forced tracks

Modified: trunk/Source/WebCore/page/PrintContext.cpp (201883 => 201884)


--- trunk/Source/WebCore/page/PrintContext.cpp	2016-06-09 21:30:35 UTC (rev 201883)
+++ trunk/Source/WebCore/page/PrintContext.cpp	2016-06-09 21:34:25 UTC (rev 201884)
@@ -31,19 +31,6 @@
 
 namespace WebCore {
 
-// 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.
-// Wide pages will be scaled down more than this.
-const float printingMinimumShrinkFactor = 1.25f;
-
-// 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)
-const float printingMaximumShrinkFactor = 2;
-
 PrintContext::PrintContext(Frame* frame)
     : m_frame(frame)
     , m_isPrinting(false)
@@ -167,10 +154,10 @@
     m_isPrinting = true;
 
     FloatSize originalPageSize = FloatSize(width, height);
-    FloatSize minLayoutSize = m_frame->resizePageRectsKeepingRatio(originalPageSize, FloatSize(width * printingMinimumShrinkFactor, height * printingMinimumShrinkFactor));
+    FloatSize minLayoutSize = m_frame->resizePageRectsKeepingRatio(originalPageSize, FloatSize(width * minimumShrinkFactor(), height * minimumShrinkFactor()));
 
     // This changes layout, so callers need to make sure that they don't paint to screen while in printing mode.
-    m_frame->setPrinting(true, minLayoutSize, originalPageSize, printingMaximumShrinkFactor / printingMinimumShrinkFactor, AdjustViewSize);
+    m_frame->setPrinting(true, minLayoutSize, originalPageSize, maximumShrinkFactor() / minimumShrinkFactor(), AdjustViewSize);
 }
 
 float PrintContext::computeAutomaticScaleFactor(const FloatSize& availablePaperSize)
@@ -186,7 +173,7 @@
     if (viewLogicalWidth < 1)
         return 1;
 
-    float maxShrinkToFitScaleFactor = 1 / printingMaximumShrinkFactor;
+    float maxShrinkToFitScaleFactor = 1 / maximumShrinkFactor();
     float shrinkToFitScaleFactor = (useViewWidth ? availablePaperSize.width() : availablePaperSize.height()) / viewLogicalWidth;
     return std::max(maxShrinkToFitScaleFactor, shrinkToFitScaleFactor);
 }

Modified: trunk/Source/WebCore/page/PrintContext.h (201883 => 201884)


--- trunk/Source/WebCore/page/PrintContext.h	2016-06-09 21:30:35 UTC (rev 201883)
+++ trunk/Source/WebCore/page/PrintContext.h	2016-06-09 21:34:25 UTC (rev 201884)
@@ -78,7 +78,20 @@
     // The height of the graphics context should be
     // (pageSizeInPixels.height() + 1) * number-of-pages - 1
     WEBCORE_EXPORT static void spoolAllPagesWithBoundaries(Frame&, GraphicsContext&, const FloatSize& pageSizeInPixels);
+    
+    // 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.
+    // Wide pages will be scaled down more than this.
+    static constexpr float minimumShrinkFactor() { return 1.25; }
 
+    // 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)
+    static constexpr float maximumShrinkFactor() { return 2; }
+
 protected:
     Frame* m_frame;
     Vector<IntRect> m_pageRects;

Modified: trunk/Source/WebKit/mac/ChangeLog (201883 => 201884)


--- trunk/Source/WebKit/mac/ChangeLog	2016-06-09 21:30:35 UTC (rev 201883)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-06-09 21:34:25 UTC (rev 201884)
@@ -1,3 +1,14 @@
+2016-06-09  Andy Estes  <[email protected]>
+
+        Define printing{Minimum,Maximum}ShrinkFactor in only one place
+        https://bugs.webkit.org/show_bug.cgi?id=158580
+
+        Reviewed by Tim Horton.
+
+        * WebView/WebHTMLView.mm: Initialized _WebHTMLViewPrintingMinimumShrinkFactor and
+        _WebHTMLViewPrintingMaximumShrinkFactor with PrintContext::minimumShrinkFactor() and
+        PrintContext::maximumShrinkFactor() instead of with duplicated float literals.
+
 2016-06-09  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r201810.

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (201883 => 201884)


--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2016-06-09 21:30:35 UTC (rev 201883)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2016-06-09 21:34:25 UTC (rev 201884)
@@ -112,6 +112,7 @@
 #import <WebCore/NSURLFileTypeMappingsSPI.h>
 #import <WebCore/NSViewSPI.h>
 #import <WebCore/Page.h>
+#import <WebCore/PrintContext.h>
 #import <WebCore/Range.h>
 #import <WebCore/RenderView.h>
 #import <WebCore/RenderWidget.h>
@@ -760,19 +761,9 @@
 @end
 #endif // !PLATFORM(IOS)
 
-// 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.
-// Wide pages will be scaled down more than this.
-const float _WebHTMLViewPrintingMinimumShrinkFactor = 1.25;
+const float _WebHTMLViewPrintingMinimumShrinkFactor = PrintContext::minimumShrinkFactor();
+const float _WebHTMLViewPrintingMaximumShrinkFactor = PrintContext::maximumShrinkFactor();
 
-// 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)
-const float _WebHTMLViewPrintingMaximumShrinkFactor = 2;
-
 #define AUTOSCROLL_INTERVAL             0.1f
 
 // Any non-zero value will do, but using something recognizable might help us debug some day.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to