Chromium Code Reviews| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 | 81 |
| 82 static bool containerSizeIsSetForLayoutObject(ImageResource& cachedImage, const LayoutObject* layoutObject) | 82 static bool containerSizeIsSetForLayoutObject(ImageResource& cachedImage, const LayoutObject* layoutObject) |
| 83 { | 83 { |
| 84 const Image* image = cachedImage.image(); | 84 const Image* image = cachedImage.image(); |
| 85 // If a container size has been specified for this layoutObject, then | 85 // If a container size has been specified for this layoutObject, then |
| 86 // imageForLayoutObject() will return the SVGImageForContainer while image() | 86 // imageForLayoutObject() will return the SVGImageForContainer while image() |
| 87 // will return the underlying SVGImage. | 87 // will return the underlying SVGImage. |
| 88 return !image->isSVGImage() || image != cachedImage.imageForLayoutObject(lay outObject); | 88 return !image->isSVGImage() || image != cachedImage.imageForLayoutObject(lay outObject); |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool LayoutSVGImage::updateImageViewport() | 91 void LayoutSVGImage::updateImageContainerSize() |
| 92 { | 92 { |
| 93 SVGImageElement* image = toSVGImageElement(element()); | 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() | |
| 104 { | |
| 94 FloatRect oldBoundaries = m_objectBoundingBox; | 105 FloatRect oldBoundaries = m_objectBoundingBox; |
| 95 | 106 |
| 96 SVGLengthContext lengthContext(image); | 107 SVGLengthContext lengthContext(element()); |
| 97 m_objectBoundingBox = FloatRect( | 108 m_objectBoundingBox = FloatRect( |
| 98 lengthContext.valueForLength(styleRef().svgStyle().x(), styleRef(), SVGL engthMode::Width), | 109 lengthContext.valueForLength(styleRef().svgStyle().x(), styleRef(), SVGL engthMode::Width), |
| 99 lengthContext.valueForLength(styleRef().svgStyle().y(), styleRef(), SVGL engthMode::Height), | 110 lengthContext.valueForLength(styleRef().svgStyle().y(), styleRef(), SVGL engthMode::Height), |
| 100 lengthContext.valueForLength(styleRef().width(), styleRef(), SVGLengthMo de::Width), | 111 lengthContext.valueForLength(styleRef().width(), styleRef(), SVGLengthMo de::Width), |
| 101 lengthContext.valueForLength(styleRef().height(), styleRef(), SVGLengthM ode::Height)); | 112 lengthContext.valueForLength(styleRef().height(), styleRef(), SVGLengthM ode::Height)); |
| 102 bool boundsChanged = oldBoundaries != m_objectBoundingBox; | 113 m_needsBoundariesUpdate |= oldBoundaries != m_objectBoundingBox; |
| 103 | |
| 104 bool updatedViewport = false; | |
| 105 ImageResource* cachedImage = m_imageResource->cachedImage(); | |
| 106 if (cachedImage && cachedImage->usesImageContainerSize()) { | |
| 107 FloatSize imageViewportSize = computeImageViewportSize(*cachedImage); | |
| 108 if (LayoutSize(imageViewportSize) != m_imageResource->imageSize(styleRef ().effectiveZoom()) | |
| 109 || !containerSizeIsSetForLayoutObject(*cachedImage, this)) { | |
| 110 m_imageResource->setContainerSizeForLayoutObject(roundedIntSize(imag eViewportSize)); | |
| 111 updatedViewport = true; | |
| 112 } | |
| 113 } | |
| 114 | |
| 115 m_needsBoundariesUpdate |= boundsChanged; | |
| 116 return updatedViewport || boundsChanged; | |
| 117 } | 114 } |
| 118 | 115 |
| 119 void LayoutSVGImage::layout() | 116 void LayoutSVGImage::layout() |
| 120 { | 117 { |
| 121 ASSERT(needsLayout()); | 118 ASSERT(needsLayout()); |
| 122 LayoutAnalyzer::Scope analyzer(*this); | 119 LayoutAnalyzer::Scope analyzer(*this); |
| 123 | 120 |
| 124 updateImageViewport(); | 121 updateBoundingBox(); |
| 122 updateImageContainerSize(); | |
| 125 | 123 |
| 126 bool transformOrBoundariesUpdate = m_needsTransformUpdate || m_needsBoundari esUpdate; | 124 bool transformOrBoundariesUpdate = m_needsTransformUpdate || m_needsBoundari esUpdate; |
| 127 if (m_needsTransformUpdate) { | 125 if (m_needsTransformUpdate) { |
| 128 m_localTransform = toSVGImageElement(element())->calculateAnimatedLocalT ransform(); | 126 m_localTransform = toSVGImageElement(element())->calculateAnimatedLocalT ransform(); |
| 129 m_needsTransformUpdate = false; | 127 m_needsTransformUpdate = false; |
| 130 } | 128 } |
| 131 | 129 |
| 132 if (m_needsBoundariesUpdate) { | 130 if (m_needsBoundariesUpdate) { |
| 133 m_bufferedForeground.clear(); | 131 m_bufferedForeground.clear(); |
| 134 | 132 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 return true; | 171 return true; |
| 174 } | 172 } |
| 175 } | 173 } |
| 176 } | 174 } |
| 177 | 175 |
| 178 return false; | 176 return false; |
| 179 } | 177 } |
| 180 | 178 |
| 181 void LayoutSVGImage::imageChanged(WrappedImagePtr, const IntRect*) | 179 void LayoutSVGImage::imageChanged(WrappedImagePtr, const IntRect*) |
| 182 { | 180 { |
| 183 // The image resource defaults to nullImage until the resource arrives. | 181 // Notify parent resources that we've changed. This also invalidates |
| 184 // This empty image may be cached by SVG resources which must be invalidated . | 182 // references from resources (filters) that may have a cached |
| 185 if (SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj ect(this)) | 183 // representation of this image/layout object. |
| 186 resources->removeClientFromCache(this); | |
| 187 | |
| 188 // Eventually notify parent resources, that we've changed. | |
| 189 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(this, false); | 184 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(this, false); |
| 190 | 185 |
| 191 // Update the SVGImageCache sizeAndScales entry in case image loading finish ed after layout. | 186 // Update the SVGImageCache sizeAndScales entry in case image loading finish ed after layout. |
| 192 // (https://bugs.webkit.org/show_bug.cgi?id=99489) | 187 // (https://bugs.webkit.org/show_bug.cgi?id=99489) |
| 193 m_objectBoundingBox = FloatRect(); | 188 updateImageContainerSize(); |
|
f(malita)
2015/07/01 16:39:34
If we're no longer updating the bbox here, is it p
fs
2015/07/01 16:58:13
The image (dimensions) does not affect the viewpor
| |
| 194 updateImageViewport(); | |
| 195 | 189 |
| 196 m_bufferedForeground.clear(); | 190 m_bufferedForeground.clear(); |
| 197 | 191 |
| 198 setShouldDoFullPaintInvalidation(); | 192 setShouldDoFullPaintInvalidation(); |
| 199 } | 193 } |
| 200 | 194 |
| 201 void LayoutSVGImage::addFocusRingRects(Vector<LayoutRect>& rects, const LayoutPo int&) const | 195 void LayoutSVGImage::addFocusRingRects(Vector<LayoutRect>& rects, const LayoutPo int&) const |
| 202 { | 196 { |
| 203 // this is called from paint() after the localTransform has already been app lied | 197 // this is called from paint() after the localTransform has already been app lied |
| 204 LayoutRect contentRect = LayoutRect(paintInvalidationRectInLocalCoordinates( )); | 198 LayoutRect contentRect = LayoutRect(paintInvalidationRectInLocalCoordinates( )); |
| 205 if (!contentRect.isEmpty()) | 199 if (!contentRect.isEmpty()) |
| 206 rects.append(contentRect); | 200 rects.append(contentRect); |
| 207 } | 201 } |
| 208 | 202 |
| 209 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |