| OLD | NEW |
| 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 "chrome/renderer/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #if defined(OS_MACOSX) && !defined(USE_SKIA) | 7 #if defined(OS_MACOSX) && !defined(USE_SKIA) |
| 8 #include <CoreGraphics/CGContext.h> | 8 #include <CoreGraphics/CGContext.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 ConvertPixelsToPointDouble(margin_left_in_pixels); | 980 ConvertPixelsToPointDouble(margin_left_in_pixels); |
| 981 } | 981 } |
| 982 | 982 |
| 983 // static - Not anonymous so that platform implementations can use it. | 983 // static - Not anonymous so that platform implementations can use it. |
| 984 void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( | 984 void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( |
| 985 WebFrame* frame, | 985 WebFrame* frame, |
| 986 WebNode* node, | 986 WebNode* node, |
| 987 PrepareFrameAndViewForPrint* prepare, | 987 PrepareFrameAndViewForPrint* prepare, |
| 988 PrintMsg_Print_Params* params) { | 988 PrintMsg_Print_Params* params) { |
| 989 PageSizeMargins page_layout_in_points; | 989 PageSizeMargins page_layout_in_points; |
| 990 prepare->UpdatePrintParams(*params); | |
| 991 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, | 990 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, |
| 992 &page_layout_in_points); | 991 &page_layout_in_points); |
| 993 int dpi = GetDPI(params); | 992 int dpi = GetDPI(params); |
| 994 params->printable_size = gfx::Size( | 993 params->printable_size = gfx::Size( |
| 995 static_cast<int>(ConvertUnitDouble( | 994 static_cast<int>(ConvertUnitDouble( |
| 996 page_layout_in_points.content_width, | 995 page_layout_in_points.content_width, |
| 997 printing::kPointsPerInch, dpi)), | 996 printing::kPointsPerInch, dpi)), |
| 998 static_cast<int>(ConvertUnitDouble( | 997 static_cast<int>(ConvertUnitDouble( |
| 999 page_layout_in_points.content_height, | 998 page_layout_in_points.content_height, |
| 1000 printing::kPointsPerInch, dpi))); | 999 printing::kPointsPerInch, dpi))); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1011 params->page_size = gfx::Size( | 1010 params->page_size = gfx::Size( |
| 1012 static_cast<int>(ConvertUnitDouble( | 1011 static_cast<int>(ConvertUnitDouble( |
| 1013 page_width_in_points, printing::kPointsPerInch, dpi)), | 1012 page_width_in_points, printing::kPointsPerInch, dpi)), |
| 1014 static_cast<int>(ConvertUnitDouble( | 1013 static_cast<int>(ConvertUnitDouble( |
| 1015 page_height_in_points, printing::kPointsPerInch, dpi))); | 1014 page_height_in_points, printing::kPointsPerInch, dpi))); |
| 1016 | 1015 |
| 1017 params->margin_top = static_cast<int>(ConvertUnitDouble( | 1016 params->margin_top = static_cast<int>(ConvertUnitDouble( |
| 1018 page_layout_in_points.margin_top, printing::kPointsPerInch, dpi)); | 1017 page_layout_in_points.margin_top, printing::kPointsPerInch, dpi)); |
| 1019 params->margin_left = static_cast<int>(ConvertUnitDouble( | 1018 params->margin_left = static_cast<int>(ConvertUnitDouble( |
| 1020 page_layout_in_points.margin_left, printing::kPointsPerInch, dpi)); | 1019 page_layout_in_points.margin_left, printing::kPointsPerInch, dpi)); |
| 1020 |
| 1021 prepare->UpdatePrintParams(*params); |
| 1021 } | 1022 } |
| 1022 | 1023 |
| 1023 bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, | 1024 bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, |
| 1024 WebKit::WebNode* node) { | 1025 WebKit::WebNode* node) { |
| 1025 DCHECK(frame); | 1026 DCHECK(frame); |
| 1026 PrintMsg_PrintPages_Params settings; | 1027 PrintMsg_PrintPages_Params settings; |
| 1027 | 1028 |
| 1028 Send(new PrintHostMsg_GetDefaultPrintSettings(routing_id(), | 1029 Send(new PrintHostMsg_GetDefaultPrintSettings(routing_id(), |
| 1029 &settings.params)); | 1030 &settings.params)); |
| 1030 // Check if the printer returned any settings, if the settings is empty, we | 1031 // Check if the printer returned any settings, if the settings is empty, we |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 const gfx::Size& | 1457 const gfx::Size& |
| 1457 PrintWebViewHelper::PrintPreviewContext::GetPrintCanvasSize() const { | 1458 PrintWebViewHelper::PrintPreviewContext::GetPrintCanvasSize() const { |
| 1458 return prep_frame_view_->GetPrintCanvasSize(); | 1459 return prep_frame_view_->GetPrintCanvasSize(); |
| 1459 } | 1460 } |
| 1460 | 1461 |
| 1461 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1462 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
| 1462 prep_frame_view_.reset(); | 1463 prep_frame_view_.reset(); |
| 1463 metafile_.reset(); | 1464 metafile_.reset(); |
| 1464 pages_to_render_.clear(); | 1465 pages_to_render_.clear(); |
| 1465 } | 1466 } |
| OLD | NEW |