OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/svg/SVGTreeScopeResources.h" | 5 #include "core/svg/SVGTreeScopeResources.h" |
6 | 6 |
7 #include "core/dom/Element.h" | 7 #include "core/dom/Element.h" |
8 #include "core/dom/TreeScope.h" | 8 #include "core/dom/TreeScope.h" |
9 #include "core/layout/svg/LayoutSVGResourceContainer.h" | 9 #include "core/layout/svg/LayoutSVGResourceContainer.h" |
10 #include "core/layout/svg/SVGResourcesCache.h" | 10 #include "core/layout/svg/SVGResourcesCache.h" |
| 11 #include "core/svg/SVGUseElement.h" |
11 #include "wtf/text/AtomicString.h" | 12 #include "wtf/text/AtomicString.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 SVGTreeScopeResources::SVGTreeScopeResources(TreeScope* treeScope) { | 16 SVGTreeScopeResources::SVGTreeScopeResources(TreeScope* treeScope) { |
16 // Whenever an object of SVGTreeScopeResources is created, to keep the code | 17 // Whenever an object of SVGTreeScopeResources is created, to keep the code |
17 // behave as before, | 18 // behave as before, |
18 // the document should also have an instance of SVGDocumentExtensions created. | 19 // the document should also have an instance of SVGDocumentExtensions created. |
19 // Thus below line is added. | 20 // Thus below line is added. |
20 treeScope->document().accessSVGExtensions(); | 21 treeScope->document().accessSVGExtensions(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 removePendingResource(id); | 146 removePendingResource(id); |
146 } | 147 } |
147 } | 148 } |
148 | 149 |
149 SVGTreeScopeResources::SVGPendingElements* | 150 SVGTreeScopeResources::SVGPendingElements* |
150 SVGTreeScopeResources::removePendingResource(const AtomicString& id) { | 151 SVGTreeScopeResources::removePendingResource(const AtomicString& id) { |
151 DCHECK(m_pendingResources.contains(id)); | 152 DCHECK(m_pendingResources.contains(id)); |
152 return m_pendingResources.take(id); | 153 return m_pendingResources.take(id); |
153 } | 154 } |
154 | 155 |
| 156 void SVGTreeScopeResources::notifyResourceAvailable(const AtomicString& id) { |
| 157 if (id.isEmpty()) |
| 158 return; |
| 159 // Get pending elements for this id. |
| 160 SVGPendingElements* pendingElements = m_pendingResources.take(id); |
| 161 if (!pendingElements) |
| 162 return; |
| 163 // Rebuild pending resources for each client of a pending resource that is |
| 164 // being removed. |
| 165 for (Element* clientElement : *pendingElements) { |
| 166 DCHECK(clientElement->hasPendingResources()); |
| 167 if (!clientElement->hasPendingResources()) |
| 168 continue; |
| 169 // TODO(fs): Ideally we'd always resolve pending resources async instead of |
| 170 // inside insertedInto and svgAttributeChanged. For now we only do it for |
| 171 // <use> since that would stamp out DOM. |
| 172 if (isSVGUseElement(clientElement)) |
| 173 toSVGUseElement(clientElement)->invalidateShadowTree(); |
| 174 else |
| 175 clientElement->buildPendingResource(); |
| 176 |
| 177 clearHasPendingResourcesIfPossible(clientElement); |
| 178 } |
| 179 } |
| 180 |
155 DEFINE_TRACE(SVGTreeScopeResources) { | 181 DEFINE_TRACE(SVGTreeScopeResources) { |
156 visitor->trace(m_pendingResources); | 182 visitor->trace(m_pendingResources); |
157 } | 183 } |
158 } | 184 } |
OLD | NEW |