| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "printing/printed_document.h" | 5 #include "printing/printed_document.h" |
| 6 | 6 |
| 7 #include "app/win_util.h" | 7 #include "app/win_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "gfx/font.h" | 10 #include "gfx/font.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #ifndef NDEBUG | 44 #ifndef NDEBUG |
| 45 { | 45 { |
| 46 // Make sure the page is from our list. | 46 // Make sure the page is from our list. |
| 47 AutoLock lock(lock_); | 47 AutoLock lock(lock_); |
| 48 DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get()); | 48 DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get()); |
| 49 } | 49 } |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 const printing::PageSetup& page_setup( | 52 const printing::PageSetup& page_setup( |
| 53 immutable_.settings_.page_setup_device_units()); | 53 immutable_.settings_.page_setup_device_units()); |
| 54 gfx::Rect content_area(page.page_content_rect()); | 54 gfx::Rect content_area; |
| 55 const gfx::Size& physical_size = page_setup.physical_size(); | 55 page.GetCenteredPageContentRect(page_setup.physical_size(), &content_area); |
| 56 // http://dev.w3.org/csswg/css3-page/#positioning-page-box | |
| 57 if (physical_size.width() > page.page_size().width()) { | |
| 58 int diff = physical_size.width() - page.page_size().width(); | |
| 59 content_area.set_x(content_area.x() + diff / 2); | |
| 60 } | |
| 61 if (physical_size.height() > page.page_size().height()) { | |
| 62 int diff = physical_size.height() - page.page_size().height(); | |
| 63 content_area.set_y(content_area.y() + diff / 2); | |
| 64 } | |
| 65 | 56 |
| 66 // Save the state to make sure the context this function call does not modify | 57 // Save the state to make sure the context this function call does not modify |
| 67 // the device context. | 58 // the device context. |
| 68 int saved_state = SaveDC(context); | 59 int saved_state = SaveDC(context); |
| 69 DCHECK_NE(saved_state, 0); | 60 DCHECK_NE(saved_state, 0); |
| 70 skia::PlatformDevice::InitializeDC(context); | 61 skia::PlatformDevice::InitializeDC(context); |
| 71 { | 62 { |
| 72 // Save the state (again) to apply the necessary world transformation. | 63 // Save the state (again) to apply the necessary world transformation. |
| 73 int saved_state = SaveDC(context); | 64 int saved_state = SaveDC(context); |
| 74 DCHECK_NE(saved_state, 0); | 65 DCHECK_NE(saved_state, 0); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 font); | 135 font); |
| 145 PrintHeaderFooter(context, page, PageOverlays::CENTER, PageOverlays::BOTTOM, | 136 PrintHeaderFooter(context, page, PageOverlays::CENTER, PageOverlays::BOTTOM, |
| 146 font); | 137 font); |
| 147 PrintHeaderFooter(context, page, PageOverlays::RIGHT, PageOverlays::BOTTOM, | 138 PrintHeaderFooter(context, page, PageOverlays::RIGHT, PageOverlays::BOTTOM, |
| 148 font); | 139 font); |
| 149 int res = RestoreDC(context, saved_state); | 140 int res = RestoreDC(context, saved_state); |
| 150 DCHECK_NE(res, 0); | 141 DCHECK_NE(res, 0); |
| 151 } | 142 } |
| 152 | 143 |
| 153 } // namespace printing | 144 } // namespace printing |
| OLD | NEW |