| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> | 2 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> |
| 3 * Copyright (C) 2006 Apple Computer, Inc. | 3 * Copyright (C) 2006 Apple Computer, Inc. |
| 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 5 * Copyright (C) 2007, 2008, 2009 Rob Buis <buis@kde.org> | 5 * Copyright (C) 2007, 2008, 2009 Rob Buis <buis@kde.org> |
| 6 * Copyright (C) 2009 Google, Inc. | 6 * Copyright (C) 2009 Google, Inc. |
| 7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 8 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> | 8 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // scaling. This can be achieved by setting the image's container size to | 72 // scaling. This can be achieved by setting the image's container size to |
| 73 // its viewport size (i.e. if a viewBox is available - use that - else use i
ntrinsic size.) | 73 // its viewport size (i.e. if a viewBox is available - use that - else use i
ntrinsic size.) |
| 74 // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The 'preserveAspectRa
tio' attribute. | 74 // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The 'preserveAspectRa
tio' attribute. |
| 75 Length intrinsicWidth; | 75 Length intrinsicWidth; |
| 76 Length intrinsicHeight; | 76 Length intrinsicHeight; |
| 77 FloatSize intrinsicRatio; | 77 FloatSize intrinsicRatio; |
| 78 cachedImage.computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intr
insicRatio); | 78 cachedImage.computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intr
insicRatio); |
| 79 return intrinsicRatio; | 79 return intrinsicRatio; |
| 80 } | 80 } |
| 81 | 81 |
| 82 static bool containerSizeIsSetForLayoutObject(ImageResource& cachedImage, const
LayoutObject* layoutObject) | |
| 83 { | |
| 84 const Image* image = cachedImage.image(); | |
| 85 // If a container size has been specified for this layoutObject, then | |
| 86 // imageForLayoutObject() will return the SVGImageForContainer while image() | |
| 87 // will return the underlying SVGImage. | |
| 88 return !image->isSVGImage() || image != cachedImage.imageForLayoutObject(lay
outObject); | |
| 89 } | |
| 90 | |
| 91 void LayoutSVGImage::updateImageContainerSize() | |
| 92 { | |
| 93 ImageResource* cachedImage = m_imageResource->cachedImage(); | |
| 94 if (!cachedImage || !cachedImage->usesImageContainerSize()) | |
| 95 return; | |
| 96 FloatSize imageViewportSize = computeImageViewportSize(*cachedImage); | |
| 97 if (LayoutSize(imageViewportSize) != m_imageResource->imageSize(styleRef().e
ffectiveZoom()) | |
| 98 || !containerSizeIsSetForLayoutObject(*cachedImage, this)) { | |
| 99 m_imageResource->setContainerSizeForLayoutObject(roundedIntSize(imageVie
wportSize)); | |
| 100 } | |
| 101 } | |
| 102 | |
| 103 void LayoutSVGImage::updateBoundingBox() | 82 void LayoutSVGImage::updateBoundingBox() |
| 104 { | 83 { |
| 105 FloatRect oldBoundaries = m_objectBoundingBox; | 84 FloatRect oldBoundaries = m_objectBoundingBox; |
| 106 | 85 |
| 107 SVGLengthContext lengthContext(element()); | 86 SVGLengthContext lengthContext(element()); |
| 108 m_objectBoundingBox = FloatRect( | 87 m_objectBoundingBox = FloatRect( |
| 109 lengthContext.valueForLength(styleRef().svgStyle().x(), styleRef(), SVGL
engthMode::Width), | 88 lengthContext.valueForLength(styleRef().svgStyle().x(), styleRef(), SVGL
engthMode::Width), |
| 110 lengthContext.valueForLength(styleRef().svgStyle().y(), styleRef(), SVGL
engthMode::Height), | 89 lengthContext.valueForLength(styleRef().svgStyle().y(), styleRef(), SVGL
engthMode::Height), |
| 111 lengthContext.valueForLength(styleRef().width(), styleRef(), SVGLengthMo
de::Width), | 90 lengthContext.valueForLength(styleRef().width(), styleRef(), SVGLengthMo
de::Width), |
| 112 lengthContext.valueForLength(styleRef().height(), styleRef(), SVGLengthM
ode::Height)); | 91 lengthContext.valueForLength(styleRef().height(), styleRef(), SVGLengthM
ode::Height)); |
| 113 m_needsBoundariesUpdate |= oldBoundaries != m_objectBoundingBox; | 92 m_needsBoundariesUpdate |= oldBoundaries != m_objectBoundingBox; |
| 114 } | 93 } |
| 115 | 94 |
| 116 void LayoutSVGImage::layout() | 95 void LayoutSVGImage::layout() |
| 117 { | 96 { |
| 118 ASSERT(needsLayout()); | 97 ASSERT(needsLayout()); |
| 119 LayoutAnalyzer::Scope analyzer(*this); | 98 LayoutAnalyzer::Scope analyzer(*this); |
| 120 | 99 |
| 121 updateBoundingBox(); | 100 updateBoundingBox(); |
| 122 updateImageContainerSize(); | |
| 123 | 101 |
| 124 bool transformOrBoundariesUpdate = m_needsTransformUpdate || m_needsBoundari
esUpdate; | 102 bool transformOrBoundariesUpdate = m_needsTransformUpdate || m_needsBoundari
esUpdate; |
| 125 if (m_needsTransformUpdate) { | 103 if (m_needsTransformUpdate) { |
| 126 m_localTransform = toSVGImageElement(element())->calculateAnimatedLocalT
ransform(); | 104 m_localTransform = toSVGImageElement(element())->calculateAnimatedLocalT
ransform(); |
| 127 m_needsTransformUpdate = false; | 105 m_needsTransformUpdate = false; |
| 128 } | 106 } |
| 129 | 107 |
| 130 if (m_needsBoundariesUpdate) { | 108 if (m_needsBoundariesUpdate) { |
| 131 m_bufferedForeground.clear(); | 109 m_bufferedForeground.clear(); |
| 132 | 110 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 return false; | 156 return false; |
| 179 } | 157 } |
| 180 | 158 |
| 181 void LayoutSVGImage::imageChanged(WrappedImagePtr, const IntRect*) | 159 void LayoutSVGImage::imageChanged(WrappedImagePtr, const IntRect*) |
| 182 { | 160 { |
| 183 // Notify parent resources that we've changed. This also invalidates | 161 // Notify parent resources that we've changed. This also invalidates |
| 184 // references from resources (filters) that may have a cached | 162 // references from resources (filters) that may have a cached |
| 185 // representation of this image/layout object. | 163 // representation of this image/layout object. |
| 186 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(this,
false); | 164 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(this,
false); |
| 187 | 165 |
| 188 // Update the SVGImageCache sizeAndScales entry in case image loading finish
ed after layout. | |
| 189 // (https://bugs.webkit.org/show_bug.cgi?id=99489) | |
| 190 updateImageContainerSize(); | |
| 191 | |
| 192 m_bufferedForeground.clear(); | 166 m_bufferedForeground.clear(); |
| 193 | 167 |
| 194 setShouldDoFullPaintInvalidation(); | 168 setShouldDoFullPaintInvalidation(); |
| 195 } | 169 } |
| 196 | 170 |
| 197 void LayoutSVGImage::addOutlineRects(Vector<LayoutRect>& rects, const LayoutPoin
t&) const | 171 void LayoutSVGImage::addOutlineRects(Vector<LayoutRect>& rects, const LayoutPoin
t&) const |
| 198 { | 172 { |
| 199 // this is called from paint() after the localTransform has already been app
lied | 173 // this is called from paint() after the localTransform has already been app
lied |
| 200 rects.append(LayoutRect(paintInvalidationRectInLocalCoordinates())); | 174 rects.append(LayoutRect(paintInvalidationRectInLocalCoordinates())); |
| 201 } | 175 } |
| 202 | 176 |
| 203 } // namespace blink | 177 } // namespace blink |
| OLD | NEW |