WebCore:
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2007 03:23:35 +0000 (03:23 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2007 03:23:35 +0000 (03:23 +0000)
commitbe284d98b52a59dce4d2d3bea7a716593a273ee1
tree5a51e4f0848cb811b908cf41ed9d4eac74074772
parentdc7ae0370afdf7526c571aa5d69af4330b445c06
WebCore:

        Reviewed by Darin.

        Fix for <rdar://problem/5641255> SVGs with width and height 100%
        fail to render when used as background images

        CachedImage now has a setImageContainerSize function. It is only
        needed for SVG right now.
        * loader/CachedImage.cpp:
        (WebCore::CachedImage::setImageContainerSize):
        * loader/CachedImage.h:

        Relatively sized SVGs have no intrinsic size. Because this call is
        low-level enough that we cannot pass in the container size and get
        the real size of the SVG, we need to know if it has relative
        dimensions, and if so, we need to get the size from scaledTileSize.
        * platform/graphics/Image.cpp:
        (WebCore::Image::drawTiled):
        * platform/graphics/Image.h:
        (WebCore::Image::setContainerSize):
        (WebCore::Image::hasRelativeWidth):
        (WebCore::Image::hasRelativeHeight):

        Re-factored calculateBackgroundSize a bit so that it returns an
        IntSize. Made it a member function so that it can send m_width and
        m_height along to setImageContainerSize.
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::calculateBackgroundSize):
        (WebCore::RenderBox::calculateBackgroundImageGeometry):
        * rendering/RenderBox.h:

        Need to account for relatively sized SVGs in calcViewport()
        * rendering/RenderSVGRoot.cpp:
        (WebCore::RenderSVGRoot::calcViewport):

        Added new member variables to store the size of the SVG container.
        relativeWidthValue() and relativeHeightValue() use the stored SVG
        container size to correctly calculate the width and height of a
        relatively sized SVG.
        * svg/SVGSVGElement.cpp:
        (WebCore::SVGSVGElement::SVGSVGElement):
        (WebCore::SVGSVGElement::setContainerSize):
        (WebCore::SVGSVGElement::relativeWidthValue):
        (WebCore::SVGSVGElement::relativeHeightValue):
        * svg/SVGSVGElement.h:
        (WebCore::SVGSVGElement::containerSize):

        Re-factored size calculations to use the size of the container.
        * svg/graphics/SVGImage.cpp:
        (WebCore::SVGImage::setContainerSize):
        (WebCore::SVGImage::size):
        (WebCore::SVGImage::hasRelativeWidth):
        (WebCore::SVGImage::hasRelativeHeight):
        * svg/graphics/SVGImage.h:

LayoutTests:

        Reviewed by Darin.

        Tests for <rdar://problem/5641255> SVGs with width and height 100%
        fail to render when used as background images

        * fast/backgrounds/resources/balloon.svg: Added.
        * fast/backgrounds/resources/eyes.svg: Added.
        * fast/backgrounds/resources/hearts.svg: Added.
        * fast/backgrounds/resources/linguistics.svg: Added.
        * fast/backgrounds/resources/map.svg: Added.
        * fast/backgrounds/resources/mouse-repel.svg: Added.
        * fast/backgrounds/svg-as-background-1.html: Added.
        * fast/backgrounds/svg-as-background-2.html: Added.
        * fast/backgrounds/svg-as-background-3.html: Added.
        * fast/backgrounds/svg-as-background-4.html: Added.
        * fast/backgrounds/svg-as-background-5.html: Added.
        * fast/backgrounds/svg-as-background-6.html: Added.
        * platform/mac/fast/backgrounds/svg-as-background-1-expected.checksum: Added.
        * platform/mac/fast/backgrounds/svg-as-background-1-expected.png: Added.
        * platform/mac/fast/backgrounds/svg-as-background-1-expected.txt: Added.
        * platform/mac/fast/backgrounds/svg-as-background-2-expected.checksum: Added.
        * platform/mac/fast/backgrounds/svg-as-background-2-expected.png: Added.
        * platform/mac/fast/backgrounds/svg-as-background-2-expected.txt: Added.
        * platform/mac/fast/backgrounds/svg-as-background-3-expected.checksum: Added.
        * platform/mac/fast/backgrounds/svg-as-background-3-expected.png: Added.
        * platform/mac/fast/backgrounds/svg-as-background-3-expected.txt: Added.
        * platform/mac/fast/backgrounds/svg-as-background-4-expected.checksum: Added.
        * platform/mac/fast/backgrounds/svg-as-background-4-expected.png: Added.
        * platform/mac/fast/backgrounds/svg-as-background-4-expected.txt: Added.
        * platform/mac/fast/backgrounds/svg-as-background-5-expected.checksum: Added.
        * platform/mac/fast/backgrounds/svg-as-background-5-expected.png: Added.
        * platform/mac/fast/backgrounds/svg-as-background-5-expected.txt: Added.
        * platform/mac/fast/backgrounds/svg-as-background-6-expected.checksum: Added.
        * platform/mac/fast/backgrounds/svg-as-background-6-expected.png: Added.
        * platform/mac/fast/backgrounds/svg-as-background-6-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28637 268f45cc-cd09-0410-ab3c-d52691b4dbfc
43 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/backgrounds/resources/balloon.svg [new file with mode: 0644]
LayoutTests/fast/backgrounds/resources/eyes.svg [new file with mode: 0644]
LayoutTests/fast/backgrounds/resources/hearts.svg [new file with mode: 0644]
LayoutTests/fast/backgrounds/resources/linguistics.svg [new file with mode: 0644]
LayoutTests/fast/backgrounds/resources/map.svg [new file with mode: 0644]
LayoutTests/fast/backgrounds/resources/mouse-repel.svg [new file with mode: 0644]
LayoutTests/fast/backgrounds/svg-as-background-1.html [new file with mode: 0644]
LayoutTests/fast/backgrounds/svg-as-background-2.html [new file with mode: 0644]
LayoutTests/fast/backgrounds/svg-as-background-3.html [new file with mode: 0644]
LayoutTests/fast/backgrounds/svg-as-background-4.html [new file with mode: 0644]
LayoutTests/fast/backgrounds/svg-as-background-5.html [new file with mode: 0644]
LayoutTests/fast/backgrounds/svg-as-background-6.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-1-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-1-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-1-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-2-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-2-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-3-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-3-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-3-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-4-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-4-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-4-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-5-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-5-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-5-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-6-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-6-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/backgrounds/svg-as-background-6-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/CachedImage.cpp
WebCore/loader/CachedImage.h
WebCore/platform/graphics/Image.cpp
WebCore/platform/graphics/Image.h
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderBox.h
WebCore/rendering/RenderSVGRoot.cpp
WebCore/svg/SVGSVGElement.cpp
WebCore/svg/SVGSVGElement.h
WebCore/svg/graphics/SVGImage.cpp
WebCore/svg/graphics/SVGImage.h