Bug 54348 - Crash when printing a document with no pages
Summary: Crash when printing a document with no pages
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Printing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.6
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-12 22:13 PST by Alexey Proskuryakov
Modified: 2011-02-13 11:03 PST (History)
2 users (show)

See Also:


Attachments
proposed fix (1.79 KB, patch)
2011-02-12 22:16 PST, Alexey Proskuryakov
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.