Bug 1659112, hide copies section if saving to PDF or using save to file printer. r=mstriemer
authorEmma Malysz <emalysz@mozilla.com>
Wed, 26 Aug 2020 23:07:39 +0000
changeset 546376 5099104ea5ee71d7069c797542e08895307affed
parent 546375 9e46a64e1a7a089ff14f66c1d3cba66bd7fbf29d
child 546377 20d40fcc3f751c7a7517fb691dc4e611872f2d76
push id37734
push userccoroiu@mozilla.com
push dateThu, 27 Aug 2020 09:30:43 +0000
treeherdermozilla-central@44ee384376ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstriemer
bugs1659112
milestone82.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 1659112, hide copies section if saving to PDF or using save to file printer. r=mstriemer Differential Revision: https://phabricator.services.mozilla.com/D88104
toolkit/components/printing/content/print.js
--- a/toolkit/components/printing/content/print.js
+++ b/toolkit/components/printing/content/print.js
@@ -526,16 +526,36 @@ const PrintSettingsViewProxy = {
     footerStrCenter: "print.print_footercenter",
     footerStrLeft: "print.print_footerleft",
     footerStrRight: "print.print_footerright",
     headerStrCenter: "print.print_headercenter",
     headerStrLeft: "print.print_headerleft",
     headerStrRight: "print.print_headerright",
   },
 
+  // This list was taken from nsDeviceContextSpecWin.cpp which records telemetry on print target type
+  knownSaveToFilePrinters: new Set([
+    "Microsoft Print to PDF",
+    "Adobe PDF",
+    "Bullzip PDF Printer",
+    "CutePDF Writer",
+    "doPDF",
+    "Foxit Reader PDF Printer",
+    "Nitro PDF Creator",
+    "novaPDF",
+    "PDF-XChange",
+    "PDF24 PDF",
+    "PDFCreator",
+    "PrimoPDF",
+    "Soda PDF",
+    "Solid PDF Creator",
+    "Universal Document Converter",
+    "Microsoft XPS Document Writer",
+  ]),
+
   async resolvePropertiesForPrinter(printerName) {
     // resolve any async properties we need on the printer
     let printer = this.availablePrinters[printerName];
     // Await the async printer data.
     if (printer.printer) {
       [printer.supportsColor, printer.paperList] = await Promise.all([
         printer.printer.supportsColor,
         printer.printer.paperList,
@@ -578,16 +598,22 @@ const PrintSettingsViewProxy = {
 
       case "printAllOrCustomRange":
         return target.printRange == Ci.nsIPrintSettings.kRangeAllPages
           ? "all"
           : "custom";
 
       case "supportsColor":
         return this.availablePrinters[target.printerName].supportsColor;
+
+      case "willSaveToFile":
+        return (
+          target.outputFormat == Ci.nsIPrintSettings.kOutputFormatPDF ||
+          this.knownSaveToFilePrinters.has(target.printerName)
+        );
     }
     return target[name];
   },
 
   set(target, name, value) {
     switch (name) {
       case "margins":
         if (!["default", "minimum", "none"].includes(value)) {
@@ -828,16 +854,17 @@ class PrintUIForm extends PrintUIControl
     this.addEventListener("click", this);
     this.addEventListener("input", this);
   }
 
   update(settings) {
     this.querySelector("#system-print").hidden =
       settings.printerName == PrintUtils.SAVE_TO_PDF_PRINTER &&
       AppConstants.platform != "macosx";
+    this.querySelector("#copies").hidden = settings.willSaveToFile;
   }
 
   handleEvent(e) {
     if (e.target.id == "open-dialog-link") {
       this.dispatchEvent(new Event("open-system-dialog", { bubbles: true }));
       return;
     }