mirror of
https://github.com/electron/electron.git
synced 2026-01-06 22:24:03 -05:00
* chore: bump chromium in DEPS to 117.0.5929.0 * chore: bump chromium in DEPS to 117.0.5931.0 * chore: bump chromium in DEPS to 117.0.5932.0 * chore: update patches * 4728317: Prevent PrintRenderFrameHelper from printing when already printing | https://chromium-review.googlesource.com/c/chromium/src/+/4728317 * 4739501: Use base::SequenceBound to manage SerialPortManagerImpl | https://chromium-review.googlesource.com/c/chromium/src/+/4739501 * 4702051: Allow overriding source in install-sysroot.py | https://chromium-review.googlesource.com/c/chromium/src/+/4702051 * chore: update filenames.libcxx.gni * 4727002: Rename "enable_arc2" to "enable_arc" | https://chromium-review.googlesource.com/c/chromium/src/+/4727002 * chore: bump chromium in DEPS to 117.0.5934.0 * 4736873: Rename ColorSpaces methods on display::Display | https://chromium-review.googlesource.com/c/chromium/src/+/4736873 * 4727203: Replace bool with an enum in as suggested in DevtoolsManagerDelegate. | https://chromium-review.googlesource.com/c/chromium/src/+/4727203 * 4744479: [DevTools] Add 'generateTaggedPDF' option to DevTools Page.printToPDF | https://chromium-review.googlesource.com/c/chromium/src/+/4744479 * 4735893: Don't share WebUSB permissions with webviews | https://chromium-review.googlesource.com/c/chromium/src/+/4735893 * revert: update filenames.libcxx.gni * chore: bump chromium in DEPS to 117.0.5936.0 * chore: update patches * 4746465: SAA: Query for embargoed StorageAccess permissions | https://chromium-review.googlesource.com/c/chromium/src/+/4746465 * 4666325: Move buildtools/third_party/lib*/trunk source paths to third_party/lib*/src. | https://chromium-review.googlesource.com/c/chromium/src/+/4666325 * chore: bump chromium in DEPS to 117.0.5938.0 * chore: bump chromium in DEPS to 118.0.5939.0 * chore: update patches * Send line bounds through CursorAnchorInfo on requestCursorUpdate https://chromium-review.googlesource.com/c/chromium/src/+/4394588 * Fixup lint for Move buildtools/third_party/lib*/trunk source paths to third_party/lib*/src * 4700305: [mac] Fix override of CHILD_PROCESS_EXE https://chromium-review.googlesource.com/c/chromium/src/+/4700305 Needed because of 4729689: Reland "Remove redundant existence check in PathService" | https://chromium-review.googlesource.com/c/chromium/src/+/4729689 * 4753759: More consistent icon handling for menus. https://chromium-review.googlesource.com/c/chromium/src/+/4753759 * chore: bump chromium in DEPS to 118.0.5941.0 * chore: update patches * chore: bump chromium in DEPS to 117.0.5938.0 * test: update nan-spec-runner cflags * build: fix isystem include path in nan-spec-runner * fixup! 4666325: Move buildtools/third_party/lib*/trunk source paths to third_party/lib*/src. | https://chromium-review.googlesource.com/c/chromium/src/+/4666325 fix a few more instances of the old path libc++.a and libc++abi.a are still in buildtools/ --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: VerteDinde <vertedinde@electronjs.org> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: Charles Kerr <charles@charleskerr.com>
131 lines
5.5 KiB
Diff
131 lines
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Shelley Vohr <shelley.vohr@gmail.com>
|
|
Date: Thu, 20 Aug 2020 10:55:48 -0700
|
|
Subject: fix: properly honor printing page ranges
|
|
|
|
The print ranges in Chromium's print job settings were not being properly
|
|
plumbed through to PMPrintSettings on mcOS. This fixes that by setting
|
|
them should they exist.
|
|
|
|
This will be upstreamed.
|
|
|
|
diff --git a/printing/printing_context_mac.h b/printing/printing_context_mac.h
|
|
index c9a13aee1e64f359cd1d5c2e440b4df204420997..7790c311400fc84bfda6c99e1ebd8da728031a77 100644
|
|
--- a/printing/printing_context_mac.h
|
|
+++ b/printing/printing_context_mac.h
|
|
@@ -84,6 +84,10 @@ class COMPONENT_EXPORT(PRINTING) PrintingContextMac : public PrintingContext {
|
|
// Returns true if the orientation was set.
|
|
bool SetOrientationIsLandscape(bool landscape);
|
|
|
|
+ // Set the page range in native print info object.
|
|
+ // Returns true if the range was set.
|
|
+ bool SetPrintRangeInPrintSettings(const PageRanges& ranges);
|
|
+
|
|
// Sets duplex mode in PMPrintSettings.
|
|
// Returns true if duplex mode is set.
|
|
bool SetDuplexModeInPrintSettings(mojom::DuplexMode mode);
|
|
diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm
|
|
index 010c7ed3025172e1e5a60fb7c89c3ea7a38c3ba5..ce13929c3b9205b71eeae32aad89c92f00d6c8c0 100644
|
|
--- a/printing/printing_context_mac.mm
|
|
+++ b/printing/printing_context_mac.mm
|
|
@@ -209,7 +209,8 @@ bool IsIppColorModelColorful(mojom::ColorModel color_model) {
|
|
!SetCollateInPrintSettings(settings_->collate()) ||
|
|
!SetDuplexModeInPrintSettings(settings_->duplex_mode()) ||
|
|
!SetOutputColor(static_cast<int>(settings_->color())) ||
|
|
- !SetResolution(settings_->dpi_size())) {
|
|
+ !SetResolution(settings_->dpi_size()) ||
|
|
+ !SetPrintRangeInPrintSettings(settings_->ranges()) ) {
|
|
return OnError();
|
|
}
|
|
}
|
|
@@ -362,6 +363,22 @@ bool IsIppColorModelColorful(mojom::ColorModel color_model) {
|
|
return PMSetCopies(print_settings, copies, false) == noErr;
|
|
}
|
|
|
|
+bool PrintingContextMac::SetPrintRangeInPrintSettings(const PageRanges& ranges) {
|
|
+ // Default is already NSPrintAllPages - we can safely bail.
|
|
+ if (ranges.empty())
|
|
+ return true;
|
|
+
|
|
+ PMPrintSettings print_settings =
|
|
+ static_cast<PMPrintSettings>([print_info_ PMPrintSettings]);
|
|
+
|
|
+ // macOS does not allow multiple ranges, so pluck the first.
|
|
+ auto range = ranges.front();
|
|
+ bool set_first_page = PMSetFirstPage(print_settings, range.from + 1, false) == noErr;
|
|
+ bool set_last_page = PMSetLastPage(print_settings, range.to + 1, false) == noErr;
|
|
+
|
|
+ return set_first_page && set_last_page;
|
|
+}
|
|
+
|
|
bool PrintingContextMac::SetCollateInPrintSettings(bool collate) {
|
|
PMPrintSettings print_settings =
|
|
static_cast<PMPrintSettings>([print_info_ PMPrintSettings]);
|
|
diff --git a/printing/printing_context_system_dialog_win.cc b/printing/printing_context_system_dialog_win.cc
|
|
index 07847521e7217c78480205812a73cc89503c00d2..586e866ca7ec0eb0b573d23e3bd95792c22bff20 100644
|
|
--- a/printing/printing_context_system_dialog_win.cc
|
|
+++ b/printing/printing_context_system_dialog_win.cc
|
|
@@ -75,14 +75,28 @@ void PrintingContextSystemDialogWin::AskUserForSettings(
|
|
PRINTPAGERANGE ranges[32];
|
|
dialog_options.nStartPage = START_PAGE_GENERAL;
|
|
if (max_pages) {
|
|
- // Default initialize to print all the pages.
|
|
memset(ranges, 0, sizeof(ranges));
|
|
- ranges[0].nFromPage = 1;
|
|
- ranges[0].nToPage = max_pages;
|
|
- dialog_options.nPageRanges = 1;
|
|
- dialog_options.nMaxPageRanges = std::size(ranges);
|
|
+
|
|
+ auto page_ranges = settings_->ranges();
|
|
+ if (!page_ranges.empty()) {
|
|
+ for (size_t i = 0; i < page_ranges.size(); i++) {
|
|
+ auto range = page_ranges[i];
|
|
+ ranges[i].nFromPage = range.from + 1;
|
|
+ ranges[i].nToPage = range.to + 1;
|
|
+ }
|
|
+ dialog_options.nPageRanges = page_ranges.size();
|
|
+
|
|
+ // Ensure the Pages radio button is selected.
|
|
+ dialog_options.Flags |= PD_PAGENUMS;
|
|
+ } else {
|
|
+ ranges[0].nFromPage = 1;
|
|
+ ranges[0].nToPage = max_pages;
|
|
+ dialog_options.nPageRanges = 1;
|
|
+ }
|
|
+
|
|
dialog_options.nMinPage = 1;
|
|
dialog_options.nMaxPage = max_pages;
|
|
+ dialog_options.nMaxPageRanges = std::size(ranges);
|
|
dialog_options.lpPageRanges = ranges;
|
|
} else {
|
|
// No need to bother, we don't know how many pages are available.
|
|
diff --git a/ui/gtk/printing/print_dialog_gtk.cc b/ui/gtk/printing/print_dialog_gtk.cc
|
|
index afa936ce95602d5e66189303a73d7824611187b3..89371a4f0d3216f21761adc51bdd2accec0c74a1 100644
|
|
--- a/ui/gtk/printing/print_dialog_gtk.cc
|
|
+++ b/ui/gtk/printing/print_dialog_gtk.cc
|
|
@@ -247,6 +247,24 @@ void PrintDialogGtk::UpdateSettings(
|
|
|
|
gtk_print_settings_set_n_copies(gtk_settings_, settings->copies());
|
|
gtk_print_settings_set_collate(gtk_settings_, settings->collate());
|
|
+
|
|
+ auto print_ranges = settings->ranges();
|
|
+ if (!print_ranges.empty()) {
|
|
+ // Tell the system that we only intend to print a subset of pages.
|
|
+ gtk_print_settings_set_print_pages(gtk_settings_, GTK_PRINT_PAGES_RANGES);
|
|
+
|
|
+ GtkPageRange* ranges;
|
|
+ ranges = g_new(GtkPageRange, print_ranges.size());
|
|
+ for (size_t i = 0; i < print_ranges.size(); i++) {
|
|
+ auto range = print_ranges[i];
|
|
+ ranges[i].start = range.from;
|
|
+ ranges[i].end = range.to;
|
|
+ }
|
|
+
|
|
+ gtk_print_settings_set_page_ranges(gtk_settings_, ranges, 1);
|
|
+ g_free(ranges);
|
|
+ }
|
|
+
|
|
if (settings->dpi_horizontal() > 0 && settings->dpi_vertical() > 0) {
|
|
gtk_print_settings_set_resolution_xy(
|
|
gtk_settings_, settings->dpi_horizontal(), settings->dpi_vertical());
|