Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Unified Diff: printing/printed_document_mac.cc

Issue 2878022: Add PrintedPage::GetCenteredPageContentRect so Mac and Win can share code. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: remove #include for gtest Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | printing/printed_document_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/printed_document_mac.cc
diff --git a/printing/printed_document_mac.cc b/printing/printed_document_mac.cc
index 3f5d75d94a950253a897543bcb87cf32b426517c..924ec0f4ff8d6d9394ac8fa8e14f32b12bb59475 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.
« no previous file with comments | « no previous file | printing/printed_document_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698