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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 // scaling. This can be achieved by setting the image's container size to | 70 // scaling. This can be achieved by setting the image's container size to |
| 71 // its viewport size (i.e. if a viewBox is available - use that - else use i ntrinsic size.) | 71 // its viewport size (i.e. if a viewBox is available - use that - else use i ntrinsic size.) |
| 72 // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The ‘preserveAspectRa tio’ attribute. | 72 // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The ‘preserveAspectRa tio’ attribute. |
| 73 Length intrinsicWidth; | 73 Length intrinsicWidth; |
| 74 Length intrinsicHeight; | 74 Length intrinsicHeight; |
| 75 FloatSize intrinsicRatio; | 75 FloatSize intrinsicRatio; |
| 76 cachedImage.computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intr insicRatio); | 76 cachedImage.computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intr insicRatio); |
| 77 return intrinsicRatio; | 77 return intrinsicRatio; |
| 78 } | 78 } |
| 79 | 79 |
| 80 static bool containerSizeIsSetForRenderer(ImageResource& cachedImage, const Rend erObject* renderer) | |
|
pdr.
2015/01/29 19:32:21
Can we put this on ImageResource?
fs
2015/01/30 09:30:20
I considered that, but since it didn't seem univer
| |
| 81 { | |
| 82 const Image* image = cachedImage.image(); | |
| 83 // If a container size has been specified for this renderer, then | |
| 84 // imageForRenderer() will return the SVGImageForContainer while image() | |
| 85 // will return the underlying SVGImage. | |
| 86 return !image->isSVGImage() || image != cachedImage.imageForRenderer(rendere r); | |
| 87 } | |
| 88 | |
| 80 bool RenderSVGImage::updateImageViewport() | 89 bool RenderSVGImage::updateImageViewport() |
| 81 { | 90 { |
| 82 SVGImageElement* image = toSVGImageElement(element()); | 91 SVGImageElement* image = toSVGImageElement(element()); |
| 83 FloatRect oldBoundaries = m_objectBoundingBox; | 92 FloatRect oldBoundaries = m_objectBoundingBox; |
| 84 | 93 |
| 85 SVGLengthContext lengthContext(image); | 94 SVGLengthContext lengthContext(image); |
| 86 m_objectBoundingBox = FloatRect(image->x()->currentValue()->value(lengthCont ext), image->y()->currentValue()->value(lengthContext), image->width()->currentV alue()->value(lengthContext), image->height()->currentValue()->value(lengthConte xt)); | 95 m_objectBoundingBox = FloatRect(image->x()->currentValue()->value(lengthCont ext), image->y()->currentValue()->value(lengthContext), image->width()->currentV alue()->value(lengthContext), image->height()->currentValue()->value(lengthConte xt)); |
| 87 bool boundsChanged = oldBoundaries != m_objectBoundingBox; | 96 bool boundsChanged = oldBoundaries != m_objectBoundingBox; |
| 88 | 97 |
| 89 bool updatedViewport = false; | 98 bool updatedViewport = false; |
| 90 ImageResource* cachedImage = m_imageResource->cachedImage(); | 99 ImageResource* cachedImage = m_imageResource->cachedImage(); |
| 91 if (cachedImage && cachedImage->usesImageContainerSize()) { | 100 if (cachedImage && cachedImage->usesImageContainerSize()) { |
| 92 FloatSize imageViewportSize = computeImageViewportSize(*cachedImage); | 101 FloatSize imageViewportSize = computeImageViewportSize(*cachedImage); |
| 93 if (LayoutSize(imageViewportSize) != m_imageResource->imageSize(style()- >effectiveZoom())) { | 102 if (LayoutSize(imageViewportSize) != m_imageResource->imageSize(style()- >effectiveZoom()) |
| 103 || !containerSizeIsSetForRenderer(*cachedImage, this)) { | |
| 94 m_imageResource->setContainerSizeForRenderer(roundedIntSize(imageVie wportSize)); | 104 m_imageResource->setContainerSizeForRenderer(roundedIntSize(imageVie wportSize)); |
| 95 updatedViewport = true; | 105 updatedViewport = true; |
| 96 } | 106 } |
| 97 } | 107 } |
| 98 | 108 |
| 99 m_needsBoundariesUpdate |= boundsChanged; | 109 m_needsBoundariesUpdate |= boundsChanged; |
| 100 return updatedViewport || boundsChanged; | 110 return updatedViewport || boundsChanged; |
| 101 } | 111 } |
| 102 | 112 |
| 103 void RenderSVGImage::layout() | 113 void RenderSVGImage::layout() |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 | 193 |
| 184 void RenderSVGImage::addFocusRingRects(Vector<LayoutRect>& rects, const LayoutPo int&) const | 194 void RenderSVGImage::addFocusRingRects(Vector<LayoutRect>& rects, const LayoutPo int&) const |
| 185 { | 195 { |
| 186 // this is called from paint() after the localTransform has already been app lied | 196 // this is called from paint() after the localTransform has already been app lied |
| 187 LayoutRect contentRect = LayoutRect(paintInvalidationRectInLocalCoordinates( )); | 197 LayoutRect contentRect = LayoutRect(paintInvalidationRectInLocalCoordinates( )); |
| 188 if (!contentRect.isEmpty()) | 198 if (!contentRect.isEmpty()) |
| 189 rects.append(contentRect); | 199 rects.append(contentRect); |
| 190 } | 200 } |
| 191 | 201 |
| 192 } // namespace blink | 202 } // namespace blink |
| OLD | NEW |