mirror of
https://github.com/electron/electron.git
synced 2026-01-08 23:18:06 -05:00
* chore: bump chromium in DEPS to 140.0.7269.2 * chore: bump chromium in DEPS to 140.0.7270.0 * chore: bump chromium in DEPS to 140.0.7271.0 * chore: bump chromium in DEPS to 140.0.7273.0 * 6516731: [ExclusiveAccessForAndroid] remove unneeded includes & deps | https://chromium-review.googlesource.com/c/chromium/src/+/6516731 * 6694809: dbus: Ensure systemd scope is started before using any portal services | https://chromium-review.googlesource.com/c/chromium/src/+/6694809 * chore: patch chromium * chore: export patches * chore: bump chromium in DEPS to 140.0.7275.0 * 6677511: [pepper] More pepper removal | https://chromium-review.googlesource.com/c/chromium/src/+/6677511 * 6513641: [gin] Rename gin::Wrappable to gin::DeprecatedWrappable | https://chromium-review.googlesource.com/c/chromium/src/+/6513641 * chore: export chromium patches * 6513641: [gin] Rename gin::Wrappable to gin::DeprecatedWrappable | https://chromium-review.googlesource.com/c/chromium/src/+/6513641 * chore: bump chromium in DEPS to 140.0.7277.0 * chore: bump chromium in DEPS to 140.0.7279.0 * chore: bump chromium in DEPS to 140.0.7281.0 * 6677314: Plumb enabled client hints in the network requestion to network layer https://chromium-review.googlesource.com/c/chromium/src/+/6677314 * 6351556: [source-phase-imports] Support Wasm Source Phase Imports https://chromium-review.googlesource.com/c/chromium/src/+/6351556 * 6700077: [renderer] Avoid calls to deprecated GetIsolate methods https://chromium-review.googlesource.com/c/chromium/src/+/6700077 * 6692873: Reland "Reland "FSA: Only normalize the hardcoded rules once during initialization"" https://chromium-review.googlesource.com/c/chromium/src/+/6692873 * 6686234: [gin] Cleanup NamedPropertyInterceptor for Wrappable https://chromium-review.googlesource.com/c/chromium/src/+/6686234 * chore: export patches * 6667723: Remove content_enable_legacy_ipc GN arg. https://chromium-review.googlesource.com/c/chromium/src/+/6667723 * 6646566: ui: Move NativeWindowTracker to its own directory https://chromium-review.googlesource.com/c/chromium/src/+/6646566 * fix: add missing includes * 6580522: [WAR, DNR] Fix unsafe redirect error to web accessible resource https://chromium-review.googlesource.com/c/chromium/src/+/6580522 * 6680477: Implement `completeCode` endpoint and expose to DevTools https://chromium-review.googlesource.com/c/chromium/src/+/6680477 * 6677511: [pepper] More pepper removal https://chromium-review.googlesource.com/c/chromium/src/+/6677511 * 6696689: Rename views::WidgetFocusManager -> NativeViewFocusManager https://chromium-review.googlesource.com/c/chromium/src/+/6696689 * 6702812: Move wtf/text/string_impl*.* to "blink" namespace https://chromium-review.googlesource.com/c/chromium/src/+/6702812 * chore: fix dialog patch * 6702431: [animation-trigger] Parse timeline-trigger-name https://chromium-review.googlesource.com/c/chromium/src/+/6702431 * chore: fixup patch indices * feat: replace webFrame.routingId with webFrame.frameToken * feat: WebFrameMain.prototype.frameToken * test: refactor to use replacement APIs * chore: fixup pip patch * test: adjust webFrame tests for frameToken changes * 6703757: Reland "Enable -fsanitize=array-bounds in non-UBSan builds" https://chromium-review.googlesource.com/c/chromium/src/+/6703757 * test: switch to frameTokens * test: routingId is fine to test in the main process * docs: add routingId to breaking changes * docs: update plugin-crashed event * chore: fixup linux dialog patch --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: alice <alice@makenotion.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
133 lines
5.6 KiB
Diff
133 lines
5.6 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 8be4ca70ff71cfc33cd812ec0cc9ae8155538532..f7985331838387232b27e557e435113479dbb780 100644
|
|
--- a/printing/printing_context_mac.h
|
|
+++ b/printing/printing_context_mac.h
|
|
@@ -85,6 +85,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 b504350cb53273d1db7204771ae080647fe6b878..8fdf6a14d0913aca8f14c412c4afae3ad7ec37e5 100644
|
|
--- a/printing/printing_context_mac.mm
|
|
+++ b/printing/printing_context_mac.mm
|
|
@@ -522,7 +522,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();
|
|
}
|
|
}
|
|
@@ -675,6 +676,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 2808248f6eb3f5c75f20775d61c9d0d20aaaecf6..7c186bd5653e9bdf1c4046398b138cac09112d42 100644
|
|
--- a/printing/printing_context_system_dialog_win.cc
|
|
+++ b/printing/printing_context_system_dialog_win.cc
|
|
@@ -74,14 +74,30 @@ void PrintingContextSystemDialogWin::AskUserForSettings(
|
|
PRINTPAGERANGE ranges[32];
|
|
dialog_options.nStartPage = START_PAGE_GENERAL;
|
|
if (max_pages) {
|
|
- // Default initialize to print all the pages.
|
|
UNSAFE_TODO(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()) {
|
|
+ UNSAFE_TODO({
|
|
+ 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 41a84930fac9cfa6d2534c96ff19c00fccbe4640..41f5e75c39e79c26e894abc1fd93b84a6a21e04a 100644
|
|
--- a/ui/gtk/printing/print_dialog_gtk.cc
|
|
+++ b/ui/gtk/printing/print_dialog_gtk.cc
|
|
@@ -257,6 +257,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());
|