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-01 07:04:05 +0000
committerhamaji@chromium.org <hamaji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-01 07:04:05 +0000
commit40c7cfe39957248d38d8c376fbfc7d332c796741 (patch)
tree1e9cbc2bda99a4b4bc3286504dbca59a7542fb70 /printing/printed_document_mac.cc
parent829c9bbc87035a0e6a5606ff7654b761a2d9d0bf (diff)
downloadchromium_src-40c7cfe39957248d38d8c376fbfc7d332c796741.zip
chromium_src-40c7cfe39957248d38d8c376fbfc7d332c796741.tar.gz
chromium_src-40c7cfe39957248d38d8c376fbfc7d332c796741.tar.bz2
Implement limited paged media support for mac.
BUG=47277 TEST=none Review URL: http://codereview.chromium.org/2876020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printed_document_mac.cc')
-rw-r--r--printing/printed_document_mac.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/printing/printed_document_mac.cc b/printing/printed_document_mac.cc
index a3ea8c4..3f5d75d 100644
--- a/printing/printed_document_mac.cc
+++ b/printing/printed_document_mac.cc
@@ -26,13 +26,23 @@ void PrintedDocument::RenderPrintedPage(
const printing::PageSetup& page_setup(
immutable_.settings_.page_setup_device_units());
- CGRect target_rect = page_setup.content_area().ToCGRect();
+ 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);
+ }
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, true, false, false,
- false);
+ metafile->RenderPage(page_number, context, target_rect.ToCGRect(),
+ true, false, false, false);
// TODO(stuartmorgan): Print the header and footer.
}