diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/printing/printing_context_mac.mm | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/printing/printing_context_mac.mm')
-rw-r--r-- | chromium/printing/printing_context_mac.mm | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/chromium/printing/printing_context_mac.mm b/chromium/printing/printing_context_mac.mm index 3930c0ec050..93438609a3a 100644 --- a/chromium/printing/printing_context_mac.mm +++ b/chromium/printing/printing_context_mac.mm @@ -12,7 +12,6 @@ #include "base/check.h" #include "base/mac/scoped_cftyperef.h" -#include "base/memory/ptr_util.h" #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" @@ -27,7 +26,7 @@ const int kMaxPaperSizeDiffereceInPoints = 2; // Return true if PPD name of paper is equal. bool IsPaperNameEqual(CFStringRef name1, const PMPaper& paper2) { - CFStringRef name2 = NULL; + CFStringRef name2 = nullptr; return (name1 && PMPaperGetPPDPaperName(paper2, &name2) == noErr) && (CFStringCompare(name1, name2, kCFCompareCaseInsensitive) == kCFCompareEqualTo); @@ -38,7 +37,7 @@ PMPaper MatchPaper(CFArrayRef paper_list, double width, double height) { double best_match = std::numeric_limits<double>::max(); - PMPaper best_matching_paper = NULL; + PMPaper best_matching_paper = nullptr; int num_papers = CFArrayGetCount(paper_list); for (int i = 0; i < num_papers; ++i) { PMPaper paper = (PMPaper)[(NSArray*)paper_list objectAtIndex:i]; @@ -68,13 +67,13 @@ PMPaper MatchPaper(CFArrayRef paper_list, // static std::unique_ptr<PrintingContext> PrintingContext::Create(Delegate* delegate) { - return base::WrapUnique(new PrintingContextMac(delegate)); + return std::make_unique<PrintingContextMac>(delegate); } PrintingContextMac::PrintingContextMac(Delegate* delegate) : PrintingContext(delegate), print_info_([[NSPrintInfo sharedPrintInfo] copy]), - context_(NULL) {} + context_(nullptr) {} PrintingContextMac::~PrintingContextMac() { ReleaseContext(); @@ -97,7 +96,7 @@ void PrintingContextMac::AskUserForSettings(int max_pages, // adding a new custom view to the panel on 10.5; 10.6 has // NSPrintPanelShowsPrintSelection). NSPrintPanel* panel = [NSPrintPanel printPanel]; - NSPrintInfo* printInfo = print_info_.get(); + NSPrintInfo* print_info = print_info_.get(); NSPrintPanelOptions options = [panel options]; options |= NSPrintPanelShowsPaperSize; @@ -110,10 +109,10 @@ void PrintingContextMac::AskUserForSettings(int max_pages, if (parent_view) { NSString* job_title = [[parent_view.GetNativeNSView() window] title]; if (job_title) { - PMPrintSettings printSettings = - (PMPrintSettings)[printInfo PMPrintSettings]; - PMPrintSettingsSetJobName(printSettings, (CFStringRef)job_title); - [printInfo updateFromPMPrintSettings]; + PMPrintSettings print_settings = + (PMPrintSettings)[print_info PMPrintSettings]; + PMPrintSettingsSetJobName(print_settings, (CFStringRef)job_title); + [print_info updateFromPMPrintSettings]; } } @@ -126,7 +125,7 @@ void PrintingContextMac::AskUserForSettings(int max_pages, // after the current transaction. See https://crbug.com/849538. __block auto block_callback = std::move(callback); [CATransaction setCompletionBlock:^{ - NSInteger selection = [panel runModalWithPrintInfo:printInfo]; + NSInteger selection = [panel runModalWithPrintInfo:print_info]; if (selection == NSOKButton) { print_info_.reset([[panel printInfo] retain]); settings_->set_ranges(GetPageRangesFromPrintInfo()); @@ -209,7 +208,8 @@ bool PrintingContextMac::SetPrintPreviewJob() { PMPrintSettings print_settings = static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); return PMSessionSetDestination(print_session, print_settings, - kPMDestinationPreview, NULL, NULL) == noErr; + kPMDestinationPreview, nullptr, + nullptr) == noErr; } void PrintingContextMac::InitPrintSettingsFromPrintInfo() { @@ -262,7 +262,7 @@ bool PrintingContextMac::UpdatePageFormatWithPaperInfo() { PMPageFormat default_page_format = static_cast<PMPageFormat>([print_info_.get() PMPageFormat]); - PMPrinter current_printer = NULL; + PMPrinter current_printer = nullptr; if (PMSessionGetCurrentPrinter(print_session, ¤t_printer) != noErr) return false; @@ -281,7 +281,7 @@ bool PrintingContextMac::UpdatePageFormatWithPaperInfo() { } // Ignore result, because we can continue without following. - CFStringRef tmp_paper_name = NULL; + CFStringRef tmp_paper_name = nullptr; PMPaperGetPPDPaperName(default_paper, &tmp_paper_name); PMPaperGetMargins(default_paper, &margins); paper_name.reset(tmp_paper_name, base::scoped_policy::RETAIN); @@ -293,7 +293,7 @@ bool PrintingContextMac::UpdatePageFormatWithPaperInfo() { paper_name.reset(base::SysUTF8ToCFStringRef(media.vendor_id)); } - CFArrayRef paper_list = NULL; + CFArrayRef paper_list = nullptr; if (PMPrinterGetPaperList(current_printer, &paper_list) != noErr) return false; @@ -307,7 +307,7 @@ bool PrintingContextMac::UpdatePageFormatWithPaperInfo() { if (media.IsDefault()) return true; - PMPaper paper = NULL; + PMPaper paper = nullptr; if (PMPaperCreateCustom(current_printer, CFSTR("Custom paper ID"), CFSTR("Custom paper"), page_width, page_height, &margins, &paper) != noErr) { @@ -320,7 +320,7 @@ bool PrintingContextMac::UpdatePageFormatWithPaperInfo() { bool PrintingContextMac::UpdatePageFormatWithPaper(PMPaper paper, PMPageFormat page_format) { - PMPageFormat new_format = NULL; + PMPageFormat new_format = nullptr; if (PMCreatePageFormatWithPMPaper(&new_format, paper) != noErr) return false; // Copy over the original format with the new page format. @@ -334,15 +334,15 @@ bool PrintingContextMac::SetCopiesInPrintSettings(int copies) { if (copies < 1) return false; - PMPrintSettings pmPrintSettings = + PMPrintSettings print_settings = static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); - return PMSetCopies(pmPrintSettings, copies, false) == noErr; + return PMSetCopies(print_settings, copies, false) == noErr; } bool PrintingContextMac::SetCollateInPrintSettings(bool collate) { - PMPrintSettings pmPrintSettings = + PMPrintSettings print_settings = static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); - return PMSetCollate(pmPrintSettings, collate) == noErr; + return PMSetCollate(print_settings, collate) == noErr; } bool PrintingContextMac::SetOrientationIsLandscape(bool landscape) { @@ -379,13 +379,13 @@ bool PrintingContextMac::SetDuplexModeInPrintSettings(mojom::DuplexMode mode) { return true; } - PMPrintSettings pmPrintSettings = + PMPrintSettings print_settings = static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); - return PMSetDuplex(pmPrintSettings, duplexSetting) == noErr; + return PMSetDuplex(print_settings, duplexSetting) == noErr; } bool PrintingContextMac::SetOutputColor(int color_mode) { - PMPrintSettings pmPrintSettings = + PMPrintSettings print_settings = static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); std::string color_setting_name; std::string color_value; @@ -395,7 +395,7 @@ bool PrintingContextMac::SetOutputColor(int color_mode) { base::ScopedCFTypeRef<CFStringRef> output_color( base::SysUTF8ToCFStringRef(color_value)); - return PMPrintSettingsSetValue(pmPrintSettings, color_setting.get(), + return PMPrintSettingsSetValue(print_settings, color_setting.get(), output_color.get(), false) == noErr; } @@ -447,7 +447,7 @@ PrintingContext::Result PrintingContextMac::NewPage() { PMPageFormat page_format = static_cast<PMPageFormat>([print_info_.get() PMPageFormat]); OSStatus status; - status = PMSessionBeginPageNoDialog(print_session, page_format, NULL); + status = PMSessionBeginPageNoDialog(print_session, page_format, nullptr); if (status != noErr) return OnError(); status = PMSessionGetCGGraphicsContext(print_session, &context_); @@ -468,7 +468,7 @@ PrintingContext::Result PrintingContextMac::PageDone() { OSStatus status = PMSessionEndPageNoDialog(print_session); if (status != noErr) OnError(); - context_ = NULL; + context_ = nullptr; return OK; } @@ -491,7 +491,7 @@ PrintingContext::Result PrintingContextMac::DocumentDone() { void PrintingContextMac::Cancel() { abort_printing_ = true; in_print_job_ = false; - context_ = NULL; + context_ = nullptr; PMPrintSession print_session = static_cast<PMPrintSession>([print_info_.get() PMPrintSession]); @@ -500,7 +500,7 @@ void PrintingContextMac::Cancel() { void PrintingContextMac::ReleaseContext() { print_info_.reset(); - context_ = NULL; + context_ = nullptr; } printing::NativeDrawingContext PrintingContextMac::context() const { |