Bug 1401899 - Don't use the printer name which gets from NSPrintInfo for storing the printer settings on macOS. r?mconley draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 22 Sep 2017 12:33:03 +0900
changeset 668851 8bb28548b02cef1e7692de70dda15ec0eae2fea6
parent 668769 68b1c083356d77c81cb6f929165f7553b2835120
child 732791 6738fd5e9dc291635910308ce583155e15673bab
push id81139
push usermantaroh@gmail.com
push dateFri, 22 Sep 2017 03:33:50 +0000
Bug 1401899 - Don't use the printer name which gets from NSPrintInfo for storing the printer settings on macOS. r?mconley The print widget of cocoa doesn't have nsIPrinterEnumerator implementation, so gecko doesn't get the printer name correctly and gecko use default printer settings which named printer.print_** preference. If gecko use printer name which gets from NSPrintInfo, gecko will store current printer settings to the preference which related to printer name. So gecko doesn't apply previous printer settings to next print job. This patch will remove serialize/deserialize printer name for it. MozReview-Commit-ID: Kgjr3po73Kt
--- a/widget/cocoa/nsPrintOptionsX.mm
+++ b/widget/cocoa/nsPrintOptionsX.mm
@@ -67,21 +67,16 @@ nsPrintOptionsX::SerializeToPrintData(ns
   data->adjustedPaperWidth() = adjustedWidth;
   data->adjustedPaperHeight() = adjustedHeight;
   NSDictionary* dict = [printInfo dictionary];
   if (NS_WARN_IF(!dict)) {
     return NS_ERROR_FAILURE;
-  NSString* printerName = [dict objectForKey: NSPrintPrinterName];
-  if (printerName) {
-    nsCocoaUtils::GetStringForNSString(printerName, data->printerName());
-  }
   NSString* faxNumber = [dict objectForKey: NSPrintFaxNumber];
   if (faxNumber) {
     nsCocoaUtils::GetStringForNSString(faxNumber, data->faxNumber());
   NSURL* printToFileURL = [dict objectForKey: NSPrintJobSavingURL];
   if (printToFileURL) {
     nsCocoaUtils::GetStringForNSString([printToFileURL absoluteString],
@@ -174,25 +169,16 @@ nsPrintOptionsX::DeserializeToPrintSetti
   // We need to create a new NSMutableDictionary to pass to NSPrintInfo with
   // the values that we got from the other process.
   NSMutableDictionary* newPrintInfoDict =
     [NSMutableDictionary dictionaryWithDictionary:sharedDict];
   if (NS_WARN_IF(!newPrintInfoDict)) {
-  NSString* printerName = nsCocoaUtils::ToNSString(data.printerName());
-  if (printerName) {
-    NSPrinter* printer = [NSPrinter printerWithName: printerName];
-    if (printer) {
-      [newPrintInfoDict setObject: printer forKey: NSPrintPrinter];
-      [newPrintInfoDict setObject: printerName forKey: NSPrintPrinterName];
-    }
-  }
   [newPrintInfoDict setObject: [NSNumber numberWithInt: data.numCopies()]
                     forKey: NSPrintCopies];
   [newPrintInfoDict setObject: [NSNumber numberWithBool: data.printAllPages()]
                     forKey: NSPrintAllPages];
   [newPrintInfoDict setObject: [NSNumber numberWithInt: data.startPageRange()]
                     forKey: NSPrintFirstPage];
   [newPrintInfoDict setObject: [NSNumber numberWithInt: data.endPageRange()]
                     forKey: NSPrintLastPage];