SVG Fragment is not rendered if it is the css background image of an HTML element
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jun 2015 00:45:58 +0000 (00:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Jun 2015 00:45:58 +0000 (00:45 +0000)
commit686d81767d63654faee81f6b442d482246e343f8
tree6fd4edb32b4f3a7e24ddfc0834fd4bd6ef2747e6
parent3572202ce642e584484a33c6b35bf1af64a6c709
SVG Fragment is not rendered if it is the css background image of an HTML element
https://bugs.webkit.org/show_bug.cgi?id=91790

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-06-09
Reviewed by Darin Adler.

Source/WebCore:

To show an SVG fragment, the SVGImage has to scrollToFragment() using
the resource url. The changes http://trac.webkit.org/changeset/164804
and http://trac.webkit.org/changeset/164983 set the url of SVGImage to
to be used later in SVGImage::draw(). The problem is the SVGImage url
is only set when it is the src of an <img> tag. We did not do the same
thing when the SVGImage is the css background image of an HTML element.

The fix is to set the url of the SVGImage always when it's created by
the CachedImage. The CachedImage must have a valid url when the SVGImage
is created.

Test: svg/css/svg-resource-fragment-identifier-background.html

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::load):
(WebCore::CachedImage::checkShouldPaintBrokenImage):
Replace the calls resourceRequest().url() and m_resourceRequest.url() by
calling url() since they are all the same.

(WebCore::CachedImage::createImage): Pass the resource url to SVGImage
and change ImageObserver& by ImageObserver*, since null is not legal.

* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::SVGImage):
* svg/graphics/SVGImage.h: Add a url parameter to SVGImage constructor.

* svg/graphics/SVGImageCache.cpp:
(WebCore::SVGImageCache::findImageForRenderer): Add a new helper function.

(WebCore::SVGImageCache::imageSizeForRenderer):
(WebCore::SVGImageCache::imageForRenderer): Code clean up.

* svg/graphics/SVGImageCache.h: Make imageForRenderer() const.

* svg/graphics/SVGImageForContainer.cpp: Remove unneeded header file.

LayoutTests:

* svg/css/svg-resource-fragment-identifier-background-expected.html: Added.
* svg/css/svg-resource-fragment-identifier-background.html: Added.
Ensure that the SVG fragment is displayed correctly when it's used as a
css background image.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185395 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/svg/css/svg-resource-fragment-identifier-background-expected.html [new file with mode: 0644]
LayoutTests/svg/css/svg-resource-fragment-identifier-background.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebCore/svg/graphics/SVGImage.h
Source/WebCore/svg/graphics/SVGImageCache.cpp
Source/WebCore/svg/graphics/SVGImageCache.h
Source/WebCore/svg/graphics/SVGImageForContainer.cpp