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

Side by Side Diff: printing/printed_page.cc

Issue 8585017: PrintPreview: Honor the print media page size and margin values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added one more test Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/printed_page.h ('k') | printing/printed_page_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_page.h" 5 #include "printing/printed_page.h"
6 6
7 namespace printing { 7 namespace printing {
8 8
9 PrintedPage::PrintedPage(int page_number, 9 PrintedPage::PrintedPage(int page_number,
10 Metafile* metafile, 10 Metafile* metafile,
11 const gfx::Size& page_size, 11 const gfx::Size& page_size,
12 const gfx::Rect& page_content_rect) 12 const gfx::Rect& page_content_rect,
13 double shrink_factor)
13 : page_number_(page_number), 14 : page_number_(page_number),
14 metafile_(metafile), 15 metafile_(metafile),
15 page_size_(page_size), 16 page_size_(page_size),
16 page_content_rect_(page_content_rect) { 17 page_content_rect_(page_content_rect),
18 shrink_factor_(shrink_factor) {
17 } 19 }
18 20
19 PrintedPage::~PrintedPage() { 21 PrintedPage::~PrintedPage() {
20 } 22 }
21 23
22 const Metafile* PrintedPage::metafile() const { 24 const Metafile* PrintedPage::metafile() const {
23 return metafile_.get(); 25 return metafile_.get();
24 } 26 }
25 27
26 void PrintedPage::GetCenteredPageContentRect( 28 void PrintedPage::GetCenteredPageContentRect(
27 const gfx::Size& paper_size, gfx::Rect* content_rect) const { 29 const gfx::Size& paper_size, gfx::Rect* content_rect) const {
28 *content_rect = page_content_rect(); 30 *content_rect = page_content_rect();
29 if (paper_size.width() > page_size().width()) { 31 if (paper_size.width() > page_size().width()) {
30 int diff = paper_size.width() - page_size().width(); 32 int diff = paper_size.width() - page_size().width();
31 content_rect->set_x(content_rect->x() + diff / 2); 33 content_rect->set_x(content_rect->x() + diff / 2);
32 } 34 }
33 if (paper_size.height() > page_size().height()) { 35 if (paper_size.height() > page_size().height()) {
34 int diff = paper_size.height() - page_size().height(); 36 int diff = paper_size.height() - page_size().height();
35 content_rect->set_y(content_rect->y() + diff / 2); 37 content_rect->set_y(content_rect->y() + diff / 2);
36 } 38 }
37 } 39 }
38 40
39 } // namespace printing 41 } // namespace printing
OLDNEW
« 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