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

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

Issue 8059034: Reland 103021: Printing preview of a PDF on Mac with Skia only previews the last page of the PDF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | chrome/renderer/print_web_view_helper_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/file_descriptor_posix.h" 7 #include "base/file_descriptor_posix.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "chrome/common/print_messages.h" 11 #include "chrome/common/print_messages.h"
12 #include "content/renderer/render_view.h" 12 #include "content/renderer/render_view.h"
13 #include "printing/metafile.h" 13 #include "printing/metafile.h"
14 #include "printing/metafile_impl.h" 14 #include "printing/metafile_impl.h"
15 #include "printing/metafile_skia_wrapper.h" 15 #include "printing/metafile_skia_wrapper.h"
16 #include "printing/page_size_margins.h" 16 #include "printing/page_size_margins.h"
17 #include "skia/ext/platform_device.h"
17 #include "skia/ext/vector_canvas.h" 18 #include "skia/ext/vector_canvas.h"
18 #include "third_party/skia/include/core/SkRefCnt.h" 19 #include "third_party/skia/include/core/SkRefCnt.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
20 21
21 #if !defined(OS_CHROMEOS) 22 #if !defined(OS_CHROMEOS)
22 #include "base/process_util.h" 23 #include "base/process_util.h"
23 #endif // !defined(OS_CHROMEOS) 24 #endif // !defined(OS_CHROMEOS)
24 25
25 using WebKit::WebFrame; 26 using WebKit::WebFrame;
26 using WebKit::WebNode; 27 using WebKit::WebNode;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 202
202 SkDevice* device = metafile->StartPageForVectorCanvas( 203 SkDevice* device = metafile->StartPageForVectorCanvas(
203 page_size, content_area, 1.0f); 204 page_size, content_area, 1.0f);
204 if (!device) 205 if (!device)
205 return; 206 return;
206 207
207 // The printPage method take a reference to the canvas we pass down, so it 208 // The printPage method take a reference to the canvas we pass down, so it
208 // can't be a stack object. 209 // can't be a stack object.
209 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); 210 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device);
210 canvas->unref(); // SkRefPtr and new both took a reference. 211 canvas->unref(); // SkRefPtr and new both took a reference.
211 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); 212 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
212 printing::MetafileSkiaWrapper::SetDraftMode(canvas.get(), 213 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_);
213 is_print_ready_metafile_sent_);
214 frame->printPage(params.page_number, canvas.get()); 214 frame->printPage(params.page_number, canvas.get());
215 215
216 if (params.params.display_header_footer) { 216 if (params.params.display_header_footer) {
217 // |page_number| is 0-based, so 1 is added. 217 // |page_number| is 0-based, so 1 is added.
218 // The scale factor on Linux is 1. 218 // The scale factor on Linux is 1.
219 PrintHeaderAndFooter(canvas.get(), params.page_number + 1, 219 PrintHeaderAndFooter(canvas.get(), params.page_number + 1,
220 print_preview_context_.total_page_count(), 1, 220 print_preview_context_.total_page_count(), 1,
221 page_layout_in_points, *header_footer_info_); 221 page_layout_in_points, *header_footer_info_);
222 } 222 }
223 223
224 // Done printing. Close the device context to retrieve the compiled metafile. 224 // Done printing. Close the device context to retrieve the compiled metafile.
225 if (!metafile->FinishPage()) 225 if (!metafile->FinishPage())
226 NOTREACHED() << "metafile failed"; 226 NOTREACHED() << "metafile failed";
227 } 227 }
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | chrome/renderer/print_web_view_helper_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698