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

Unified Diff: printing/printed_page.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 | « printing/printed_page.h ('k') | printing/printed_page_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/printed_page.cc
diff --git a/printing/printed_page.cc b/printing/printed_page.cc
index 8abedeee846660fca3d6724cfa9bc478d4d724ba..1661813b78996529958c756890bcb968018c0b76 100644
--- a/printing/printed_page.cc
+++ b/printing/printed_page.cc
@@ -25,4 +25,17 @@ const NativeMetafile* PrintedPage::native_metafile() const {
return native_metafile_.get();
}
+void PrintedPage::GetCenteredPageContentRect(
+ const gfx::Size& paper_size, gfx::Rect* content_rect) const {
+ *content_rect = page_content_rect();
+ if (paper_size.width() > page_size().width()) {
+ int diff = paper_size.width() - page_size().width();
+ content_rect->set_x(content_rect->x() + diff / 2);
+ }
+ if (paper_size.height() > page_size().height()) {
+ int diff = paper_size.height() - page_size().height();
+ content_rect->set_y(content_rect->y() + diff / 2);
+ }
+}
+
} // namespace printing
« no previous file with comments | « printing/printed_page.h ('k') | printing/printed_page_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698