OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Inc. All rights reserved. |
3 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
4 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 4 * Copyright (C) 2007 Rob Buis <buis@kde.org> |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 if (m_pendingResources.contains(id)) | 221 if (m_pendingResources.contains(id)) |
222 m_pendingResources.get(id)->add(element); | 222 m_pendingResources.get(id)->add(element); |
223 else { | 223 else { |
224 SVGPendingElements* set = new SVGPendingElements; | 224 SVGPendingElements* set = new SVGPendingElements; |
225 set->add(element); | 225 set->add(element); |
226 | 226 |
227 m_pendingResources.add(id, set); | 227 m_pendingResources.add(id, set); |
228 } | 228 } |
229 | 229 |
230 element->setHasPendingResources(true); | 230 element->setHasPendingResources(); |
231 } | 231 } |
232 | 232 |
233 bool SVGDocumentExtensions::hasPendingResources(const AtomicString& id) const | 233 bool SVGDocumentExtensions::hasPendingResources(const AtomicString& id) const |
234 { | 234 { |
235 if (id.isEmpty()) | 235 if (id.isEmpty()) |
236 return false; | 236 return false; |
237 | 237 |
238 return m_pendingResources.contains(id); | 238 return m_pendingResources.contains(id); |
239 } | 239 } |
240 | 240 |
| 241 bool SVGDocumentExtensions::isElementInPendingResources(SVGStyledElement* elemen
t) const |
| 242 { |
| 243 ASSERT(element); |
| 244 |
| 245 if (m_pendingResources.isEmpty()) |
| 246 return false; |
| 247 |
| 248 HashMap<AtomicString, SVGPendingElements*>::const_iterator end = m_pendingRe
sources.end(); |
| 249 for (HashMap<AtomicString, SVGPendingElements*>::const_iterator it = m_pendi
ngResources.begin(); it != end; ++it) { |
| 250 SVGPendingElements* elements = it->second; |
| 251 ASSERT(elements); |
| 252 |
| 253 if (elements->contains(element)) |
| 254 return true; |
| 255 } |
| 256 return false; |
| 257 } |
| 258 |
241 void SVGDocumentExtensions::removeElementFromPendingResources(SVGStyledElement*
element) | 259 void SVGDocumentExtensions::removeElementFromPendingResources(SVGStyledElement*
element) |
242 { | 260 { |
243 ASSERT(element); | 261 ASSERT(element); |
244 | 262 |
245 if (m_pendingResources.isEmpty() || !element->hasPendingResources()) | 263 if (m_pendingResources.isEmpty() || !element->hasPendingResources()) |
246 return; | 264 return; |
247 | 265 |
248 element->setHasPendingResources(false); | |
249 | |
250 Vector<AtomicString> toBeRemoved; | 266 Vector<AtomicString> toBeRemoved; |
251 HashMap<AtomicString, SVGPendingElements*>::iterator end = m_pendingResource
s.end(); | 267 HashMap<AtomicString, SVGPendingElements*>::iterator end = m_pendingResource
s.end(); |
252 for (HashMap<AtomicString, SVGPendingElements*>::iterator it = m_pendingReso
urces.begin(); it != end; ++it) { | 268 for (HashMap<AtomicString, SVGPendingElements*>::iterator it = m_pendingReso
urces.begin(); it != end; ++it) { |
253 SVGPendingElements* elements = it->second; | 269 SVGPendingElements* elements = it->second; |
254 ASSERT(elements); | 270 ASSERT(elements); |
255 ASSERT(!elements->isEmpty()); | 271 ASSERT(!elements->isEmpty()); |
256 | 272 |
257 elements->remove(element); | 273 elements->remove(element); |
258 if (elements->isEmpty()) | 274 if (elements->isEmpty()) |
259 toBeRemoved.append(it->first); | 275 toBeRemoved.append(it->first); |
260 } | 276 } |
261 | 277 |
| 278 element->clearHasPendingResourcesIfPossible(); |
| 279 |
262 if (toBeRemoved.isEmpty()) | 280 if (toBeRemoved.isEmpty()) |
263 return; | 281 return; |
264 | 282 |
265 Vector<AtomicString>::iterator endVector = toBeRemoved.end(); | 283 Vector<AtomicString>::iterator endVector = toBeRemoved.end(); |
266 for (Vector<AtomicString>::iterator it = toBeRemoved.begin(); it != endVecto
r; ++it) | 284 for (Vector<AtomicString>::iterator it = toBeRemoved.begin(); it != endVecto
r; ++it) |
267 m_pendingResources.remove(*it); | 285 m_pendingResources.remove(*it); |
268 } | 286 } |
269 | 287 |
270 PassOwnPtr<SVGDocumentExtensions::SVGPendingElements> SVGDocumentExtensions::rem
ovePendingResource(const AtomicString& id) | 288 PassOwnPtr<SVGDocumentExtensions::SVGPendingElements> SVGDocumentExtensions::rem
ovePendingResource(const AtomicString& id) |
271 { | 289 { |
272 ASSERT(m_pendingResources.contains(id)); | 290 ASSERT(m_pendingResources.contains(id)); |
273 | 291 |
274 OwnPtr<SVGPendingElements> set = adoptPtr(m_pendingResources.get(id)); | 292 OwnPtr<SVGPendingElements> set = adoptPtr(m_pendingResources.get(id)); |
275 m_pendingResources.remove(id); | 293 m_pendingResources.remove(id); |
276 return set.release(); | 294 return set.release(); |
277 } | 295 } |
278 | 296 |
279 } | 297 } |
280 | 298 |
281 #endif | 299 #endif |
OLD | NEW |