[Webkit-unassigned] [Bug 61256] Print HTML with only 1 line, then 2 pages are printed

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun May 29 18:46:56 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=61256





--- Comment #24 from Kentaro Hara <haraken at google.com>  2011-05-29 18:46:56 PST ---
> LayoutTestController::numberOfPages() is supposed to just call PrintContext::numberOfPages(). The stack trace you posted shows that Chromium's DRT is doing something different, and thus likely incorrect.

As I wrote earlier, I agree that LayoutTestController::numberOfPages() should call PrintContext::numberOfPages() directly, but this is not the problem here. Even if LayoutTestController::numberOfPages() calls PrintContext::numberOfPages() directly, the same problem happens as follows (I confirmed on Linux Chromium):

int PrintContext::numberOfPages(Frame* frame, const FloatSize& pageSizeInPixels) // [539.0, 755.0]
{
    frame->document()->updateLayout();
    FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels); // [539.0, 755.0]
    PrintContext printContext(frame);
    printContext.begin(pageRect.width(), pageRect.height()); // this internally sets frame->view()->contentsSize() to [673, 943] (, which is the rounded value of [539.0 * 1.25, 755.0 * 1.25])
    FloatSize scaledPageSize = pageSizeInPixels; // [539.0, 755.0]
    scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width()); // [539.0 * (673 / 539.0), 755.0 * (673 / 539.0)] => [673, 942.699]
    printContext.computePageRectsWithPageSize(scaledPageSize, false); // this internally calculates the page count as ceilf(943 / 942.699) = 2!
    return printContext.pageCount();
}

(Note: As I mentioned earlier, currently, LayoutTestController::numberOfPages() tracks a bit strange call path instead of  calling  PrintContext::numberOfPages() directly, but it is actually doing the equivalent calculation as the case that LayoutTestController::numberOfPages() calls PrintContext::numberOfPages() directly.)

> If this bug is Chromium only, the fix also needs to be in Chromium code, unless you can make a very strong case for why cross-platform code is wrong.

Although I did not yet confirm the behavior of other browsers, I guess that this problem can happen on any browser when we give the page size of [539.0, 755.0] to PrintContext::numberOfPages(). (The value is critical to cause the rounding error).

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list