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

Side by Side Diff: Source/core/rendering/svg/SVGResourcesCycleSolver.cpp

Issue 27648002: Refine toRenderSVGResourceContainer() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 2 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 | « Source/core/rendering/svg/SVGRenderTreeAsText.cpp ('k') | Source/core/svg/SVGElement.cpp » ('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) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Stash all resources into a HashSet for the ease of traversing. 105 // Stash all resources into a HashSet for the ease of traversing.
106 HashSet<RenderSVGResourceContainer*> localResources; 106 HashSet<RenderSVGResourceContainer*> localResources;
107 m_resources->buildSetOfResources(localResources); 107 m_resources->buildSetOfResources(localResources);
108 ASSERT(!localResources.isEmpty()); 108 ASSERT(!localResources.isEmpty());
109 109
110 // Add all parent resource containers to the HashSet. 110 // Add all parent resource containers to the HashSet.
111 HashSet<RenderSVGResourceContainer*> parentResources; 111 HashSet<RenderSVGResourceContainer*> parentResources;
112 RenderObject* parent = m_renderer->parent(); 112 RenderObject* parent = m_renderer->parent();
113 while (parent) { 113 while (parent) {
114 if (parent->isSVGResourceContainer()) 114 if (parent->isSVGResourceContainer())
115 parentResources.add(parent->toRenderSVGResourceContainer()); 115 parentResources.add(toRenderSVGResourceContainer(parent));
116 parent = parent->parent(); 116 parent = parent->parent();
117 } 117 }
118 118
119 #if DEBUG_CYCLE_DETECTION > 0 119 #if DEBUG_CYCLE_DETECTION > 0
120 fprintf(stderr, "\nDetecting wheter any resources references any of followin g objects:\n"); 120 fprintf(stderr, "\nDetecting wheter any resources references any of followin g objects:\n");
121 { 121 {
122 fprintf(stderr, "Local resources:\n"); 122 fprintf(stderr, "Local resources:\n");
123 HashSet<RenderSVGResourceContainer*>::iterator end = localResources.end( ); 123 HashSet<RenderSVGResourceContainer*>::iterator end = localResources.end( );
124 for (HashSet<RenderSVGResourceContainer*>::iterator it = localResources. begin(); it != end; ++it) 124 for (HashSet<RenderSVGResourceContainer*>::iterator it = localResources. begin(); it != end; ++it)
125 fprintf(stderr, "|> %s: object=%p (node=%p)\n", (*it)->renderName(), *it, (*it)->node()); 125 fprintf(stderr, "|> %s: object=%p (node=%p)\n", (*it)->renderName(), *it, (*it)->node());
126 126
127 fprintf(stderr, "Parent resources:\n"); 127 fprintf(stderr, "Parent resources:\n");
128 end = parentResources.end(); 128 end = parentResources.end();
129 for (HashSet<RenderSVGResourceContainer*>::iterator it = parentResources .begin(); it != end; ++it) 129 for (HashSet<RenderSVGResourceContainer*>::iterator it = parentResources .begin(); it != end; ++it)
130 fprintf(stderr, "|> %s: object=%p (node=%p)\n", (*it)->renderName(), *it, (*it)->node()); 130 fprintf(stderr, "|> %s: object=%p (node=%p)\n", (*it)->renderName(), *it, (*it)->node());
131 } 131 }
132 #endif 132 #endif
133 133
134 // Build combined set of local and parent resources. 134 // Build combined set of local and parent resources.
135 m_allResources = localResources; 135 m_allResources = localResources;
136 HashSet<RenderSVGResourceContainer*>::iterator end = parentResources.end(); 136 HashSet<RenderSVGResourceContainer*>::iterator end = parentResources.end();
137 for (HashSet<RenderSVGResourceContainer*>::iterator it = parentResources.beg in(); it != end; ++it) 137 for (HashSet<RenderSVGResourceContainer*>::iterator it = parentResources.beg in(); it != end; ++it)
138 m_allResources.add(*it); 138 m_allResources.add(*it);
139 139
140 // If we're a resource, add ourselves to the HashSet. 140 // If we're a resource, add ourselves to the HashSet.
141 if (m_renderer->isSVGResourceContainer()) 141 if (m_renderer->isSVGResourceContainer())
142 m_allResources.add(m_renderer->toRenderSVGResourceContainer()); 142 m_allResources.add(toRenderSVGResourceContainer(m_renderer));
143 143
144 ASSERT(!m_allResources.isEmpty()); 144 ASSERT(!m_allResources.isEmpty());
145 145
146 // The job of this function is to determine wheter any of the 'resources' as sociated with the given 'renderer' 146 // The job of this function is to determine wheter any of the 'resources' as sociated with the given 'renderer'
147 // references us (or wheter any of its kids references us) -> that's a cycle , we need to find and break it. 147 // references us (or wheter any of its kids references us) -> that's a cycle , we need to find and break it.
148 end = localResources.end(); 148 end = localResources.end();
149 for (HashSet<RenderSVGResourceContainer*>::iterator it = localResources.begi n(); it != end; ++it) { 149 for (HashSet<RenderSVGResourceContainer*>::iterator it = localResources.begi n(); it != end; ++it) {
150 RenderSVGResourceContainer* resource = *it; 150 RenderSVGResourceContainer* resource = *it;
151 if (parentResources.contains(resource) || resourceContainsCycles(resourc e)) 151 if (parentResources.contains(resource) || resourceContainsCycles(resourc e))
152 breakCycle(resource); 152 breakCycle(resource);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 ASSERT(resourceLeadingToCycle == m_resources->clipper()); 199 ASSERT(resourceLeadingToCycle == m_resources->clipper());
200 m_resources->resetClipper(); 200 m_resources->resetClipper();
201 break; 201 break;
202 case SolidColorResourceType: 202 case SolidColorResourceType:
203 ASSERT_NOT_REACHED(); 203 ASSERT_NOT_REACHED();
204 break; 204 break;
205 } 205 }
206 } 206 }
207 207
208 } 208 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/SVGRenderTreeAsText.cpp ('k') | Source/core/svg/SVGElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698