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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 static inline SVGTreeScopeResources& svgTreeScopeResourcesFromElement( | 30 static inline SVGTreeScopeResources& svgTreeScopeResourcesFromElement( |
31 Element* element) { | 31 Element* element) { |
32 DCHECK(element); | 32 DCHECK(element); |
33 return element->treeScope().ensureSVGTreeScopedResources(); | 33 return element->treeScope().ensureSVGTreeScopedResources(); |
34 } | 34 } |
35 | 35 |
36 LayoutSVGResourceContainer::LayoutSVGResourceContainer(SVGElement* node) | 36 LayoutSVGResourceContainer::LayoutSVGResourceContainer(SVGElement* node) |
37 : LayoutSVGHiddenContainer(node), | 37 : LayoutSVGHiddenContainer(node), |
38 m_isInLayout(false), | 38 m_isInLayout(false), |
39 m_id(node->getIdAttribute()), | |
40 m_invalidationMask(0), | 39 m_invalidationMask(0), |
41 m_registered(false), | 40 m_registered(false), |
42 m_isInvalidating(false) {} | 41 m_isInvalidating(false) {} |
43 | 42 |
44 LayoutSVGResourceContainer::~LayoutSVGResourceContainer() {} | 43 LayoutSVGResourceContainer::~LayoutSVGResourceContainer() {} |
45 | 44 |
46 void LayoutSVGResourceContainer::layout() { | 45 void LayoutSVGResourceContainer::layout() { |
47 // FIXME: Investigate a way to detect and break resource layout dependency | 46 // FIXME: Investigate a way to detect and break resource layout dependency |
48 // cycles early. Then we can remove this method altogether, and fall back onto | 47 // cycles early. Then we can remove this method altogether, and fall back onto |
49 // LayoutSVGHiddenContainer::layout(). | 48 // LayoutSVGHiddenContainer::layout(). |
(...skipping 17 matching lines...) Expand all Loading... |
67 proxySet->notifyContentChanged(element()->treeScope()); | 66 proxySet->notifyContentChanged(element()->treeScope()); |
68 } | 67 } |
69 | 68 |
70 void LayoutSVGResourceContainer::willBeDestroyed() { | 69 void LayoutSVGResourceContainer::willBeDestroyed() { |
71 // Detach all clients referring to this resource. If the resource itself is | 70 // Detach all clients referring to this resource. If the resource itself is |
72 // a client, it will be detached from any such resources by the call to | 71 // a client, it will be detached from any such resources by the call to |
73 // LayoutSVGHiddenContainer::willBeDestroyed() below. | 72 // LayoutSVGHiddenContainer::willBeDestroyed() below. |
74 detachAllClients(); | 73 detachAllClients(); |
75 | 74 |
76 LayoutSVGHiddenContainer::willBeDestroyed(); | 75 LayoutSVGHiddenContainer::willBeDestroyed(); |
77 if (m_registered) | 76 if (!m_registered) |
78 svgTreeScopeResourcesFromElement(element()).removeResource(m_id); | 77 return; |
| 78 svgTreeScopeResourcesFromElement(element()).removeResource( |
| 79 element()->getIdAttribute()); |
79 } | 80 } |
80 | 81 |
81 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, | 82 void LayoutSVGResourceContainer::styleDidChange(StyleDifference diff, |
82 const ComputedStyle* oldStyle) { | 83 const ComputedStyle* oldStyle) { |
83 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle); | 84 LayoutSVGHiddenContainer::styleDidChange(diff, oldStyle); |
84 | 85 |
85 if (m_registered) | 86 if (m_registered) |
86 return; | 87 return; |
87 m_registered = true; | 88 m_registered = true; |
88 svgTreeScopeResourcesFromElement(element()).updateResource(m_id, this); | 89 svgTreeScopeResourcesFromElement(element()).updateResource( |
| 90 element()->getIdAttribute(), this); |
89 } | 91 } |
90 | 92 |
91 void LayoutSVGResourceContainer::detachAllClients() { | 93 void LayoutSVGResourceContainer::detachAllClients() { |
| 94 const AtomicString& id = element()->getIdAttribute(); |
92 for (auto* client : m_clients) { | 95 for (auto* client : m_clients) { |
93 // Unlink the resource from the client's SVGResources. (The actual | 96 // Unlink the resource from the client's SVGResources. (The actual |
94 // removal will be signaled after processing all the clients.) | 97 // removal will be signaled after processing all the clients.) |
95 SVGResources* resources = | 98 SVGResources* resources = |
96 SVGResourcesCache::cachedResourcesForLayoutObject(client); | 99 SVGResourcesCache::cachedResourcesForLayoutObject(client); |
97 // Or else the client wouldn't be in the list in the first place. | 100 // Or else the client wouldn't be in the list in the first place. |
98 DCHECK(resources); | 101 DCHECK(resources); |
99 resources->resourceDestroyed(this); | 102 resources->resourceDestroyed(this); |
100 | 103 |
101 // 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. |
102 Element* clientElement = toElement(client->node()); | 105 Element* clientElement = toElement(client->node()); |
103 svgTreeScopeResourcesFromElement(clientElement) | 106 svgTreeScopeResourcesFromElement(clientElement) |
104 .addPendingResource(m_id, *clientElement); | 107 .addPendingResource(id, *clientElement); |
105 } | 108 } |
106 | 109 |
107 removeAllClientsFromCache(); | 110 removeAllClientsFromCache(); |
108 } | 111 } |
109 | 112 |
110 void LayoutSVGResourceContainer::idChanged() { | 113 void LayoutSVGResourceContainer::idChanged(const AtomicString& oldId, |
| 114 const AtomicString& newId) { |
111 // Invalidate all our current clients. | 115 // Invalidate all our current clients. |
112 removeAllClientsFromCache(); | 116 removeAllClientsFromCache(); |
113 | 117 |
114 // Remove old id, that is guaranteed to be present in cache. | 118 // Remove old id, that is guaranteed to be present in cache. |
115 SVGTreeScopeResources& treeScopeResources = | 119 SVGTreeScopeResources& treeScopeResources = |
116 svgTreeScopeResourcesFromElement(element()); | 120 svgTreeScopeResourcesFromElement(element()); |
117 treeScopeResources.removeResource(m_id); | 121 treeScopeResources.removeResource(oldId); |
118 m_id = element()->getIdAttribute(); | 122 treeScopeResources.updateResource(newId, this); |
119 treeScopeResources.updateResource(m_id, this); | |
120 } | 123 } |
121 | 124 |
122 void LayoutSVGResourceContainer::markAllClientsForInvalidation( | 125 void LayoutSVGResourceContainer::markAllClientsForInvalidation( |
123 InvalidationMode mode) { | 126 InvalidationMode mode) { |
124 if (m_isInvalidating) | 127 if (m_isInvalidating) |
125 return; | 128 return; |
126 SVGElementProxySet* proxySet = elementProxySet(); | 129 SVGElementProxySet* proxySet = elementProxySet(); |
127 if (m_clients.isEmpty() && (!proxySet || proxySet->isEmpty())) | 130 if (m_clients.isEmpty() && (!proxySet || proxySet->isEmpty())) |
128 return; | 131 return; |
129 if (m_invalidationMask & mode) | 132 if (m_invalidationMask & mode) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // This will process the rest of the ancestors. | 271 // This will process the rest of the ancestors. |
269 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); | 272 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); |
270 break; | 273 break; |
271 } | 274 } |
272 | 275 |
273 current = current->parent(); | 276 current = current->parent(); |
274 } | 277 } |
275 } | 278 } |
276 | 279 |
277 } // namespace blink | 280 } // namespace blink |
OLD | NEW |