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

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

Issue 6879098: Fix print preview clipping issues due to scaling. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Proposed modification to metafile interface. Created 9 years, 8 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
« no previous file with comments | « no previous file | printing/emf_win.h » ('j') | printing/metafile.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/logging.h" 7 #include "base/logging.h"
8 #include "base/process_util.h" 8 #include "base/process_util.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "chrome/common/print_messages.h" 10 #include "chrome/common/print_messages.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 height = ConvertUnit(params.page_size.height(), dpi, desired_dpi); 200 height = ConvertUnit(params.page_size.height(), dpi, desired_dpi);
201 } else { 201 } else {
202 // Since WebKit extends the page width depending on the magical scale factor 202 // Since WebKit extends the page width depending on the magical scale factor
203 // we make sure the canvas covers the worst case scenario (x2.0 currently). 203 // we make sure the canvas covers the worst case scenario (x2.0 currently).
204 // PrintContext will then set the correct clipping region. 204 // PrintContext will then set the correct clipping region.
205 width = static_cast<int>(content_width_in_points * params.max_shrink); 205 width = static_cast<int>(content_width_in_points * params.max_shrink);
206 height = static_cast<int>(content_height_in_points * params.max_shrink); 206 height = static_cast<int>(content_height_in_points * params.max_shrink);
207 } 207 }
208 208
209 gfx::Size page_size(width, height); 209 gfx::Size page_size(width, height);
210 gfx::Size content_size(static_cast<int>(content_width_in_points),
211 static_cast<int>(content_height_in_points));
210 gfx::Point content_origin(static_cast<int>(margin_left_in_points), 212 gfx::Point content_origin(static_cast<int>(margin_left_in_points),
211 static_cast<int>(margin_top_in_points)); 213 static_cast<int>(margin_top_in_points));
212 skia::PlatformDevice* device = (*metafile)->StartPageForVectorCanvas( 214 skia::PlatformDevice* device = (*metafile)->StartPageForVectorCanvas(
213 page_size, content_origin, frame->getPrintPageShrink(page_number)); 215 page_size, content_size, content_origin,
216 frame->getPrintPageShrink(page_number));
214 DCHECK(device); 217 DCHECK(device);
215 skia::VectorCanvas canvas(device); 218 skia::VectorCanvas canvas(device);
216 219
217 float webkit_scale_factor = frame->printPage(page_number, &canvas); 220 float webkit_scale_factor = frame->printPage(page_number, &canvas);
218 if (*scale_factor <= 0 || webkit_scale_factor <= 0) { 221 if (*scale_factor <= 0 || webkit_scale_factor <= 0) {
219 NOTREACHED() << "Printing page " << page_number << " failed."; 222 NOTREACHED() << "Printing page " << page_number << " failed.";
220 } else { 223 } else {
221 // Update the dpi adjustment with the "page |scale_factor|" calculated in 224 // Update the dpi adjustment with the "page |scale_factor|" calculated in
222 // webkit. 225 // webkit.
223 *scale_factor /= webkit_scale_factor; 226 *scale_factor /= webkit_scale_factor;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Copy the bits into shared memory. 307 // Copy the bits into shared memory.
305 if (!metafile->GetData(shared_buf.memory(), buf_size)) { 308 if (!metafile->GetData(shared_buf.memory(), buf_size)) {
306 NOTREACHED() << "GetData() failed"; 309 NOTREACHED() << "GetData() failed";
307 shared_buf.Unmap(); 310 shared_buf.Unmap();
308 return false; 311 return false;
309 } 312 }
310 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); 313 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle);
311 shared_buf.Unmap(); 314 shared_buf.Unmap();
312 return true; 315 return true;
313 } 316 }
OLDNEW
« no previous file with comments | « no previous file | printing/emf_win.h » ('j') | printing/metafile.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698