| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 void PrintWebViewHelper::RenderPage( | 135 void PrintWebViewHelper::RenderPage( |
| 136 const PrintMsg_Print_Params& params, int page_number, WebFrame* frame, | 136 const PrintMsg_Print_Params& params, int page_number, WebFrame* frame, |
| 137 bool is_preview, printing::Metafile* metafile, gfx::Size* page_size, | 137 bool is_preview, printing::Metafile* metafile, gfx::Size* page_size, |
| 138 gfx::Rect* content_rect) { | 138 gfx::Rect* content_rect) { |
| 139 double scale_factor = 1.0f; | 139 double scale_factor = 1.0f; |
| 140 double webkit_shrink_factor = frame->getPrintPageShrink(page_number); | 140 double webkit_shrink_factor = frame->getPrintPageShrink(page_number); |
| 141 printing::PageSizeMargins page_layout_in_points; | 141 printing::PageSizeMargins page_layout_in_points; |
| 142 gfx::Rect content_area; | 142 gfx::Rect content_area; |
| 143 | 143 |
| 144 ComputePageLayoutInPointsForCss(frame, page_number, params, | 144 ComputePageLayoutInPointsForCss(frame, page_number, params, |
| 145 ignore_css_margins_, fit_to_page_, | 145 ignore_css_margins_, &scale_factor, |
| 146 &scale_factor, &page_layout_in_points); | 146 &page_layout_in_points); |
| 147 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, page_size, | 147 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, page_size, |
| 148 &content_area); | 148 &content_area); |
| 149 if (content_rect) | 149 if (content_rect) |
| 150 *content_rect = content_area; | 150 *content_rect = content_area; |
| 151 | 151 |
| 152 scale_factor *= webkit_shrink_factor; | 152 scale_factor *= webkit_shrink_factor; |
| 153 { | 153 { |
| 154 #if defined(USE_SKIA) | 154 #if defined(USE_SKIA) |
| 155 SkDevice* device = metafile->StartPageForVectorCanvas( | 155 SkDevice* device = metafile->StartPageForVectorCanvas( |
| 156 *page_size, content_area, scale_factor); | 156 *page_size, content_area, scale_factor); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 print_preview_context_.total_page_count(), | 195 print_preview_context_.total_page_count(), |
| 196 scale_factor, page_layout_in_points, | 196 scale_factor, page_layout_in_points, |
| 197 *header_footer_info_); | 197 *header_footer_info_); |
| 198 } | 198 } |
| 199 #endif // defined(USE_SKIA) | 199 #endif // defined(USE_SKIA) |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Done printing. Close the device context to retrieve the compiled metafile. | 202 // Done printing. Close the device context to retrieve the compiled metafile. |
| 203 metafile->FinishPage(); | 203 metafile->FinishPage(); |
| 204 } | 204 } |
| OLD | NEW |