summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/print_web_view_helper_win.cc4
-rw-r--r--printing/emf_win.cc3
-rw-r--r--printing/emf_win.h5
-rw-r--r--printing/emf_win_unittest.cc1
4 files changed, 10 insertions, 3 deletions
diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc
index 840e5fb..b7ed1cb 100644
--- a/chrome/renderer/print_web_view_helper_win.cc
+++ b/chrome/renderer/print_web_view_helper_win.cc
@@ -233,6 +233,10 @@ void PrintWebViewHelper::RenderPage(
skia::VectorPlatformDevice* platform_device =
static_cast<skia::VectorPlatformDevice*>(device);
if (platform_device->alpha_blend_used() && !params.supports_alpha_blend) {
+ // Currently, we handle alpha blend transparency for a single page.
+ // Therefore, expecting a metafile with page count 1.
+ DCHECK((*metafile)->GetPageCount() == 1);
+
// Close the device context to retrieve the compiled metafile.
if (!(*metafile)->FinishDocument())
NOTREACHED();
diff --git a/printing/emf_win.cc b/printing/emf_win.cc
index 467d4b3..849e125 100644
--- a/printing/emf_win.cc
+++ b/printing/emf_win.cc
@@ -49,7 +49,7 @@ bool DIBFormatNativelySupported(HDC dc, uint32 escape, const BYTE* bits,
return !!supported;
}
-Emf::Emf() : emf_(NULL), hdc_(NULL) {
+Emf::Emf() : emf_(NULL), hdc_(NULL), page_count_(0) {
}
Emf::~Emf() {
@@ -421,6 +421,7 @@ bool Emf::StartPage(const gfx::Size& /*page_size*/,
DCHECK(hdc_);
if (!hdc_)
return false;
+ page_count_++;
PageBreakRecord record(PageBreakRecord::START_PAGE);
return !!GdiComment(hdc_, sizeof(record),
reinterpret_cast<const BYTE *>(&record));
diff --git a/printing/emf_win.h b/printing/emf_win.h
index 5f9bd5a..ecc1028 100644
--- a/printing/emf_win.h
+++ b/printing/emf_win.h
@@ -70,8 +70,7 @@ class Emf : public NativeMetafile {
virtual gfx::Rect GetPageBounds(unsigned int page_number) const;
virtual unsigned int GetPageCount() const {
- // TODO(dpapad): count the number of times StartPage() is called
- return 1;
+ return page_count_;
}
virtual HDC context() const {
@@ -106,6 +105,8 @@ class Emf : public NativeMetafile {
// Valid when generating EMF data through a virtual HDC.
HDC hdc_;
+ int page_count_;
+
DISALLOW_COPY_AND_ASSIGN(Emf);
};
diff --git a/printing/emf_win_unittest.cc b/printing/emf_win_unittest.cc
index b401f5b..3ea1282 100644
--- a/printing/emf_win_unittest.cc
+++ b/printing/emf_win_unittest.cc
@@ -141,6 +141,7 @@ TEST_F(EmfPrintingTest, PageBreak) {
EXPECT_TRUE(emf.FinishPage());
--pages;
}
+ EXPECT_EQ(3U, emf.GetPageCount());
EXPECT_TRUE(emf.FinishDocument());
size = emf.GetDataSize();
EXPECT_TRUE(emf.GetDataAsVector(&data));