<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[190306] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/190306">190306</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-09-29 01:38:42 -0700 (Tue, 29 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>printing does not use minimum page zoom factor
https://bugs.webkit.org/show_bug.cgi?id=108507

Reviewed by Darin Adler.

Source/WebCore:

* page/PrintContext.cpp:
(WebCore::PrintContext::beginAndComputePageRectsWithPageSize):
Helper function to share common code from numberOfPages() and
spoolAllPagesWithBoundaries().
(WebCore::PrintContext::numberOfPages): Use beginAndComputePageRectsWithPageSize().
(WebCore::PrintContext::spoolAllPagesWithBoundaries): Use
beginAndComputePageRectsWithPageSize() and don't flip the Y axis
for non Cocoa platforms.
* page/PrintContext.h:

Source/WebKit/mac:

Pass a the frame as a reference instead of using pointers.

* Misc/WebCoreStatistics.mm:
(-[WebFrame numberOfPagesWithPageWidth:pageHeight:]):
(-[WebFrame printToCGContext:pageWidth:pageHeight:]):

Source/WebKit2:

Add kWKSnapshotOptionsPrinting flag to indicate the snapshot
should be generated in printing mode.

* Shared/API/c/WKImage.h:
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toSnapshotOptions):
* Shared/ImageOptions.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::numberOfPages): Pass the frame as a
reference instead of a pointer.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::scaledSnapshotWithOptions): In case of printing,
calculate the bitmap height based on the number of pages.
(WebKit::WebPage::snapshotAtSize): In case of printing, use
PrintContext::spoolAllPagesWithBoundaries() and return.

Tools:

WebKitTestRunner always takes the snapshots from the UI process
(expect for IOS), so in the case of printing, the layout in the
web view is not the expected one. When printing, we need to take
the snapshot in the web process and ensure it's rendered with a
PrintContext.

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::dump): When dumping pixels, pass
kWKSnapshotOptionsPrinting option to
WKBundlePageCreateSnapshotWithOptions() when printing.

LayoutTests:

Unskip printing reftests that should pass now.

* platform/gtk/TestExpectations:
* platform/mac-wk2/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformgtkTestExpectations">trunk/LayoutTests/platform/gtk/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2TestExpectations">trunk/LayoutTests/platform/mac-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepagePrintContextcpp">trunk/Source/WebCore/page/PrintContext.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePrintContexth">trunk/Source/WebCore/page/PrintContext.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebCoreStatisticsmm">trunk/Source/WebKit/mac/Misc/WebCoreStatistics.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedAPIcWKImageh">trunk/Source/WebKit2/Shared/API/c/WKImage.h</a></li>
<li><a href="#trunkSourceWebKit2SharedAPIcWKSharedAPICasth">trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h</a></li>
<li><a href="#trunkSourceWebKit2SharedImageOptionsh">trunk/Source/WebKit2/Shared/ImageOptions.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleInjectedBundlecpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlePagecpp">trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/LayoutTests/ChangeLog        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2015-09-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        printing does not use minimum page zoom factor
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+
+        Reviewed by Darin Adler.
+
+        Unskip printing reftests that should pass now.
+
+        * platform/gtk/TestExpectations:
+        * platform/mac-wk2/TestExpectations:
+
</ins><span class="cx"> 2015-09-28  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         fast/repaint/absolute-position-changed.html and fast/repaint/fixed.html are flaky.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/TestExpectations (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/TestExpectations        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/LayoutTests/platform/gtk/TestExpectations        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -2411,10 +2411,6 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/143924 fast/text/hyphen-min-preferred-width.html [ Skip ]
</span><span class="cx"> 
</span><del>-webkit.org/b/144494 printing/quirks-percentage-height-body.html [ ImageOnlyFailure ]
-webkit.org/b/144494 printing/quirks-percentage-height.html [ ImageOnlyFailure ]
-webkit.org/b/144494 printing/standards-percentage-heights.html [ ImageOnlyFailure ]
-
</del><span class="cx"> webkit.org/b/144575 http/tests/loading/promote-img-preload-priority.html [ Failure ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/144673 fast/forms/button-line-height.html [ ImageOnlyFailure ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/TestExpectations        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -199,10 +199,6 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/105960 plugins/navigator-plugins.html [ Failure ]
</span><span class="cx"> 
</span><del>-webkit.org/b/108507 printing/quirks-percentage-height-body.html [ Skip ]
-webkit.org/b/108507 printing/quirks-percentage-height.html [ Skip ]
-webkit.org/b/108507 printing/standards-percentage-heights.html [ Skip ]
-
</del><span class="cx"> webkit.org/b/104954 http/tests/canvas/canvas-slow-font-loading.html [ ImageOnlyFailure ]
</span><span class="cx"> 
</span><span class="cx"> # Flaky everywhere.
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebCore/ChangeLog        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-09-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        printing does not use minimum page zoom factor
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+
+        Reviewed by Darin Adler.
+
+        * page/PrintContext.cpp:
+        (WebCore::PrintContext::beginAndComputePageRectsWithPageSize):
+        Helper function to share common code from numberOfPages() and
+        spoolAllPagesWithBoundaries().
+        (WebCore::PrintContext::numberOfPages): Use beginAndComputePageRectsWithPageSize().
+        (WebCore::PrintContext::spoolAllPagesWithBoundaries): Use
+        beginAndComputePageRectsWithPageSize() and don't flip the Y axis
+        for non Cocoa platforms.
+        * page/PrintContext.h:
+
</ins><span class="cx"> 2015-09-29  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         Add support for WebIDL JSBuiltin attributes
</span></span></pre></div>
<a id="trunkSourceWebCorepagePrintContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PrintContext.cpp (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PrintContext.cpp        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebCore/page/PrintContext.cpp        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -301,33 +301,37 @@
</span><span class="cx">            String::number(marginTop) + ' ' + String::number(marginRight) + ' ' + String::number(marginBottom) + ' ' + String::number(marginLeft);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int PrintContext::numberOfPages(Frame* frame, const FloatSize&amp; pageSizeInPixels)
</del><ins>+bool PrintContext::beginAndComputePageRectsWithPageSize(Frame&amp; frame, const FloatSize&amp; pageSizeInPixels)
</ins><span class="cx"> {
</span><del>-    frame-&gt;document()-&gt;updateLayout();
</del><ins>+    if (!frame.document() || !frame.view() || !frame.document()-&gt;renderView())
+        return false;
</ins><span class="cx"> 
</span><del>-    FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
-    PrintContext printContext(frame);
-    printContext.begin(pageRect.width(), pageRect.height());
</del><ins>+    frame.document()-&gt;updateLayout();
+
+    begin(pageSizeInPixels.width(), pageSizeInPixels.height());
</ins><span class="cx">     // Account for shrink-to-fit.
</span><span class="cx">     FloatSize scaledPageSize = pageSizeInPixels;
</span><del>-    scaledPageSize.scale(frame-&gt;view()-&gt;contentsSize().width() / pageRect.width());
-    printContext.computePageRectsWithPageSize(scaledPageSize, false);
</del><ins>+    scaledPageSize.scale(frame.view()-&gt;contentsSize().width() / pageSizeInPixels.width());
+    computePageRectsWithPageSize(scaledPageSize, false);
+
+    return true;
+}
+
+int PrintContext::numberOfPages(Frame&amp; frame, const FloatSize&amp; pageSizeInPixels)
+{
+    PrintContext printContext(&amp;frame);
+    if (!printContext.beginAndComputePageRectsWithPageSize(frame, pageSizeInPixels))
+        return -1;
+
</ins><span class="cx">     return printContext.pageCount();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PrintContext::spoolAllPagesWithBoundaries(Frame* frame, GraphicsContext&amp; graphicsContext, const FloatSize&amp; pageSizeInPixels)
</del><ins>+void PrintContext::spoolAllPagesWithBoundaries(Frame&amp; frame, GraphicsContext&amp; graphicsContext, const FloatSize&amp; pageSizeInPixels)
</ins><span class="cx"> {
</span><del>-    if (!frame-&gt;document() || !frame-&gt;view() || !frame-&gt;document()-&gt;renderView())
</del><ins>+    PrintContext printContext(&amp;frame);
+    if (!printContext.beginAndComputePageRectsWithPageSize(frame, pageSizeInPixels))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    frame-&gt;document()-&gt;updateLayout();
-
-    PrintContext printContext(frame);
-    printContext.begin(pageSizeInPixels.width(), pageSizeInPixels.height());
-
-    float pageHeight;
-    printContext.computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight);
-
</del><span class="cx">     const float pageWidth = pageSizeInPixels.width();
</span><span class="cx">     const Vector&lt;IntRect&gt;&amp; pageRects = printContext.pageRects();
</span><span class="cx">     int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;
</span><span class="lines">@@ -337,18 +341,24 @@
</span><span class="cx">     graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
</span><span class="cx"> 
</span><span class="cx">     graphicsContext.save();
</span><ins>+#if PLATFORM(COCOA)
</ins><span class="cx">     graphicsContext.translate(0, totalHeight);
</span><span class="cx">     graphicsContext.scale(FloatSize(1, -1));
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     int currentHeight = 0;
</span><span class="cx">     for (size_t pageIndex = 0; pageIndex &lt; pageRects.size(); pageIndex++) {
</span><span class="cx">         // Draw a line for a page boundary if this isn't the first page.
</span><span class="cx">         if (pageIndex &gt; 0) {
</span><ins>+#if PLATFORM(COCOA)
+            int boundaryLineY = currentHeight;
+#else
+            int boundaryLineY = currentHeight - 1;
+#endif
</ins><span class="cx">             graphicsContext.save();
</span><span class="cx">             graphicsContext.setStrokeColor(Color(0, 0, 255), ColorSpaceDeviceRGB);
</span><span class="cx">             graphicsContext.setFillColor(Color(0, 0, 255), ColorSpaceDeviceRGB);
</span><del>-            graphicsContext.drawLine(IntPoint(0, currentHeight),
-                                     IntPoint(pageWidth, currentHeight));
</del><ins>+            graphicsContext.drawLine(IntPoint(0, boundaryLineY), IntPoint(pageWidth, boundaryLineY));
</ins><span class="cx">             graphicsContext.restore();
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepagePrintContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PrintContext.h (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PrintContext.h        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebCore/page/PrintContext.h        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -73,11 +73,11 @@
</span><span class="cx">     WEBCORE_EXPORT static String pageProperty(Frame*, const char* propertyName, int pageNumber);
</span><span class="cx">     WEBCORE_EXPORT static bool isPageBoxVisible(Frame*, int pageNumber);
</span><span class="cx">     WEBCORE_EXPORT static String pageSizeAndMarginsInPixels(Frame*, int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
</span><del>-    WEBCORE_EXPORT static int numberOfPages(Frame*, const FloatSize&amp; pageSizeInPixels);
</del><ins>+    WEBCORE_EXPORT static int numberOfPages(Frame&amp;, const FloatSize&amp; pageSizeInPixels);
</ins><span class="cx">     // Draw all pages into a graphics context with lines which mean page boundaries.
</span><span class="cx">     // The height of the graphics context should be
</span><span class="cx">     // (pageSizeInPixels.height() + 1) * number-of-pages - 1
</span><del>-    WEBCORE_EXPORT static void spoolAllPagesWithBoundaries(Frame*, GraphicsContext&amp;, const FloatSize&amp; pageSizeInPixels);
</del><ins>+    WEBCORE_EXPORT static void spoolAllPagesWithBoundaries(Frame&amp;, GraphicsContext&amp;, const FloatSize&amp; pageSizeInPixels);
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     Frame* m_frame;
</span><span class="lines">@@ -85,6 +85,7 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void computePageRectsWithPageSizeInternal(const FloatSize&amp; pageSizeInPixels, bool allowHorizontalTiling);
</span><ins>+    bool beginAndComputePageRectsWithPageSize(Frame&amp;, const FloatSize&amp; pageSizeInPixels);
</ins><span class="cx"> 
</span><span class="cx">     // Used to prevent misuses of begin() and end() (e.g., call end without begin).
</span><span class="cx">     bool m_isPrinting;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebCore/testing/Internals.cpp        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -2013,7 +2013,7 @@
</span><span class="cx">     if (!frame())
</span><span class="cx">         return -1;
</span><span class="cx"> 
</span><del>-    return PrintContext::numberOfPages(frame(), FloatSize(pageWidth, pageHeight));
</del><ins>+    return PrintContext::numberOfPages(*frame(), FloatSize(pageWidth, pageHeight));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String Internals::pageProperty(String propertyName, int pageNumber, ExceptionCode&amp; ec) const
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebKit/mac/ChangeLog        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-09-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        printing does not use minimum page zoom factor
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+
+        Reviewed by Darin Adler.
+
+        Pass a the frame as a reference instead of using pointers.
+
+        * Misc/WebCoreStatistics.mm:
+        (-[WebFrame numberOfPagesWithPageWidth:pageHeight:]):
+        (-[WebFrame printToCGContext:pageWidth:pageHeight:]):
+
</ins><span class="cx"> 2015-09-25  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Clean up user media request internal API
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebCoreStatisticsmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebCoreStatistics.mm (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebCoreStatistics.mm        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebKit/mac/Misc/WebCoreStatistics.mm        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -276,7 +276,11 @@
</span><span class="cx"> 
</span><span class="cx"> - (int)numberOfPagesWithPageWidth:(float)pageWidthInPixels pageHeight:(float)pageHeightInPixels
</span><span class="cx"> {
</span><del>-    return PrintContext::numberOfPages(_private-&gt;coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
</del><ins>+    Frame* coreFrame = _private-&gt;coreFrame;
+    if (!coreFrame)
+        return -1;
+
+    return PrintContext::numberOfPages(*coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)printToCGContext:(CGContextRef)cgContext pageWidth:(float)pageWidthInPixels pageHeight:(float)pageHeightInPixels
</span><span class="lines">@@ -286,7 +290,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     GraphicsContext graphicsContext(cgContext);
</span><del>-    PrintContext::spoolAllPagesWithBoundaries(coreFrame, graphicsContext, FloatSize(pageWidthInPixels, pageHeightInPixels));
</del><ins>+    PrintContext::spoolAllPagesWithBoundaries(*coreFrame, graphicsContext, FloatSize(pageWidthInPixels, pageHeightInPixels));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebKit2/ChangeLog        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2015-09-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        printing does not use minimum page zoom factor
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+
+        Reviewed by Darin Adler.
+
+        Add kWKSnapshotOptionsPrinting flag to indicate the snapshot
+        should be generated in printing mode.
+
+        * Shared/API/c/WKImage.h:
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toSnapshotOptions):
+        * Shared/ImageOptions.h:
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::numberOfPages): Pass the frame as a
+        reference instead of a pointer.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::scaledSnapshotWithOptions): In case of printing,
+        calculate the bitmap height based on the number of pages.
+        (WebKit::WebPage::snapshotAtSize): In case of printing, use
+        PrintContext::spoolAllPagesWithBoundaries() and return.
+
</ins><span class="cx"> 2015-09-28  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Expose 'geometryFlipped' state for debugging/logging purposes
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedAPIcWKImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/API/c/WKImage.h (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/API/c/WKImage.h        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebKit2/Shared/API/c/WKImage.h        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx">     kWKSnapshotOptionsPaintSelectionRectangle = 1 &lt;&lt; 3,
</span><span class="cx">     kWKSnapshotOptionsForceBlackText = 1 &lt;&lt; 4,
</span><span class="cx">     kWKSnapshotOptionsForceWhiteText = 1 &lt;&lt; 5,
</span><ins>+    kWKSnapshotOptionsPrinting = 1 &lt;&lt; 6,
</ins><span class="cx"> };
</span><span class="cx"> typedef uint32_t WKSnapshotOptions;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedAPIcWKSharedAPICasth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -951,6 +951,8 @@
</span><span class="cx">         snapshotOptions |= SnapshotOptionsForceBlackText;
</span><span class="cx">     if (wkSnapshotOptions &amp; kWKSnapshotOptionsForceWhiteText)
</span><span class="cx">         snapshotOptions |= SnapshotOptionsForceWhiteText;
</span><ins>+    if (wkSnapshotOptions &amp; kWKSnapshotOptionsPrinting)
+        snapshotOptions |= SnapshotOptionsPrinting;
</ins><span class="cx"> 
</span><span class="cx">     return snapshotOptions;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedImageOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/ImageOptions.h (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/ImageOptions.h        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebKit2/Shared/ImageOptions.h        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx">     SnapshotOptionsExcludeDeviceScaleFactor = 1 &lt;&lt; 5,
</span><span class="cx">     SnapshotOptionsForceBlackText = 1 &lt;&lt; 6,
</span><span class="cx">     SnapshotOptionsForceWhiteText = 1 &lt;&lt; 7,
</span><ins>+    SnapshotOptionsPrinting = 1 &lt;&lt; 8,
</ins><span class="cx"> };
</span><span class="cx"> typedef uint32_t SnapshotOptions;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleInjectedBundlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -407,7 +407,7 @@
</span><span class="cx">     if (!pageHeightInPixels)
</span><span class="cx">         pageHeightInPixels = coreFrame-&gt;view()-&gt;height();
</span><span class="cx"> 
</span><del>-    return PrintContext::numberOfPages(coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
</del><ins>+    return PrintContext::numberOfPages(*coreFrame, FloatSize(pageWidthInPixels, pageHeightInPixels));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int InjectedBundle::pageNumberForElementById(WebFrame* frame, const String&amp; id, double pageWidthInPixels, double pageHeightInPixels)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -1717,10 +1717,18 @@
</span><span class="cx"> {
</span><span class="cx">     IntRect snapshotRect = rect;
</span><span class="cx">     IntSize bitmapSize = snapshotRect.size();
</span><del>-    double scaleFactor = additionalScaleFactor;
-    if (!(options &amp; SnapshotOptionsExcludeDeviceScaleFactor))
-        scaleFactor *= corePage()-&gt;deviceScaleFactor();
-    bitmapSize.scale(scaleFactor);
</del><ins>+    if (options &amp; SnapshotOptionsPrinting) {
+        ASSERT(additionalScaleFactor == 1);
+        Frame* coreFrame = m_mainFrame-&gt;coreFrame();
+        if (!coreFrame)
+            return nullptr;
+        bitmapSize.setHeight(PrintContext::numberOfPages(*coreFrame, bitmapSize) * (bitmapSize.height() + 1) - 1);
+    } else {
+        double scaleFactor = additionalScaleFactor;
+        if (!(options &amp; SnapshotOptionsExcludeDeviceScaleFactor))
+            scaleFactor *= corePage()-&gt;deviceScaleFactor();
+        bitmapSize.scale(scaleFactor);
+    }
</ins><span class="cx"> 
</span><span class="cx">     return snapshotAtSize(rect, bitmapSize, options);
</span><span class="cx"> }
</span><span class="lines">@@ -1746,6 +1754,11 @@
</span><span class="cx"> 
</span><span class="cx">     auto graphicsContext = snapshot-&gt;bitmap()-&gt;createGraphicsContext();
</span><span class="cx"> 
</span><ins>+    if (options &amp; SnapshotOptionsPrinting) {
+        PrintContext::spoolAllPagesWithBoundaries(*coreFrame, *graphicsContext, snapshotRect.size());
+        return snapshot.release();
+    }
+
</ins><span class="cx">     Color documentBackgroundColor = frameView-&gt;documentBackgroundColor();
</span><span class="cx">     Color backgroundColor = (coreFrame-&gt;settings().backgroundShouldExtendBeyondPage() &amp;&amp; documentBackgroundColor.isValid()) ? documentBackgroundColor : frameView-&gt;baseBackgroundColor();
</span><span class="cx">     graphicsContext-&gt;fillRect(IntRect(IntPoint(), bitmapSize), backgroundColor, ColorSpaceDeviceRGB);
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Tools/ChangeLog        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2015-09-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        printing does not use minimum page zoom factor
+        https://bugs.webkit.org/show_bug.cgi?id=108507
+
+        Reviewed by Darin Adler.
+
+        WebKitTestRunner always takes the snapshots from the UI process
+        (expect for IOS), so in the case of printing, the layout in the
+        web view is not the expected one. When printing, we need to take
+        the snapshot in the web process and ensure it's rendered with a
+        PrintContext.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::dump): When dumping pixels, pass
+        kWKSnapshotOptionsPrinting option to
+        WKBundlePageCreateSnapshotWithOptions() when printing.
+
</ins><span class="cx"> 2015-09-28  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WTR] Pixel tests generate the snapshots twice in Web and UI processes
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (190305 => 190306)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp        2015-09-29 08:01:09 UTC (rev 190305)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp        2015-09-29 08:38:42 UTC (rev 190306)
</span><span class="lines">@@ -894,15 +894,27 @@
</span><span class="cx">     if (injectedBundle.shouldDumpPixels() &amp;&amp; injectedBundle.testRunner()-&gt;shouldDumpPixels()) {
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">         // IOS doesn't implement PlatformWebView::windowSnapshotImage() yet, so we need to generate the snapshot in the web process.
</span><del>-        WKSnapshotOptions options = kWKSnapshotOptionsShareable | kWKSnapshotOptionsInViewCoordinates;
-        if (injectedBundle.testRunner()-&gt;shouldDumpSelectionRect())
-            options |= kWKSnapshotOptionsPaintSelectionRectangle;
-
-        injectedBundle.setPixelResult(adoptWK(WKBundlePageCreateSnapshotWithOptions(m_page, WKBundleFrameGetVisibleContentBounds(WKBundlePageGetMainFrame(m_page)), options)).get());
</del><ins>+        bool shouldCreateSnapshot = true;
</ins><span class="cx"> #else
</span><del>-        injectedBundle.setPixelResultIsPending(true);
</del><ins>+        bool shouldCreateSnapshot = injectedBundle.testRunner()-&gt;isPrinting();
</ins><span class="cx"> #endif
</span><del>-        if (WKBundlePageIsTrackingRepaints(m_page))
</del><ins>+        if (shouldCreateSnapshot) {
+            WKSnapshotOptions options = kWKSnapshotOptionsShareable;
+            WKRect snapshotRect = WKBundleFrameGetVisibleContentBounds(WKBundlePageGetMainFrame(m_page));
+
+            if (injectedBundle.testRunner()-&gt;isPrinting())
+                options |= kWKSnapshotOptionsPrinting;
+            else {
+                options |= kWKSnapshotOptionsInViewCoordinates;
+                if (injectedBundle.testRunner()-&gt;shouldDumpSelectionRect())
+                    options |= kWKSnapshotOptionsPaintSelectionRectangle;
+            }
+
+            injectedBundle.setPixelResult(adoptWK(WKBundlePageCreateSnapshotWithOptions(m_page, snapshotRect, options)).get());
+        } else
+            injectedBundle.setPixelResultIsPending(true);
+
+        if (WKBundlePageIsTrackingRepaints(m_page) &amp;&amp; !injectedBundle.testRunner()-&gt;isPrinting())
</ins><span class="cx">             injectedBundle.setRepaintRects(adoptWK(WKBundlePageCopyTrackedRepaintRects(m_page)).get());
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>