OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 double margin_top_in_points; | 361 double margin_top_in_points; |
362 double margin_right_in_points; | 362 double margin_right_in_points; |
363 double margin_bottom_in_points; | 363 double margin_bottom_in_points; |
364 double margin_left_in_points; | 364 double margin_left_in_points; |
365 PrepareFrameAndViewForPrint prepare(*params, frame, frame->view()); | 365 PrepareFrameAndViewForPrint prepare(*params, frame, frame->view()); |
366 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, | 366 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, |
367 &content_width_in_points, &content_height_in_points, | 367 &content_width_in_points, &content_height_in_points, |
368 &margin_top_in_points, &margin_right_in_points, | 368 &margin_top_in_points, &margin_right_in_points, |
369 &margin_bottom_in_points, &margin_left_in_points); | 369 &margin_bottom_in_points, &margin_left_in_points); |
370 | 370 |
371 int dpi = static_cast<int>(params->dpi); | |
Lei Zhang
2011/01/11 22:17:25
you can rewrite this as:
int dpi =
#if defined(OS
kmadhusu
2011/01/11 23:55:54
Done.
| |
371 #if defined(OS_MACOSX) | 372 #if defined(OS_MACOSX) |
373 // On the Mac, the printable area is in points, don't do any scaling based | |
374 // on dpi. | |
375 dpi = printing::kPointsPerInch; | |
376 #endif // defined(OS_MACOSX) | |
377 params->printable_size = gfx::Size( | |
378 static_cast<int>(ConvertUnitDouble(content_width_in_points, | |
379 printing::kPointsPerInch, dpi)), | |
380 static_cast<int>(ConvertUnitDouble(content_height_in_points, | |
381 printing::kPointsPerInch, dpi))); | |
382 | |
372 params->page_size = gfx::Size( | 383 params->page_size = gfx::Size( |
373 static_cast<int>(content_width_in_points + | 384 static_cast<int>(ConvertUnitDouble(content_width_in_points + |
374 margin_left_in_points + margin_right_in_points), | 385 margin_left_in_points + margin_right_in_points, |
375 static_cast<int>(content_height_in_points + | 386 printing::kPointsPerInch, dpi)), |
376 margin_top_in_points + margin_bottom_in_points)); | 387 static_cast<int>(ConvertUnitDouble(content_height_in_points + |
388 margin_top_in_points + margin_bottom_in_points, | |
389 printing::kPointsPerInch, dpi))); | |
377 | 390 |
378 params->printable_size = gfx::Size(static_cast<int>(content_width_in_points), | 391 params->margin_top = static_cast<int>(ConvertUnitDouble( |
379 static_cast<int>(content_height_in_points)); | 392 margin_top_in_points, printing::kPointsPerInch, dpi)); |
380 #else | 393 params->margin_left = static_cast<int>(ConvertUnitDouble( |
381 params->printable_size = gfx::Size( | 394 margin_left_in_points, printing::kPointsPerInch, dpi)); |
382 static_cast<int>(ConvertUnitDouble( | |
383 content_width_in_points, printing::kPointsPerInch, params->dpi)), | |
384 static_cast<int>(ConvertUnitDouble( | |
385 content_height_in_points, printing::kPointsPerInch, params->dpi))); | |
386 #endif | |
387 params->margin_top = static_cast<int>(margin_top_in_points); | |
388 params->margin_left = static_cast<int>(margin_left_in_points); | |
389 } | 395 } |
390 | 396 |
391 bool PrintWebViewHelper::InitPrintSettings(WebFrame* frame) { | 397 bool PrintWebViewHelper::InitPrintSettings(WebFrame* frame) { |
392 ViewMsg_PrintPages_Params settings; | 398 ViewMsg_PrintPages_Params settings; |
393 if (GetDefaultPrintSettings(frame, &settings.params)) { | 399 if (GetDefaultPrintSettings(frame, &settings.params)) { |
394 print_pages_params_.reset(new ViewMsg_PrintPages_Params(settings)); | 400 print_pages_params_.reset(new ViewMsg_PrintPages_Params(settings)); |
395 print_pages_params_->pages.clear(); | 401 print_pages_params_->pages.clear(); |
396 return true; | 402 return true; |
397 } | 403 } |
398 return false; | 404 return false; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), | 504 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), |
499 shared_mem_handle); | 505 shared_mem_handle); |
500 return true; | 506 return true; |
501 } | 507 } |
502 } | 508 } |
503 } | 509 } |
504 NOTREACHED(); | 510 NOTREACHED(); |
505 return false; | 511 return false; |
506 } | 512 } |
507 #endif | 513 #endif |
OLD | NEW |