diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 00:15:21 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 00:15:21 +0000 |
commit | d69d322dcd9d2ace6b0f27d958db6894d1cfb080 (patch) | |
tree | 46bf39a09da4838796163b09be4053e229ca7e67 /printing | |
parent | 1eec5ca7adc5b5ac202af117a95d2e3e96831e20 (diff) | |
download | chromium_src-d69d322dcd9d2ace6b0f27d958db6894d1cfb080.zip chromium_src-d69d322dcd9d2ace6b0f27d958db6894d1cfb080.tar.gz chromium_src-d69d322dcd9d2ace6b0f27d958db6894d1cfb080.tar.bz2 |
For no margins, or printable area margins, don't factor in the header/footer size.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/8328001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105973 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing')
-rw-r--r-- | printing/page_setup.cc | 13 | ||||
-rw-r--r-- | printing/page_setup.h | 4 | ||||
-rw-r--r-- | printing/print_settings.cc | 8 |
3 files changed, 15 insertions, 10 deletions
diff --git a/printing/page_setup.cc b/printing/page_setup.cc index 2411f6f..b870323e 100644 --- a/printing/page_setup.cc +++ b/printing/page_setup.cc @@ -76,19 +76,19 @@ void PageSetup::Init(const gfx::Size& physical_size, printable_area_ = printable_area; text_height_ = text_height; - CalculateSizesWithinRect(printable_area_); + CalculateSizesWithinRect(printable_area_, text_height_); } void PageSetup::SetRequestedMargins(const PageMargins& requested_margins) { requested_margins_ = requested_margins; if (printable_area_.width() && printable_area_.height()) - CalculateSizesWithinRect(printable_area_); + CalculateSizesWithinRect(printable_area_, text_height_); } void PageSetup::ForceRequestedMargins(const PageMargins& requested_margins) { requested_margins_ = requested_margins; if (physical_size_.width() && physical_size_.height()) - CalculateSizesWithinRect(gfx::Rect(physical_size_)); + CalculateSizesWithinRect(gfx::Rect(physical_size_), 0); } void PageSetup::FlipOrientation() { @@ -104,7 +104,8 @@ void PageSetup::FlipOrientation() { } } -void PageSetup::CalculateSizesWithinRect(const gfx::Rect& bounds) { +void PageSetup::CalculateSizesWithinRect(const gfx::Rect& bounds, + int text_height) { // Calculate the effective margins. The tricky part. effective_margins_.header = std::max(requested_margins_.header, bounds.y()); @@ -115,14 +116,14 @@ void PageSetup::CalculateSizesWithinRect(const gfx::Rect& bounds) { bounds.x()); effective_margins_.top = std::max(std::max(requested_margins_.top, bounds.y()), - effective_margins_.header + text_height_); + effective_margins_.header + text_height); effective_margins_.right = std::max(requested_margins_.right, physical_size_.width() - bounds.right()); effective_margins_.bottom = std::max(std::max(requested_margins_.bottom, physical_size_.height() - bounds.bottom()), - effective_margins_.footer + text_height_); + effective_margins_.footer + text_height); // Calculate the overlay area. If the margins are excessive, the overlay_area // size will be (0, 0). diff --git a/printing/page_setup.h b/printing/page_setup.h index ef1552d..9173475 100644 --- a/printing/page_setup.h +++ b/printing/page_setup.h @@ -65,8 +65,8 @@ class PRINTING_EXPORT PageSetup { private: // Calculate overlay_area_, effective_margins_, and content_area_, based on - // a constraint of |bounds|. - void CalculateSizesWithinRect(const gfx::Rect& bounds); + // a constraint of |bounds| and |text_height|. + void CalculateSizesWithinRect(const gfx::Rect& bounds, int text_height); // Physical size of the page, including non-printable margins. gfx::Size physical_size_; diff --git a/printing/print_settings.cc b/printing/print_settings.cc index 0e1a743..d5a0a78 100644 --- a/printing/print_settings.cc +++ b/printing/print_settings.cc @@ -158,13 +158,13 @@ void PrintSettings::SetPrinterPrintableArea( header_footer_text_height); PageMargins margins; - margins.header = header_footer_text_height; - margins.footer = header_footer_text_height; switch (margin_type) { case DEFAULT_MARGINS: { // Default margins 1.0cm = ~2/5 of an inch. int margin_printer_units = ConvertUnit(1000, kHundrethsMMPerInch, units_per_inch); + margins.header = header_footer_text_height; + margins.footer = header_footer_text_height; margins.top = margin_printer_units; margins.bottom = margin_printer_units; margins.left = margin_printer_units; @@ -173,6 +173,8 @@ void PrintSettings::SetPrinterPrintableArea( } case NO_MARGINS: case PRINTABLE_AREA_MARGINS: { + margins.header = 0; + margins.footer = 0; margins.top = 0; margins.bottom = 0; margins.left = 0; @@ -180,6 +182,8 @@ void PrintSettings::SetPrinterPrintableArea( break; } case CUSTOM_MARGINS: { + margins.header = 0; + margins.footer = 0; margins.top = ConvertUnitDouble(custom_margins_in_points_.top, printing::kPointsPerInch, units_per_inch); |