Bug 1185236 - Shorten print job name when GTK version is older than 3.18.2. r=karlt
☠☠ backed out by 7ec4ec57761e ☠ ☠
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 13 Oct 2017 09:46:39 +0900
changeset 385979 0466471b9f67aa6a60bf3fb98515532e8a53095d
parent 385978 445f1e6fc862f32dc126085c01452dd0e3a03fb6
child 385980 2cbe403d5c16ca26e4fc4af2b2153c337429070b
push id32672
push userarchaeopteryx@coole-files.de
push dateFri, 13 Oct 2017 09:00:05 +0000
treeherdermozilla-central@3efcb26e5f37 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1185236
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1185236 - Shorten print job name when GTK version is older than 3.18.2. r=karlt Since GTK 3.18.2, GTK allows setting job name with more than 255 bytes. As result, CUPS received the IPP error. (RFC 2911, Section 4.3.1) This patch will shorten print job name, if runtime GTK version is older than 3.18.2. MozReview-Commit-ID: EfB87Bvo6hX
widget/gtk/nsDeviceContextSpecG.cpp
--- a/widget/gtk/nsDeviceContextSpecG.cpp
+++ b/widget/gtk/nsDeviceContextSpecG.cpp
@@ -290,18 +290,24 @@ nsDeviceContextSpecGTK::EnumeratePrinter
                          nullptr, TRUE);
 }
 
 NS_IMETHODIMP
 nsDeviceContextSpecGTK::BeginDocument(const nsAString& aTitle,
                                       const nsAString& aPrintToFileName,
                                       int32_t aStartPage, int32_t aEndPage)
 {
-  mTitle.Truncate();
-  AppendUTF16toUTF8(aTitle, mTitle);
+  // Print job names exceeding 255 bytes are safe with GTK version 3.18.2 or
+  // newer. This is a workaround for old GTK.
+  if (gtk_check_version(3,18,2) != nullptr) {
+    PrintTarget::AdjustPrintJobNameForIPP(aTitle, mTitle);
+  } else {
+    CopyUTF16toUTF8(aTitle, mTitle);
+  }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP nsDeviceContextSpecGTK::EndDocument()
 {
   if (mToPrinter) {
     // At this point, we might have a GtkPrinter set up in nsPrintSettingsGTK,
     // or we might not. In the single-process case, we probably will, as this