Index: printing/emf_win.cc |
diff --git a/printing/emf_win.cc b/printing/emf_win.cc |
index 5497495af5d35f238f82482fd43dc603a1f05b6d..f042b2997f73a41fa89447401710c04ceae0520c 100644 |
--- a/printing/emf_win.cc |
+++ b/printing/emf_win.cc |
@@ -21,22 +21,6 @@ |
namespace { |
-const int kCustomGdiCommentSignature = 0xdeadbabe; |
-struct PageBreakRecord { |
- int signature; |
- enum PageBreakType { |
- START_PAGE, |
- END_PAGE, |
- } type; |
- explicit PageBreakRecord(PageBreakType type_in) |
- : signature(kCustomGdiCommentSignature), type(type_in) { |
- } |
- bool IsValid() const { |
- return (signature == kCustomGdiCommentSignature) && |
- (type >= START_PAGE) && (type <= END_PAGE); |
- } |
-}; |
- |
int CALLBACK IsAlphaBlendUsedEnumProc(HDC, |
HANDLETABLE*, |
const ENHMETARECORD *record, |
@@ -166,7 +150,7 @@ bool DIBFormatNativelySupported(HDC dc, uint32 escape, const BYTE* bits, |
return !!supported; |
} |
-Emf::Emf() : emf_(NULL), hdc_(NULL), page_count_(0) { |
+Emf::Emf() : emf_(NULL), hdc_(NULL) { |
} |
Emf::~Emf() { |
@@ -236,8 +220,10 @@ bool Emf::SafePlayback(HDC context) const { |
} |
Emf::EnumerationContext playback_context; |
playback_context.base_matrix = &base_matrix; |
- RECT rect = GetPageBounds(1).ToRECT(); |
- return EnumEnhMetaFile(context, |
+ gfx::Rect bound = GetPageBounds(1); |
+ RECT rect = bound.ToRECT(); |
+ return bound.IsEmpty() || |
+ EnumEnhMetaFile(context, |
emf_, |
&Emf::SafePlaybackProc, |
reinterpret_cast<void*>(&playback_context), |
@@ -455,34 +441,6 @@ bool Emf::Record::SafePlayback(Emf::EnumerationContext* context) const { |
// Ignore it. |
res = true; |
break; |
- case EMR_GDICOMMENT: { |
- const EMRGDICOMMENT* comment_record = |
- reinterpret_cast<const EMRGDICOMMENT*>(record()); |
- if (comment_record->cbData == sizeof(PageBreakRecord)) { |
- const PageBreakRecord* page_break_record = |
- reinterpret_cast<const PageBreakRecord*>(comment_record->Data); |
- if (page_break_record && page_break_record->IsValid()) { |
- if (page_break_record->type == PageBreakRecord::START_PAGE) { |
- res = !!::StartPage(context->hdc); |
- DCHECK_EQ(0, context->dc_on_page_start); |
- context->dc_on_page_start = ::SaveDC(context->hdc); |
- } else if (page_break_record->type == PageBreakRecord::END_PAGE) { |
- DCHECK_NE(0, context->dc_on_page_start); |
- ::RestoreDC(context->hdc, context->dc_on_page_start); |
- context->dc_on_page_start = 0; |
- res = !!::EndPage(context->hdc); |
- } else { |
- res = false; |
- NOTREACHED(); |
- } |
- } else { |
- res = Play(context); |
- } |
- } else { |
- res = true; |
- } |
- break; |
- } |
default: { |
res = Play(context); |
break; |
@@ -505,22 +463,11 @@ SkBaseDevice* Emf::StartPageForVectorCanvas( |
bool Emf::StartPage(const gfx::Size& /*page_size*/, |
const gfx::Rect& /*content_area*/, |
const float& /*scale_factor*/) { |
- DCHECK(hdc_); |
- if (!hdc_) |
- return false; |
- page_count_++; |
- PageBreakRecord record(PageBreakRecord::START_PAGE); |
- return !!GdiComment(hdc_, sizeof(record), |
- reinterpret_cast<const BYTE *>(&record)); |
+ return true; |
} |
bool Emf::FinishPage() { |
- DCHECK(hdc_); |
- if (!hdc_) |
- return false; |
- PageBreakRecord record(PageBreakRecord::END_PAGE); |
- return !!GdiComment(hdc_, sizeof(record), |
- reinterpret_cast<const BYTE *>(&record)); |
+ return true; |
} |
Emf::Enumerator::Enumerator(const Emf& emf, HDC context, const RECT* rect) { |