OLD | NEW |
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (node != resource && node->isSVGResourceContainer()) { | 79 if (node != resource && node->isSVGResourceContainer()) { |
80 node = node->nextInPreOrderAfterChildren(resource); | 80 node = node->nextInPreOrderAfterChildren(resource); |
81 continue; | 81 continue; |
82 } | 82 } |
83 if (SVGResources* nodeResources = SVGResourcesCache::cachedResourcesForL
ayoutObject(node)) { | 83 if (SVGResources* nodeResources = SVGResourcesCache::cachedResourcesForL
ayoutObject(node)) { |
84 // Fetch all the resources referenced by |node|. | 84 // Fetch all the resources referenced by |node|. |
85 ResourceSet nodeSet; | 85 ResourceSet nodeSet; |
86 nodeResources->buildSetOfResources(nodeSet); | 86 nodeResources->buildSetOfResources(nodeSet); |
87 | 87 |
88 // Iterate resources referenced by |node|. | 88 // Iterate resources referenced by |node|. |
89 ResourceSet::iterator end = nodeSet.end(); | 89 for (auto* node : nodeSet) { |
90 for (ResourceSet::iterator it = nodeSet.begin(); it != end; ++it) { | 90 if (m_activeResources.contains(node) || resourceContainsCycles(n
ode)) |
91 if (m_activeResources.contains(*it) || resourceContainsCycles(*i
t)) | |
92 return true; | 91 return true; |
93 } | 92 } |
94 } | 93 } |
95 node = node->nextInPreOrder(resource); | 94 node = node->nextInPreOrder(resource); |
96 } | 95 } |
97 | 96 |
98 // No cycles found in (or from) this resource. Add it to the "DAG cache". | 97 // No cycles found in (or from) this resource. Add it to the "DAG cache". |
99 m_dagCache.add(resource); | 98 m_dagCache.add(resource); |
100 return false; | 99 return false; |
101 } | 100 } |
102 | 101 |
103 void SVGResourcesCycleSolver::resolveCycles() | 102 void SVGResourcesCycleSolver::resolveCycles() |
104 { | 103 { |
105 ASSERT(m_activeResources.isEmpty()); | 104 ASSERT(m_activeResources.isEmpty()); |
106 | 105 |
107 // If the starting LayoutObject is a resource container itself, then add it | 106 // If the starting LayoutObject is a resource container itself, then add it |
108 // to the active set (to break direct self-references.) | 107 // to the active set (to break direct self-references.) |
109 if (m_layoutObject->isSVGResourceContainer()) | 108 if (m_layoutObject->isSVGResourceContainer()) |
110 m_activeResources.add(toLayoutSVGResourceContainer(m_layoutObject)); | 109 m_activeResources.add(toLayoutSVGResourceContainer(m_layoutObject)); |
111 | 110 |
112 ResourceSet localResources; | 111 ResourceSet localResources; |
113 m_resources->buildSetOfResources(localResources); | 112 m_resources->buildSetOfResources(localResources); |
114 | 113 |
115 // This performs a depth-first search for a back-edge in all the | 114 // This performs a depth-first search for a back-edge in all the |
116 // (potentially disjoint) graphs formed by the resources referenced by | 115 // (potentially disjoint) graphs formed by the resources referenced by |
117 // |m_layoutObject|. | 116 // |m_layoutObject|. |
118 ResourceSet::iterator end = localResources.end(); | 117 for (auto* localResource : localResources) { |
119 for (ResourceSet::iterator it = localResources.begin(); it != end; ++it) { | 118 if (m_activeResources.contains(localResource) || resourceContainsCycles(
localResource)) |
120 if (m_activeResources.contains(*it) || resourceContainsCycles(*it)) | 119 breakCycle(localResource); |
121 breakCycle(*it); | |
122 } | 120 } |
123 | 121 |
124 m_activeResources.clear(); | 122 m_activeResources.clear(); |
125 } | 123 } |
126 | 124 |
127 void SVGResourcesCycleSolver::breakCycle(LayoutSVGResourceContainer* resourceLea
dingToCycle) | 125 void SVGResourcesCycleSolver::breakCycle(LayoutSVGResourceContainer* resourceLea
dingToCycle) |
128 { | 126 { |
129 ASSERT(resourceLeadingToCycle); | 127 ASSERT(resourceLeadingToCycle); |
130 if (resourceLeadingToCycle == m_resources->linkedResource()) { | 128 if (resourceLeadingToCycle == m_resources->linkedResource()) { |
131 m_resources->resetLinkedResource(); | 129 m_resources->resetLinkedResource(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 ASSERT(resourceLeadingToCycle == m_resources->clipper()); | 161 ASSERT(resourceLeadingToCycle == m_resources->clipper()); |
164 m_resources->resetClipper(); | 162 m_resources->resetClipper(); |
165 break; | 163 break; |
166 default: | 164 default: |
167 ASSERT_NOT_REACHED(); | 165 ASSERT_NOT_REACHED(); |
168 break; | 166 break; |
169 } | 167 } |
170 } | 168 } |
171 | 169 |
172 } | 170 } |
OLD | NEW |