Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(840)

Side by Side Diff: chrome/renderer/print_web_view_helper_mac.mm

Issue 7348010: Added Header and Footer support using Skia (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove header_footer_info from settings Dictionary. Changes as per Steve and Kausalya's comments. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 18 matching lines...) Expand all
29 printing::NativeMetafile metafile; 29 printing::NativeMetafile metafile;
30 if (!metafile.Init()) 30 if (!metafile.Init())
31 return; 31 return;
32 32
33 float scale_factor = frame->getPrintPageShrink(params.page_number); 33 float scale_factor = frame->getPrintPageShrink(params.page_number);
34 int page_number = params.page_number; 34 int page_number = params.page_number;
35 int page_slot = params.page_slot; 35 int page_slot = params.page_slot;
36 36
37 // Render page for printing. 37 // Render page for printing.
38 gfx::Rect content_area(params.params.printable_size); 38 gfx::Rect content_area(params.params.printable_size);
39 params.display_header_footer = false;
39 RenderPage(params.params.printable_size, content_area, scale_factor, 40 RenderPage(params.params.printable_size, content_area, scale_factor,
40 page_number, page_slot, frame, &metafile); 41 page_number, page_slot, frame, &metafile);
41 metafile.FinishDocument(); 42 metafile.FinishDocument();
42 43
43 PrintHostMsg_DidPrintPage_Params page_params; 44 PrintHostMsg_DidPrintPage_Params page_params;
44 page_params.data_size = metafile.GetDataSize(); 45 page_params.data_size = metafile.GetDataSize();
45 page_params.page_number = page_number; 46 page_params.page_number = page_number;
46 page_params.document_cookie = params.params.document_cookie; 47 page_params.document_cookie = params.params.document_cookie;
47 page_params.actual_shrink = scale_factor; 48 page_params.actual_shrink = scale_factor;
48 page_params.page_size = params.params.page_size; 49 page_params.page_size = params.params.page_size;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 #else 132 #else
132 bool success = metafile->StartPage(page_size, content_area, scale_factor); 133 bool success = metafile->StartPage(page_size, content_area, scale_factor);
133 DCHECK(success); 134 DCHECK(success);
134 // printPage can create autoreleased references to |context|. PDF contexts 135 // printPage can create autoreleased references to |context|. PDF contexts
135 // don't write all their data until they are destroyed, so we need to make 136 // don't write all their data until they are destroyed, so we need to make
136 // certain that there are no lingering references. 137 // certain that there are no lingering references.
137 base::mac::ScopedNSAutoreleasePool pool; 138 base::mac::ScopedNSAutoreleasePool pool;
138 CGContextRef cgContext = metafile->context(); 139 CGContextRef cgContext = metafile->context();
139 CGContextRef canvasPtr = cgContext; 140 CGContextRef canvasPtr = cgContext;
140 #endif 141 #endif
141 frame->printPage(page_number, canvasPtr); 142 float webkit_scale_factor = frame->printPage(page_number, canvasPtr);
143 #if defined(USE_SKIA)
144 PrintMsg_Print_Params printParams = print_preview_context_.print_params();
145 if (printParams.display_header_footer) {
146 PageSizeMargins page_layout_in_points;
147 GetPageSizeAndMarginsInPoints(frame, page_number, printParams,
148 &page_layout_in_points);
149 // |page_number| is 0-based, so 1 is added.
150 PrintHeaderAndFooter(device, canvas.get(), page_number + 1,
151 print_preview_context_.total_page_count(),
152 webkit_scale_factor, page_layout_in_points,
153 *header_footer_info_);
154 }
155 #endif // USE_SKIA
142 } 156 }
143 157
144 // Done printing. Close the device context to retrieve the compiled metafile. 158 // Done printing. Close the device context to retrieve the compiled metafile.
145 metafile->FinishPage(); 159 metafile->FinishPage();
146 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698