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

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

Issue 6611032: Unifying NativeMetafile class interface (as much as possible) for Linux, Mac, Win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed win unittests, style changes, cleaned up StartPage parameters for cairo. Created 9 years, 9 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
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/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 #if defined(OS_CHROMEOS) 76 #if defined(OS_CHROMEOS)
77 int sequence_number = -1; 77 int sequence_number = -1;
78 base::FileDescriptor fd; 78 base::FileDescriptor fd;
79 79
80 // Ask the browser to open a file for us. 80 // Ask the browser to open a file for us.
81 if (!Send(new ViewHostMsg_AllocateTempFileForPrinting(&fd, 81 if (!Send(new ViewHostMsg_AllocateTempFileForPrinting(&fd,
82 &sequence_number))) { 82 &sequence_number))) {
83 return; 83 return;
84 } 84 }
85 if (!metafile->SaveTo(fd)) 85 if (!metafile->SaveToFD(fd))
86 return; 86 return;
87 87
88 // Tell the browser we've finished writing the file. 88 // Tell the browser we've finished writing the file.
89 Send(new ViewHostMsg_TempFileForPrintingWritten(sequence_number)); 89 Send(new ViewHostMsg_TempFileForPrintingWritten(sequence_number));
90 #else 90 #else
91 ViewHostMsg_DidPrintPage_Params printed_page_params; 91 ViewHostMsg_DidPrintPage_Params printed_page_params;
92 printed_page_params.data_size = 0; 92 printed_page_params.data_size = 0;
93 printed_page_params.document_cookie = params.params.document_cookie; 93 printed_page_params.document_cookie = params.params.document_cookie;
94 94
95 base::SharedMemoryHandle shared_mem_handle; 95 base::SharedMemoryHandle shared_mem_handle;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
216 static_cast<int>(content_width_in_points + margin_right_in_points +
vandebo (ex-Chrome) 2011/03/14 22:55:05 A cast shouldn't be needed for double -> int conve
dpapad 2011/03/15 16:11:06 Done. No it didn't complain, I just thought it is
217 margin_left_in_points),
218 static_cast<int>(content_height_in_points + margin_top_in_points +
219 margin_bottom_in_points));
220
215 cairo_t* cairo_context = 221 cairo_t* cairo_context =
216 metafile->StartPage(content_width_in_points, 222 metafile->StartPage(page_size,
217 content_height_in_points,
218 margin_top_in_points, 223 margin_top_in_points,
219 margin_right_in_points,
220 margin_bottom_in_points,
221 margin_left_in_points); 224 margin_left_in_points);
222 if (!cairo_context) 225 if (!cairo_context)
223 return; 226 return;
224 227
225 canvas->reset(new skia::VectorCanvas(cairo_context, 228 canvas->reset(new skia::VectorCanvas(cairo_context,
226 canvas_size.width(), 229 canvas_size.width(),
227 canvas_size.height())); 230 canvas_size.height()));
228 frame->printPage(params.page_number, canvas->get()); 231 frame->printPage(params.page_number, canvas->get());
229 232
230 // TODO(myhuang): We should handle transformation for paper margins. 233 // TODO(myhuang): We should handle transformation for paper margins.
231 // TODO(myhuang): We should render the header and the footer. 234 // TODO(myhuang): We should render the header and the footer.
232 235
233 // Done printing. Close the device context to retrieve the compiled metafile. 236 // Done printing. Close the device context to retrieve the compiled metafile.
234 if (!metafile->FinishPage()) 237 if (!metafile->FinishPage())
235 NOTREACHED() << "metafile failed"; 238 NOTREACHED() << "metafile failed";
236 } 239 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698