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 17 matching lines...) Expand all Loading... |
28 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 28 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
29 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" | 29 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" |
30 #include "core/layout/svg/SVGResources.h" | 30 #include "core/layout/svg/SVGResources.h" |
31 #include "core/layout/svg/SVGResourcesCache.h" | 31 #include "core/layout/svg/SVGResourcesCache.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 SVGResourcesCycleSolver::SVGResourcesCycleSolver(LayoutObject* layoutObject, | 35 SVGResourcesCycleSolver::SVGResourcesCycleSolver(LayoutObject* layoutObject, |
36 SVGResources* resources) | 36 SVGResources* resources) |
37 : m_layoutObject(layoutObject), m_resources(resources) { | 37 : m_layoutObject(layoutObject), m_resources(resources) { |
38 ASSERT(m_layoutObject); | 38 DCHECK(m_layoutObject); |
39 ASSERT(m_resources); | 39 DCHECK(m_resources); |
40 } | 40 } |
41 | 41 |
42 SVGResourcesCycleSolver::~SVGResourcesCycleSolver() {} | 42 SVGResourcesCycleSolver::~SVGResourcesCycleSolver() {} |
43 | 43 |
44 struct ActiveFrame { | 44 struct ActiveFrame { |
45 typedef SVGResourcesCycleSolver::ResourceSet ResourceSet; | 45 typedef SVGResourcesCycleSolver::ResourceSet ResourceSet; |
46 | 46 |
47 ActiveFrame(ResourceSet& activeSet, LayoutSVGResourceContainer* resource) | 47 ActiveFrame(ResourceSet& activeSet, LayoutSVGResourceContainer* resource) |
48 : m_activeSet(activeSet), m_resource(resource) { | 48 : m_activeSet(activeSet), m_resource(resource) { |
49 m_activeSet.insert(m_resource); | 49 m_activeSet.insert(m_resource); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 node = node->nextInPreOrder(resource); | 86 node = node->nextInPreOrder(resource); |
87 } | 87 } |
88 | 88 |
89 // No cycles found in (or from) this resource. Add it to the "DAG cache". | 89 // No cycles found in (or from) this resource. Add it to the "DAG cache". |
90 m_dagCache.insert(resource); | 90 m_dagCache.insert(resource); |
91 return false; | 91 return false; |
92 } | 92 } |
93 | 93 |
94 void SVGResourcesCycleSolver::resolveCycles() { | 94 void SVGResourcesCycleSolver::resolveCycles() { |
95 ASSERT(m_activeResources.isEmpty()); | 95 DCHECK(m_activeResources.isEmpty()); |
96 | 96 |
97 // If the starting LayoutObject is a resource container itself, then add it | 97 // If the starting LayoutObject is a resource container itself, then add it |
98 // to the active set (to break direct self-references.) | 98 // to the active set (to break direct self-references.) |
99 if (m_layoutObject->isSVGResourceContainer()) | 99 if (m_layoutObject->isSVGResourceContainer()) |
100 m_activeResources.insert(toLayoutSVGResourceContainer(m_layoutObject)); | 100 m_activeResources.insert(toLayoutSVGResourceContainer(m_layoutObject)); |
101 | 101 |
102 ResourceSet localResources; | 102 ResourceSet localResources; |
103 m_resources->buildSetOfResources(localResources); | 103 m_resources->buildSetOfResources(localResources); |
104 | 104 |
105 // This performs a depth-first search for a back-edge in all the | 105 // This performs a depth-first search for a back-edge in all the |
106 // (potentially disjoint) graphs formed by the resources referenced by | 106 // (potentially disjoint) graphs formed by the resources referenced by |
107 // |m_layoutObject|. | 107 // |m_layoutObject|. |
108 for (auto* localResource : localResources) { | 108 for (auto* localResource : localResources) { |
109 if (m_activeResources.contains(localResource) || | 109 if (m_activeResources.contains(localResource) || |
110 resourceContainsCycles(localResource)) | 110 resourceContainsCycles(localResource)) |
111 breakCycle(localResource); | 111 breakCycle(localResource); |
112 } | 112 } |
113 | 113 |
114 m_activeResources.clear(); | 114 m_activeResources.clear(); |
115 } | 115 } |
116 | 116 |
117 void SVGResourcesCycleSolver::breakCycle( | 117 void SVGResourcesCycleSolver::breakCycle( |
118 LayoutSVGResourceContainer* resourceLeadingToCycle) { | 118 LayoutSVGResourceContainer* resourceLeadingToCycle) { |
119 ASSERT(resourceLeadingToCycle); | 119 DCHECK(resourceLeadingToCycle); |
120 if (resourceLeadingToCycle == m_resources->linkedResource()) { | 120 if (resourceLeadingToCycle == m_resources->linkedResource()) { |
121 m_resources->resetLinkedResource(); | 121 m_resources->resetLinkedResource(); |
122 return; | 122 return; |
123 } | 123 } |
124 | 124 |
125 switch (resourceLeadingToCycle->resourceType()) { | 125 switch (resourceLeadingToCycle->resourceType()) { |
126 case MaskerResourceType: | 126 case MaskerResourceType: |
127 ASSERT(resourceLeadingToCycle == m_resources->masker()); | 127 DCHECK_EQ(resourceLeadingToCycle, m_resources->masker()); |
128 m_resources->resetMasker(); | 128 m_resources->resetMasker(); |
129 break; | 129 break; |
130 case MarkerResourceType: | 130 case MarkerResourceType: |
131 ASSERT(resourceLeadingToCycle == m_resources->markerStart() || | 131 DCHECK(resourceLeadingToCycle == m_resources->markerStart() || |
132 resourceLeadingToCycle == m_resources->markerMid() || | 132 resourceLeadingToCycle == m_resources->markerMid() || |
133 resourceLeadingToCycle == m_resources->markerEnd()); | 133 resourceLeadingToCycle == m_resources->markerEnd()); |
134 if (m_resources->markerStart() == resourceLeadingToCycle) | 134 if (m_resources->markerStart() == resourceLeadingToCycle) |
135 m_resources->resetMarkerStart(); | 135 m_resources->resetMarkerStart(); |
136 if (m_resources->markerMid() == resourceLeadingToCycle) | 136 if (m_resources->markerMid() == resourceLeadingToCycle) |
137 m_resources->resetMarkerMid(); | 137 m_resources->resetMarkerMid(); |
138 if (m_resources->markerEnd() == resourceLeadingToCycle) | 138 if (m_resources->markerEnd() == resourceLeadingToCycle) |
139 m_resources->resetMarkerEnd(); | 139 m_resources->resetMarkerEnd(); |
140 break; | 140 break; |
141 case PatternResourceType: | 141 case PatternResourceType: |
142 case LinearGradientResourceType: | 142 case LinearGradientResourceType: |
143 case RadialGradientResourceType: | 143 case RadialGradientResourceType: |
144 ASSERT(resourceLeadingToCycle == m_resources->fill() || | 144 DCHECK(resourceLeadingToCycle == m_resources->fill() || |
145 resourceLeadingToCycle == m_resources->stroke()); | 145 resourceLeadingToCycle == m_resources->stroke()); |
146 if (m_resources->fill() == resourceLeadingToCycle) | 146 if (m_resources->fill() == resourceLeadingToCycle) |
147 m_resources->resetFill(); | 147 m_resources->resetFill(); |
148 if (m_resources->stroke() == resourceLeadingToCycle) | 148 if (m_resources->stroke() == resourceLeadingToCycle) |
149 m_resources->resetStroke(); | 149 m_resources->resetStroke(); |
150 break; | 150 break; |
151 case FilterResourceType: | 151 case FilterResourceType: |
152 ASSERT(resourceLeadingToCycle == m_resources->filter()); | 152 DCHECK_EQ(resourceLeadingToCycle, m_resources->filter()); |
153 m_resources->resetFilter(); | 153 m_resources->resetFilter(); |
154 break; | 154 break; |
155 case ClipperResourceType: | 155 case ClipperResourceType: |
156 ASSERT(resourceLeadingToCycle == m_resources->clipper()); | 156 DCHECK_EQ(resourceLeadingToCycle, m_resources->clipper()); |
157 m_resources->resetClipper(); | 157 m_resources->resetClipper(); |
158 break; | 158 break; |
159 default: | 159 default: |
160 NOTREACHED(); | 160 NOTREACHED(); |
161 break; | 161 break; |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 } // namespace blink | 165 } // namespace blink |
OLD | NEW |