Skip to content

Commit

Permalink
Fix generation of the complete metafile for print preview flow.
Browse files Browse the repository at this point in the history
- Start/Finish page was missing.
- transform was off as well.
- This CL is on top of http://codereview.chromium.org/7585012/

BUG=91727
TEST=View saved PDF form print preview, content and margins should be correct.


Review URL: http://codereview.chromium.org/7584019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95844 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
vandebo@chromium.org committed Aug 8, 2011
1 parent 25577ef commit f2c794f
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions chrome/renderer/print_web_view_helper_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

printing::Metafile* initial_render_metafile =
print_preview_context_.metafile();
scoped_ptr<printing::Metafile> draft_metafile;
scoped_ptr<printing::PreviewMetafile> draft_metafile;
#if !defined(USE_SKIA)
if (print_preview_context_.IsModifiable()) {
draft_metafile.reset(new printing::PreviewMetafile);
Expand All @@ -95,16 +95,26 @@
draft_metafile->FinishDocument();

// With CG, we rendered into a new metafile so we could get it as a draft
// document. Now we need to add it to complete document.
// document. Now we need to add it to complete document. But the document
// has already been scaled and adjusted for margins, so do a 1:1 drawing.
printing::Metafile* complete_metafile = print_preview_context_.metafile();
bool success = complete_metafile->StartPage(
printParams.page_size, gfx::Rect(printParams.page_size), 1.0);
DCHECK(success);
// StartPage unconditionally flips the content over, flip it back since it
// was already flipped in |draft_metafile|.
CGContextTranslateCTM(complete_metafile->context(), 0,
printParams.page_size.height());
CGContextScaleCTM(complete_metafile->context(), 1.0, -1.0);

draft_metafile->RenderPage(1,
print_preview_context_.metafile()->context(),
CGRectMake(content_area.x(), content_area.y(),
content_area.width(),
content_area.height()),
false /*shrunk_to_fit*/,
false /*stretch_to_fit*/,
true /*center_horizontally*/,
true /*center_vertically*/);
complete_metafile->context(),
draft_metafile->GetPageBounds(1).ToCGRect(),
false /* shrink_to_fit */,
false /* stretch_to_fit */,
true /* center_horizontally */,
true /* center_vertically */);
complete_metafile->FinishPage();
#endif
}

Expand Down

0 comments on commit f2c794f

Please sign in to comment.