Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Unified Diff: chrome/browser/printing/pdf_to_emf_converter.cc

Issue 2714073002: Eliminate PS printing edge cases (Closed)
Patch Set: Fix compile errors Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/printing/pdf_to_emf_converter.cc
diff --git a/chrome/browser/printing/pdf_to_emf_converter.cc b/chrome/browser/printing/pdf_to_emf_converter.cc
index f5066dc429f9543446f777ba40154f476c7c4ada..3aeefb11be168a2bf377356d5fefb0c223d54844 100644
--- a/chrome/browser/printing/pdf_to_emf_converter.cc
+++ b/chrome/browser/printing/pdf_to_emf_converter.cc
@@ -364,6 +364,14 @@ bool PostScriptMetaFile::SafePlayback(HDC hdc) const {
{
// Ensure enumerator destruction before calling Close() below.
Emf::Enumerator emf_enum(emf, nullptr, nullptr);
+
+ // Check if postscript passthrough is supported. Use normal passthrough if
+ // it is not.
+ DWORD escape = POSTSCRIPT_PASSTHROUGH;
+ const char* ptr = reinterpret_cast<const char*>(&escape);
+ bool postscript_passthrough =
Lei Zhang 2017/02/25 03:03:35 int passthrough = ExtEscape(hdc, QUERYESCSUPPORT,
+ ExtEscape(hdc, QUERYESCSUPPORT, sizeof(escape), ptr, 0, nullptr) > 0;
+
for (const Emf::Record& record : emf_enum) {
auto* emf_record = record.record();
if (emf_record->iType != EMR_GDICOMMENT)
@@ -373,8 +381,13 @@ bool PostScriptMetaFile::SafePlayback(HDC hdc) const {
reinterpret_cast<const EMRGDICOMMENT*>(emf_record);
const char* data = reinterpret_cast<const char*>(comment->Data);
const uint16_t* ptr = reinterpret_cast<const uint16_t*>(data);
- int ret =
- ExtEscape(hdc, POSTSCRIPT_PASSTHROUGH, 2 + *ptr, data, 0, nullptr);
+ int ret = 0;
+ if (postscript_passthrough) {
+ ret =
+ ExtEscape(hdc, POSTSCRIPT_PASSTHROUGH, 2 + *ptr, data, 0, nullptr);
+ } else {
+ ret = ExtEscape(hdc, PASSTHROUGH, 2 + *ptr, data, 0, nullptr);
+ }
DCHECK_EQ(*ptr, ret);
}
}
« no previous file with comments | « no previous file | chrome/browser/printing/print_job_worker.cc » ('j') | printing/print_settings_initializer_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698