| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/SVGImagePainter.h" | 5 #include "core/paint/SVGImagePainter.h" |
| 6 | 6 |
| 7 #include "core/layout/ImageQualityController.h" | 7 #include "core/layout/ImageQualityController.h" |
| 8 #include "core/layout/LayoutImageResource.h" | 8 #include "core/layout/LayoutImageResource.h" |
| 9 #include "core/layout/svg/LayoutSVGImage.h" | 9 #include "core/layout/svg/LayoutSVGImage.h" |
| 10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 InterpolationQuality previousInterpolationQuality = paintInfo.context.imageI
nterpolationQuality(); | 67 InterpolationQuality previousInterpolationQuality = paintInfo.context.imageI
nterpolationQuality(); |
| 68 paintInfo.context.setImageInterpolationQuality(interpolationQuality); | 68 paintInfo.context.setImageInterpolationQuality(interpolationQuality); |
| 69 paintInfo.context.drawImage(image.get(), destRect, &srcRect); | 69 paintInfo.context.drawImage(image.get(), destRect, &srcRect); |
| 70 paintInfo.context.setImageInterpolationQuality(previousInterpolationQuality)
; | 70 paintInfo.context.setImageInterpolationQuality(previousInterpolationQuality)
; |
| 71 } | 71 } |
| 72 | 72 |
| 73 FloatSize SVGImagePainter::computeImageViewportSize() const | 73 FloatSize SVGImagePainter::computeImageViewportSize() const |
| 74 { | 74 { |
| 75 ASSERT(m_layoutSVGImage.imageResource()->hasImage()); | 75 ASSERT(m_layoutSVGImage.imageResource()->hasImage()); |
| 76 | 76 |
| 77 if (toSVGImageElement(m_layoutSVGImage.element())->preserveAspectRatio()->cu
rrentValue()->align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) | 77 if (toSVGImageElement(m_layoutSVGImage.element())->preserveAspectRatio()->cu
rrentValue()->align() != SVGPreserveAspectRatio::kSvgPreserveaspectratioNone) |
| 78 return m_layoutSVGImage.objectBoundingBox().size(); | 78 return m_layoutSVGImage.objectBoundingBox().size(); |
| 79 | 79 |
| 80 ImageResource* cachedImage = m_layoutSVGImage.imageResource()->cachedImage()
; | 80 ImageResource* cachedImage = m_layoutSVGImage.imageResource()->cachedImage()
; |
| 81 | 81 |
| 82 // Images with preserveAspectRatio=none should force non-uniform scaling. Th
is can be achieved | 82 // Images with preserveAspectRatio=none should force non-uniform scaling. Th
is can be achieved |
| 83 // by setting the image's container size to its viewport size (i.e. concrete
object size | 83 // by setting the image's container size to its viewport size (i.e. concrete
object size |
| 84 // returned by the default sizing algorithm.) See | 84 // returned by the default sizing algorithm.) See |
| 85 // https://www.w3.org/TR/SVG/single-page.html#coords-PreserveAspectRatioAttr
ibute and | 85 // https://www.w3.org/TR/SVG/single-page.html#coords-PreserveAspectRatioAttr
ibute and |
| 86 // https://drafts.csswg.org/css-images-3/#default-sizing. | 86 // https://drafts.csswg.org/css-images-3/#default-sizing. |
| 87 | 87 |
| 88 // Avoid returning the size of the broken image. | 88 // Avoid returning the size of the broken image. |
| 89 if (cachedImage->errorOccurred()) | 89 if (cachedImage->errorOccurred()) |
| 90 return FloatSize(); | 90 return FloatSize(); |
| 91 | 91 |
| 92 if (cachedImage->getImage()->isSVGImage()) | 92 if (cachedImage->getImage()->isSVGImage()) |
| 93 return toSVGImage(cachedImage->getImage())->concreteObjectSize(m_layoutS
VGImage.objectBoundingBox().size()); | 93 return toSVGImage(cachedImage->getImage())->concreteObjectSize(m_layoutS
VGImage.objectBoundingBox().size()); |
| 94 | 94 |
| 95 return FloatSize(cachedImage->getImage()->size()); | 95 return FloatSize(cachedImage->getImage()->size()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace blink | 98 } // namespace blink |
| OLD | NEW |