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

Unified Diff: Source/core/rendering/svg/SVGRenderSupport.cpp

Issue 458833002: [SVG] Skip layout viewport change calculation when not needed. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test + minor cleanup. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/svg/SVGRenderSupport.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/svg/SVGRenderSupport.cpp
diff --git a/Source/core/rendering/svg/SVGRenderSupport.cpp b/Source/core/rendering/svg/SVGRenderSupport.cpp
index 1046290315be148223c9f7b54edc54e2ebcd0943..69a869ad84b631e253ecd2cd988f7fd0faf8d7dd 100644
--- a/Source/core/rendering/svg/SVGRenderSupport.cpp
+++ b/Source/core/rendering/svg/SVGRenderSupport.cpp
@@ -157,16 +157,6 @@ const RenderSVGRoot* SVGRenderSupport::findTreeRootObject(const RenderObject* st
return toRenderSVGRoot(start);
}
-inline void SVGRenderSupport::invalidateResourcesOfChildren(RenderObject* start)
-{
- ASSERT(!start->needsLayout());
- if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(start))
- resources->removeClientFromCache(start, false);
-
- for (RenderObject* child = start->slowFirstChild(); child; child = child->nextSibling())
- invalidateResourcesOfChildren(child);
-}
-
inline bool SVGRenderSupport::layoutSizeOfNearestViewportChanged(const RenderObject* start)
{
while (start && !start->isSVGRoot() && !start->isSVGViewportContainer())
@@ -195,24 +185,27 @@ bool SVGRenderSupport::transformToRootChanged(RenderObject* ancestor)
void SVGRenderSupport::layoutChildren(RenderObject* start, bool selfNeedsLayout)
{
- bool layoutSizeChanged = layoutSizeOfNearestViewportChanged(start);
+ // When hasRelativeLengths() is false, no descendants have relative lengths
+ // (hence no one is interested in viewport size changes).
+ bool layoutSizeChanged = toSVGElement(start->node())->hasRelativeLengths()
+ && layoutSizeOfNearestViewportChanged(start);
bool transformChanged = transformToRootChanged(start);
- HashSet<RenderObject*> notlayoutedObjects;
for (RenderObject* child = start->slowFirstChild(); child; child = child->nextSibling()) {
- bool needsLayout = selfNeedsLayout;
+ bool forceLayout = selfNeedsLayout;
if (transformChanged) {
// If the transform changed we need to update the text metrics (note: this also happens for layoutSizeChanged=true).
if (child->isSVGText())
toRenderSVGText(child)->setNeedsTextMetricsUpdate();
- needsLayout = true;
+ forceLayout = true;
}
if (layoutSizeChanged) {
// When selfNeedsLayout is false and the layout size changed, we have to check whether this child uses relative lengths
if (SVGElement* element = child->node()->isSVGElement() ? toSVGElement(child->node()) : 0) {
if (element->hasRelativeLengths()) {
+ // FIXME: this should be done on invalidation, not during layout.
// When the layout size changed and when using relative values tell the RenderSVGShape to update its shape object
if (child->isSVGShape()) {
toRenderSVGShape(child)->setNeedsShapeUpdate();
@@ -221,7 +214,7 @@ void SVGRenderSupport::layoutChildren(RenderObject* start, bool selfNeedsLayout)
toRenderSVGText(child)->setNeedsPositioningValuesUpdate();
}
- needsLayout = true;
+ forceLayout = true;
}
}
}
@@ -231,27 +224,13 @@ void SVGRenderSupport::layoutChildren(RenderObject* start, bool selfNeedsLayout)
// Since they only care about viewport size changes (to resolve their relative lengths), we trigger
// their invalidation directly from SVGSVGElement::svgAttributeChange() or at a higher
// SubtreeLayoutScope (in RenderView::layout()).
- if (needsLayout && !child->isSVGResourceContainer())
+ if (forceLayout && !child->isSVGResourceContainer())
layoutScope.setNeedsLayout(child);
+ // Lay out any referenced resources before the child.
layoutResourcesIfNeeded(child);
-
- if (child->needsLayout()) {
- child->layout();
- } else if (layoutSizeChanged) {
- notlayoutedObjects.add(child);
- }
+ child->layoutIfNeeded();
}
-
- if (!layoutSizeChanged) {
- ASSERT(notlayoutedObjects.isEmpty());
- return;
- }
-
- // If the layout size changed, invalidate all resources of all children that didn't go through the layout() code path.
- HashSet<RenderObject*>::iterator end = notlayoutedObjects.end();
- for (HashSet<RenderObject*>::iterator it = notlayoutedObjects.begin(); it != end; ++it)
- invalidateResourcesOfChildren(*it);
}
void SVGRenderSupport::layoutResourcesIfNeeded(const RenderObject* object)
« no previous file with comments | « Source/core/rendering/svg/SVGRenderSupport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698