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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "core/layout/svg/LayoutSVGResourceContainer.h" | 20 #include "core/layout/svg/LayoutSVGResourceContainer.h" |
21 | 21 |
22 #include "core/SVGElementTypeHelpers.h" | 22 #include "core/SVGElementTypeHelpers.h" |
23 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 23 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
24 #include "core/layout/svg/LayoutSVGResourceFilter.h" | 24 #include "core/layout/svg/LayoutSVGResourceFilter.h" |
25 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 25 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
26 #include "core/layout/svg/SVGResources.h" | 26 #include "core/layout/svg/SVGResources.h" |
27 #include "core/layout/svg/SVGResourcesCache.h" | 27 #include "core/layout/svg/SVGResourcesCache.h" |
28 #include "core/svg/SVGElementProxy.h" | 28 #include "core/svg/SVGElementProxy.h" |
| 29 #include "core/svg/SVGTreeScopeResources.h" |
29 #include "wtf/AutoReset.h" | 30 #include "wtf/AutoReset.h" |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 static inline SVGDocumentExtensions& svgExtensionsFromElement( | 34 static inline SVGTreeScopeResources& svgTreeScopeResourcesFromElement( |
34 Element* element) { | 35 Element* element) { |
35 ASSERT(element); | 36 DCHECK(element); |
36 return element->document().accessSVGExtensions(); | 37 return element->treeScope().accessSVGTreeScopedResources(); |
37 } | 38 } |
38 | 39 |
39 LayoutSVGResourceContainer::LayoutSVGResourceContainer(SVGElement* node) | 40 LayoutSVGResourceContainer::LayoutSVGResourceContainer(SVGElement* node) |
40 : LayoutSVGHiddenContainer(node), | 41 : LayoutSVGHiddenContainer(node), |
41 m_isInLayout(false), | 42 m_isInLayout(false), |
42 m_id(node->getIdAttribute()), | 43 m_id(node->getIdAttribute()), |
43 m_invalidationMask(0), | 44 m_invalidationMask(0), |
44 m_registered(false), | 45 m_registered(false), |
45 m_isInvalidating(false) {} | 46 m_isInvalidating(false) {} |
46 | 47 |
(...skipping 24 matching lines...) Expand all Loading... |
71 } | 72 } |
72 | 73 |
73 void LayoutSVGResourceContainer::willBeDestroyed() { | 74 void LayoutSVGResourceContainer::willBeDestroyed() { |
74 // Detach all clients referring to this resource. If the resource itself is | 75 // Detach all clients referring to this resource. If the resource itself is |
75 // a client, it will be detached from any such resources by the call to | 76 // a client, it will be detached from any such resources by the call to |
76 // LayoutSVGHiddenContainer::willBeDestroyed() below. | 77 // LayoutSVGHiddenContainer::willBeDestroyed() below. |
77 detachAllClients(); | 78 detachAllClients(); |
78 | 79 |
79 LayoutSVGHiddenContainer::willBeDestroyed(); | 80 LayoutSVGHiddenContainer::willBeDestroyed(); |
80 if (m_registered) | 81 if (m_registered) |
81 svgExtensionsFromElement(element()).removeResource(m_id); | 82 svgTreeScopeResourcesFromElement(element()).removeResource(m_id); |
82 } | 83 } |
83 | 84 |
84 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, | 85 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, |
85 const ComputedStyle* oldStyle) { | 86 const ComputedStyle* oldStyle) { |
86 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle); | 87 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle); |
87 | 88 |
88 if (!m_registered) { | 89 if (!m_registered) { |
89 m_registered = true; | 90 m_registered = true; |
90 registerResource(); | 91 registerResource(); |
91 } | 92 } |
92 } | 93 } |
93 | 94 |
94 void LayoutSVGResourceContainer::detachAllClients() { | 95 void LayoutSVGResourceContainer::detachAllClients() { |
95 for (auto* client : m_clients) { | 96 for (auto* client : m_clients) { |
96 // Unlink the resource from the client's SVGResources. (The actual | 97 // Unlink the resource from the client's SVGResources. (The actual |
97 // removal will be signaled after processing all the clients.) | 98 // removal will be signaled after processing all the clients.) |
98 SVGResources* resources = | 99 SVGResources* resources = |
99 SVGResourcesCache::cachedResourcesForLayoutObject(client); | 100 SVGResourcesCache::cachedResourcesForLayoutObject(client); |
100 // Or else the client wouldn't be in the list in the first place. | 101 // Or else the client wouldn't be in the list in the first place. |
101 DCHECK(resources); | 102 DCHECK(resources); |
102 resources->resourceDestroyed(this); | 103 resources->resourceDestroyed(this); |
103 | 104 |
104 // Add a pending resolution based on the id of the old resource. | 105 // Add a pending resolution based on the id of the old resource. |
105 Element* clientElement = toElement(client->node()); | 106 Element* clientElement = toElement(client->node()); |
106 svgExtensionsFromElement(clientElement) | 107 svgTreeScopeResourcesFromElement(clientElement) |
107 .addPendingResource(m_id, clientElement); | 108 .addPendingResource(m_id, clientElement); |
108 } | 109 } |
109 | 110 |
110 removeAllClientsFromCache(); | 111 removeAllClientsFromCache(); |
111 } | 112 } |
112 | 113 |
113 void LayoutSVGResourceContainer::idChanged() { | 114 void LayoutSVGResourceContainer::idChanged() { |
114 // Invalidate all our current clients. | 115 // Invalidate all our current clients. |
115 removeAllClientsFromCache(); | 116 removeAllClientsFromCache(); |
116 | 117 |
117 // Remove old id, that is guaranteed to be present in cache. | 118 // Remove old id, that is guaranteed to be present in cache. |
118 SVGDocumentExtensions& extensions = svgExtensionsFromElement(element()); | 119 SVGTreeScopeResources& treeScopeResources = |
119 extensions.removeResource(m_id); | 120 svgTreeScopeResourcesFromElement(element()); |
| 121 treeScopeResources.removeResource(m_id); |
120 m_id = element()->getIdAttribute(); | 122 m_id = element()->getIdAttribute(); |
121 | 123 |
122 registerResource(); | 124 registerResource(); |
123 } | 125 } |
124 | 126 |
125 void LayoutSVGResourceContainer::markAllClientsForInvalidation( | 127 void LayoutSVGResourceContainer::markAllClientsForInvalidation( |
126 InvalidationMode mode) { | 128 InvalidationMode mode) { |
127 if (m_isInvalidating) | 129 if (m_isInvalidating) |
128 return; | 130 return; |
129 SVGElementProxySet* proxySet = elementProxySet(); | 131 SVGElementProxySet* proxySet = elementProxySet(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 207 |
206 setNeedsLayoutAndFullPaintInvalidation( | 208 setNeedsLayoutAndFullPaintInvalidation( |
207 LayoutInvalidationReason::SvgResourceInvalidated, MarkContainerChain, | 209 LayoutInvalidationReason::SvgResourceInvalidated, MarkContainerChain, |
208 layoutScope); | 210 layoutScope); |
209 | 211 |
210 if (everHadLayout()) | 212 if (everHadLayout()) |
211 removeAllClientsFromCache(); | 213 removeAllClientsFromCache(); |
212 } | 214 } |
213 | 215 |
214 void LayoutSVGResourceContainer::registerResource() { | 216 void LayoutSVGResourceContainer::registerResource() { |
215 SVGDocumentExtensions& extensions = svgExtensionsFromElement(element()); | 217 SVGTreeScopeResources& treeScopeResources = |
216 if (!extensions.hasPendingResource(m_id)) { | 218 svgTreeScopeResourcesFromElement(element()); |
217 extensions.addResource(m_id, this); | 219 if (!treeScopeResources.hasPendingResource(m_id)) { |
| 220 treeScopeResources.addResource(m_id, this); |
218 return; | 221 return; |
219 } | 222 } |
220 | 223 |
221 SVGDocumentExtensions::SVGPendingElements* clients( | 224 SVGTreeScopeResources::SVGPendingElements* clients( |
222 extensions.removePendingResource(m_id)); | 225 treeScopeResources.removePendingResource(m_id)); |
223 | 226 |
224 // Cache us with the new id. | 227 // Cache us with the new id. |
225 extensions.addResource(m_id, this); | 228 treeScopeResources.addResource(m_id, this); |
226 | 229 |
227 // Update cached resources of pending clients. | 230 // Update cached resources of pending clients. |
228 for (const auto& pendingClient : *clients) { | 231 for (const auto& pendingClient : *clients) { |
229 DCHECK(pendingClient->hasPendingResources()); | 232 DCHECK(pendingClient->hasPendingResources()); |
230 extensions.clearHasPendingResourcesIfPossible(pendingClient); | 233 treeScopeResources.clearHasPendingResourcesIfPossible(pendingClient); |
231 LayoutObject* layoutObject = pendingClient->layoutObject(); | 234 LayoutObject* layoutObject = pendingClient->layoutObject(); |
232 if (!layoutObject) | 235 if (!layoutObject) |
233 continue; | 236 continue; |
234 DCHECK(layoutObject->isSVG() && (resourceType() != FilterResourceType || | 237 DCHECK(layoutObject->isSVG() && (resourceType() != FilterResourceType || |
235 !layoutObject->isSVGRoot())); | 238 !layoutObject->isSVGRoot())); |
236 | 239 |
237 StyleDifference diff; | 240 StyleDifference diff; |
238 diff.setNeedsFullLayout(); | 241 diff.setNeedsFullLayout(); |
239 SVGResourcesCache::clientStyleChanged(layoutObject, diff, | 242 SVGResourcesCache::clientStyleChanged(layoutObject, diff, |
240 layoutObject->styleRef()); | 243 layoutObject->styleRef()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // This will process the rest of the ancestors. | 313 // This will process the rest of the ancestors. |
311 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); | 314 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); |
312 break; | 315 break; |
313 } | 316 } |
314 | 317 |
315 current = current->parent(); | 318 current = current->parent(); |
316 } | 319 } |
317 } | 320 } |
318 | 321 |
319 } // namespace blink | 322 } // namespace blink |
OLD | NEW |