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

Side by Side Diff: chrome/renderer/print_web_view_helper_win.cc

Issue 7348010: Added Header and Footer support using Skia (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Changes based on 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 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 page_size, content_area, frame->getPrintPageShrink(page_number)); 180 page_size, content_area, frame->getPrintPageShrink(page_number));
181 DCHECK(device); 181 DCHECK(device);
182 // The printPage method may take a reference to the canvas we pass down, so it 182 // The printPage method may take a reference to the canvas we pass down, so it
183 // can't be a stack object. 183 // can't be a stack object.
184 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); 184 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device);
185 canvas->unref(); // SkRefPtr and new both took a reference. 185 canvas->unref(); // SkRefPtr and new both took a reference.
186 if (is_preview) 186 if (is_preview)
187 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); 187 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile);
188 188
189 float webkit_scale_factor = frame->printPage(page_number, canvas.get()); 189 float webkit_scale_factor = frame->printPage(page_number, canvas.get());
190
191 if (is_preview && params.display_header_footer) {
vandebo (ex-Chrome) 2011/08/12 22:18:20 is_preview isn't needed
Aayush Kumar 2011/08/13 04:04:53 Done.
192 // |page_number| is 0-based, so 1 is added.
193 PrintHeaderAndFooter(device, canvas.get(), page_number + 1,
194 print_preview_context_.total_page_count(),
195 webkit_scale_factor, page_layout_in_points,
196 *header_footer_info_);
197 }
198
190 if (*scale_factor <= 0 || webkit_scale_factor <= 0) { 199 if (*scale_factor <= 0 || webkit_scale_factor <= 0) {
191 NOTREACHED() << "Printing page " << page_number << " failed."; 200 NOTREACHED() << "Printing page " << page_number << " failed.";
192 } else { 201 } else {
193 // Update the dpi adjustment with the "page |scale_factor|" calculated in 202 // Update the dpi adjustment with the "page |scale_factor|" calculated in
194 // webkit. 203 // webkit.
195 *scale_factor /= webkit_scale_factor; 204 *scale_factor /= webkit_scale_factor;
196 } 205 }
197 206
198 bool result = metafile->FinishPage(); 207 bool result = metafile->FinishPage();
199 DCHECK(result); 208 DCHECK(result);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 shared_buf.Unmap(); 287 shared_buf.Unmap();
279 return false; 288 return false;
280 } 289 }
281 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); 290 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle);
282 shared_buf.Unmap(); 291 shared_buf.Unmap();
283 292
284 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, 293 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle,
285 shared_mem_handle)); 294 shared_mem_handle));
286 return true; 295 return true;
287 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698