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

Side by Side Diff: printing/page_setup.cc

Issue 8505024: PrintPreview: [LINUX] While flipping the orientation, do not rotate the margins values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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/page_setup.h ('k') | printing/page_setup_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/page_setup.h" 5 #include "printing/page_setup.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 namespace printing { 11 namespace printing {
12 12
13 PageMargins::PageMargins() 13 PageMargins::PageMargins()
14 : header(0), 14 : header(0),
15 footer(0), 15 footer(0),
16 left(0), 16 left(0),
17 right(0), 17 right(0),
18 top(0), 18 top(0),
19 bottom(0) { 19 bottom(0) {
20 } 20 }
21 21
22 void PageMargins::Rotate() {
23 int temp_right = right;
24 right = bottom;
25 bottom = left;
26 left = top;
27 top = temp_right;
28 }
29
30 void PageMargins::Clear() { 22 void PageMargins::Clear() {
31 header = 0; 23 header = 0;
32 footer = 0; 24 footer = 0;
33 left = 0; 25 left = 0;
34 right = 0; 26 right = 0;
35 top = 0; 27 top = 0;
36 bottom = 0; 28 bottom = 0;
37 } 29 }
38 30
39 bool PageMargins::Equals(const PageMargins& rhs) const { 31 bool PageMargins::Equals(const PageMargins& rhs) const {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 92
101 void PageSetup::FlipOrientation() { 93 void PageSetup::FlipOrientation() {
102 if (physical_size_.width() && physical_size_.height()) { 94 if (physical_size_.width() && physical_size_.height()) {
103 gfx::Size new_size(physical_size_.height(), physical_size_.width()); 95 gfx::Size new_size(physical_size_.height(), physical_size_.width());
104 int new_y = physical_size_.width() - 96 int new_y = physical_size_.width() -
105 (printable_area_.width() + printable_area_.x()); 97 (printable_area_.width() + printable_area_.x());
106 gfx::Rect new_printable_area(printable_area_.y(), 98 gfx::Rect new_printable_area(printable_area_.y(),
107 new_y, 99 new_y,
108 printable_area_.height(), 100 printable_area_.height(),
109 printable_area_.width()); 101 printable_area_.width());
110 requested_margins_.Rotate();
111 Init(new_size, new_printable_area, text_height_); 102 Init(new_size, new_printable_area, text_height_);
112 } 103 }
113 } 104 }
114 105
115 void PageSetup::SetRequestedMarginsAndCalculateSizes( 106 void PageSetup::SetRequestedMarginsAndCalculateSizes(
116 const PageMargins& requested_margins) { 107 const PageMargins& requested_margins) {
117 requested_margins_ = requested_margins; 108 requested_margins_ = requested_margins;
118 if (physical_size_.width() && physical_size_.height()) { 109 if (physical_size_.width() && physical_size_.height()) {
119 if (forced_margins_) 110 if (forced_margins_)
120 CalculateSizesWithinRect(gfx::Rect(physical_size_), 0); 111 CalculateSizesWithinRect(gfx::Rect(physical_size_), 0);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 physical_size_.width() - 156 physical_size_.width() -
166 effective_margins_.right - 157 effective_margins_.right -
167 content_area_.x())); 158 content_area_.x()));
168 content_area_.set_height(std::max(0, 159 content_area_.set_height(std::max(0,
169 physical_size_.height() - 160 physical_size_.height() -
170 effective_margins_.bottom - 161 effective_margins_.bottom -
171 content_area_.y())); 162 content_area_.y()));
172 } 163 }
173 164
174 } // namespace printing 165 } // namespace printing
OLDNEW
« no previous file with comments | « printing/page_setup.h ('k') | printing/page_setup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698