OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
10 #include "chrome/renderer/render_view.h" | 10 #include "chrome/renderer/render_view.h" |
11 #include "gfx/codec/jpeg_codec.h" | 11 #include "gfx/codec/jpeg_codec.h" |
12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
13 #include "printing/units.h" | 13 #include "printing/units.h" |
14 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
16 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" |
18 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" |
19 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" |
20 #include "webkit/glue/webkit_glue.h" | 20 #include "webkit/glue/webkit_glue.h" |
21 | 21 |
22 using printing::ConvertPixelsToPoint; | 22 using printing::ConvertPixelsToPoint; |
23 using printing::ConvertPixelsToPointDouble; | 23 using printing::ConvertPixelsToPointDouble; |
24 using printing::ConvertUnit; | 24 using printing::ConvertUnit; |
| 25 using printing::ConvertUnitDouble; |
25 using WebKit::WebConsoleMessage; | 26 using WebKit::WebConsoleMessage; |
26 using WebKit::WebFrame; | 27 using WebKit::WebFrame; |
27 using WebKit::WebRect; | 28 using WebKit::WebRect; |
28 using WebKit::WebSize; | 29 using WebKit::WebSize; |
29 using WebKit::WebScreenInfo; | 30 using WebKit::WebScreenInfo; |
30 using WebKit::WebString; | 31 using WebKit::WebString; |
31 using WebKit::WebURLRequest; | 32 using WebKit::WebURLRequest; |
32 using WebKit::WebView; | 33 using WebKit::WebView; |
33 | 34 |
34 PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( | 35 PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 if (margin_bottom_in_points) | 431 if (margin_bottom_in_points) |
431 *margin_bottom_in_points = | 432 *margin_bottom_in_points = |
432 ConvertPixelsToPointDouble(margin_bottom_in_pixels); | 433 ConvertPixelsToPointDouble(margin_bottom_in_pixels); |
433 if (margin_left_in_points) | 434 if (margin_left_in_points) |
434 *margin_left_in_points = | 435 *margin_left_in_points = |
435 ConvertPixelsToPointDouble(margin_left_in_pixels); | 436 ConvertPixelsToPointDouble(margin_left_in_pixels); |
436 } | 437 } |
437 | 438 |
438 void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( | 439 void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( |
439 WebFrame* frame, ViewMsg_Print_Params* params) { | 440 WebFrame* frame, ViewMsg_Print_Params* params) { |
440 #if defined(OS_MACOSX) | |
441 double content_width_in_points; | 441 double content_width_in_points; |
442 double content_height_in_points; | 442 double content_height_in_points; |
443 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, | 443 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, |
444 &content_width_in_points, | 444 &content_width_in_points, |
445 &content_height_in_points, | 445 &content_height_in_points, |
446 NULL, NULL, NULL, NULL); | 446 NULL, NULL, NULL, NULL); |
| 447 #if defined(OS_MACOSX) |
447 params->printable_size = gfx::Size( | 448 params->printable_size = gfx::Size( |
448 static_cast<int>(content_width_in_points), | 449 static_cast<int>(content_width_in_points), |
449 static_cast<int>(content_height_in_points)); | 450 static_cast<int>(content_height_in_points)); |
| 451 #else |
| 452 params->printable_size = gfx::Size( |
| 453 static_cast<int>(ConvertUnitDouble( |
| 454 content_width_in_points, printing::kPointsPerInch, params->dpi)), |
| 455 static_cast<int>(ConvertUnitDouble( |
| 456 content_height_in_points, printing::kPointsPerInch, params->dpi))); |
450 #endif | 457 #endif |
451 } | 458 } |
OLD | NEW |