b=462872 print as pdf where possible r=karlt
authorAdrian Johnson <ajohnson@redneon.com>
Fri, 25 Mar 2011 16:38:59 +1300
changeset 63997 dacd66ab4dc4dd4242d3000e7cabdb32e2c8d954
parent 63996 014fb62e09058d891a6caff670fc2f2a55481ff7
child 63998 315cbee8f00cf0529de92e6281dced2e66e77a5a
push id19298
push userktomlinson@mozilla.com
push dateMon, 28 Mar 2011 01:54:05 +0000
treeherdermozilla-central@dacd66ab4dc4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs462872
milestone2.2a1pre
first release with
nightly linux32
dacd66ab4dc4 / 4.2a1pre / 20110328030450 / files
nightly linux64
dacd66ab4dc4 / 4.2a1pre / 20110328030450 / files
nightly mac
dacd66ab4dc4 / 4.2a1pre / 20110328030450 / files
nightly win32
dacd66ab4dc4 / 4.2a1pre / 20110328030450 / files
nightly win64
dacd66ab4dc4 / 4.2a1pre / 20110328030202 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=462872 print as pdf where possible r=karlt
widget/src/gtk2/nsDeviceContextSpecG.cpp
--- a/widget/src/gtk2/nsDeviceContextSpecG.cpp
+++ b/widget/src/gtk2/nsDeviceContextSpecG.cpp
@@ -471,19 +471,30 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::Ge
   if (format == nsIPrintSettings::kOutputFormatNative) {
     if (mIsPPreview) {
       // There is nothing to detect on Print Preview, use PS.
       format = nsIPrintSettings::kOutputFormatPS;
     } else {
       const gchar* fmtGTK = gtk_print_settings_get(mGtkPrintSettings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT);
       if (!fmtGTK && GTK_IS_PRINTER(mGtkPrinter)) {
         // Likely not print-to-file, check printer's capabilities
-        format = (gtk_printer_accepts_ps(mGtkPrinter))
-          ? static_cast<PRInt16>(nsIPrintSettings::kOutputFormatPS)
-          : static_cast<PRInt16>(nsIPrintSettings::kOutputFormatPDF);
+
+        // Prior to gtk 2.24, gtk_printer_accepts_pdf() and
+        // gtk_printer_accepts_ps() always returned true regardless of the
+        // printer's capability.
+        if (gtk_major_version > 2 ||
+            (gtk_major_version == 2 && gtk_minor_version >= 24)) {
+          format =
+            gtk_printer_accepts_pdf(mGtkPrinter) ?
+            static_cast<PRInt16>(nsIPrintSettings::kOutputFormatPDF) :
+            static_cast<PRInt16>(nsIPrintSettings::kOutputFormatPS);
+        } else {
+          format = nsIPrintSettings::kOutputFormatPS;
+        }
+
       } else if (nsDependentCString(fmtGTK).EqualsIgnoreCase("pdf")) {
         format = nsIPrintSettings::kOutputFormatPDF;
       } else {
         format = nsIPrintSettings::kOutputFormatPS;
       }
     }
   }