OLD | NEW |
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" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 &margin_left_in_points); | 223 &margin_left_in_points); |
224 | 224 |
225 gfx::Size page_size( | 225 gfx::Size page_size( |
226 content_width_in_points + margin_right_in_points + | 226 content_width_in_points + margin_right_in_points + |
227 margin_left_in_points, | 227 margin_left_in_points, |
228 content_height_in_points + margin_top_in_points + | 228 content_height_in_points + margin_top_in_points + |
229 margin_bottom_in_points); | 229 margin_bottom_in_points); |
230 gfx::Rect content_area(margin_left_in_points, margin_top_in_points, | 230 gfx::Rect content_area(margin_left_in_points, margin_top_in_points, |
231 content_width_in_points, content_height_in_points); | 231 content_width_in_points, content_height_in_points); |
232 | 232 |
233 skia::PlatformDevice* device = metafile->StartPageForVectorCanvas( | 233 SkDevice* device = metafile->StartPageForVectorCanvas( |
234 page_size, content_area, 1.0f); | 234 page_size, content_area, 1.0f); |
235 if (!device) | 235 if (!device) |
236 return; | 236 return; |
237 | 237 |
238 canvas->reset(new skia::VectorCanvas(device)); | 238 canvas->reset(new skia::VectorCanvas(device)); |
239 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas->get(), metafile); | 239 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas->get(), metafile); |
240 frame->printPage(params.page_number, canvas->get()); | 240 frame->printPage(params.page_number, canvas->get()); |
241 | 241 |
242 // TODO(myhuang): We should handle transformation for paper margins. | 242 // TODO(myhuang): We should handle transformation for paper margins. |
243 // TODO(myhuang): We should render the header and the footer. | 243 // TODO(myhuang): We should render the header and the footer. |
244 | 244 |
245 // Done printing. Close the device context to retrieve the compiled metafile. | 245 // Done printing. Close the device context to retrieve the compiled metafile. |
246 if (!metafile->FinishPage()) | 246 if (!metafile->FinishPage()) |
247 NOTREACHED() << "metafile failed"; | 247 NOTREACHED() << "metafile failed"; |
248 } | 248 } |
OLD | NEW |