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