summaryrefslogtreecommitdiffstats
path: root/printing
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-12 09:49:08 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-12 09:49:08 +0000
commit9de1347ae1cb4b93ebf28d1d65ea48d8ec4b1cf7 (patch)
treee023cf3d9ebf59efc7c6919f41f42b621ee2b666 /printing
parent191b853fd4b0178094f79ba352462280c1b72f10 (diff)
downloadchromium_src-9de1347ae1cb4b93ebf28d1d65ea48d8ec4b1cf7.zip
chromium_src-9de1347ae1cb4b93ebf28d1d65ea48d8ec4b1cf7.tar.gz
chromium_src-9de1347ae1cb4b93ebf28d1d65ea48d8ec4b1cf7.tar.bz2
Guarded shrink setting with ifdefs to make clear where it is used.
Shrink value passed over IPC only in if defined (OS_WIN && !WIN_PDF_METAFILE_FOR_PRINTING) This build config should be gone in near future. PrintedPage::shrink_factor_ is used only for OS_WIN. BUG=379961 NOTRY=true Review URL: https://codereview.chromium.org/335473002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r--printing/printed_document.cc11
-rw-r--r--printing/printed_document.h9
-rw-r--r--printing/printed_page.cc9
-rw-r--r--printing/printed_page.h16
-rw-r--r--printing/printed_page_unittest.cc44
5 files changed, 49 insertions, 40 deletions
diff --git a/printing/printed_document.cc b/printing/printed_document.cc
index 7c2392d..77e3953 100644
--- a/printing/printed_document.cc
+++ b/printing/printed_document.cc
@@ -65,17 +65,18 @@ PrintedDocument::~PrintedDocument() {
void PrintedDocument::SetPage(int page_number,
Metafile* metafile,
+#if defined(OS_WIN)
double shrink,
+#endif // OS_WIN
const gfx::Size& paper_size,
const gfx::Rect& page_rect) {
// Notice the page_number + 1, the reason is that this is the value that will
// be shown. Users dislike 0-based counting.
scoped_refptr<PrintedPage> page(
- new PrintedPage(page_number + 1,
- metafile,
- paper_size,
- page_rect,
- shrink));
+ new PrintedPage(page_number + 1, metafile, paper_size, page_rect));
+#if defined(OS_WIN)
+ page->set_shrink_factor(shrink);
+#endif // OS_WIN
{
base::AutoLock lock(lock_);
mutable_.pages_[page_number] = page;
diff --git a/printing/printed_document.h b/printing/printed_document.h
index b8af4bb..3341d54 100644
--- a/printing/printed_document.h
+++ b/printing/printed_document.h
@@ -42,8 +42,13 @@ class PRINTING_EXPORT PrintedDocument
// Sets a page's data. 0-based. Takes metafile ownership.
// Note: locks for a short amount of time.
- void SetPage(int page_number, Metafile* metafile, double shrink,
- const gfx::Size& paper_size, const gfx::Rect& page_rect);
+ void SetPage(int page_number,
+ Metafile* metafile,
+#if defined(OS_WIN)
+ double shrink,
+#endif // OS_WIN
+ const gfx::Size& paper_size,
+ const gfx::Rect& page_rect);
// Retrieves a page. If the page is not available right now, it
// requests to have this page be rendered and returns false.
diff --git a/printing/printed_page.cc b/printing/printed_page.cc
index af7b738..19b9fd3 100644
--- a/printing/printed_page.cc
+++ b/printing/printed_page.cc
@@ -9,13 +9,14 @@ namespace printing {
PrintedPage::PrintedPage(int page_number,
Metafile* metafile,
const gfx::Size& page_size,
- const gfx::Rect& page_content_rect,
- double shrink_factor)
+ const gfx::Rect& page_content_rect)
: page_number_(page_number),
metafile_(metafile),
+#if defined(OS_WIN)
+ shrink_factor_(0.0f),
+#endif // OS_WIN
page_size_(page_size),
- page_content_rect_(page_content_rect),
- shrink_factor_(shrink_factor) {
+ page_content_rect_(page_content_rect) {
}
PrintedPage::~PrintedPage() {
diff --git a/printing/printed_page.h b/printing/printed_page.h
index 40e96e0..a1adfa4 100644
--- a/printing/printed_page.h
+++ b/printing/printed_page.h
@@ -25,15 +25,19 @@ class PRINTING_EXPORT PrintedPage
PrintedPage(int page_number,
Metafile* metafile,
const gfx::Size& page_size,
- const gfx::Rect& page_content_rect,
- double shrink_factor);
+ const gfx::Rect& page_content_rect);
// Getters
int page_number() const { return page_number_; }
const Metafile* metafile() const;
const gfx::Size& page_size() const { return page_size_; }
const gfx::Rect& page_content_rect() const { return page_content_rect_; }
+#if defined(OS_WIN)
+ void set_shrink_factor(double shrink_factor) {
+ shrink_factor_ = shrink_factor;
+ }
double shrink_factor() const { return shrink_factor_; }
+#endif // OS_WIN
// Get page content rect adjusted based on
// http://dev.w3.org/csswg/css3-page/#positioning-page-box
@@ -51,6 +55,11 @@ class PRINTING_EXPORT PrintedPage
// Actual paint data.
const scoped_ptr<Metafile> metafile_;
+#if defined(OS_WIN)
+ // Shrink done in comparison to desired_dpi.
+ double shrink_factor_;
+#endif // OS_WIN
+
// The physical page size. To support multiple page formats inside on print
// job.
const gfx::Size page_size_;
@@ -58,9 +67,6 @@ class PRINTING_EXPORT PrintedPage
// The printable area of the page.
const gfx::Rect page_content_rect_;
- // Shrink done in comparison to desired_dpi.
- double shrink_factor_;
-
DISALLOW_COPY_AND_ASSIGN(PrintedPage);
};
diff --git a/printing/printed_page_unittest.cc b/printing/printed_page_unittest.cc
index 9cce52a..d37d93a 100644
--- a/printing/printed_page_unittest.cc
+++ b/printing/printed_page_unittest.cc
@@ -12,56 +12,52 @@ TEST(PrintedPageTest, GetCenteredPageContentRect) {
gfx::Rect page_content;
// No centering.
- page = new PrintedPage(1,
- NULL,
- gfx::Size(1200, 1200),
- gfx::Rect(0, 0, 400, 1100),
- 0.2f);
+ page = new PrintedPage(
+ 1, NULL, gfx::Size(1200, 1200), gfx::Rect(0, 0, 400, 1100));
page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
EXPECT_EQ(0, page_content.x());
EXPECT_EQ(0, page_content.y());
EXPECT_EQ(400, page_content.width());
EXPECT_EQ(1100, page_content.height());
- EXPECT_EQ(0.2f, page->shrink_factor());
// X centered.
- page = new PrintedPage(1,
- NULL,
- gfx::Size(500, 1200),
- gfx::Rect(0, 0, 400, 1100),
- 0.8f);
+ page = new PrintedPage(
+ 1, NULL, gfx::Size(500, 1200), gfx::Rect(0, 0, 400, 1100));
page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
EXPECT_EQ(250, page_content.x());
EXPECT_EQ(0, page_content.y());
EXPECT_EQ(400, page_content.width());
EXPECT_EQ(1100, page_content.height());
- EXPECT_EQ(0.8f, page->shrink_factor());
// Y centered.
- page = new PrintedPage(1,
- NULL,
- gfx::Size(1200, 500),
- gfx::Rect(0, 0, 400, 1100),
- 1.0f);
+ page = new PrintedPage(
+ 1, NULL, gfx::Size(1200, 500), gfx::Rect(0, 0, 400, 1100));
page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
EXPECT_EQ(0, page_content.x());
EXPECT_EQ(250, page_content.y());
EXPECT_EQ(400, page_content.width());
EXPECT_EQ(1100, page_content.height());
- EXPECT_EQ(1.0f, page->shrink_factor());
// Both X and Y centered.
- page = new PrintedPage(1,
- NULL,
- gfx::Size(500, 500),
- gfx::Rect(0, 0, 400, 1100),
- 0.3f);
+ page =
+ new PrintedPage(1, NULL, gfx::Size(500, 500), gfx::Rect(0, 0, 400, 1100));
page->GetCenteredPageContentRect(gfx::Size(1000, 1000), &page_content);
EXPECT_EQ(250, page_content.x());
EXPECT_EQ(250, page_content.y());
EXPECT_EQ(400, page_content.width());
EXPECT_EQ(1100, page_content.height());
- EXPECT_EQ(0.3f, page->shrink_factor());
}
+#if defined(OS_WIN)
+TEST(PrintedPageTest, Shrink) {
+ scoped_refptr<PrintedPage> page = new PrintedPage(
+ 1, NULL, gfx::Size(1200, 1200), gfx::Rect(0, 0, 400, 1100));
+ EXPECT_EQ(0.0f, page->shrink_factor());
+ page->set_shrink_factor(0.2f);
+ EXPECT_EQ(0.2f, page->shrink_factor());
+ page->set_shrink_factor(0.7f);
+ EXPECT_EQ(0.7f, page->shrink_factor());
+}
+#endif // OS_WIN
+
} // namespace printing