WebCore:
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2007 07:53:52 +0000 (07:53 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2007 07:53:52 +0000 (07:53 +0000)
commit9446054e671c63ef8c5a7762c660dd59b71aa13d
treead6abea84c4e323e2189cbbcccd30f42516da0a6
parentcedd448f0a5dd22ec870773257072b288488c2d0
WebCore:

        Reviewed by Oliver.

        Fix for <rdar://problem/5616982> SVGs with width and height 100%
        fail to render when used as <img> or CSS image (16167)

        This final part of the work fixes the <img> tag.

        This is the real fix.
        * rendering/RenderImage.cpp:
        (WebCore::RenderImage::calcReplacedWidth): Set the container size
        on the image. Setting the container size only actually sticks if
        the values are non-zero, so if the container size really was set,
        use the imageSize that is calculated using the container size. If
        it did not stick but the image does have relative width (meaning
        that the container size is 0), set the width to 0 by hand. We want
        to avoid setting the width before we have a container size or we
        will end up incorrectly using the default size of 300x150.
        (WebCore::RenderImage::calcReplacedHeight): Same as above, but for
        height.

        A few more pieces of information have to be exposed through cached
        image to make this happen.
        * loader/CachedImage.cpp:
        (WebCore::CachedImage::usesImageContainerSize): As mentioned above,
        when setContainerSize() is called, the container size is only
        actually set if the values are non-zero. This call tells you if it
        was set.
        (WebCore::CachedImage::imageHasRelativeWidth):
        (WebCore::CachedImage::imageHasRelativeHeight):
        * loader/CachedImage.h:
        * platform/graphics/Image.h:
        (WebCore::Image::usesContainerSize):
        * svg/graphics/SVGImage.cpp:
        (WebCore::SVGImage::usesContainerSize):
        * svg/graphics/SVGImage.h:

LayoutTests:

        Reviewed by Oliver.

        Test for <rdar://problem/5616982> SVGs with width and height 100%
        fail to render when used as <img> or CSS image (16167)

        * fast/images/resources/green-relative-size-rect.svg: Added.
        * fast/images/svg-as-relative-image.html: Added.
        * platform/mac/fast/images/svg-as-relative-image-expected.checksum: Added.
        * platform/mac/fast/images/svg-as-relative-image-expected.png: Added.
        * platform/mac/fast/images/svg-as-relative-image-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/images/resources/green-relative-size-rect.svg [new file with mode: 0644]
LayoutTests/fast/images/svg-as-relative-image.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/images/svg-as-relative-image-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/images/svg-as-relative-image-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/images/svg-as-relative-image-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/CachedImage.cpp
WebCore/loader/CachedImage.h
WebCore/platform/graphics/Image.h
WebCore/rendering/RenderImage.cpp
WebCore/svg/graphics/SVGImage.cpp
WebCore/svg/graphics/SVGImage.h