| 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); | |
| 124 } | 122 } |
| 125 | 123 |
| 126 void PageSetup::SetRequestedMargins(const PageMargins& requested_margins) { | 124 void PageSetup::SetRequestedMargins(const PageMargins& requested_margins) { |
| 127 requested_margins_ = requested_margins; | 125 requested_margins_ = requested_margins; |
| 128 if (physical_size_.width() && physical_size_.height()) | 126 if (physical_size_.width() && physical_size_.height()) |
| 129 Init(physical_size_, printable_area_, text_height_); | 127 Init(physical_size_, printable_area_, text_height_); |
| 130 } | 128 } |
| 131 | 129 |
| 132 void PageSetup::FlipOrientation() { | 130 void PageSetup::FlipOrientation() { |
| 133 if (physical_size_.width() && physical_size_.height()) { | 131 if (physical_size_.width() && physical_size_.height()) { |
| 134 gfx::Size new_size(physical_size_.height(), physical_size_.width()); | 132 gfx::Size new_size(physical_size_.height(), physical_size_.width()); |
| 135 int new_y = physical_size_.width() - | 133 int new_y = physical_size_.width() - |
| 136 (printable_area_.width() + printable_area_.x()); | 134 (printable_area_.width() + printable_area_.x()); |
| 137 gfx::Rect new_printable_area(printable_area_.y(), | 135 gfx::Rect new_printable_area(printable_area_.y(), |
| 138 new_y, | 136 new_y, |
| 139 printable_area_.height(), | 137 printable_area_.height(), |
| 140 printable_area_.width()); | 138 printable_area_.width()); |
| 141 Init(new_size, new_printable_area, text_height_); | 139 Init(new_size, new_printable_area, text_height_); |
| 142 } | 140 } |
| 143 } | 141 } |
| 144 | 142 |
| 145 } // namespace printing | 143 } // namespace printing |
| OLD | NEW |