<!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>[162349] releases/WebKitGTK/webkit-2.2</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/162349">162349</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-20 08:43:42 -0800 (Mon, 20 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/162073">r162073</a> - [GTK] Web process sometimes crashes when printing in synchronous mode
https://bugs.webkit.org/show_bug.cgi?id=126979

Reviewed by Gustavo Noronha Silva.

Source/WebKit2:

When printing synchronously in GTK+ we need to make sure that we
have a list of Printers before starting the print operation. Getting
the list of printers is done synchronously by GTK+, but using a
nested main loop that might process IPC messages comming from the
UI process like EndPrinting. When the EndPrinting message is
received while the printer list is being populated, the print
operation is finished unexpectely and the web process crashes. The
PrinterListGtk class gets the list of printers in the constructor
so we just need to ensure there's an instance alive during the
synchronous print operation. In case of asynchronous printing the
printer list will be created during the print operation without
any risk, because the EndPrinting message is not sent until the
printing callback has been received in the UI process.

* GNUmakefile.list.am: Add new files to compilation.
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::print): Ensure PrinterListGtk is created
before the synchronous printing and destroyed afterwards.
* WebProcess/WebPage/gtk/PrinterListGtk.cpp: Added.
(WebKit::PrinterListGtk::shared): Return the singleton.
(WebKit::PrinterListGtk::enumeratePrintersFunction): Callback
called by gtk_enumerate_printers() when a new printer is found.
(WebKit::PrinterListGtk::PrinterListGtk): Call
gtk_enumerate_printers() in syhchronous mode.
(WebKit::PrinterListGtk::~PrinterListGtk):
(WebKit::PrinterListGtk::addPrinter): Add the printer to the list
and set the default printer if needed.
(WebKit::PrinterListGtk::findPrinter): Find the printer for the
given name.
* WebProcess/WebPage/gtk/PrinterListGtk.h: Added.
* WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp: Use
PrinterListGtk class to find the printer instead of calling
gtk_enumerate_printers().

Tools:

* Scripts/run-gtk-tests:
(TestRunner): Unskip
/webkit2/WebKitPrintOperation/close-after-print.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit22SourceWebKit2ChangeLog">releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebKit2GNUmakefilelistam">releases/WebKitGTK/webkit-2.2/Source/WebKit2/GNUmakefile.list.am</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp">releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebKit2WebProcessWebPagegtkWebPrintOperationGtkcpp">releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22ToolsChangeLog">releases/WebKitGTK/webkit-2.2/Tools/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit22ToolsScriptsrungtktests">releases/WebKitGTK/webkit-2.2/Tools/Scripts/run-gtk-tests</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit22SourceWebKit2WebProcessWebPagegtkPrinterListGtkcpp">releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit22SourceWebKit2WebProcessWebPagegtkPrinterListGtkh">releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit22SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog (162348 => 162349)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog        2014-01-20 16:36:19 UTC (rev 162348)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog        2014-01-20 16:43:42 UTC (rev 162349)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2014-01-15  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Web process sometimes crashes when printing in synchronous mode
+        https://bugs.webkit.org/show_bug.cgi?id=126979
+
+        Reviewed by Gustavo Noronha Silva.
+
+        When printing synchronously in GTK+ we need to make sure that we
+        have a list of Printers before starting the print operation. Getting
+        the list of printers is done synchronously by GTK+, but using a
+        nested main loop that might process IPC messages comming from the
+        UI process like EndPrinting. When the EndPrinting message is
+        received while the printer list is being populated, the print
+        operation is finished unexpectely and the web process crashes. The
+        PrinterListGtk class gets the list of printers in the constructor
+        so we just need to ensure there's an instance alive during the
+        synchronous print operation. In case of asynchronous printing the
+        printer list will be created during the print operation without
+        any risk, because the EndPrinting message is not sent until the
+        printing callback has been received in the UI process.
+
+        * GNUmakefile.list.am: Add new files to compilation.
+        * PlatformGTK.cmake: Ditto.
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::print): Ensure PrinterListGtk is created
+        before the synchronous printing and destroyed afterwards.
+        * WebProcess/WebPage/gtk/PrinterListGtk.cpp: Added.
+        (WebKit::PrinterListGtk::shared): Return the singleton.
+        (WebKit::PrinterListGtk::enumeratePrintersFunction): Callback
+        called by gtk_enumerate_printers() when a new printer is found.
+        (WebKit::PrinterListGtk::PrinterListGtk): Call
+        gtk_enumerate_printers() in syhchronous mode.
+        (WebKit::PrinterListGtk::~PrinterListGtk):
+        (WebKit::PrinterListGtk::addPrinter): Add the printer to the list
+        and set the default printer if needed.
+        (WebKit::PrinterListGtk::findPrinter): Find the printer for the
+        given name.
+        * WebProcess/WebPage/gtk/PrinterListGtk.h: Added.
+        * WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp: Use
+        PrinterListGtk class to find the printer instead of calling
+        gtk_enumerate_printers().
+
</ins><span class="cx"> 2014-01-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Remove the weak pointer added to the web view in WebKitPrintOperation
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebKit2GNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/GNUmakefile.list.am (162348 => 162349)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/GNUmakefile.list.am        2014-01-20 16:36:19 UTC (rev 162348)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/GNUmakefile.list.am        2014-01-20 16:43:42 UTC (rev 162349)
</span><span class="lines">@@ -1227,6 +1227,8 @@
</span><span class="cx">         Source/WebKit2/WebProcess/WebPage/TapHighlightController.h \
</span><span class="cx">         Source/WebKit2/WebProcess/WebPage/atk/WebPageAccessibilityObject.h \
</span><span class="cx">         Source/WebKit2/WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp \
</span><ins>+        Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.h \
+        Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.cpp \
</ins><span class="cx">         Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorGtk.cpp \
</span><span class="cx">         Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp \
</span><span class="cx">         Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp \
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (162348 => 162349)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2014-01-20 16:36:19 UTC (rev 162348)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2014-01-20 16:43:42 UTC (rev 162349)
</span><span class="lines">@@ -69,6 +69,10 @@
</span><span class="cx"> #include &lt;WebCore/SecurityOrigin.h&gt;
</span><span class="cx"> #include &lt;WebCore/Settings.h&gt;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(GTK)
+#include &quot;PrinterListGtk.h&quot;
+#endif
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> using namespace HTMLNames;
</span><span class="cx"> 
</span><span class="lines">@@ -574,6 +578,16 @@
</span><span class="cx">     WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient-&gt;webFrame() : 0;
</span><span class="cx">     ASSERT(webFrame);
</span><span class="cx"> 
</span><ins>+#if PLATFORM(GTK) &amp;&amp; defined(HAVE_GTK_UNIX_PRINTING)
+    // When printing synchronously in GTK+ we need to make sure that we have a list of Printers before starting the print operation.
+    // Getting the list of printers is done synchronously by GTK+, but using a nested main loop that might process IPC messages
+    // comming from the UI process like EndPrinting. When the EndPriting message is received while the printer list is being populated,
+    // the print operation is finished unexpectely and the web process crashes, see https://bugs.webkit.org/show_bug.cgi?id=126979.
+    // The PrinterListGtk class gets the list of printers in the constructor so we just need to ensure there's an instance alive
+    // during the synchronous print operation.
+    RefPtr&lt;PrinterListGtk&gt; printerList = PrinterListGtk::shared();
+#endif
+
</ins><span class="cx">     m_page-&gt;sendSync(Messages::WebPageProxy::PrintFrame(webFrame-&gt;frameID()), Messages::WebPageProxy::PrintFrame::Reply());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebKit2WebProcessWebPagegtkPrinterListGtkcpp"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.cpp (0 => 162349)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.cpp                                (rev 0)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.cpp        2014-01-20 16:43:42 UTC (rev 162349)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;PrinterListGtk.h&quot;
+
+#ifdef HAVE_GTK_UNIX_PRINTING
+
+#include &lt;gtk/gtkunixprint.h&gt;
+
+namespace WebKit {
+
+PrinterListGtk* PrinterListGtk::s_sharedPrinterList = nullptr;
+
+RefPtr&lt;PrinterListGtk&gt; PrinterListGtk::shared()
+{
+    if (s_sharedPrinterList)
+        return s_sharedPrinterList;
+
+    return adoptRef(new PrinterListGtk);
+}
+
+gboolean PrinterListGtk::enumeratePrintersFunction(GtkPrinter* printer)
+{
+    ASSERT(s_sharedPrinterList);
+    s_sharedPrinterList-&gt;addPrinter(printer);
+    return FALSE;
+}
+
+PrinterListGtk::PrinterListGtk()
+    : m_defaultPrinter(nullptr)
+{
+    ASSERT(!s_sharedPrinterList);
+    s_sharedPrinterList = this;
+    gtk_enumerate_printers(reinterpret_cast&lt;GtkPrinterFunc&gt;(&amp;enumeratePrintersFunction), nullptr, nullptr, TRUE);
+}
+
+PrinterListGtk::~PrinterListGtk()
+{
+    ASSERT(s_sharedPrinterList);
+    s_sharedPrinterList = nullptr;
+}
+
+void PrinterListGtk::addPrinter(GtkPrinter* printer)
+{
+    m_printerList.append(printer);
+    if (gtk_printer_is_default(printer))
+        m_defaultPrinter = printer;
+}
+
+GtkPrinter* PrinterListGtk::findPrinter(const char* printerName) const
+{
+    for (auto&amp; printer : m_printerList) {
+        if (!strcmp(printerName, gtk_printer_get_name(printer.get())))
+            return printer.get();
+    }
+    return nullptr;
+}
+
+} // namespace WebKit
+
+#endif // HAVE_GTK_UNIX_PRINTING
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebKit2WebProcessWebPagegtkPrinterListGtkh"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.h (0 => 162349)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.h                                (rev 0)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/PrinterListGtk.h        2014-01-20 16:43:42 UTC (rev 162349)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PrinterListGtk_h
+#define PrinterListGtk_h
+
+#ifdef HAVE_GTK_UNIX_PRINTING
+
+#include &lt;wtf/RefCounted.h&gt;
+#include &lt;wtf/Vector.h&gt;
+#include &lt;wtf/gobject/GRefPtr.h&gt;
+
+typedef struct _GtkPrinter GtkPrinter;
+
+namespace WebKit {
+
+class PrinterListGtk: public RefCounted&lt;PrinterListGtk&gt; {
+public:
+    static RefPtr&lt;PrinterListGtk&gt; shared();
+    ~PrinterListGtk();
+
+    GtkPrinter* findPrinter(const char*) const;
+    GtkPrinter* defaultPrinter() const { return m_defaultPrinter; }
+
+private:
+    PrinterListGtk();
+
+    static gboolean enumeratePrintersFunction(GtkPrinter*);
+    void addPrinter(GtkPrinter*);
+
+    Vector&lt;GRefPtr&lt;GtkPrinter&gt;, 4&gt; m_printerList;
+    GtkPrinter* m_defaultPrinter;
+    static PrinterListGtk* s_sharedPrinterList;
+};
+
+} // namespace WebKit
+
+#endif // HAVE_GTK_UNIX_PRINTING
+
+#endif // WebPrintOperationGtk_h
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit22SourceWebKit2WebProcessWebPagegtkWebPrintOperationGtkcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp (162348 => 162349)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp        2014-01-20 16:36:19 UTC (rev 162348)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp        2014-01-20 16:43:42 UTC (rev 162349)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #include &lt;wtf/gobject/GOwnPtr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #ifdef HAVE_GTK_UNIX_PRINTING
</span><ins>+#include &quot;PrinterListGtk.h&quot;
</ins><span class="cx"> #include &lt;cairo-pdf.h&gt;
</span><span class="cx"> #include &lt;cairo-ps.h&gt;
</span><span class="cx"> #include &lt;gtk/gtkunixprint.h&gt;
</span><span class="lines">@@ -56,62 +57,49 @@
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static gboolean enumeratePrintersFunction(GtkPrinter* printer, WebPrintOperationGtkUnix* printOperation)
</del><ins>+    void startPrint(WebCore::PrintContext* printContext, uint64_t callbackID)
</ins><span class="cx">     {
</span><del>-        const char* printerName = gtk_print_settings_get_printer(printOperation-&gt;printSettings());
-        if ((printerName &amp;&amp; strcmp(printerName, gtk_printer_get_name(printer)))
-            || (!printerName &amp;&amp; !gtk_printer_is_default(printer)))
-            return FALSE;
</del><ins>+        m_printContext = printContext;
+        m_callbackID = callbackID;
</ins><span class="cx"> 
</span><ins>+        RefPtr&lt;PrinterListGtk&gt; printerList = PrinterListGtk::shared();
+        const char* printerName = gtk_print_settings_get_printer(m_printSettings.get());
+        GtkPrinter* printer = printerName ? printerList-&gt;findPrinter(printerName) : printerList-&gt;defaultPrinter();
+        if (!printer) {
+            printDone(printerNotFoundError(m_printContext));
+            return;
+        }
+
</ins><span class="cx">         static int jobNumber = 0;
</span><span class="cx">         const char* applicationName = g_get_application_name();
</span><span class="cx">         GOwnPtr&lt;char&gt;jobName(g_strdup_printf(&quot;%s job #%d&quot;, applicationName ? applicationName : &quot;WebKit&quot;, ++jobNumber));
</span><del>-        printOperation-&gt;m_printJob = adoptGRef(gtk_print_job_new(jobName.get(), printer,
-                                                                 printOperation-&gt;printSettings(),
-                                                                 printOperation-&gt;pageSetup()));
-        return TRUE;
-    }
</del><ins>+        m_printJob = adoptGRef(gtk_print_job_new(jobName.get(), printer, m_printSettings.get(), m_pageSetup.get()));
</ins><span class="cx"> 
</span><del>-    static void enumeratePrintersFinished(WebPrintOperationGtkUnix* printOperation)
-    {
-        if (!printOperation-&gt;m_printJob) {
-            printOperation-&gt;printDone(printerNotFoundError(printOperation-&gt;m_printContext));
-            return;
-        }
-
</del><span class="cx">         GOwnPtr&lt;GError&gt; error;
</span><del>-        cairo_surface_t* surface = gtk_print_job_get_surface(printOperation-&gt;m_printJob.get(), &amp;error.outPtr());
</del><ins>+        cairo_surface_t* surface = gtk_print_job_get_surface(m_printJob.get(), &amp;error.outPtr());
</ins><span class="cx">         if (!surface) {
</span><del>-            printOperation-&gt;printDone(printError(printOperation-&gt;m_printContext, error-&gt;message));
</del><ins>+            printDone(printError(m_printContext, error-&gt;message));
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         int rangesCount;
</span><del>-        printOperation-&gt;m_pageRanges = gtk_print_job_get_page_ranges(printOperation-&gt;m_printJob.get(), &amp;rangesCount);
-        printOperation-&gt;m_pageRangesCount = rangesCount;
-        printOperation-&gt;m_pagesToPrint = gtk_print_job_get_pages(printOperation-&gt;m_printJob.get());
-        printOperation-&gt;m_needsRotation = gtk_print_job_get_rotate(printOperation-&gt;m_printJob.get());
</del><ins>+        m_pageRanges = gtk_print_job_get_page_ranges(m_printJob.get(), &amp;rangesCount);
+        m_pageRangesCount = rangesCount;
+        m_pagesToPrint = gtk_print_job_get_pages(m_printJob.get());
+        m_needsRotation = gtk_print_job_get_rotate(m_printJob.get());
</ins><span class="cx"> 
</span><span class="cx">         // Manual capabilities.
</span><del>-        printOperation-&gt;m_numberUp = gtk_print_job_get_n_up(printOperation-&gt;m_printJob.get());
-        printOperation-&gt;m_numberUpLayout = gtk_print_job_get_n_up_layout(printOperation-&gt;m_printJob.get());
-        printOperation-&gt;m_pageSet = gtk_print_job_get_page_set(printOperation-&gt;m_printJob.get());
-        printOperation-&gt;m_reverse = gtk_print_job_get_reverse(printOperation-&gt;m_printJob.get());
-        printOperation-&gt;m_copies = gtk_print_job_get_num_copies(printOperation-&gt;m_printJob.get());
-        printOperation-&gt;m_collateCopies = gtk_print_job_get_collate(printOperation-&gt;m_printJob.get());
-        printOperation-&gt;m_scale = gtk_print_job_get_scale(printOperation-&gt;m_printJob.get());
</del><ins>+        m_numberUp = gtk_print_job_get_n_up(m_printJob.get());
+        m_numberUpLayout = gtk_print_job_get_n_up_layout(m_printJob.get());
+        m_pageSet = gtk_print_job_get_page_set(m_printJob.get());
+        m_reverse = gtk_print_job_get_reverse(m_printJob.get());
+        m_copies = gtk_print_job_get_num_copies(m_printJob.get());
+        m_collateCopies = gtk_print_job_get_collate(m_printJob.get());
+        m_scale = gtk_print_job_get_scale(m_printJob.get());
</ins><span class="cx"> 
</span><del>-        printOperation-&gt;print(surface, 72, 72);
</del><ins>+        print(surface, 72, 72);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void startPrint(WebCore::PrintContext* printContext, uint64_t callbackID)
-    {
-        m_printContext = printContext;
-        m_callbackID = callbackID;
-        gtk_enumerate_printers(reinterpret_cast&lt;GtkPrinterFunc&gt;(enumeratePrintersFunction), this,
-            reinterpret_cast&lt;GDestroyNotify&gt;(enumeratePrintersFinished), m_printMode == PrintInfo::PrintModeSync);
-    }
-
</del><span class="cx">     void startPage(cairo_t* cr)
</span><span class="cx">     {
</span><span class="cx">         if (!currentPageIsFirstPageOfSheet())
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22ToolsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Tools/ChangeLog (162348 => 162349)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Tools/ChangeLog        2014-01-20 16:36:19 UTC (rev 162348)
+++ releases/WebKitGTK/webkit-2.2/Tools/ChangeLog        2014-01-20 16:43:42 UTC (rev 162349)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-01-15  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Web process sometimes crashes when printing in synchronous mode
+        https://bugs.webkit.org/show_bug.cgi?id=126979
+
+        Reviewed by Gustavo Noronha Silva.
+
+        * Scripts/run-gtk-tests:
+        (TestRunner): Unskip
+        /webkit2/WebKitPrintOperation/close-after-print.
+
</ins><span class="cx"> 2014-01-14  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] UI process crashes when the web process crashes while printing
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit22ToolsScriptsrungtktests"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.2/Tools/Scripts/run-gtk-tests (162348 => 162349)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.2/Tools/Scripts/run-gtk-tests        2014-01-20 16:36:19 UTC (rev 162348)
+++ releases/WebKitGTK/webkit-2.2/Tools/Scripts/run-gtk-tests        2014-01-20 16:43:42 UTC (rev 162349)
</span><span class="lines">@@ -70,7 +70,6 @@
</span><span class="cx">         SkippedTest(&quot;WebKit2Gtk/TestUIClient&quot;, &quot;/webkit2/WebKitWebView/mouse-target&quot;, &quot;Test times out after r150890&quot;, 117689),
</span><span class="cx">         SkippedTest(&quot;WebKit2Gtk/TestAuthentication&quot;, SkippedTest.ENTIRE_SUITE, &quot;Test times out after r150890&quot;, 117689),
</span><span class="cx">         SkippedTest(&quot;WebKit2Gtk/TestContextMenu&quot;, SkippedTest.ENTIRE_SUITE, &quot;Test times out after r150890&quot;, 117689),
</span><del>-        SkippedTest(&quot;WebKit2Gtk/TestPrinting&quot;, &quot;/webkit2/WebKitPrintOperation/close-after-print&quot;, &quot;Test times out&quot;, 126979),
</del><span class="cx">         SkippedTest(&quot;WebKit2/TestWebKit2&quot;, &quot;WebKit2.MouseMoveAfterCrash&quot;, &quot;Test is flaky&quot;, 85066),
</span><span class="cx">         SkippedTest(&quot;WebKit2/TestWebKit2&quot;, &quot;WebKit2.NewFirstVisuallyNonEmptyLayoutForImages&quot;, &quot;Test is flaky&quot;, 85066),
</span><span class="cx">         SkippedTest(&quot;WebKit2/TestWebKit2&quot;, &quot;WebKit2.NewFirstVisuallyNonEmptyLayoutFrames&quot;, &quot;Test fails&quot;, 85037),
</span></span></pre>
</div>
</div>

</body>
</html>