summaryrefslogtreecommitdiffstats
path: root/printing/printed_document_mac.cc
diff options
context:
space:
mode:
authorhamaji@chromium.org <hamaji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-05 06:45:21 +0000
committerhamaji@chromium.org <hamaji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-05 06:45:21 +0000
commita12552b019c9b03162fba54aa9f2f8398f0ea32c (patch)
tree64a1b64484b0e1eb68a9c25bf96f502d3ab792f4 /printing/printed_document_mac.cc
parent1322d8777c7c76eae42500407ec55adbc5e5187e (diff)
downloadchromium_src-a12552b019c9b03162fba54aa9f2f8398f0ea32c.zip
chromium_src-a12552b019c9b03162fba54aa9f2f8398f0ea32c.tar.gz
chromium_src-a12552b019c9b03162fba54aa9f2f8398f0ea32c.tar.bz2
Add PrintedPage::GetCenteredPageContentRect so Mac and Win can share code.
BUG=47277 TEST=printed_page_unittest Review URL: http://codereview.chromium.org/2878022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51626 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printed_document_mac.cc')
-rw-r--r--printing/printed_document_mac.cc15
1 files changed, 3 insertions, 12 deletions
diff --git a/printing/printed_document_mac.cc b/printing/printed_document_mac.cc
index 3f5d75d..924ec0f 100644
--- a/printing/printed_document_mac.cc
+++ b/printing/printed_document_mac.cc
@@ -26,22 +26,13 @@ void PrintedDocument::RenderPrintedPage(
const printing::PageSetup& page_setup(
immutable_.settings_.page_setup_device_units());
- gfx::Rect target_rect = page.page_content_rect();
- const gfx::Rect& physical_size = page_setup.physical_size();
- // http://dev.w3.org/csswg/css3-page/#positioning-page-box
- if (physical_size.width() > page.page_size().width()) {
- int diff = physical_size.width() - page.page_size().width();
- target_rect.set_x(target_rect.x() + diff / 2);
- }
- if (physical_size.height() > page.page_size().height()) {
- int diff = physical_size.height() - page.page_size().height();
- target_rect.set_y(target_rect.y() + diff / 2);
- }
+ gfx::Rect content_area;
+ page.GetCenteredPageContentRect(page_setup.physical_size(), &content_area);
const printing::NativeMetafile* metafile = page.native_metafile();
// Each NativeMetafile is a one-page PDF, and pages use 1-based indexing.
const int page_number = 1;
- metafile->RenderPage(page_number, context, target_rect.ToCGRect(),
+ metafile->RenderPage(page_number, context, content_area.ToCGRect(),
true, false, false, false);
// TODO(stuartmorgan): Print the header and footer.