Index: chrome/renderer/print_web_view_helper_win.cc |
diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc |
index 4627e0dab9211d7fecfd624e470c5bea900b7df1..dedb08f3889ae4a066e110b12fc7f4baa359bb99 100644 |
--- a/chrome/renderer/print_web_view_helper_win.cc |
+++ b/chrome/renderer/print_web_view_helper_win.cc |
@@ -145,15 +145,8 @@ void PrintWebViewHelper::RenderPreviewPage(int page_number) { |
void PrintWebViewHelper::RenderPage( |
const PrintMsg_Print_Params& params, float* scale_factor, int page_number, |
bool is_preview, WebFrame* frame, scoped_ptr<Metafile>* metafile) { |
- double content_width_in_points; |
- double content_height_in_points; |
- double margin_top_in_points; |
- double margin_left_in_points; |
- GetPageSizeAndMarginsInPoints(frame, page_number, params, |
- &content_width_in_points, |
- &content_height_in_points, |
- &margin_top_in_points, NULL, NULL, |
- &margin_left_in_points); |
+ PageSizeMargins page_size_margins_in_points = |
+ GetPageSizeAndMarginsInPoints(frame, page_number, params); |
int width; |
int height; |
@@ -166,15 +159,18 @@ void PrintWebViewHelper::RenderPage( |
// Since WebKit extends the page width depending on the magical scale factor |
// we make sure the canvas covers the worst case scenario (x2.0 currently). |
// PrintContext will then set the correct clipping region. |
- width = static_cast<int>(content_width_in_points * params.max_shrink); |
- height = static_cast<int>(content_height_in_points * params.max_shrink); |
+ width = static_cast<int>(page_size_margins_in_points.content_width * |
+ params.max_shrink); |
+ height = static_cast<int>(page_size_margins_in_points.content_height * |
+ params.max_shrink); |
} |
gfx::Size page_size(width, height); |
- gfx::Rect content_area(static_cast<int>(margin_left_in_points), |
- static_cast<int>(margin_top_in_points), |
- static_cast<int>(content_width_in_points), |
- static_cast<int>(content_height_in_points)); |
+ gfx::Rect content_area( |
+ static_cast<int>(page_size_margins_in_points.margin_left), |
+ static_cast<int>(page_size_margins_in_points.margin_top), |
+ static_cast<int>(page_size_margins_in_points.content_width), |
+ static_cast<int>(page_size_margins_in_points.content_height)); |
SkDevice* device = (*metafile)->StartPageForVectorCanvas( |
page_size, content_area, frame->getPrintPageShrink(page_number)); |
DCHECK(device); |
@@ -188,6 +184,16 @@ void PrintWebViewHelper::RenderPage( |
} |
float webkit_scale_factor = frame->printPage(page_number, canvas.get()); |
+ |
+ if (is_preview && params.display_header_footer) { |
+ // The page_number count starts from 0, so we add 1. |
+ PrintHeaderAndFooter(static_cast<skia::VectorPlatformDeviceSkia*>(device), |
+ canvas, page_number + 1, |
+ print_preview_context_.total_page_count(), |
+ webkit_scale_factor, page_size_margins_in_points, |
+ header_footer_info_); |
+ } |
+ |
if (*scale_factor <= 0 || webkit_scale_factor <= 0) { |
NOTREACHED() << "Printing page " << page_number << " failed."; |
} else { |