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/paint/PaintLayer.h" | 28 #include "core/paint/PaintLayer.h" |
29 | 29 #include "core/svg/SVGDocumentExtensions.h" |
| 30 #include "core/svg/SVGTreeScopeResources.h" |
30 #include "wtf/TemporaryChange.h" | 31 #include "wtf/TemporaryChange.h" |
31 | 32 |
32 namespace blink { | 33 namespace blink { |
33 | 34 |
34 static inline SVGDocumentExtensions& svgExtensionsFromElement(Element* element) | 35 static inline SVGTreeScopeResources& svgTreeScopeResourcesFromElement(Element* e
lement) |
35 { | 36 { |
36 ASSERT(element); | 37 ASSERT(element); |
37 return element->document().accessSVGExtensions(); | 38 return element->treeScope().accessSVGTreeScopedResources(); |
38 } | 39 } |
39 | |
40 LayoutSVGResourceContainer::LayoutSVGResourceContainer(SVGElement* node) | 40 LayoutSVGResourceContainer::LayoutSVGResourceContainer(SVGElement* node) |
41 : LayoutSVGHiddenContainer(node) | 41 : LayoutSVGHiddenContainer(node) |
42 , m_isInLayout(false) | 42 , m_isInLayout(false) |
43 , m_id(node->getIdAttribute()) | 43 , m_id(node->getIdAttribute()) |
44 , m_invalidationMask(0) | 44 , m_invalidationMask(0) |
45 , m_registered(false) | 45 , m_registered(false) |
46 , m_isInvalidating(false) | 46 , m_isInvalidating(false) |
47 { | 47 { |
48 } | 48 } |
49 | 49 |
(...skipping 22 matching lines...) Expand all Loading... |
72 // a client, it will be detached from any such resources by the call to | 72 // a client, it will be detached from any such resources by the call to |
73 // LayoutSVGHiddenContainer::willBeDestroyed() below. | 73 // LayoutSVGHiddenContainer::willBeDestroyed() below. |
74 detachAllClients(); | 74 detachAllClients(); |
75 | 75 |
76 for (SVGResourceClient* client : m_resourceClients) | 76 for (SVGResourceClient* client : m_resourceClients) |
77 client->filterWillBeDestroyed(toSVGFilterElement(element())); | 77 client->filterWillBeDestroyed(toSVGFilterElement(element())); |
78 m_resourceClients.clear(); | 78 m_resourceClients.clear(); |
79 | 79 |
80 LayoutSVGHiddenContainer::willBeDestroyed(); | 80 LayoutSVGHiddenContainer::willBeDestroyed(); |
81 if (m_registered) | 81 if (m_registered) |
82 svgExtensionsFromElement(element()).removeResource(m_id); | 82 svgTreeScopeResourcesFromElement(element()).removeResource(m_id); |
83 } | 83 } |
84 | 84 |
85 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, const Comp
utedStyle* oldStyle) | 85 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, const Comp
utedStyle* oldStyle) |
86 { | 86 { |
87 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle); | 87 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle); |
88 | 88 |
89 if (!m_registered) { | 89 if (!m_registered) { |
90 m_registered = true; | 90 m_registered = true; |
91 registerResource(); | 91 registerResource(); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 void LayoutSVGResourceContainer::detachAllClients() | 95 void LayoutSVGResourceContainer::detachAllClients() |
96 { | 96 { |
97 for (auto* client : m_clients) { | 97 for (auto* client : m_clients) { |
98 // Unlink the resource from the client's SVGResources. (The actual | 98 // Unlink the resource from the client's SVGResources. (The actual |
99 // removal will be signaled after processing all the clients.) | 99 // removal will be signaled after processing all the clients.) |
100 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(client); | 100 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(client); |
101 ASSERT(resources); // Or else the client wouldn't be in the list in the
first place. | 101 ASSERT(resources); // Or else the client wouldn't be in the list in the
first place. |
102 resources->resourceDestroyed(this); | 102 resources->resourceDestroyed(this); |
103 | 103 |
104 // Add a pending resolution based on the id of the old resource. | 104 // Add a pending resolution based on the id of the old resource. |
105 Element* clientElement = toElement(client->node()); | 105 Element* clientElement = toElement(client->node()); |
106 svgExtensionsFromElement(clientElement).addPendingResource(m_id, clientE
lement); | 106 svgTreeScopeResourcesFromElement(clientElement).addPendingResource(m_id,
clientElement); |
107 } | 107 } |
108 | 108 |
109 removeAllClientsFromCache(); | 109 removeAllClientsFromCache(); |
110 } | 110 } |
111 | 111 |
112 void LayoutSVGResourceContainer::idChanged() | 112 void LayoutSVGResourceContainer::idChanged() |
113 { | 113 { |
114 // Invalidate all our current clients. | 114 // Invalidate all our current clients. |
115 removeAllClientsFromCache(); | 115 removeAllClientsFromCache(); |
116 | 116 |
117 // Remove old id, that is guaranteed to be present in cache. | 117 // Remove old id, that is guaranteed to be present in cache. |
118 SVGDocumentExtensions& extensions = svgExtensionsFromElement(element()); | 118 SVGTreeScopeResources& treeScopeResources = svgTreeScopeResourcesFromElement
(element()); |
119 extensions.removeResource(m_id); | 119 treeScopeResources.removeResource(m_id); |
120 m_id = element()->getIdAttribute(); | 120 m_id = element()->getIdAttribute(); |
121 | 121 |
122 registerResource(); | 122 registerResource(); |
123 } | 123 } |
124 | 124 |
125 void LayoutSVGResourceContainer::markAllClientsForInvalidation(InvalidationMode
mode) | 125 void LayoutSVGResourceContainer::markAllClientsForInvalidation(InvalidationMode
mode) |
126 { | 126 { |
127 if ((m_clients.isEmpty() && m_resourceClients.isEmpty()) || m_isInvalidating
) | 127 if ((m_clients.isEmpty() && m_resourceClients.isEmpty()) || m_isInvalidating
) |
128 return; | 128 return; |
129 | 129 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 return; | 214 return; |
215 | 215 |
216 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::SvgResource
Invalidated, MarkContainerChain, layoutScope); | 216 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::SvgResource
Invalidated, MarkContainerChain, layoutScope); |
217 | 217 |
218 if (everHadLayout()) | 218 if (everHadLayout()) |
219 removeAllClientsFromCache(); | 219 removeAllClientsFromCache(); |
220 } | 220 } |
221 | 221 |
222 void LayoutSVGResourceContainer::registerResource() | 222 void LayoutSVGResourceContainer::registerResource() |
223 { | 223 { |
224 SVGDocumentExtensions& extensions = svgExtensionsFromElement(element()); | 224 SVGTreeScopeResources& treeScopeResources = svgTreeScopeResourcesFromElement
(element()); |
225 if (!extensions.hasPendingResource(m_id)) { | 225 |
226 extensions.addResource(m_id, this); | 226 if (!treeScopeResources.hasPendingResource(m_id)) { |
| 227 treeScopeResources.addResource(m_id, this); |
227 return; | 228 return; |
228 } | 229 } |
229 | 230 SVGTreeScopeResources::SVGPendingElements* clients(treeScopeResources.remove
PendingResource(m_id)); |
230 SVGDocumentExtensions::SVGPendingElements* clients(extensions.removePendingR
esource(m_id)); | |
231 | 231 |
232 // Cache us with the new id. | 232 // Cache us with the new id. |
233 extensions.addResource(m_id, this); | 233 treeScopeResources.addResource(m_id, this); |
234 | 234 |
235 // Update cached resources of pending clients. | 235 // Update cached resources of pending clients. |
236 for (const auto& pendingClient : *clients) { | 236 for (const auto& pendingClient : *clients) { |
237 ASSERT(pendingClient->hasPendingResources()); | 237 ASSERT(pendingClient->hasPendingResources()); |
238 extensions.clearHasPendingResourcesIfPossible(pendingClient); | 238 treeScopeResources.clearHasPendingResourcesIfPossible(pendingClient); |
239 LayoutObject* layoutObject = pendingClient->layoutObject(); | 239 LayoutObject* layoutObject = pendingClient->layoutObject(); |
240 if (!layoutObject) | 240 if (!layoutObject) |
241 continue; | 241 continue; |
242 | 242 |
243 const ComputedStyle& style = layoutObject->styleRef(); | 243 const ComputedStyle& style = layoutObject->styleRef(); |
244 | 244 |
245 // If the client has a layer (is a non-SVGElement) we need to signal | 245 // If the client has a layer (is a non-SVGElement) we need to signal |
246 // invalidation in the same way as is done in markAllResourceClientsForI
nvalidation above. | 246 // invalidation in the same way as is done in markAllResourceClientsForI
nvalidation above. |
247 if (layoutObject->hasLayer() && resourceType() == FilterResourceType) { | 247 if (layoutObject->hasLayer() && resourceType() == FilterResourceType) { |
248 if (!style.hasFilter()) | 248 if (!style.hasFilter()) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // This will process the rest of the ancestors. | 320 // This will process the rest of the ancestors. |
321 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); | 321 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); |
322 break; | 322 break; |
323 } | 323 } |
324 | 324 |
325 current = current->parent(); | 325 current = current->parent(); |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 } // namespace blink | 329 } // namespace blink |
OLD | NEW |