Bug 126633

Summary: PDFDocumentImage can be very slow to do the initial paint
Product: WebKit Reporter: Tim Horton <thorton>
Component: PDFAssignee: Tim Horton <thorton>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, commit-queue, sam, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
none
style
simon.fraser: review+
new approach simon.fraser: review+

Description Tim Horton 2014-01-08 02:25:59 PST
When going to paint, PDFDocumentImage transforms the context by scaling into "page" space. It currently does so on a per-axis basis, but this means that sometimes small floating-point rounding issues can cause the scales to be slightly different. This causes us to do a non-uniform scale which both imperceptibly squishes the PDF and throws CoreGraphics onto a slow painting path.
Comment 1 Radar WebKit Bug Importer 2014-01-08 02:26:12 PST
<rdar://problem/15770980>
Comment 2 Tim Horton 2014-01-08 02:37:38 PST
I guess we have to decide whether PDF-in-<img> should behave like an image (and stretch if width and height are both specified) or like an SVG (and fit inside the box).
Comment 3 Tim Horton 2014-01-08 02:38:39 PST
Created attachment 220617 [details]
patch

If we decide it should behave like SVG and fit inside the box, this patch will do.
Comment 4 WebKit Commit Bot 2014-01-08 02:39:36 PST
Attachment 220617 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp', '--commit-queue']" exit_code: 1
ERROR: Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp:139:  Use std::min() or std::min<type>() instead of the MIN() macro.  [runtime/max_min_macros] [4]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Tim Horton 2014-01-08 02:43:07 PST
Created attachment 220619 [details]
style
Comment 6 Simon Fraser (smfr) 2014-01-08 08:40:24 PST
Comment on attachment 220619 [details]
style

Nice find!

This is really an "aspect-ratio fit" right? Do we have other code for that?
Comment 7 Tim Horton 2014-01-09 11:50:15 PST
Created attachment 220754 [details]
new approach
Comment 8 Tim Horton 2014-01-09 12:10:50 PST
http://trac.webkit.org/changeset/161568
Comment 9 Tim Horton 2014-01-09 14:06:24 PST
Layout test in http://trac.webkit.org/changeset/161581