| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 &margin_left_in_points); | 213 &margin_left_in_points); |
| 214 | 214 |
| 215 gfx::Size page_size( | 215 gfx::Size page_size( |
| 216 content_width_in_points + margin_right_in_points + | 216 content_width_in_points + margin_right_in_points + |
| 217 margin_left_in_points, | 217 margin_left_in_points, |
| 218 content_height_in_points + margin_top_in_points + | 218 content_height_in_points + margin_top_in_points + |
| 219 margin_bottom_in_points); | 219 margin_bottom_in_points); |
| 220 gfx::Rect content_area(margin_left_in_points, margin_top_in_points, | 220 gfx::Rect content_area(margin_left_in_points, margin_top_in_points, |
| 221 content_width_in_points, content_height_in_points); | 221 content_width_in_points, content_height_in_points); |
| 222 | 222 |
| 223 skia::PlatformDevice* device = metafile->StartPageForVectorCanvas( | 223 SkDevice* device = metafile->StartPageForVectorCanvas( |
| 224 page_size, content_area, 1.0f); | 224 page_size, content_area, 1.0f); |
| 225 if (!device) | 225 if (!device) |
| 226 return; | 226 return; |
| 227 | 227 |
| 228 // The printPage method take a reference to the canvas we pass down, so it | 228 // The printPage method take a reference to the canvas we pass down, so it |
| 229 // can't be a stack object. | 229 // can't be a stack object. |
| 230 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); | 230 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); |
| 231 canvas->unref(); // SkRefPtr and new both took a reference. | 231 canvas->unref(); // SkRefPtr and new both took a reference. |
| 232 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); | 232 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); |
| 233 frame->printPage(params.page_number, canvas.get()); | 233 frame->printPage(params.page_number, canvas.get()); |
| 234 | 234 |
| 235 // TODO(myhuang): We should render the header and the footer. | 235 // TODO(myhuang): We should render the header and the footer. |
| 236 | 236 |
| 237 // Done printing. Close the device context to retrieve the compiled metafile. | 237 // Done printing. Close the device context to retrieve the compiled metafile. |
| 238 if (!metafile->FinishPage()) | 238 if (!metafile->FinishPage()) |
| 239 NOTREACHED() << "metafile failed"; | 239 NOTREACHED() << "metafile failed"; |
| 240 } | 240 } |
| OLD | NEW |