Preserve container size requests across image loads
authorpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 22:27:44 +0000 (22:27 +0000)
committerpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 22:27:44 +0000 (22:27 +0000)
commit1d09910deec696064e006af22b2d219f77ae8b2e
tree3083ebfc5bd336ab3d00cf0db3d868b3c652a5c9
parentc675c92bec4450f082ce28f5e56145479a1049d1
Preserve container size requests across image loads
https://bugs.webkit.org/show_bug.cgi?id=106733

Reviewed by Tim Horton.

Source/WebCore:

Some images, such as SVG with relative dimensions, depend on the renderer's container size.
r137981 introduced the ability to store pending container size requests that are made
after the image element lays out but before the image loads. Before this patch, cached
images could discard these pending container size requests during cache revalidation.

During a cached image load, two CachedImages exist: the image in cache and a new CachedImage
that will be used if the cache is stale. Pending container size requests are stored
on the second cached image which is discarded if a 304 not modified response is received.

This patch modifies the switchClientsToRevalidatedResource logic to maintain pending
container size requests. This fixes a bug where cached SVG images would be sized
incorrectly.

Test: http/tests/svg/cached-image-sizing.html

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::switchClientsToRevalidatedResource):

    In this virtual call we special-case images with pending size requests and
    transfer these requests to the revalidating resource. Note that all container size
    requests received before revalidation will be pending because the image has not loaded.
    Therefore, there is no risk of discarding non-pending container size requests.

(WebCore):
* loader/cache/CachedImage.h:
(CachedImage):
* loader/cache/CachedResource.h:
(CachedResource):

LayoutTests:

* http/tests/svg/cached-image-sizing-expected.html: Added.
* http/tests/svg/cached-image-sizing.html: Added.
* http/tests/svg/resources/delayCachedLoad.php: Added.
* http/tests/svg/resources/greenSquare.svg: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/svg/cached-image-sizing-expected.html [new file with mode: 0644]
LayoutTests/http/tests/svg/cached-image-sizing.html [new file with mode: 0644]
LayoutTests/http/tests/svg/resources/delayCachedLoad.php [new file with mode: 0644]
LayoutTests/http/tests/svg/resources/greenSquare.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedImage.h
Source/WebCore/loader/cache/CachedResource.h