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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/SVGResourcesCycleSolver.cpp

Issue 2657443005: Migrate WTF::HashSet::add() to ::insert() [part 1 of N] (Closed)
Patch Set: Created 3 years, 10 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
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 28 matching lines...) Expand all
39 ASSERT(m_resources); 39 ASSERT(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.add(m_resource); 49 m_activeSet.insert(m_resource);
50 } 50 }
51 ~ActiveFrame() { m_activeSet.remove(m_resource); } 51 ~ActiveFrame() { m_activeSet.remove(m_resource); }
52 52
53 ResourceSet& m_activeSet; 53 ResourceSet& m_activeSet;
54 LayoutSVGResourceContainer* m_resource; 54 LayoutSVGResourceContainer* m_resource;
55 }; 55 };
56 56
57 bool SVGResourcesCycleSolver::resourceContainsCycles( 57 bool SVGResourcesCycleSolver::resourceContainsCycles(
58 LayoutSVGResourceContainer* resource) { 58 LayoutSVGResourceContainer* resource) {
59 // If we've traversed this sub-graph before and no cycles were observed, then 59 // If we've traversed this sub-graph before and no cycles were observed, then
(...skipping 20 matching lines...) Expand all
80 // Iterate resources referenced by |node|. 80 // Iterate resources referenced by |node|.
81 for (auto* node : nodeSet) { 81 for (auto* node : nodeSet) {
82 if (m_activeResources.contains(node) || resourceContainsCycles(node)) 82 if (m_activeResources.contains(node) || resourceContainsCycles(node))
83 return true; 83 return true;
84 } 84 }
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.add(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 ASSERT(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.add(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))
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 ASSERT(resourceLeadingToCycle == m_resources->clipper()); 156 ASSERT(resourceLeadingToCycle == m_resources->clipper());
157 m_resources->resetClipper(); 157 m_resources->resetClipper();
158 break; 158 break;
159 default: 159 default:
160 ASSERT_NOT_REACHED(); 160 ASSERT_NOT_REACHED();
161 break; 161 break;
162 } 162 }
163 } 163 }
164 164
165 } // namespace blink 165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698