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

Unified Diff: printing/printed_document_win.cc

Issue 2859040: Implement limited paged media support for win. (Closed)
Patch Set: the comment fix 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_document.cc ('k') | printing/printed_page.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/printed_document_win.cc
diff --git a/printing/printed_document_win.cc b/printing/printed_document_win.cc
index 42c1b45f6db36f1d0ff56e212489f2ea76729efe..e80ac78a749e6576aef22ee12fa726e08ed514b5 100644
--- a/printing/printed_document_win.cc
+++ b/printing/printed_document_win.cc
@@ -51,6 +51,17 @@ void PrintedDocument::RenderPrintedPage(
const printing::PageSetup& page_setup(
immutable_.settings_.page_setup_device_units());
+ gfx::Rect content_area(page.page_content_rect());
+ const gfx::Size& 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();
+ content_area.set_x(content_area.x() + diff / 2);
+ }
+ if (physical_size.height() > page.page_size().height()) {
+ int diff = physical_size.height() - page.page_size().height();
+ content_area.set_y(content_area.y() + diff / 2);
+ }
// Save the state to make sure the context this function call does not modify
// the device context.
@@ -81,7 +92,7 @@ void PrintedDocument::RenderPrintedPage(
SelectObject(context, CreateSolidBrush(RGB(0xb0, 0xb0, 0xb0)));
DrawRect(context, debug_overlay_area);
// Content area:
- gfx::Rect debug_content_area(page_setup.content_area());
+ gfx::Rect debug_content_area(content_area());
debug_content_area.Offset(-page_setup.printable_area().x(),
-page_setup.printable_area().y());
SelectObject(context, CreateSolidBrush(RGB(0xd0, 0xd0, 0xd0)));
@@ -94,8 +105,8 @@ void PrintedDocument::RenderPrintedPage(
// That is 0,0 is offset by PHYSICALOFFSETX/Y from the page.
SimpleModifyWorldTransform(
context,
- page_setup.content_area().x() - page_setup.printable_area().x(),
- page_setup.content_area().y() - page_setup.printable_area().y(),
+ content_area.x() - page_setup.printable_area().x(),
+ content_area.y() - page_setup.printable_area().y(),
mutable_.shrink_factor);
if (!page.native_metafile()->SafePlayback(context)) {
« no previous file with comments | « printing/printed_document.cc ('k') | printing/printed_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698