diff options
author | aayushkumar@chromium.org <aayushkumar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-25 21:12:02 +0000 |
---|---|---|
committer | aayushkumar@chromium.org <aayushkumar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-25 21:12:02 +0000 |
commit | 9d0d357eb0baf6be8ed51c7de7bc132ab64c10d1 (patch) | |
tree | e4b09b31ac5b8013c1fdcf0071089fe667751514 /chrome/renderer/print_web_view_helper.cc | |
parent | b0ff4e7c000ef7974e2b316388b4416d2ee59007 (diff) | |
download | chromium_src-9d0d357eb0baf6be8ed51c7de7bc132ab64c10d1.zip chromium_src-9d0d357eb0baf6be8ed51c7de7bc132ab64c10d1.tar.gz chromium_src-9d0d357eb0baf6be8ed51c7de7bc132ab64c10d1.tar.bz2 |
Added a struct to hold page sizes and margins.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7492031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93943 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/print_web_view_helper.cc')
-rw-r--r-- | chrome/renderer/print_web_view_helper.cc | 80 |
1 files changed, 33 insertions, 47 deletions
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index 00c36ed..36a67c4 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -575,12 +575,7 @@ void PrintWebViewHelper::GetPageSizeAndMarginsInPoints( WebFrame* frame, int page_index, const PrintMsg_Print_Params& default_params, - double* content_width_in_points, - double* content_height_in_points, - double* margin_top_in_points, - double* margin_right_in_points, - double* margin_bottom_in_points, - double* margin_left_in_points) { + PageSizeMargins* page_layout_in_points) { int dpi = GetDPI(&default_params); WebSize page_size_in_pixels( @@ -612,38 +607,30 @@ void PrintWebViewHelper::GetPageSizeAndMarginsInPoints( margin_left_in_pixels); } - *content_width_in_points = ConvertPixelsToPoint(page_size_in_pixels.width - - margin_left_in_pixels - - margin_right_in_pixels); - *content_height_in_points = ConvertPixelsToPoint(page_size_in_pixels.height - - margin_top_in_pixels - - margin_bottom_in_pixels); + page_layout_in_points->content_width = + ConvertPixelsToPoint(page_size_in_pixels.width - + margin_left_in_pixels - + margin_right_in_pixels); + page_layout_in_points->content_height = + ConvertPixelsToPoint(page_size_in_pixels.height - + margin_top_in_pixels - + margin_bottom_in_pixels); // Invalid page size and/or margins. We just use the default setting. - if (*content_width_in_points < 1.0 || *content_height_in_points < 1.0) { - GetPageSizeAndMarginsInPoints(NULL, - page_index, - default_params, - content_width_in_points, - content_height_in_points, - margin_top_in_points, - margin_right_in_points, - margin_bottom_in_points, - margin_left_in_points); + if (page_layout_in_points->content_width < 1.0 || + page_layout_in_points->content_height < 1.0) { + GetPageSizeAndMarginsInPoints(NULL, page_index, default_params, + page_layout_in_points); return; } - if (margin_top_in_points) - *margin_top_in_points = + page_layout_in_points->margin_top = ConvertPixelsToPointDouble(margin_top_in_pixels); - if (margin_right_in_points) - *margin_right_in_points = + page_layout_in_points->margin_right = ConvertPixelsToPointDouble(margin_right_in_pixels); - if (margin_bottom_in_points) - *margin_bottom_in_points = + page_layout_in_points->margin_bottom = ConvertPixelsToPointDouble(margin_bottom_in_pixels); - if (margin_left_in_points) - *margin_left_in_points = + page_layout_in_points->margin_left = ConvertPixelsToPointDouble(margin_left_in_pixels); } @@ -651,28 +638,27 @@ void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( WebFrame* frame, WebNode* node, PrintMsg_Print_Params* params) { - double content_width_in_points; - double content_height_in_points; - double margin_top_in_points; - double margin_right_in_points; - double margin_bottom_in_points; - double margin_left_in_points; PrepareFrameAndViewForPrint prepare(*params, frame, node); + PageSizeMargins page_layout_in_points; PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, - &content_width_in_points, &content_height_in_points, - &margin_top_in_points, &margin_right_in_points, - &margin_bottom_in_points, &margin_left_in_points); + &page_layout_in_points); int dpi = GetDPI(params); params->printable_size = gfx::Size( - static_cast<int>(ConvertUnitDouble(content_width_in_points, + static_cast<int>(ConvertUnitDouble( + page_layout_in_points.content_width, printing::kPointsPerInch, dpi)), - static_cast<int>(ConvertUnitDouble(content_height_in_points, + static_cast<int>(ConvertUnitDouble( + page_layout_in_points.content_height, printing::kPointsPerInch, dpi))); - double page_width_in_points = content_width_in_points + - margin_left_in_points + margin_right_in_points; - double page_height_in_points = content_height_in_points + - margin_top_in_points + margin_bottom_in_points; + double page_width_in_points = + page_layout_in_points.content_width + + page_layout_in_points.margin_left + + page_layout_in_points.margin_right; + double page_height_in_points = + page_layout_in_points.content_height + + page_layout_in_points.margin_top + + page_layout_in_points.margin_bottom; params->page_size = gfx::Size( static_cast<int>(ConvertUnitDouble( @@ -681,9 +667,9 @@ void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( page_height_in_points, printing::kPointsPerInch, dpi))); params->margin_top = static_cast<int>(ConvertUnitDouble( - margin_top_in_points, printing::kPointsPerInch, dpi)); + page_layout_in_points.margin_top, printing::kPointsPerInch, dpi)); params->margin_left = static_cast<int>(ConvertUnitDouble( - margin_left_in_points, printing::kPointsPerInch, dpi)); + page_layout_in_points.margin_left, printing::kPointsPerInch, dpi)); } bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, |