Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/Source/core/paint/SVGImagePainter.cpp

Issue 1720853002: Remove Image::computeIntrinsicDimensions() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-and-use-updateconcretesize-upload
Patch Set: Avoid using the size of the error image. Null-check in ImageResource saved the day in previous patc… Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Avoid returning the size of the broken image.
90 return intrinsicRatio; 91 if (cachedImage->errorOccurred())
92 return FloatSize();
93
94 if (cachedImage->image()->isSVGImage())
95 return toSVGImage(cachedImage->image())->concreteObjectSize(m_layoutSVGI mage.objectBoundingBox().size());
96
97 return FloatSize(cachedImage->image()->size());
91 } 98 }
92 99
93 } // namespace blink 100 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698