diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-10 00:04:54 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-10 00:04:54 +0000 |
commit | e6fae168d6fd6556f4455265fb18323db9ca56de (patch) | |
tree | 492466a306ab8199e4c1bef36a5adfe035f7f06a /chrome/renderer/print_web_view_helper_linux.cc | |
parent | ffec6bf36fb4527d051960d4871623a5b91ec122 (diff) | |
download | chromium_src-e6fae168d6fd6556f4455265fb18323db9ca56de.zip chromium_src-e6fae168d6fd6556f4455265fb18323db9ca56de.tar.gz chromium_src-e6fae168d6fd6556f4455265fb18323db9ca56de.tar.bz2 |
Linux: fix printing somewhat.
BUG=29148
TEST=prints documents greater than one page (to real printers)
Review URL: http://codereview.chromium.org/1520014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44161 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/print_web_view_helper_linux.cc')
-rw-r--r-- | chrome/renderer/print_web_view_helper_linux.cc | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc index 415bf1d..ed977c3 100644 --- a/chrome/renderer/print_web_view_helper_linux.cc +++ b/chrome/renderer/print_web_view_helper_linux.cc @@ -103,38 +103,19 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, const gfx::Size& canvas_size, WebFrame* frame, printing::NativeMetafile* metafile) { - // Since WebKit extends the page width depending on the magical shrink - // factor we make sure the canvas covers the worst case scenario - // (x2.0 currently). PrintContext will then set the correct clipping region. - int size_x = static_cast<int>(canvas_size.width() * params.params.max_shrink); - int size_y = static_cast<int>(canvas_size.height() * - params.params.max_shrink); - // Calculate the dpi adjustment. - float shrink = static_cast<float>(canvas_size.width()) / - params.params.printable_size.width(); - - cairo_t* cairo_context = metafile->StartPage(size_x, size_y); - if (!cairo_context) { - // TODO(myhuang): We should handle such kind of error further! - // We already have had DLOG(ERROR) in NativeMetafile::StartPage(), - // log the error here, too? + cairo_t* cairo_context = + metafile->StartPage(canvas_size.width(), canvas_size.height()); + if (!cairo_context) return; - } - skia::VectorCanvas canvas(cairo_context, size_x, size_y); - float webkit_shrink = frame->printPage(params.page_number, &canvas); - if (webkit_shrink <= 0) { - NOTREACHED() << "Printing page " << params.page_number << " failed."; - } else { - // Update the dpi adjustment with the "page shrink" calculated in webkit. - shrink /= webkit_shrink; - } + skia::VectorCanvas canvas(cairo_context, + canvas_size.width(), canvas_size.height()); + frame->printPage(params.page_number, &canvas); // TODO(myhuang): We should handle transformation for paper margins. // TODO(myhuang): We should render the header and the footer. // Done printing. Close the device context to retrieve the compiled metafile. - if (!metafile->FinishPage(shrink)) { + if (!metafile->FinishPage()) NOTREACHED() << "metafile failed"; - } } |