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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 bool RenderSVGImage::updateImageViewport() | 59 bool RenderSVGImage::updateImageViewport() |
60 { | 60 { |
61 SVGImageElement* image = toSVGImageElement(element()); | 61 SVGImageElement* image = toSVGImageElement(element()); |
62 FloatRect oldBoundaries = m_objectBoundingBox; | 62 FloatRect oldBoundaries = m_objectBoundingBox; |
63 bool updatedViewport = false; | 63 bool updatedViewport = false; |
64 | 64 |
65 SVGLengthContext lengthContext(image); | 65 SVGLengthContext lengthContext(image); |
66 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)); | 66 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)); |
67 | 67 |
| 68 bool boundsChanged = oldBoundaries != m_objectBoundingBox; |
| 69 |
68 // Images with preserveAspectRatio=none should force non-uniform scaling. Th
is can be achieved | 70 // Images with preserveAspectRatio=none should force non-uniform scaling. Th
is can be achieved |
69 // by setting the image's container size to its intrinsic size. | 71 // by setting the image's container size to its intrinsic size. |
70 // 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 IntSize newViewportSize; |
71 if (image->preserveAspectRatio()->currentValue()->align() == SVGPreserveAspe
ctRatio::SVG_PRESERVEASPECTRATIO_NONE) { | 74 if (image->preserveAspectRatio()->currentValue()->align() == SVGPreserveAspe
ctRatio::SVG_PRESERVEASPECTRATIO_NONE) { |
72 if (ImageResource* cachedImage = m_imageResource->cachedImage()) { | 75 LayoutSize intrinsicSize = m_imageResource->intrinsicSize(style()->effec
tiveZoom()); |
73 LayoutSize intrinsicSize = cachedImage->imageSizeForRenderer(0, styl
e()->effectiveZoom()); | 76 if (intrinsicSize != m_imageResource->imageSize(style()->effectiveZoom()
)) { |
74 if (intrinsicSize != m_imageResource->imageSize(style()->effectiveZo
om())) { | 77 newViewportSize = roundedIntSize(intrinsicSize); |
75 m_imageResource->setContainerSizeForRenderer(roundedIntSize(intr
insicSize)); | 78 updatedViewport = true; |
76 updatedViewport = true; | |
77 } | |
78 } | 79 } |
| 80 } else if (boundsChanged) { |
| 81 newViewportSize = enclosingIntRect(m_objectBoundingBox).size(); |
| 82 updatedViewport = true; |
79 } | 83 } |
80 | 84 if (updatedViewport) |
81 if (oldBoundaries != m_objectBoundingBox) { | 85 m_imageResource->setContainerSizeForRenderer(newViewportSize); |
82 if (!updatedViewport) | 86 m_needsBoundariesUpdate |= boundsChanged; |
83 m_imageResource->setContainerSizeForRenderer(enclosingIntRect(m_obje
ctBoundingBox).size()); | |
84 updatedViewport = true; | |
85 m_needsBoundariesUpdate = true; | |
86 } | |
87 | |
88 return updatedViewport; | 87 return updatedViewport; |
89 } | 88 } |
90 | 89 |
91 void RenderSVGImage::layout() | 90 void RenderSVGImage::layout() |
92 { | 91 { |
93 ASSERT(needsLayout()); | 92 ASSERT(needsLayout()); |
94 | 93 |
95 updateImageViewport(); | 94 updateImageViewport(); |
96 | 95 |
97 bool transformOrBoundariesUpdate = m_needsTransformUpdate || m_needsBoundari
esUpdate; | 96 bool transformOrBoundariesUpdate = m_needsTransformUpdate || m_needsBoundari
esUpdate; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 226 |
228 void RenderSVGImage::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint
&, const RenderLayerModelObject*) | 227 void RenderSVGImage::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint
&, const RenderLayerModelObject*) |
229 { | 228 { |
230 // this is called from paint() after the localTransform has already been app
lied | 229 // this is called from paint() after the localTransform has already been app
lied |
231 IntRect contentRect = enclosingIntRect(paintInvalidationRectInLocalCoordinat
es()); | 230 IntRect contentRect = enclosingIntRect(paintInvalidationRectInLocalCoordinat
es()); |
232 if (!contentRect.isEmpty()) | 231 if (!contentRect.isEmpty()) |
233 rects.append(contentRect); | 232 rects.append(contentRect); |
234 } | 233 } |
235 | 234 |
236 } // namespace WebCore | 235 } // namespace WebCore |
OLD | NEW |