diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 00:05:15 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 00:05:15 +0000 |
commit | eb37e0a4a6e723abde3ca6aa1f6fecc75955363c (patch) | |
tree | 035d97802c5c8f252d24bac784a18c1d463dcac5 /chrome/renderer | |
parent | 1ce8f543ecdc029983ccd141b06f70c5bdb65fc0 (diff) | |
download | chromium_src-eb37e0a4a6e723abde3ca6aa1f6fecc75955363c.zip chromium_src-eb37e0a4a6e723abde3ca6aa1f6fecc75955363c.tar.gz chromium_src-eb37e0a4a6e723abde3ca6aa1f6fecc75955363c.tar.bz2 |
Cleanup: Move several ifdefs into a single function.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6523006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74882 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/print_web_view_helper.cc | 36 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper.h | 1 |
2 files changed, 17 insertions, 20 deletions
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index c46a383..b15e121 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -41,6 +41,20 @@ using WebKit::WebString; using WebKit::WebURLRequest; using WebKit::WebView; +namespace { + +int GetDPI(const ViewMsg_Print_Params* print_params) { +#if defined(OS_MACOSX) + // On the Mac, the printable area is in points, don't do any scaling based + // on dpi. + return printing::kPointsPerInch; +#else + return static_cast<int>(print_params->dpi); +#endif // defined(OS_MACOSX) +} + +} // namespace + PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( const ViewMsg_Print_Params& print_params, WebFrame* frame, @@ -48,12 +62,7 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( WebView* web_view) : frame_(frame), web_view_(web_view), expected_pages_count_(0), use_browser_overlays_(true) { - int dpi = static_cast<int>(print_params.dpi); -#if defined(OS_MACOSX) - // On the Mac, the printable area is in points, don't do any scaling based - // on dpi. - dpi = printing::kPointsPerInch; -#endif // defined(OS_MACOSX) + int dpi = GetDPI(&print_params); print_canvas_size_.set_width( ConvertUnit(print_params.printable_size.width(), dpi, print_params.desired_dpi)); @@ -347,12 +356,7 @@ void PrintWebViewHelper::GetPageSizeAndMarginsInPoints( double* margin_right_in_points, double* margin_bottom_in_points, double* margin_left_in_points) { - int dpi = static_cast<int>(default_params.dpi); -#if defined(OS_MACOSX) - // On the Mac, the printable area is in points, don't do any scaling based - // on dpi. - dpi = printing::kPointsPerInch; -#endif + int dpi = GetDPI(&default_params); WebSize page_size_in_pixels( ConvertUnit(default_params.page_size.width(), @@ -433,13 +437,7 @@ void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( &content_width_in_points, &content_height_in_points, &margin_top_in_points, &margin_right_in_points, &margin_bottom_in_points, &margin_left_in_points); -#if defined(OS_MACOSX) - // On the Mac, the printable area is in points, don't do any scaling based - // on dpi. - int dpi = printing::kPointsPerInch; -#else - int dpi = static_cast<int>(params->dpi); -#endif // defined(OS_MACOSX) + int dpi = GetDPI(params); params->printable_size = gfx::Size( static_cast<int>(ConvertUnitDouble(content_width_in_points, printing::kPointsPerInch, dpi)), diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index 3f7e1b5..c8789ee 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -33,7 +33,6 @@ class VectorCanvas; struct ViewMsg_Print_Params; struct ViewMsg_PrintPage_Params; struct ViewMsg_PrintPages_Params; -struct ViewHostMsg_DidPreviewDocument_Params; // Class that calls the Begin and End print functions on the frame and changes // the size of the view temporarily to support full page printing.. |