mirror of
https://github.com/electron/electron.git
synced 2026-01-06 22:24:03 -05:00
* chore: bump chromium in DEPS to 144.0.7504.0
* chore: bump chromium in DEPS to 144.0.7506.0
* chore: update patches
* Revert "build: explicitly disable reclient"
This reverts commit e08c6adb08.
No longer needed after https://crrev.com/c/7099239
* 7097498: Remove MSG_ROUTING_* constants from ipc_message.h
https://chromium-review.googlesource.com/c/chromium/src/+/7097498
* 7090671: [//gpu] Remove unneeded GpuInfo methods
https://chromium-review.googlesource.com/c/chromium/src/+/7090671
* 7103701: Remove IPC::PlatformFileForTransit.
https://chromium-review.googlesource.com/c/chromium/src/+/7103701
(This should have been removed with https://github.com/electron/electron/pull/17406).
* chore: update filenames.libcxx.gni
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
150 lines
6.3 KiB
Diff
150 lines
6.3 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 a8afc92f4894f32774573920271f1eb7c47822c2..963ad79fb4b46e048a36e1b7e696f7e0d26ed151 100644
|
|
--- a/printing/printing_context_mac.mm
|
|
+++ b/printing/printing_context_mac.mm
|
|
@@ -544,7 +544,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();
|
|
}
|
|
}
|
|
@@ -697,6 +698,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 f8e903f21cee7041dea67b479c298baf9093d719..ed5d59f29992b0925efd89cb0ac4b33a03a31788 100644
|
|
--- a/printing/printing_context_system_dialog_win.cc
|
|
+++ b/printing/printing_context_system_dialog_win.cc
|
|
@@ -4,10 +4,12 @@
|
|
|
|
#include "printing/printing_context_system_dialog_win.h"
|
|
|
|
+#include <algorithm>
|
|
#include <utility>
|
|
|
|
#include "base/auto_reset.h"
|
|
#include "base/compiler_specific.h"
|
|
+#include "base/containers/span.h"
|
|
#include "base/strings/utf_string_conversions.h"
|
|
#include "base/task/current_thread.h"
|
|
#include "printing/backend/win_helper.h"
|
|
@@ -74,13 +76,28 @@ void PrintingContextSystemDialogWin::AskUserForSettings(
|
|
PRINTPAGERANGE ranges[32] = {};
|
|
dialog_options.nStartPage = START_PAGE_GENERAL;
|
|
if (max_pages) {
|
|
- // Default initialize to print all the pages.
|
|
- ranges[0].nFromPage = 1;
|
|
- ranges[0].nToPage = max_pages;
|
|
- dialog_options.nPageRanges = 1;
|
|
- dialog_options.nMaxPageRanges = std::size(ranges);
|
|
+ if (const auto& src = settings_->ranges(); !src.empty()) {
|
|
+ const auto transform = [](const printing::PageRange& range) {
|
|
+ return PRINTPAGERANGE{
|
|
+ .nFromPage = range.from + 1U,
|
|
+ .nToPage = range.to + 1U
|
|
+ };
|
|
+ };
|
|
+ const size_t n_items = std::min(std::size(src), std::size(ranges));
|
|
+ std::ranges::transform(base::span(src).first(n_items), ranges, transform);
|
|
+ dialog_options.nPageRanges = n_items;
|
|
+
|
|
+ // 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 987b7a034621fd854148ffb1161749748c6f3fa4..525dadb85d23865b0d401e7feca60959b8596097 100644
|
|
--- a/ui/gtk/printing/print_dialog_gtk.cc
|
|
+++ b/ui/gtk/printing/print_dialog_gtk.cc
|
|
@@ -20,6 +20,7 @@
|
|
#include "base/logging.h"
|
|
#include "base/memory/raw_ptr.h"
|
|
#include "base/no_destructor.h"
|
|
+#include "base/numerics/safe_conversions.h"
|
|
#include "base/sequence_checker.h"
|
|
#include "base/strings/string_number_conversions.h"
|
|
#include "base/strings/utf_string_conversions.h"
|
|
@@ -253,6 +254,22 @@ void PrintDialogGtk::UpdateSettings(
|
|
|
|
gtk_print_settings_set_n_copies(gtk_settings_, settings->copies());
|
|
gtk_print_settings_set_collate(gtk_settings_, settings->collate());
|
|
+
|
|
+ if (const auto& ranges = settings->ranges(); !ranges.empty()) {
|
|
+ // Tell the system that we only intend to print a subset of pages.
|
|
+ std::vector<GtkPageRange> granges;
|
|
+ granges.reserve(ranges.size());
|
|
+ auto transform = [](const printing::PageRange& src) {
|
|
+ return GtkPageRange{
|
|
+ .start = base::ClampedNumeric<int>(src.from),
|
|
+ .end = base::ClampedNumeric<int>(src.to),
|
|
+ };
|
|
+ };
|
|
+ std::ranges::transform(ranges, std::back_inserter(granges), transform);
|
|
+ gtk_print_settings_set_print_pages(gtk_settings_, GTK_PRINT_PAGES_RANGES);
|
|
+ gtk_print_settings_set_page_ranges(gtk_settings_, granges.data(), granges.size());
|
|
+ }
|
|
+
|
|
if (settings->dpi_horizontal() > 0 && settings->dpi_vertical() > 0) {
|
|
gtk_print_settings_set_resolution_xy(
|
|
gtk_settings_, settings->dpi_horizontal(), settings->dpi_vertical());
|