| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 204 } |
| 205 | 205 |
| 206 void SVGDocumentExtensions::clearHasPendingResourcesIfPossible( | 206 void SVGDocumentExtensions::clearHasPendingResourcesIfPossible( |
| 207 Element* element) { | 207 Element* element) { |
| 208 if (!isElementPendingResources(element)) | 208 if (!isElementPendingResources(element)) |
| 209 element->clearHasPendingResources(); | 209 element->clearHasPendingResources(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void SVGDocumentExtensions::removeElementFromPendingResources( | 212 void SVGDocumentExtensions::removeElementFromPendingResources( |
| 213 Element* element) { | 213 Element* element) { |
| 214 ASSERT(element); | 214 DCHECK(element); |
| 215 | 215 |
| 216 // Remove the element from pending resources. | 216 // Remove the element from pending resources. |
| 217 if (!m_pendingResources.isEmpty() && element->hasPendingResources()) { | 217 if (m_pendingResources.isEmpty() || !element->hasPendingResources()) |
| 218 Vector<AtomicString> toBeRemoved; | 218 return; |
| 219 for (const auto& entry : m_pendingResources) { | |
| 220 SVGPendingElements* elements = entry.value.get(); | |
| 221 ASSERT(elements); | |
| 222 ASSERT(!elements->isEmpty()); | |
| 223 | 219 |
| 224 elements->remove(element); | 220 Vector<AtomicString> toBeRemoved; |
| 225 if (elements->isEmpty()) | 221 for (const auto& entry : m_pendingResources) { |
| 226 toBeRemoved.append(entry.key); | 222 SVGPendingElements* elements = entry.value.get(); |
| 227 } | 223 DCHECK(elements); |
| 224 DCHECK(!elements->isEmpty()); |
| 228 | 225 |
| 229 clearHasPendingResourcesIfPossible(element); | 226 elements->remove(element); |
| 230 | 227 if (elements->isEmpty()) |
| 231 // We use the removePendingResource function here because it deals with set | 228 toBeRemoved.append(entry.key); |
| 232 // lifetime correctly. | |
| 233 for (const AtomicString& id : toBeRemoved) | |
| 234 removePendingResource(id); | |
| 235 } | 229 } |
| 236 | 230 |
| 237 // Remove the element from pending resources that were scheduled for removal. | 231 clearHasPendingResourcesIfPossible(element); |
| 238 if (!m_pendingResourcesForRemoval.isEmpty()) { | |
| 239 Vector<AtomicString> toBeRemoved; | |
| 240 for (const auto& entry : m_pendingResourcesForRemoval) { | |
| 241 SVGPendingElements* elements = entry.value.get(); | |
| 242 ASSERT(elements); | |
| 243 ASSERT(!elements->isEmpty()); | |
| 244 | 232 |
| 245 elements->remove(element); | 233 m_pendingResources.removeAll(toBeRemoved); |
| 246 if (elements->isEmpty()) | |
| 247 toBeRemoved.append(entry.key); | |
| 248 } | |
| 249 | |
| 250 // We use the removePendingResourceForRemoval function here because it deals | |
| 251 // with set lifetime correctly. | |
| 252 for (const AtomicString& id : toBeRemoved) | |
| 253 removePendingResourceForRemoval(id); | |
| 254 } | |
| 255 } | 234 } |
| 256 | 235 |
| 257 SVGDocumentExtensions::SVGPendingElements* | 236 SVGDocumentExtensions::SVGPendingElements* |
| 258 SVGDocumentExtensions::removePendingResource(const AtomicString& id) { | 237 SVGDocumentExtensions::removePendingResource(const AtomicString& id) { |
| 259 ASSERT(m_pendingResources.contains(id)); | 238 ASSERT(m_pendingResources.contains(id)); |
| 260 return m_pendingResources.take(id); | 239 return m_pendingResources.take(id); |
| 261 } | 240 } |
| 262 | 241 |
| 263 SVGDocumentExtensions::SVGPendingElements* | |
| 264 SVGDocumentExtensions::removePendingResourceForRemoval(const AtomicString& id) { | |
| 265 ASSERT(m_pendingResourcesForRemoval.contains(id)); | |
| 266 return m_pendingResourcesForRemoval.take(id); | |
| 267 } | |
| 268 | |
| 269 void SVGDocumentExtensions::markPendingResourcesForRemoval( | |
| 270 const AtomicString& id) { | |
| 271 if (id.isEmpty()) | |
| 272 return; | |
| 273 | |
| 274 ASSERT(!m_pendingResourcesForRemoval.contains(id)); | |
| 275 | |
| 276 Member<SVGPendingElements> existing = m_pendingResources.take(id); | |
| 277 if (existing && !existing->isEmpty()) | |
| 278 m_pendingResourcesForRemoval.add(id, existing.release()); | |
| 279 } | |
| 280 | |
| 281 Element* SVGDocumentExtensions::removeElementFromPendingResourcesForRemoval( | |
| 282 const AtomicString& id) { | |
| 283 if (id.isEmpty()) | |
| 284 return nullptr; | |
| 285 | |
| 286 SVGPendingElements* resourceSet = m_pendingResourcesForRemoval.get(id); | |
| 287 if (!resourceSet || resourceSet->isEmpty()) | |
| 288 return nullptr; | |
| 289 | |
| 290 SVGPendingElements::iterator firstElement = resourceSet->begin(); | |
| 291 Element* element = *firstElement; | |
| 292 | |
| 293 resourceSet->remove(firstElement); | |
| 294 | |
| 295 if (resourceSet->isEmpty()) | |
| 296 removePendingResourceForRemoval(id); | |
| 297 | |
| 298 return element; | |
| 299 } | |
| 300 | |
| 301 void SVGDocumentExtensions::addSVGRootWithRelativeLengthDescendents( | 242 void SVGDocumentExtensions::addSVGRootWithRelativeLengthDescendents( |
| 302 SVGSVGElement* svgRoot) { | 243 SVGSVGElement* svgRoot) { |
| 303 ASSERT(!m_inRelativeLengthSVGRootsInvalidation); | 244 ASSERT(!m_inRelativeLengthSVGRootsInvalidation); |
| 304 m_relativeLengthSVGRoots.add(svgRoot); | 245 m_relativeLengthSVGRoots.add(svgRoot); |
| 305 } | 246 } |
| 306 | 247 |
| 307 void SVGDocumentExtensions::removeSVGRootWithRelativeLengthDescendents( | 248 void SVGDocumentExtensions::removeSVGRootWithRelativeLengthDescendents( |
| 308 SVGSVGElement* svgRoot) { | 249 SVGSVGElement* svgRoot) { |
| 309 ASSERT(!m_inRelativeLengthSVGRootsInvalidation); | 250 ASSERT(!m_inRelativeLengthSVGRootsInvalidation); |
| 310 m_relativeLengthSVGRoots.remove(svgRoot); | 251 m_relativeLengthSVGRoots.remove(svgRoot); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 ASSERT(m_document); | 295 ASSERT(m_document); |
| 355 return rootElement(*m_document); | 296 return rootElement(*m_document); |
| 356 } | 297 } |
| 357 | 298 |
| 358 DEFINE_TRACE(SVGDocumentExtensions) { | 299 DEFINE_TRACE(SVGDocumentExtensions) { |
| 359 visitor->trace(m_document); | 300 visitor->trace(m_document); |
| 360 visitor->trace(m_timeContainers); | 301 visitor->trace(m_timeContainers); |
| 361 visitor->trace(m_webAnimationsPendingSVGElements); | 302 visitor->trace(m_webAnimationsPendingSVGElements); |
| 362 visitor->trace(m_relativeLengthSVGRoots); | 303 visitor->trace(m_relativeLengthSVGRoots); |
| 363 visitor->trace(m_pendingResources); | 304 visitor->trace(m_pendingResources); |
| 364 visitor->trace(m_pendingResourcesForRemoval); | |
| 365 } | 305 } |
| 366 | 306 |
| 367 } // namespace blink | 307 } // namespace blink |
| OLD | NEW |