Changeset 28856 in webkit
- Timestamp:
- Dec 18, 2007 11:53:52 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r28845 r28856 1 2007-12-18 Beth Dakin <bdakin@apple.com> 2 3 Reviewed by Oliver. 4 5 Test for <rdar://problem/5616982> SVGs with width and height 100% 6 fail to render when used as <img> or CSS image (16167) 7 8 * fast/images/resources/green-relative-size-rect.svg: Added. 9 * fast/images/svg-as-relative-image.html: Added. 10 * platform/mac/fast/images/svg-as-relative-image-expected.checksum: Added. 11 * platform/mac/fast/images/svg-as-relative-image-expected.png: Added. 12 * platform/mac/fast/images/svg-as-relative-image-expected.txt: Added. 13 1 14 2007-12-18 Dan Bernstein <mitz@apple.com> 2 15 -
trunk/WebCore/ChangeLog
r28846 r28856 1 2007-12-18 Beth Dakin <bdakin@apple.com> 2 3 Reviewed by Oliver. 4 5 Fix for <rdar://problem/5616982> SVGs with width and height 100% 6 fail to render when used as <img> or CSS image (16167) 7 8 This final part of the work fixes the <img> tag. 9 10 This is the real fix. 11 * rendering/RenderImage.cpp: 12 (WebCore::RenderImage::calcReplacedWidth): Set the container size 13 on the image. Setting the container size only actually sticks if 14 the values are non-zero, so if the container size really was set, 15 use the imageSize that is calculated using the container size. If 16 it did not stick but the image does have relative width (meaning 17 that the container size is 0), set the width to 0 by hand. We want 18 to avoid setting the width before we have a container size or we 19 will end up incorrectly using the default size of 300x150. 20 (WebCore::RenderImage::calcReplacedHeight): Same as above, but for 21 height. 22 23 A few more pieces of information have to be exposed through cached 24 image to make this happen. 25 * loader/CachedImage.cpp: 26 (WebCore::CachedImage::usesImageContainerSize): As mentioned above, 27 when setContainerSize() is called, the container size is only 28 actually set if the values are non-zero. This call tells you if it 29 was set. 30 (WebCore::CachedImage::imageHasRelativeWidth): 31 (WebCore::CachedImage::imageHasRelativeHeight): 32 * loader/CachedImage.h: 33 * platform/graphics/Image.h: 34 (WebCore::Image::usesContainerSize): 35 * svg/graphics/SVGImage.cpp: 36 (WebCore::SVGImage::usesContainerSize): 37 * svg/graphics/SVGImage.h: 38 1 39 2007-12-18 Mark Rowe <mrowe@apple.com> 2 40 -
trunk/WebCore/loader/CachedImage.cpp
r28637 r28856 118 118 if (m_image) 119 119 m_image->setContainerSize(containerSize); 120 } 121 122 bool CachedImage::usesImageContainerSize() const 123 { 124 if (m_image) 125 return m_image->usesContainerSize(); 126 127 return false; 128 } 129 130 bool CachedImage::imageHasRelativeWidth() const 131 { 132 if (m_image) 133 return m_image->hasRelativeWidth(); 134 135 return false; 136 } 137 138 bool CachedImage::imageHasRelativeHeight() const 139 { 140 if (m_image) 141 return m_image->hasRelativeHeight(); 142 143 return false; 120 144 } 121 145 -
trunk/WebCore/loader/CachedImage.h
r28637 r28856 47 47 bool canRender() const { return !errorOccurred() && imageSize().width() > 0 && imageSize().height() > 0; } 48 48 49 // These are ony used for SVGImage right now 49 50 void setImageContainerSize(const IntSize&); 51 bool usesImageContainerSize() const; 52 bool imageHasRelativeWidth() const; 53 bool imageHasRelativeHeight() const; 50 54 51 55 IntSize imageSize() const; // returns the size of the complete image -
trunk/WebCore/platform/graphics/Image.h
r28637 r28856 83 83 // These are ony used for SVGImage right now 84 84 virtual void setContainerSize(const IntSize&) { } 85 virtual bool usesContainerSize() const { return false; } 85 86 virtual bool hasRelativeWidth() const { return false; } 86 87 virtual bool hasRelativeHeight() const { return false; } -
trunk/WebCore/rendering/RenderImage.cpp
r28397 r28856 325 325 int RenderImage::calcReplacedWidth() const 326 326 { 327 if (m_cachedImage && m_cachedImage->imageHasRelativeWidth() && !m_cachedImage->usesImageContainerSize()) 328 if (RenderObject* cb = isPositioned() ? container() : containingBlock()) 329 m_cachedImage->setImageContainerSize(IntSize(cb->availableWidth(), cb->availableHeight())); 330 327 331 int width; 328 332 if (isWidthSpecified()) 329 333 width = calcReplacedWidthUsing(style()->width()); 334 else if (m_cachedImage && m_cachedImage->usesImageContainerSize()) 335 width = m_cachedImage->imageSize().width(); 336 else if (m_cachedImage && m_cachedImage->imageHasRelativeWidth()) 337 width = 0; // If the image is relatively-sized, set the width to 0 until there is a set container size. 330 338 else 331 339 width = calcAspectRatioWidth(); … … 342 350 if (isHeightSpecified()) 343 351 height = calcReplacedHeightUsing(style()->height()); 352 else if (m_cachedImage && m_cachedImage->usesImageContainerSize()) 353 height = m_cachedImage->imageSize().height(); 354 else if (m_cachedImage && m_cachedImage->imageHasRelativeHeight()) 355 height = 0; // If the image is relatively-sized, set the height to 0 until there is a set container size. 344 356 else 345 357 height = calcAspectRatioHeight(); -
trunk/WebCore/svg/graphics/SVGImage.cpp
r28637 r28856 77 77 } 78 78 79 bool SVGImage::usesContainerSize() const 80 { 81 SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement(); 82 if (!rootElement) 83 return false; 84 85 return rootElement->hasSetContainerSize(); 86 } 87 79 88 IntSize SVGImage::size() const 80 89 { -
trunk/WebCore/svg/graphics/SVGImage.h
r28637 r28856 47 47 48 48 virtual void setContainerSize(const IntSize&); 49 virtual bool usesContainerSize() const; 49 50 virtual bool hasRelativeWidth() const; 50 51 virtual bool hasRelativeHeight() const;
Note: See TracChangeset
for help on using the changeset viewer.