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

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

Issue 1907333002: Order bounds update correctly for LayoutSVGShape and LayoutSVGImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> 8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com>
9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
10 * Copyright (C) 2011 University of Szeged 10 * Copyright (C) 2011 University of Szeged
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 SVGGraphicsElement* graphicsElement = toSVGGraphicsElement(element()); 149 SVGGraphicsElement* graphicsElement = toSVGGraphicsElement(element());
150 if (graphicsElement->hasAnimatedLocalTransform()) { 150 if (graphicsElement->hasAnimatedLocalTransform()) {
151 m_localTransform.setTransform(graphicsElement->calculateAnimatedLocalTra nsform()); 151 m_localTransform.setTransform(graphicsElement->calculateAnimatedLocalTra nsform());
152 } else { 152 } else {
153 m_localTransform = AffineTransform(); 153 m_localTransform = AffineTransform();
154 } 154 }
155 } 155 }
156 156
157 void LayoutSVGShape::layout() 157 void LayoutSVGShape::layout()
158 { 158 {
159 bool updateCachedBoundariesInParents = false;
160 LayoutAnalyzer::Scope analyzer(*this); 159 LayoutAnalyzer::Scope analyzer(*this);
161 160
161 bool updateParentBoundaries = false;
162 // updateShapeFromElement() also updates the object & stroke bounds - which
163 // feeds into the paint invalidation rect - so we need to call it for both
164 // the shape-update and the bounds-update flag, since .
162 if (m_needsShapeUpdate || m_needsBoundariesUpdate) { 165 if (m_needsShapeUpdate || m_needsBoundariesUpdate) {
163 updateShapeFromElement(); 166 updateShapeFromElement();
164 m_needsShapeUpdate = false; 167 m_needsShapeUpdate = false;
165 updatePaintInvalidationBoundingBox(); 168
166 m_needsBoundariesUpdate = false; 169 m_needsBoundariesUpdate = true;
167 updateCachedBoundariesInParents = true; 170 updateParentBoundaries = true;
168 } 171 }
169 172
170 if (m_needsTransformUpdate) { 173 if (m_needsTransformUpdate) {
171 updateLocalTransform(); 174 updateLocalTransform();
172 m_needsTransformUpdate = false; 175 m_needsTransformUpdate = false;
173 updateCachedBoundariesInParents = true; 176 updateParentBoundaries = true;
174 } 177 }
175 178
176 // Invalidate all resources of this client if our layout changed. 179 // Invalidate all resources of this client if our layout changed.
177 if (everHadLayout() && selfNeedsLayout()) 180 if (everHadLayout() && selfNeedsLayout())
178 SVGResourcesCache::clientLayoutChanged(this); 181 SVGResourcesCache::clientLayoutChanged(this);
179 182
183 if (m_needsBoundariesUpdate) {
184 m_paintInvalidationBoundingBox = strokeBoundingBox();
185 SVGLayoutSupport::intersectPaintInvalidationRectWithResources(this, m_pa intInvalidationBoundingBox);
186 m_needsBoundariesUpdate = false;
187 updateParentBoundaries = true;
188 }
189
180 // If our bounds changed, notify the parents. 190 // If our bounds changed, notify the parents.
181 if (updateCachedBoundariesInParents) 191 if (updateParentBoundaries)
182 LayoutSVGModelObject::setNeedsBoundariesUpdate(); 192 LayoutSVGModelObject::setNeedsBoundariesUpdate();
183 193
184 clearNeedsLayout(); 194 clearNeedsLayout();
185 } 195 }
186 196
187 Path* LayoutSVGShape::nonScalingStrokePath(const Path* path, const AffineTransfo rm& strokeTransform) const 197 Path* LayoutSVGShape::nonScalingStrokePath(const Path* path, const AffineTransfo rm& strokeTransform) const
188 { 198 {
189 LayoutSVGShapeRareData& rareData = ensureRareData(); 199 LayoutSVGShapeRareData& rareData = ensureRareData();
190 if (!rareData.m_cachedNonScalingStrokePath.isEmpty() && strokeTransform == r areData.m_cachedNonScalingStrokeTransform) 200 if (!rareData.m_cachedNonScalingStrokePath.isEmpty() && strokeTransform == r areData.m_cachedNonScalingStrokeTransform)
191 return &rareData.m_cachedNonScalingStrokePath; 201 return &rareData.m_cachedNonScalingStrokePath;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 strokeBoundingBox.unite(strokeBoundingRect); 286 strokeBoundingBox.unite(strokeBoundingRect);
277 } 287 }
278 } else { 288 } else {
279 strokeBoundingBox.unite(path().strokeBoundingRect(strokeData)); 289 strokeBoundingBox.unite(path().strokeBoundingRect(strokeData));
280 } 290 }
281 } 291 }
282 292
283 return strokeBoundingBox; 293 return strokeBoundingBox;
284 } 294 }
285 295
286 void LayoutSVGShape::updatePaintInvalidationBoundingBox()
287 {
288 m_paintInvalidationBoundingBox = strokeBoundingBox();
289 SVGLayoutSupport::intersectPaintInvalidationRectWithResources(this, m_paintI nvalidationBoundingBox);
290 }
291
292 float LayoutSVGShape::strokeWidth() const 296 float LayoutSVGShape::strokeWidth() const
293 { 297 {
294 SVGLengthContext lengthContext(element()); 298 SVGLengthContext lengthContext(element());
295 return lengthContext.valueForLength(style()->svgStyle().strokeWidth()); 299 return lengthContext.valueForLength(style()->svgStyle().strokeWidth());
296 } 300 }
297 301
298 LayoutSVGShapeRareData& LayoutSVGShape::ensureRareData() const 302 LayoutSVGShapeRareData& LayoutSVGShape::ensureRareData() const
299 { 303 {
300 if (!m_rareData) 304 if (!m_rareData)
301 m_rareData = adoptPtr(new LayoutSVGShapeRareData()); 305 m_rareData = adoptPtr(new LayoutSVGShapeRareData());
302 return *m_rareData.get(); 306 return *m_rareData.get();
303 } 307 }
304 308
305 } // namespace blink 309 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698