Commit d362d859 authored by Jonathan Watt's avatar Jonathan Watt
Browse files

Bug 1769129. Remove nsIPrintSettings.isPrintSelectionRBEnabled. r=emilio

nsIPrintSettings is supposed to be a collection of settings passed to the
platform code to determine how the document prints. The
isPrintSelectionRBEnabled member doesn't belong here since it is a flag that
is passed to the OS native print settings dialog to tell it whether to
display a "Print selection only" radio button.

Differential Revision: https://phabricator.services.mozilla.com/D146251
parent 154323f3
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -562,10 +562,6 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
    }
  }

  // Now determine how to set up the Frame print UI
  printData->mPrintSettings->SetIsPrintSelectionRBEnabled(
      !mDisallowSelectionPrint && printData->mSelectionRoot);

  bool printingViaParent =
      XRE_IsContentProcess() && StaticPrefs::print_print_via_parent();
  nsCOMPtr<nsIDeviceContextSpec> devspec;
+17 −9
Original line number Diff line number Diff line
@@ -298,9 +298,6 @@ var PrintEventHandler = {
        this.settings.printerName == PrintUtils.SAVE_TO_PDF_PRINTER
          ? PrintUtils.getPrintSettings(this.viewSettings.defaultSystemPrinter)
          : this.settings.clone();
      // Update the settings print options on whether there is a selection since
      // getPrintSettings won't have the correct value.
      settings.isPrintSelectionRBEnabled = this.hasSelection;
      // We set the title so that if the user chooses save-to-PDF from the
      // system dialog the title will be used to generate the prepopulated
      // filename in the file picker.
@@ -313,7 +310,12 @@ var PrintEventHandler = {
          "printing.dialog_opened_via_preview_tm",
          1
        );
        await this._showPrintDialog(PRINTDIALOGSVC, window, settings);
        await this._showPrintDialog(
          PRINTDIALOGSVC,
          window,
          this.hasSelection,
          settings
        );
      } catch (e) {
        if (e.result == Cr.NS_ERROR_ABORT) {
          Services.telemetry.scalarAdd(
@@ -844,9 +846,6 @@ var PrintEventHandler = {
      this.updatePrintPreview();
    }

    // Update the settings print options on whether there is a selection.
    settings.isPrintSelectionRBEnabled = this.hasSelection;

    document.dispatchEvent(
      new CustomEvent("page-count", {
        detail: { sheetCount, totalPages: totalPageCount },
@@ -1007,8 +1006,17 @@ var PrintEventHandler = {
   * testing purposes. The showPrintDialog() call blocks until the dialog is
   * closed, so we mark it as async to allow us to reject from the test.
   */
  async _showPrintDialog(aPrintDialogService, aWindow, aSettings) {
    return aPrintDialogService.showPrintDialog(aWindow, aSettings);
  async _showPrintDialog(
    aPrintDialogService,
    aWindow,
    aHaveSelection,
    aSettings
  ) {
    return aPrintDialogService.showPrintDialog(
      aWindow,
      aHaveSelection,
      aSettings
    );
  },
};

+5 −2
Original line number Diff line number Diff line
@@ -330,14 +330,17 @@ var PrintUtils = {
        const hasSelection = await PrintUtils.checkForSelection(
          browsingContext
        );
        settings.isPrintSelectionRBEnabled = hasSelection;

        // Prompt the user to choose a printer and make any desired print
        // settings changes.
        try {
          await Cc["@mozilla.org/widget/printdialog-service;1"]
            .getService(Ci.nsIPrintDialogService)
            .showPrintDialog(browsingContext.topChromeWindow, settings);
            .showPrintDialog(
              browsingContext.topChromeWindow,
              hasSelection,
              settings
            );
        } catch (e) {
          if (browser) {
            browser.remove(); // don't leak this
+5 −3
Original line number Diff line number Diff line
@@ -233,9 +233,11 @@ add_task(async function open_system_print_with_selection_and_pdf() {
        helper.resolvePrint();
      });

      helper.assertPrintedWithSettings({
        isPrintSelectionRBEnabled: true,
      });
      ok(
        helper.systemDialogOpenedWithSelection,
        "Expect system print dialog to be notified of selection"
      );

      PrintHelper.resetPrintPrefs();
    }
  );
+8 −1
Original line number Diff line number Diff line
@@ -252,7 +252,14 @@ class PrintHelper {
    });

    // Mock PrintEventHandler with our Promises.
    this.win.PrintEventHandler._showPrintDialog = () => showSystemDialogPromise;
    this.win.PrintEventHandler._showPrintDialog = (
      dialogSvc,
      haveSelection,
      settings
    ) => {
      this.systemDialogOpenedWithSelection = haveSelection;
      return showSystemDialogPromise;
    };
    this.win.PrintEventHandler._doPrint = (bc, settings) => {
      this._printedSettings = settings;
      return printPromise;
Loading