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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGImage.cpp

Issue 2592613002: LayoutSVGImage should work correctly even when image size is unavailable (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/loader/resource/ImageResourceContent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> 2 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org>
3 * Copyright (C) 2006 Apple Computer, Inc. 3 * Copyright (C) 2006 Apple Computer, Inc.
4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
5 * Copyright (C) 2007, 2008, 2009 Rob Buis <buis@kde.org> 5 * Copyright (C) 2007, 2008, 2009 Rob Buis <buis@kde.org>
6 * Copyright (C) 2009 Google, Inc. 6 * Copyright (C) 2009 Google, Inc.
7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
8 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> 8 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return height * intrinsicRatio.width() / intrinsicRatio.height(); 62 return height * intrinsicRatio.width() / intrinsicRatio.height();
63 } 63 }
64 64
65 static float resolveHeightForRatio(float width, 65 static float resolveHeightForRatio(float width,
66 const FloatSize& intrinsicRatio) { 66 const FloatSize& intrinsicRatio) {
67 return width * intrinsicRatio.height() / intrinsicRatio.width(); 67 return width * intrinsicRatio.height() / intrinsicRatio.width();
68 } 68 }
69 69
70 FloatSize LayoutSVGImage::calculateObjectSize() const { 70 FloatSize LayoutSVGImage::calculateObjectSize() const {
71 ImageResourceContent* cachedImage = m_imageResource->cachedImage(); 71 ImageResourceContent* cachedImage = m_imageResource->cachedImage();
72 if (!cachedImage || cachedImage->errorOccurred()) 72 if (!cachedImage || cachedImage->errorOccurred() ||
73 !cachedImage->isSizeAvailable())
fs 2016/12/20 10:08:12 Would this not affect other similar code-paths sim
yhirano 2016/12/20 12:06:30 I'm not sure (I'm not familiar with the layout / i
fs 2016/12/20 12:15:45 My observation was mostly that other code seems to
hiroshige 2016/12/21 17:51:06 If we can replace isSizeAvailable() here and in Im
73 return m_objectBoundingBox.size(); 74 return m_objectBoundingBox.size();
74 75
75 FloatSize intrinsicSize = FloatSize(cachedImage->getImage()->size()); 76 FloatSize intrinsicSize = FloatSize(cachedImage->getImage()->size());
76 if (styleRef().width().isAuto() && styleRef().height().isAuto()) 77 if (styleRef().width().isAuto() && styleRef().height().isAuto())
77 return intrinsicSize; 78 return intrinsicSize;
78 79
79 if (styleRef().height().isAuto()) 80 if (styleRef().height().isAuto())
80 return FloatSize( 81 return FloatSize(
81 m_objectBoundingBox.width(), 82 m_objectBoundingBox.width(),
82 resolveHeightForRatio(m_objectBoundingBox.width(), intrinsicSize)); 83 resolveHeightForRatio(m_objectBoundingBox.width(), intrinsicSize));
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 203
203 void LayoutSVGImage::addOutlineRects(Vector<LayoutRect>& rects, 204 void LayoutSVGImage::addOutlineRects(Vector<LayoutRect>& rects,
204 const LayoutPoint&, 205 const LayoutPoint&,
205 IncludeBlockVisualOverflowOrNot) const { 206 IncludeBlockVisualOverflowOrNot) const {
206 // this is called from paint() after the localTransform has already been 207 // this is called from paint() after the localTransform has already been
207 // applied 208 // applied
208 rects.append(LayoutRect(visualRectInLocalSVGCoordinates())); 209 rects.append(LayoutRect(visualRectInLocalSVGCoordinates()));
209 } 210 }
210 211
211 } // namespace blink 212 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/loader/resource/ImageResourceContent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698