diff options
author | hamaji@chromium.org <hamaji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 07:04:05 +0000 |
---|---|---|
committer | hamaji@chromium.org <hamaji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 07:04:05 +0000 |
commit | 40c7cfe39957248d38d8c376fbfc7d332c796741 (patch) | |
tree | 1e9cbc2bda99a4b4bc3286504dbca59a7542fb70 /chrome/renderer/print_web_view_helper.cc | |
parent | 829c9bbc87035a0e6a5606ff7654b761a2d9d0bf (diff) | |
download | chromium_src-40c7cfe39957248d38d8c376fbfc7d332c796741.zip chromium_src-40c7cfe39957248d38d8c376fbfc7d332c796741.tar.gz chromium_src-40c7cfe39957248d38d8c376fbfc7d332c796741.tar.bz2 |
Implement limited paged media support for mac.
BUG=47277
TEST=none
Review URL: http://codereview.chromium.org/2876020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51347 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 | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index d229df1..fb0ece7 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -44,12 +44,12 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( dpi = printing::kPointsPerInch; #endif // defined(OS_MACOSX) print_canvas_size_.set_width( - printing::ConvertUnit(print_params.printable_size.width(), dpi, - print_params.desired_dpi)); + ConvertUnit(print_params.printable_size.width(), dpi, + print_params.desired_dpi)); print_canvas_size_.set_height( - printing::ConvertUnit(print_params.printable_size.height(), dpi, - print_params.desired_dpi)); + ConvertUnit(print_params.printable_size.height(), dpi, + print_params.desired_dpi)); // Layout page according to printer page size. Since WebKit shrinks the // size of the page automatically (from 125% to 200%) we trick it to @@ -131,6 +131,8 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { return; } + UpdatePrintableSizeInPrintParameters(frame, &default_settings); + // Continue only if the settings are valid. if (default_settings.dpi && default_settings.document_cookie) { int expected_pages_count = 0; @@ -173,6 +175,8 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { if (Send(msg)) { msg = NULL; + UpdatePrintableSizeInPrintParameters(frame, &print_settings.params); + // If the settings are invalid, early quit. if (print_settings.params.dpi && print_settings.params.document_cookie) { @@ -430,3 +434,18 @@ void PrintWebViewHelper::GetPageSizeAndMarginsInPoints( *margin_left_in_points = ConvertPixelsToPointDouble(margin_left_in_pixels); } + +void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( + WebFrame* frame, ViewMsg_Print_Params* params) { +#if defined(OS_MACOSX) + double content_width_in_points; + double content_height_in_points; + PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, + &content_width_in_points, + &content_height_in_points, + NULL, NULL, NULL, NULL); + params->printable_size = gfx::Size( + static_cast<int>(content_width_in_points), + static_cast<int>(content_height_in_points)); +#endif +} |