Chromium Code Reviews| Index: components/printing/renderer/print_web_view_helper.cc |
| diff --git a/components/printing/renderer/print_web_view_helper.cc b/components/printing/renderer/print_web_view_helper.cc |
| index fa79d1a2714353a0a665ff0e7f4c77d78738f0ea..3b030fd654ab1817b8e5084c07a5880b43897dda 100644 |
| --- a/components/printing/renderer/print_web_view_helper.cc |
| +++ b/components/printing/renderer/print_web_view_helper.cc |
| @@ -126,9 +126,9 @@ PrintMsg_Print_Params GetCssPrintParams( |
| PrintMsg_Print_Params page_css_params = page_params; |
| int dpi = GetDPI(&page_params); |
| - blink::WebSize page_size_in_pixels( |
| - ConvertUnit(page_params.page_size.width(), dpi, kPixelsPerInch), |
| - ConvertUnit(page_params.page_size.height(), dpi, kPixelsPerInch)); |
| + blink::WebFloatSize page_size_in_pixels( |
| + ConvertUnitDouble(page_params.page_size.width(), dpi, kPixelsPerInch), |
| + ConvertUnitDouble(page_params.page_size.height(), dpi, kPixelsPerInch)); |
| int margin_top_in_pixels = |
| ConvertUnit(page_params.margin_top, dpi, kPixelsPerInch); |
| int margin_right_in_pixels = ConvertUnit( |
| @@ -143,8 +143,6 @@ PrintMsg_Print_Params GetCssPrintParams( |
| page_params.margin_left, |
| dpi, kPixelsPerInch); |
| - blink::WebSize original_page_size_in_pixels = page_size_in_pixels; |
| - |
| if (frame) { |
| frame->pageSizeAndMarginsInPixels(page_index, |
| page_size_in_pixels, |
| @@ -154,9 +152,9 @@ PrintMsg_Print_Params GetCssPrintParams( |
| margin_left_in_pixels); |
| } |
| - int new_content_width = page_size_in_pixels.width - |
| + float new_content_width = page_size_in_pixels.width - |
| margin_left_in_pixels - margin_right_in_pixels; |
| - int new_content_height = page_size_in_pixels.height - |
| + float new_content_height = 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. |
| @@ -166,20 +164,14 @@ PrintMsg_Print_Params GetCssPrintParams( |
| return page_css_params; |
| } |
| + page_css_params.page_size = |
| + gfx::Size(ConvertUnit(page_size_in_pixels.width, |
| + kPixelsPerInch, dpi), |
| + ConvertUnit(page_size_in_pixels.height, |
|
Lei Zhang
2016/07/06 18:26:45
Just run: clang-format -i -style=Chromium $file, a
|
| + kPixelsPerInch, dpi)); |
| page_css_params.content_size = |
| gfx::Size(ConvertUnit(new_content_width, kPixelsPerInch, dpi), |
| - ConvertUnit(new_content_height, kPixelsPerInch, dpi)); |
| - |
| - if (original_page_size_in_pixels != page_size_in_pixels) { |
| - page_css_params.page_size = |
| - gfx::Size(ConvertUnit(page_size_in_pixels.width, kPixelsPerInch, dpi), |
| - ConvertUnit(page_size_in_pixels.height, kPixelsPerInch, dpi)); |
| - } else { |
| - // Printing frame doesn't have any page size css. Pixels to dpi conversion |
| - // causes rounding off errors. Therefore use the default page size values |
| - // directly. |
| - page_css_params.page_size = page_params.page_size; |
| - } |
| + ConvertUnit(new_content_height, kPixelsPerInch, dpi)); |
| page_css_params.margin_top = |
| ConvertUnit(margin_top_in_pixels, kPixelsPerInch, dpi); |