| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 FloatSize SVGImagePainter::computeImageViewportSize() const { | 86 FloatSize SVGImagePainter::computeImageViewportSize() const { |
| 87 DCHECK(m_layoutSVGImage.imageResource()->hasImage()); | 87 DCHECK(m_layoutSVGImage.imageResource()->hasImage()); |
| 88 | 88 |
| 89 if (toSVGImageElement(m_layoutSVGImage.element()) | 89 if (toSVGImageElement(m_layoutSVGImage.element()) |
| 90 ->preserveAspectRatio() | 90 ->preserveAspectRatio() |
| 91 ->currentValue() | 91 ->currentValue() |
| 92 ->align() != SVGPreserveAspectRatio::kSvgPreserveaspectratioNone) | 92 ->align() != SVGPreserveAspectRatio::kSvgPreserveaspectratioNone) |
| 93 return m_layoutSVGImage.objectBoundingBox().size(); | 93 return m_layoutSVGImage.objectBoundingBox().size(); |
| 94 | 94 |
| 95 ImageResource* cachedImage = m_layoutSVGImage.imageResource()->cachedImage(); | 95 ImageResourceContent* cachedImage = |
| 96 m_layoutSVGImage.imageResource()->cachedImage(); |
| 96 | 97 |
| 97 // Images with preserveAspectRatio=none should force non-uniform scaling. This | 98 // Images with preserveAspectRatio=none should force non-uniform scaling. This |
| 98 // can be achieved by setting the image's container size to its viewport size | 99 // can be achieved by setting the image's container size to its viewport size |
| 99 // (i.e. concrete object size returned by the default sizing algorithm.) See | 100 // (i.e. concrete object size returned by the default sizing algorithm.) See |
| 100 // https://www.w3.org/TR/SVG/single-page.html#coords-PreserveAspectRatioAttrib
ute | 101 // https://www.w3.org/TR/SVG/single-page.html#coords-PreserveAspectRatioAttrib
ute |
| 101 // and https://drafts.csswg.org/css-images-3/#default-sizing. | 102 // and https://drafts.csswg.org/css-images-3/#default-sizing. |
| 102 | 103 |
| 103 // Avoid returning the size of the broken image. | 104 // Avoid returning the size of the broken image. |
| 104 if (cachedImage->errorOccurred()) | 105 if (cachedImage->errorOccurred()) |
| 105 return FloatSize(); | 106 return FloatSize(); |
| 106 | 107 |
| 107 if (cachedImage->getImage()->isSVGImage()) | 108 if (cachedImage->getImage()->isSVGImage()) |
| 108 return toSVGImage(cachedImage->getImage()) | 109 return toSVGImage(cachedImage->getImage()) |
| 109 ->concreteObjectSize(m_layoutSVGImage.objectBoundingBox().size()); | 110 ->concreteObjectSize(m_layoutSVGImage.objectBoundingBox().size()); |
| 110 | 111 |
| 111 return FloatSize(cachedImage->getImage()->size()); | 112 return FloatSize(cachedImage->getImage()->size()); |
| 112 } | 113 } |
| 113 | 114 |
| 114 } // namespace blink | 115 } // namespace blink |
| OLD | NEW |