Roll src/third_party/WebKit abedb26:aa7113d (svn 202478:202479)
[chromium-blink-merge.git] / printing / printed_page.cc
blob998f8be5e51fc488dd28001b1534fb047af716f5
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
3 // found in the LICENSE file.
5 #include "printing/printed_page.h"
7 namespace printing {
9 PrintedPage::PrintedPage(int page_number,
10 scoped_ptr<MetafilePlayer> metafile,
11 const gfx::Size& page_size,
12 const gfx::Rect& page_content_rect)
13 : page_number_(page_number),
14 metafile_(metafile.Pass()),
15 #if defined(OS_WIN)
16 shrink_factor_(0.0f),
17 #endif // OS_WIN
18 page_size_(page_size),
19 page_content_rect_(page_content_rect) {
22 PrintedPage::~PrintedPage() {
25 const MetafilePlayer* PrintedPage::metafile() const {
26 return metafile_.get();
29 void PrintedPage::GetCenteredPageContentRect(
30 const gfx::Size& paper_size, gfx::Rect* content_rect) const {
31 *content_rect = page_content_rect();
32 if (paper_size.width() > page_size().width()) {
33 int diff = paper_size.width() - page_size().width();
34 content_rect->set_x(content_rect->x() + diff / 2);
36 if (paper_size.height() > page_size().height()) {
37 int diff = paper_size.height() - page_size().height();
38 content_rect->set_y(content_rect->y() + diff / 2);
42 } // namespace printing