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

Side by Side Diff: Source/WebCore/rendering/RenderImage.cpp

Issue 10383163: Merge 116693 - Crash in computedCSSPadding* functions due to RenderImage::imageDimensionsChanged ca… (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « LayoutTests/fast/images/script-counter-imageDimensionChanged-crash-expected.txt ('k') | no next file » | 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com)
6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
10 * 10 *
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (newSize == intrinsicSize() && !imageSizeChanged) 181 if (newSize == intrinsicSize() && !imageSizeChanged)
182 return false; 182 return false;
183 if (m_imageResource->errorOccurred()) 183 if (m_imageResource->errorOccurred())
184 return imageSizeChanged; 184 return imageSizeChanged;
185 setIntrinsicSize(newSize); 185 setIntrinsicSize(newSize);
186 return true; 186 return true;
187 } 187 }
188 188
189 void RenderImage::imageDimensionsChanged(bool imageSizeChanged, const IntRect* r ect) 189 void RenderImage::imageDimensionsChanged(bool imageSizeChanged, const IntRect* r ect)
190 { 190 {
191 bool intrinsicSizeChanged = updateIntrinsicSizeIfNeeded(m_imageResource->ima geSize(style()->effectiveZoom()), imageSizeChanged);
192
193 // In the case of generated image content using :before/:after/content, we m ight not be
194 // in the render tree yet. In that case, we just need to update our intrinsi c size.
195 // layout() will be called after we are inserted in the tree which will take care of
196 // what we are doing here.
197 if (!containingBlock())
198 return;
199
191 bool shouldRepaint = true; 200 bool shouldRepaint = true;
192 if (updateIntrinsicSizeIfNeeded(m_imageResource->imageSize(style()->effectiv eZoom()), imageSizeChanged)) { 201 if (intrinsicSizeChanged) {
193 // In the case of generated image content using :before/:after, we might not be in the 202 // lets see if we need to relayout at all..
194 // render tree yet. In that case, we don't need to worry about check fo r layout, since we'll get a 203 int oldwidth = width();
195 // layout when we get added in to the render tree hierarchy later. 204 int oldheight = height();
196 if (containingBlock()) { 205 if (!preferredLogicalWidthsDirty())
197 // lets see if we need to relayout at all.. 206 setPreferredLogicalWidthsDirty(true);
198 int oldwidth = width(); 207 computeLogicalWidth();
199 int oldheight = height(); 208 computeLogicalHeight();
200 if (!preferredLogicalWidthsDirty())
201 setPreferredLogicalWidthsDirty(true);
202 computeLogicalWidth();
203 computeLogicalHeight();
204 209
205 if (imageSizeChanged || width() != oldwidth || height() != oldheight ) { 210 if (imageSizeChanged || width() != oldwidth || height() != oldheight) {
206 shouldRepaint = false; 211 shouldRepaint = false;
207 if (!selfNeedsLayout()) 212 if (!selfNeedsLayout())
208 setNeedsLayout(true); 213 setNeedsLayout(true);
209 } 214 }
210 215
211 setWidth(oldwidth); 216 setWidth(oldwidth);
212 setHeight(oldheight); 217 setHeight(oldheight);
213 }
214 } 218 }
215 219
216 if (shouldRepaint) { 220 if (shouldRepaint) {
217 LayoutRect repaintRect; 221 LayoutRect repaintRect;
218 if (rect) { 222 if (rect) {
219 // The image changed rect is in source image coordinates (pre-zoomin g), 223 // The image changed rect is in source image coordinates (pre-zoomin g),
220 // so map from the bounds of the image to the contentsBox. 224 // so map from the bounds of the image to the contentsBox.
221 repaintRect = enclosingIntRect(mapRect(*rect, FloatRect(FloatPoint() , m_imageResource->imageSize(1.0f)), contentBoxRect())); 225 repaintRect = enclosingIntRect(mapRect(*rect, FloatRect(FloatPoint() , m_imageResource->imageSize(1.0f)), contentBoxRect()));
222 // Guard against too-large changed rects. 226 // Guard against too-large changed rects.
223 repaintRect.intersect(contentBoxRect()); 227 repaintRect.intersect(contentBoxRect());
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 #if ENABLE(SVG) 551 #if ENABLE(SVG)
548 CachedImage* cachedImage = m_imageResource->cachedImage(); 552 CachedImage* cachedImage = m_imageResource->cachedImage();
549 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 553 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
550 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox( ); 554 return static_cast<SVGImage*>(cachedImage->image())->embeddedContentBox( );
551 #endif 555 #endif
552 556
553 return 0; 557 return 0;
554 } 558 }
555 559
556 } // namespace WebCore 560 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/images/script-counter-imageDimensionChanged-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698