OLD | NEW |
1 // Copyright (c) 2012 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 #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" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 gfx::Rect canvas_area = | 187 gfx::Rect canvas_area = |
188 params.params.display_header_footer ? gfx::Rect(page_size) : content_area; | 188 params.params.display_header_footer ? gfx::Rect(page_size) : content_area; |
189 | 189 |
190 SkDevice* device = metafile->StartPageForVectorCanvas(page_size, canvas_area, | 190 SkDevice* device = metafile->StartPageForVectorCanvas(page_size, canvas_area, |
191 scale_factor); | 191 scale_factor); |
192 if (!device) | 192 if (!device) |
193 return; | 193 return; |
194 | 194 |
195 // The printPage method take a reference to the canvas we pass down, so it | 195 // The printPage method take a reference to the canvas we pass down, so it |
196 // can't be a stack object. | 196 // can't be a stack object. |
197 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); | 197 skia::RefPtr<skia::VectorCanvas> canvas = |
198 canvas->unref(); // SkRefPtr and new both took a reference. | 198 skia::AdoptRef(new skia::VectorCanvas(device)); |
199 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); | 199 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); |
200 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); | 200 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); |
201 | 201 |
202 if (params.params.display_header_footer) { | 202 if (params.params.display_header_footer) { |
203 // |page_number| is 0-based, so 1 is added. | 203 // |page_number| is 0-based, so 1 is added. |
204 // TODO(vitalybuka) : why does it work only with 1.25? | 204 // TODO(vitalybuka) : why does it work only with 1.25? |
205 PrintHeaderAndFooter(canvas.get(), params.page_number + 1, | 205 PrintHeaderAndFooter(canvas.get(), params.page_number + 1, |
206 print_preview_context_.total_page_count(), | 206 print_preview_context_.total_page_count(), |
207 scale_factor / 1.25, | 207 scale_factor / 1.25, |
208 page_layout_in_points, *header_footer_info_, | 208 page_layout_in_points, *header_footer_info_, |
209 params.params); | 209 params.params); |
210 } | 210 } |
211 RenderPageContent(frame, params.page_number, canvas_area, content_area, | 211 RenderPageContent(frame, params.page_number, canvas_area, content_area, |
212 scale_factor, canvas.get()); | 212 scale_factor, canvas.get()); |
213 | 213 |
214 // Done printing. Close the device context to retrieve the compiled metafile. | 214 // Done printing. Close the device context to retrieve the compiled metafile. |
215 if (!metafile->FinishPage()) | 215 if (!metafile->FinishPage()) |
216 NOTREACHED() << "metafile failed"; | 216 NOTREACHED() << "metafile failed"; |
217 } | 217 } |
OLD | NEW |