Bug 99489 - Incorrect embedded SVG image sizing on first load
Summary: Incorrect embedded SVG image sizing on first load
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Florin Malita
URL:
Keywords:
Depends on:
Blocks: 99481
  Show dependency treegraph
 
Reported: 2012-10-16 12:30 PDT by Florin Malita
Modified: 2012-10-22 07:10 PDT (History)
7 users (show)

See Also:


Attachments
No red should be visible, only a large green rect. (472 bytes, text/html)
2012-10-16 12:30 PDT, Florin Malita
no flags Details
Patch (3.96 KB, patch)
2012-10-17 12:52 PDT, Florin Malita
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florin Malita 2012-10-16 12:30:28 PDT
Created attachment 168997 [details]
No red should be visible, only a large green rect.

This seems to be timing sensitive, so it may take a few tries: when the attached test is first opened in a new tab/window, the embedded SVG image (data:image/svg+xml) is not scaled according to its container transform.
Comment 1 Florin Malita 2012-10-17 10:59:37 PDT
Looks like a race between layout and the image loader:

* SVGImageCache::lookupOrCreateBitmapImageForRenderer() needs a m_sizeAndScalesMap entry for the renderer
* the only time this is set is from  RenderSVGImage::layout() (via updateImageViewport() >> m_imageResource->setContainerSizeForRenderer() >> m_cachedImage->setContainerSizeForRenderer() >> m_svgImageCache->setRequestedSizeAndScales())


The problem is that for this to work, the cached image needs to be present/loaded when RenderSVGImage::layout() is called. If loading finishes after layout, setRequestedSizeAndScales() never gets called.

Extending RenderSVGImage::imageChanged() to either force a relayout or just call setRequestedSizeAndScales() should cover this case.
Comment 2 Florin Malita 2012-10-17 12:52:25 PDT
Created attachment 169237 [details]
Patch
Comment 3 Nikolas Zimmermann 2012-10-21 07:52:52 PDT
Comment on attachment 169237 [details]
Patch

Good catch!
Comment 4 WebKit Review Bot 2012-10-22 07:10:28 PDT
Comment on attachment 169237 [details]
Patch

Clearing flags on attachment: 169237

Committed r132069: <http://trac.webkit.org/changeset/132069>
Comment 5 WebKit Review Bot 2012-10-22 07:10:31 PDT
All reviewed patches have been landed.  Closing bug.