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

Side by Side Diff: third_party/WebKit/Source/core/page/PrintContext.cpp

Issue 2116283002: Don't let rounding prematurely influence document size when printing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@620456-2
Patch Set: bug 467579 Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 2 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
3 * Copyright (C) 2007 Apple Inc. 3 * Copyright (C) 2007 Apple Inc.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 return String("pageProperty() unimplemented for: ") + propertyName; 287 return String("pageProperty() unimplemented for: ") + propertyName;
288 } 288 }
289 289
290 bool PrintContext::isPageBoxVisible(LocalFrame* frame, int pageNumber) 290 bool PrintContext::isPageBoxVisible(LocalFrame* frame, int pageNumber)
291 { 291 {
292 return frame->document()->isPageBoxVisible(pageNumber); 292 return frame->document()->isPageBoxVisible(pageNumber);
293 } 293 }
294 294
295 String PrintContext::pageSizeAndMarginsInPixels(LocalFrame* frame, int pageNumbe r, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) 295 String PrintContext::pageSizeAndMarginsInPixels(LocalFrame* frame, int pageNumbe r, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft)
296 { 296 {
297 IntSize pageSize(width, height); 297 DoubleSize pageSize(width, height);
298 frame->document()->pageSizeAndMarginsInPixels(pageNumber, pageSize, marginTo p, marginRight, marginBottom, marginLeft); 298 frame->document()->pageSizeAndMarginsInPixels(pageNumber, pageSize, marginTo p, marginRight, marginBottom, marginLeft);
299 299
300 return "(" + String::number(pageSize.width()) + ", " + String::number(pageSi ze.height()) + ") " + 300 return "(" + String::number(floor(pageSize.width())) + ", " + String::number (floor(pageSize.height())) + ") " +
301 String::number(marginTop) + ' ' + String::number(marginRight) + ' ' + St ring::number(marginBottom) + ' ' + String::number(marginLeft); 301 String::number(marginTop) + ' ' + String::number(marginRight) + ' ' + St ring::number(marginBottom) + ' ' + String::number(marginLeft);
302 } 302 }
303 303
304 int PrintContext::numberOfPages(LocalFrame* frame, const FloatSize& pageSizeInPi xels) 304 int PrintContext::numberOfPages(LocalFrame* frame, const FloatSize& pageSizeInPi xels)
305 { 305 {
306 frame->document()->updateStyleAndLayout(); 306 frame->document()->updateStyleAndLayout();
307 307
308 FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels); 308 FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
309 PrintContext printContext(frame); 309 PrintContext printContext(frame);
310 printContext.begin(pageRect.width(), pageRect.height()); 310 printContext.begin(pageRect.width(), pageRect.height());
311 // Account for shrink-to-fit. 311 // Account for shrink-to-fit.
312 FloatSize scaledPageSize = pageSizeInPixels; 312 FloatSize scaledPageSize = pageSizeInPixels;
313 scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width( )); 313 scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width( ));
314 printContext.computePageRectsWithPageSize(scaledPageSize); 314 printContext.computePageRectsWithPageSize(scaledPageSize);
315 return printContext.pageCount(); 315 return printContext.pageCount();
316 } 316 }
317 317
318 DEFINE_TRACE(PrintContext) 318 DEFINE_TRACE(PrintContext)
319 { 319 {
320 visitor->trace(m_frame); 320 visitor->trace(m_frame);
321 visitor->trace(m_linkedDestinations); 321 visitor->trace(m_linkedDestinations);
322 } 322 }
323 323
324 } // namespace blink 324 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698