Chromium Code Reviews| Index: chrome/renderer/print_web_view_helper_win.cc |
| diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc |
| index 08b6bed88b9da5c34538dc8c3e403623fd9ac0dc..851e8d45f7f10cf95f653950018bbe78b10d8551 100644 |
| --- a/chrome/renderer/print_web_view_helper_win.cc |
| +++ b/chrome/renderer/print_web_view_helper_win.cc |
| @@ -109,8 +109,8 @@ void PrintWebViewHelper::PrintPageInternal( |
| int page_number = params.page_number; |
| // Calculate the dpi adjustment. |
| - float scale_factor = static_cast<float>(params.params.desired_dpi / |
| - params.params.dpi); |
| + double scale_factor = static_cast<float>(params.params.desired_dpi / |
| + params.params.dpi); |
| // Render page for printing. |
| metafile.reset(RenderPage(params.params, &scale_factor, page_number, false, |
| @@ -146,7 +146,7 @@ void PrintWebViewHelper::PrintPageInternal( |
| bool PrintWebViewHelper::RenderPreviewPage(int page_number) { |
| PrintMsg_Print_Params print_params = print_preview_context_.print_params(); |
| // Calculate the dpi adjustment. |
| - float scale_factor = static_cast<float>(print_params.desired_dpi / |
| + double scale_factor = static_cast<float>(print_params.desired_dpi / |
| print_params.dpi); |
| scoped_ptr<Metafile> draft_metafile; |
| printing::Metafile* initial_render_metafile = |
| @@ -178,19 +178,24 @@ bool PrintWebViewHelper::RenderPreviewPage(int page_number) { |
| } |
| Metafile* PrintWebViewHelper::RenderPage( |
| - const PrintMsg_Print_Params& params, float* scale_factor, int page_number, |
| + const PrintMsg_Print_Params& params, double* scale_factor, int page_number, |
| bool is_preview, WebFrame* frame, Metafile* metafile) { |
| printing::PageSizeMargins page_layout_in_points; |
| + *scale_factor = frame->getPrintPageShrink(page_number); |
| GetPageSizeAndMarginsInPoints(frame, page_number, params, |
| - &page_layout_in_points); |
| - |
| + ignore_frame_margins_css_, fit_to_page_, |
| + scale_factor, &page_layout_in_points); |
| int width; |
| int height; |
| if (is_preview) { |
| int dpi = static_cast<int>(params.dpi); |
| int desired_dpi = printing::kPointsPerInch; |
| - width = ConvertUnit(params.page_size.width(), dpi, desired_dpi); |
| - height = ConvertUnit(params.page_size.height(), dpi, desired_dpi); |
| + width = page_layout_in_points.content_width + |
|
vandebo (ex-Chrome)
2011/12/04 22:20:34
Why is the width no longer just params.page_size_w
kmadhusu
2011/12/05 09:06:54
(same here)
When source is html (with a special m
|
| + page_layout_in_points.margin_right + |
| + page_layout_in_points.margin_left; |
| + height = page_layout_in_points.content_height + |
| + page_layout_in_points.margin_top + |
| + page_layout_in_points.margin_bottom; |
| } else { |
| // Since WebKit extends the page width depending on the magical scale factor |
| // we make sure the canvas covers the worst case scenario (x2.0 currently). |
| @@ -208,7 +213,7 @@ Metafile* PrintWebViewHelper::RenderPage( |
| static_cast<int>(page_layout_in_points.content_width), |
| static_cast<int>(page_layout_in_points.content_height)); |
| SkDevice* device = metafile->StartPageForVectorCanvas( |
| - page_size, content_area, frame->getPrintPageShrink(page_number)); |
| + page_size, content_area, *scale_factor); |
| DCHECK(device); |
| // The printPage method may take a reference to the canvas we pass down, so it |
| // can't be a stack object. |
| @@ -226,7 +231,7 @@ Metafile* PrintWebViewHelper::RenderPage( |
| // |page_number| is 0-based, so 1 is added. |
| PrintHeaderAndFooter(canvas.get(), page_number + 1, |
| print_preview_context_.total_page_count(), |
| - webkit_scale_factor, page_layout_in_points, |
| + *scale_factor, page_layout_in_points, |
| *header_footer_info_); |
| } |