OLD | NEW |
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 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 content_area_.set_x(effective_margins_.left); | 112 content_area_.set_x(effective_margins_.left); |
113 content_area_.set_y(effective_margins_.top); | 113 content_area_.set_y(effective_margins_.top); |
114 content_area_.set_width(std::max(0, | 114 content_area_.set_width(std::max(0, |
115 physical_size.width() - | 115 physical_size.width() - |
116 effective_margins_.right - | 116 effective_margins_.right - |
117 content_area_.x())); | 117 content_area_.x())); |
118 content_area_.set_height(std::max(0, | 118 content_area_.set_height(std::max(0, |
119 physical_size.height() - | 119 physical_size.height() - |
120 effective_margins_.bottom - | 120 effective_margins_.bottom - |
121 content_area_.y())); | 121 content_area_.y())); |
| 122 // TODO(vandebo) Remove once bug 96063 is resolved. |
| 123 CHECK(content_area_.width() > 0 && content_area_.height() > 0); |
122 } | 124 } |
123 | 125 |
124 void PageSetup::SetRequestedMargins(const PageMargins& requested_margins) { | 126 void PageSetup::SetRequestedMargins(const PageMargins& requested_margins) { |
125 requested_margins_ = requested_margins; | 127 requested_margins_ = requested_margins; |
126 if (physical_size_.width() && physical_size_.height()) | 128 if (physical_size_.width() && physical_size_.height()) |
127 Init(physical_size_, printable_area_, text_height_); | 129 Init(physical_size_, printable_area_, text_height_); |
128 } | 130 } |
129 | 131 |
130 void PageSetup::FlipOrientation() { | 132 void PageSetup::FlipOrientation() { |
131 if (physical_size_.width() && physical_size_.height()) { | 133 if (physical_size_.width() && physical_size_.height()) { |
132 gfx::Size new_size(physical_size_.height(), physical_size_.width()); | 134 gfx::Size new_size(physical_size_.height(), physical_size_.width()); |
133 int new_y = physical_size_.width() - | 135 int new_y = physical_size_.width() - |
134 (printable_area_.width() + printable_area_.x()); | 136 (printable_area_.width() + printable_area_.x()); |
135 gfx::Rect new_printable_area(printable_area_.y(), | 137 gfx::Rect new_printable_area(printable_area_.y(), |
136 new_y, | 138 new_y, |
137 printable_area_.height(), | 139 printable_area_.height(), |
138 printable_area_.width()); | 140 printable_area_.width()); |
139 Init(new_size, new_printable_area, text_height_); | 141 Init(new_size, new_printable_area, text_height_); |
140 } | 142 } |
141 } | 143 } |
142 | 144 |
143 } // namespace printing | 145 } // namespace printing |
OLD | NEW |