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 15 matching lines...) Expand all Loading... |
26 #include "core/rendering/svg/RenderSVGResourceClipper.h" | 26 #include "core/rendering/svg/RenderSVGResourceClipper.h" |
27 #include "core/rendering/svg/RenderSVGResourceFilter.h" | 27 #include "core/rendering/svg/RenderSVGResourceFilter.h" |
28 #include "core/rendering/svg/RenderSVGResourceMarker.h" | 28 #include "core/rendering/svg/RenderSVGResourceMarker.h" |
29 #include "core/rendering/svg/RenderSVGResourceMasker.h" | 29 #include "core/rendering/svg/RenderSVGResourceMasker.h" |
30 #include "core/rendering/svg/RenderSVGResourcePaintServer.h" | 30 #include "core/rendering/svg/RenderSVGResourcePaintServer.h" |
31 #include "core/rendering/svg/SVGResources.h" | 31 #include "core/rendering/svg/SVGResources.h" |
32 #include "core/rendering/svg/SVGResourcesCache.h" | 32 #include "core/rendering/svg/SVGResourcesCache.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 SVGResourcesCycleSolver::SVGResourcesCycleSolver(RenderObject* renderer, SVGReso
urces* resources) | 36 SVGResourcesCycleSolver::SVGResourcesCycleSolver(LayoutObject* renderer, SVGReso
urces* resources) |
37 : m_renderer(renderer) | 37 : m_renderer(renderer) |
38 , m_resources(resources) | 38 , m_resources(resources) |
39 { | 39 { |
40 ASSERT(m_renderer); | 40 ASSERT(m_renderer); |
41 ASSERT(m_resources); | 41 ASSERT(m_resources); |
42 } | 42 } |
43 | 43 |
44 SVGResourcesCycleSolver::~SVGResourcesCycleSolver() | 44 SVGResourcesCycleSolver::~SVGResourcesCycleSolver() |
45 { | 45 { |
46 } | 46 } |
(...skipping 18 matching lines...) Expand all Loading... |
65 | 65 |
66 bool SVGResourcesCycleSolver::resourceContainsCycles(RenderSVGResourceContainer*
resource) | 66 bool SVGResourcesCycleSolver::resourceContainsCycles(RenderSVGResourceContainer*
resource) |
67 { | 67 { |
68 // If we've traversed this sub-graph before and no cycles were observed, the
n | 68 // If we've traversed this sub-graph before and no cycles were observed, the
n |
69 // reuse that result. | 69 // reuse that result. |
70 if (m_dagCache.contains(resource)) | 70 if (m_dagCache.contains(resource)) |
71 return false; | 71 return false; |
72 | 72 |
73 ActiveFrame frame(m_activeResources, resource); | 73 ActiveFrame frame(m_activeResources, resource); |
74 | 74 |
75 RenderObject* node = resource; | 75 LayoutObject* node = resource; |
76 while (node) { | 76 while (node) { |
77 // Skip subtrees which are themselves resources. (They will be | 77 // Skip subtrees which are themselves resources. (They will be |
78 // processed - if needed - when they are actually referenced.) | 78 // processed - if needed - when they are actually referenced.) |
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::cachedResourcesForR
enderObject(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 ResourceSet::iterator end = nodeSet.end(); |
90 for (ResourceSet::iterator it = nodeSet.begin(); it != end; ++it) { | 90 for (ResourceSet::iterator it = nodeSet.begin(); it != end; ++it) { |
91 if (m_activeResources.contains(*it) || resourceContainsCycles(*i
t)) | 91 if (m_activeResources.contains(*it) || resourceContainsCycles(*i
t)) |
92 return true; | 92 return true; |
93 } | 93 } |
94 } | 94 } |
95 node = node->nextInPreOrder(resource); | 95 node = node->nextInPreOrder(resource); |
96 } | 96 } |
97 | 97 |
98 // No cycles found in (or from) this resource. Add it to the "DAG cache". | 98 // No cycles found in (or from) this resource. Add it to the "DAG cache". |
99 m_dagCache.add(resource); | 99 m_dagCache.add(resource); |
100 return false; | 100 return false; |
101 } | 101 } |
102 | 102 |
103 void SVGResourcesCycleSolver::resolveCycles() | 103 void SVGResourcesCycleSolver::resolveCycles() |
104 { | 104 { |
105 ASSERT(m_activeResources.isEmpty()); | 105 ASSERT(m_activeResources.isEmpty()); |
106 | 106 |
107 // If the starting RenderObject is a resource container itself, then add it | 107 // If the starting LayoutObject is a resource container itself, then add it |
108 // to the active set (to break direct self-references.) | 108 // to the active set (to break direct self-references.) |
109 if (m_renderer->isSVGResourceContainer()) | 109 if (m_renderer->isSVGResourceContainer()) |
110 m_activeResources.add(toRenderSVGResourceContainer(m_renderer)); | 110 m_activeResources.add(toRenderSVGResourceContainer(m_renderer)); |
111 | 111 |
112 ResourceSet localResources; | 112 ResourceSet localResources; |
113 m_resources->buildSetOfResources(localResources); | 113 m_resources->buildSetOfResources(localResources); |
114 | 114 |
115 // This performs a depth-first search for a back-edge in all the | 115 // This performs a depth-first search for a back-edge in all the |
116 // (potentially disjoint) graphs formed by the resources referenced by | 116 // (potentially disjoint) graphs formed by the resources referenced by |
117 // |m_renderer|. | 117 // |m_renderer|. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 ASSERT(resourceLeadingToCycle == m_resources->clipper()); | 163 ASSERT(resourceLeadingToCycle == m_resources->clipper()); |
164 m_resources->resetClipper(); | 164 m_resources->resetClipper(); |
165 break; | 165 break; |
166 default: | 166 default: |
167 ASSERT_NOT_REACHED(); | 167 ASSERT_NOT_REACHED(); |
168 break; | 168 break; |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 } | 172 } |
OLD | NEW |