Bug 54348

Summary: Crash when printing a document with no pages
Product: WebKit Reporter: Alexey Proskuryakov <ap>
Component: PrintingAssignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, mitz
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.6   
Attachments:
Description Flags
proposed fix none

Description Alexey Proskuryakov 2011-02-12 22:13:46 PST
WKPage always reports at least one page to print, but then it fails to actually print it.
Comment 1 Alexey Proskuryakov 2011-02-12 22:16:46 PST
Created attachment 82249 [details]
proposed fix
Comment 2 mitz 2011-02-12 22:33:05 PST
Comment on attachment 82249 [details]
proposed fix

View in context: https://bugs.webkit.org/attachment.cgi?id=82249&action=review

> Source/WebKit2/ChangeLog:8
> +        * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::drawPagesToPDF): Don't fail on a fake

Can you add a newline between the filename and the function name?

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2015
> +        CGRect mediaBox = m_printContext->pageCount() ? m_printContext->pageRect(0) : CGRectMake(0, 0, 1, 1);

What happens if you use CGRectZero instead?
Comment 3 Alexey Proskuryakov 2011-02-12 22:44:49 PST
> Can you add a newline between the filename and the function name?

Not without taking this out of commit queue :)

> What happens if you use CGRectZero instead?

AppKit prints a blank page without headers and footers, which is probably incorrect. In fact, we end up passing a zero rectangle in -[WKPrintingView rectForPage:] due to IntRect.scale() rounding to zero in the end, and this rounding is not good.

However, this is a situation that should not really ever happen, and I only noticed this because of <rdar://problem/8994076>. I don't want to achieve perfect behavior in this impossible situation (or even to file bugs), but I wanted to avoid crashing, and I didn't want to explicitly write incorrect code returning a zero rect.
Comment 4 WebKit Commit Bot 2011-02-13 11:03:19 PST
Comment on attachment 82249 [details]
proposed fix

Clearing flags on attachment: 82249

Committed r78432: <http://trac.webkit.org/changeset/78432>
Comment 5 WebKit Commit Bot 2011-02-13 11:03:23 PST
All reviewed patches have been landed.  Closing bug.