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

Unified Diff: chrome/renderer/print_web_view_helper_mac.mm

Issue 7584019: Fix generation of the complete metafile for print preview flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/print_web_view_helper_mac.mm
diff --git a/chrome/renderer/print_web_view_helper_mac.mm b/chrome/renderer/print_web_view_helper_mac.mm
index 55cccb650a20b756130bb4427995f21867fb4bbf..cd640ed28911c89ca8e499179822a5a54ea396de 100644
--- a/chrome/renderer/print_web_view_helper_mac.mm
+++ b/chrome/renderer/print_web_view_helper_mac.mm
@@ -68,7 +68,7 @@ void PrintWebViewHelper::RenderPreviewPage(int page_number) {
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);
@@ -96,15 +96,24 @@ void PrintWebViewHelper::RenderPreviewPage(int page_number) {
// 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.
+ printing::Metafile* complete_metafile = print_preview_context_.metafile();
+ bool success = complete_metafile->StartPage(
+ printParams.page_size, gfx::Rect(printParams.page_size), 1.0);
kmadhusu 2011/08/05 23:33:52 Please document that the scale factor is always 1.
kmadhusu 2011/08/05 23:33:52 Why can't we use the content_area rather than "gfx
vandebo (ex-Chrome) 2011/08/06 00:43:43 Done.
vandebo (ex-Chrome) 2011/08/06 00:43:43 Because we want a 1:1 rendering of the source PDF,
+ 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*/,
+ complete_metafile->context(),
+ draft_metafile->GetPageBounds(1).ToCGRect(),
+ false /*shrink_to_fit*/,
kmadhusu 2011/08/05 23:33:52 style nit: Add a space after "/*" and before "*/".
vandebo (ex-Chrome) 2011/08/06 00:43:43 Done.
false /*stretch_to_fit*/,
true /*center_horizontally*/,
true /*center_vertically*/);
+ complete_metafile->FinishPage();
#endif
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698