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/layout/svg/SVGLayoutSupport.h" | 10 #include "core/layout/svg/SVGLayoutSupport.h" |
11 #include "core/paint/LayoutObjectDrawingRecorder.h" | 11 #include "core/paint/LayoutObjectDrawingRecorder.h" |
12 #include "core/paint/ObjectPainter.h" | 12 #include "core/paint/ObjectPainter.h" |
13 #include "core/paint/PaintInfo.h" | 13 #include "core/paint/PaintInfo.h" |
14 #include "core/paint/SVGPaintContext.h" | 14 #include "core/paint/SVGPaintContext.h" |
15 #include "core/paint/TransformRecorder.h" | 15 #include "core/paint/TransformRecorder.h" |
16 #include "core/svg/SVGImageElement.h" | 16 #include "core/svg/SVGImageElement.h" |
17 #include "core/svg/graphics/SVGImage.h" | |
17 #include "platform/graphics/GraphicsContext.h" | 18 #include "platform/graphics/GraphicsContext.h" |
18 #include "third_party/skia/include/core/SkPicture.h" | 19 #include "third_party/skia/include/core/SkPicture.h" |
19 | 20 |
20 namespace blink { | 21 namespace blink { |
21 | 22 |
22 void SVGImagePainter::paint(const PaintInfo& paintInfo) | 23 void SVGImagePainter::paint(const PaintInfo& paintInfo) |
23 { | 24 { |
24 if (paintInfo.phase != PaintPhaseForeground | 25 if (paintInfo.phase != PaintPhaseForeground |
25 || m_layoutSVGImage.style()->visibility() == HIDDEN | 26 || m_layoutSVGImage.style()->visibility() == HIDDEN |
26 || !m_layoutSVGImage.imageResource()->hasImage()) | 27 || !m_layoutSVGImage.imageResource()->hasImage()) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 | 74 |
74 FloatSize SVGImagePainter::computeImageViewportSize() const | 75 FloatSize SVGImagePainter::computeImageViewportSize() const |
75 { | 76 { |
76 ASSERT(m_layoutSVGImage.imageResource()->hasImage()); | 77 ASSERT(m_layoutSVGImage.imageResource()->hasImage()); |
77 | 78 |
78 if (toSVGImageElement(m_layoutSVGImage.element())->preserveAspectRatio()->cu rrentValue()->align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) | 79 if (toSVGImageElement(m_layoutSVGImage.element())->preserveAspectRatio()->cu rrentValue()->align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) |
79 return m_layoutSVGImage.objectBoundingBox().size(); | 80 return m_layoutSVGImage.objectBoundingBox().size(); |
80 | 81 |
81 ImageResource* cachedImage = m_layoutSVGImage.imageResource()->cachedImage() ; | 82 ImageResource* cachedImage = m_layoutSVGImage.imageResource()->cachedImage() ; |
82 | 83 |
83 // Images with preserveAspectRatio=none should force non-uniform | 84 // Images with preserveAspectRatio=none should force non-uniform scaling. Th is can be achieved |
84 // scaling. This can be achieved by setting the image's container size to | 85 // by setting the image's container size to its viewport size (i.e. concrete object size |
85 // its viewport size (i.e. if a viewBox is available - use that - else use i ntrinsic size.) | 86 // returned by the default sizing algorithm.) See |
86 // See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The 'preserveAspectRa tio' attribute. | 87 // https://www.w3.org/TR/SVG/single-page.html#coords-PreserveAspectRatioAttr ibute and |
87 FloatSize intrinsicSize; | 88 // https://drafts.csswg.org/css-images-3/#default-sizing. |
88 FloatSize intrinsicRatio; | 89 |
89 cachedImage->computeIntrinsicDimensions(intrinsicSize, intrinsicRatio); | 90 if (cachedImage->image()->isSVGImage()) |
90 return intrinsicRatio; | 91 return toSVGImage(cachedImage->image())->concreteObjectSize(m_layoutSVGI mage.objectBoundingBox().size()); |
92 | |
93 return FloatSize(cachedImage->imageSize(DoNotRespectImageOrientation, 1)); | |
fs
2016/03/04 15:10:10
Any reason in particular to use imageSize() here a
davve
2016/03/04 15:22:41
None other than vague plans to look over (and poss
fs
2016/03/04 15:29:05
Yeah, I don't really mind if you want to play it o
| |
91 } | 94 } |
92 | 95 |
93 } // namespace blink | 96 } // namespace blink |
OLD | NEW |