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:41:21 +0900
changeset 668856 f0e29cb868dd9aa819eb65c4faa90746e23f6f11
parent 668769 68b1c083356d77c81cb6f929165f7553b2835120
child 732793 789e92f75d3cbb8a260f63759dee79b6d380e90a
push id81141
push usermantaroh@gmail.com
push dateFri, 22 Sep 2017 03:45:45 +0000
reviewersmconley
bugs1401899
milestone58.0a1
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 global printer settings which are named print.print_** preference. If gecko use printer name which gets from NSPrintInfo, the gecko will store current printer settings to the preference which is related to the printer name. (i.e. print.<printer_name>.print_**) So the gecko doesn't apply previous printer settings to next print job. This patch will remove serialize/deserialize printer name in order to use global printer settings. MozReview-Commit-ID: Kgjr3po73Kt
widget/cocoa/nsPrintOptionsX.mm
--- 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)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  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];