Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
befbbc2
commit 1eb4c8e
Showing
5 changed files
with
80 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
patches/chromium/fix_properly_honor_print_range_on_macos.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
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 print range on macOS | ||
|
||
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 06cdc0e1a4a50e29a148c97c964c30a939e800da..5db5cdb61be0beee4506313dcde46c499e011383 100644 | ||
--- a/printing/printing_context_mac.h | ||
+++ b/printing/printing_context_mac.h | ||
@@ -81,6 +81,10 @@ class PRINTING_EXPORT 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 56bcfbe625537c7b1bc2a999c261836bb15896ba..3965b877718160ce55e7c97d75e8992f45ac3f2f 100644 | ||
--- a/printing/printing_context_mac.mm | ||
+++ b/printing/printing_context_mac.mm | ||
@@ -188,7 +188,8 @@ PMPaper MatchPaper(CFArrayRef paper_list, | ||
!SetCopiesInPrintSettings(settings_->copies()) || | ||
!SetCollateInPrintSettings(settings_->collate()) || | ||
!SetDuplexModeInPrintSettings(settings_->duplex_mode()) || | ||
- !SetOutputColor(settings_->color())) { | ||
+ !SetOutputColor(settings_->color()) || | ||
+ !SetPrintRangeInPrintSettings(settings_->ranges()) ) { | ||
return OnError(); | ||
} | ||
} | ||
@@ -341,6 +342,22 @@ PMPaper MatchPaper(CFArrayRef paper_list, | ||
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_.get() 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_.get() PMPrintSettings]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters