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

Side by Side Diff: printing/print_settings.cc

Issue 8328001: For no margins, or printable area margins, don't factor in the header/footer size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comment Created 9 years, 2 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/page_setup.cc ('k') | no next file » | 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/print_settings.h" 5 #include "printing/print_settings.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "printing/print_job_constants.h" 9 #include "printing/print_job_constants.h"
10 #include "printing/units.h" 10 #include "printing/units.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (display_header_footer) { 151 if (display_header_footer) {
152 // Hard-code text_height = 0.5cm = ~1/5 of inch. 152 // Hard-code text_height = 0.5cm = ~1/5 of inch.
153 header_footer_text_height = ConvertUnit(kSettingHeaderFooterInterstice, 153 header_footer_text_height = ConvertUnit(kSettingHeaderFooterInterstice,
154 kPointsPerInch, units_per_inch); 154 kPointsPerInch, units_per_inch);
155 } 155 }
156 page_setup_device_units_.Init(physical_size_device_units, 156 page_setup_device_units_.Init(physical_size_device_units,
157 printable_area_device_units, 157 printable_area_device_units,
158 header_footer_text_height); 158 header_footer_text_height);
159 159
160 PageMargins margins; 160 PageMargins margins;
161 margins.header = header_footer_text_height;
162 margins.footer = header_footer_text_height;
163 switch (margin_type) { 161 switch (margin_type) {
164 case DEFAULT_MARGINS: { 162 case DEFAULT_MARGINS: {
165 // Default margins 1.0cm = ~2/5 of an inch. 163 // Default margins 1.0cm = ~2/5 of an inch.
166 int margin_printer_units = ConvertUnit(1000, kHundrethsMMPerInch, 164 int margin_printer_units = ConvertUnit(1000, kHundrethsMMPerInch,
167 units_per_inch); 165 units_per_inch);
166 margins.header = header_footer_text_height;
167 margins.footer = header_footer_text_height;
168 margins.top = margin_printer_units; 168 margins.top = margin_printer_units;
169 margins.bottom = margin_printer_units; 169 margins.bottom = margin_printer_units;
170 margins.left = margin_printer_units; 170 margins.left = margin_printer_units;
171 margins.right = margin_printer_units; 171 margins.right = margin_printer_units;
172 break; 172 break;
173 } 173 }
174 case NO_MARGINS: 174 case NO_MARGINS:
175 case PRINTABLE_AREA_MARGINS: { 175 case PRINTABLE_AREA_MARGINS: {
176 margins.header = 0;
177 margins.footer = 0;
176 margins.top = 0; 178 margins.top = 0;
177 margins.bottom = 0; 179 margins.bottom = 0;
178 margins.left = 0; 180 margins.left = 0;
179 margins.right = 0; 181 margins.right = 0;
180 break; 182 break;
181 } 183 }
182 case CUSTOM_MARGINS: { 184 case CUSTOM_MARGINS: {
185 margins.header = 0;
186 margins.footer = 0;
183 margins.top = ConvertUnitDouble(custom_margins_in_points_.top, 187 margins.top = ConvertUnitDouble(custom_margins_in_points_.top,
184 printing::kPointsPerInch, 188 printing::kPointsPerInch,
185 units_per_inch); 189 units_per_inch);
186 margins.bottom = ConvertUnitDouble(custom_margins_in_points_.bottom, 190 margins.bottom = ConvertUnitDouble(custom_margins_in_points_.bottom,
187 printing::kPointsPerInch, 191 printing::kPointsPerInch,
188 units_per_inch); 192 units_per_inch);
189 margins.left = ConvertUnitDouble(custom_margins_in_points_.left, 193 margins.left = ConvertUnitDouble(custom_margins_in_points_.left,
190 printing::kPointsPerInch, 194 printing::kPointsPerInch,
191 units_per_inch); 195 units_per_inch);
192 margins.right = ConvertUnitDouble(custom_margins_in_points_.right, 196 margins.right = ConvertUnitDouble(custom_margins_in_points_.right,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 234 }
231 235
232 void PrintSettings::SetOrientation(bool landscape) { 236 void PrintSettings::SetOrientation(bool landscape) {
233 if (landscape_ != landscape) { 237 if (landscape_ != landscape) {
234 landscape_ = landscape; 238 landscape_ = landscape;
235 page_setup_device_units_.FlipOrientation(); 239 page_setup_device_units_.FlipOrientation();
236 } 240 }
237 } 241 }
238 242
239 } // namespace printing 243 } // namespace printing
OLDNEW
« no previous file with comments | « printing/page_setup.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698