| 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/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 GetPageSizeAndMarginsInPoints(frame, | 205 GetPageSizeAndMarginsInPoints(frame, |
| 206 params.page_number, | 206 params.page_number, |
| 207 params.params, | 207 params.params, |
| 208 &content_width_in_points, | 208 &content_width_in_points, |
| 209 &content_height_in_points, | 209 &content_height_in_points, |
| 210 &margin_top_in_points, | 210 &margin_top_in_points, |
| 211 &margin_right_in_points, | 211 &margin_right_in_points, |
| 212 &margin_bottom_in_points, | 212 &margin_bottom_in_points, |
| 213 &margin_left_in_points); | 213 &margin_left_in_points); |
| 214 | 214 |
| 215 gfx::Size page_size(static_cast<int>(content_width_in_points), |
| 216 static_cast<int>(content_height_in_points)); |
| 217 |
| 215 cairo_t* cairo_context = | 218 cairo_t* cairo_context = |
| 216 metafile->StartPage(content_width_in_points, | 219 metafile->StartPage(page_size, |
| 217 content_height_in_points, | |
| 218 margin_top_in_points, | 220 margin_top_in_points, |
| 219 margin_right_in_points, | 221 margin_right_in_points, |
| 220 margin_bottom_in_points, | 222 margin_bottom_in_points, |
| 221 margin_left_in_points); | 223 margin_left_in_points); |
| 222 if (!cairo_context) | 224 if (!cairo_context) |
| 223 return; | 225 return; |
| 224 | 226 |
| 225 canvas->reset(new skia::VectorCanvas(cairo_context, | 227 canvas->reset(new skia::VectorCanvas(cairo_context, |
| 226 canvas_size.width(), | 228 canvas_size.width(), |
| 227 canvas_size.height())); | 229 canvas_size.height())); |
| 228 frame->printPage(params.page_number, canvas->get()); | 230 frame->printPage(params.page_number, canvas->get()); |
| 229 | 231 |
| 230 // TODO(myhuang): We should handle transformation for paper margins. | 232 // TODO(myhuang): We should handle transformation for paper margins. |
| 231 // TODO(myhuang): We should render the header and the footer. | 233 // TODO(myhuang): We should render the header and the footer. |
| 232 | 234 |
| 233 // Done printing. Close the device context to retrieve the compiled metafile. | 235 // Done printing. Close the device context to retrieve the compiled metafile. |
| 234 if (!metafile->FinishPage()) | 236 if (!metafile->FinishPage()) |
| 235 NOTREACHED() << "metafile failed"; | 237 NOTREACHED() << "metafile failed"; |
| 236 } | 238 } |
| OLD | NEW |