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 20 matching lines...) Expand all Loading... |
31 #include "core/svg/SVGViewSpec.h" | 31 #include "core/svg/SVGViewSpec.h" |
32 #include "core/svg/SVGZoomAndPan.h" | 32 #include "core/svg/SVGZoomAndPan.h" |
33 #include "core/svg/animation/SMILTimeContainer.h" | 33 #include "core/svg/animation/SMILTimeContainer.h" |
34 #include "wtf/TemporaryChange.h" | 34 #include "wtf/TemporaryChange.h" |
35 #include "wtf/text/AtomicString.h" | 35 #include "wtf/text/AtomicString.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 SVGDocumentExtensions::SVGDocumentExtensions(Document* document) | 39 SVGDocumentExtensions::SVGDocumentExtensions(Document* document) |
40 : m_document(document) | 40 : m_document(document) |
| 41 , m_elementDependencies(adoptPtrWillBeNoop(new ElementDependenciesMap)) |
41 , m_resourcesCache(adoptPtr(new SVGResourcesCache)) | 42 , m_resourcesCache(adoptPtr(new SVGResourcesCache)) |
42 #if !ASSERT_DISABLED | 43 #if !ASSERT_DISABLED |
43 , m_inRelativeLengthSVGRootsInvalidation(false) | 44 , m_inRelativeLengthSVGRootsInvalidation(false) |
44 #endif | 45 #endif |
45 { | 46 { |
46 } | 47 } |
47 | 48 |
48 SVGDocumentExtensions::~SVGDocumentExtensions() | 49 SVGDocumentExtensions::~SVGDocumentExtensions() |
49 { | 50 { |
50 } | 51 } |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 Element* element = *firstElement; | 301 Element* element = *firstElement; |
301 | 302 |
302 resourceSet->remove(firstElement); | 303 resourceSet->remove(firstElement); |
303 | 304 |
304 if (resourceSet->isEmpty()) | 305 if (resourceSet->isEmpty()) |
305 removePendingResourceForRemoval(id); | 306 removePendingResourceForRemoval(id); |
306 | 307 |
307 return element; | 308 return element; |
308 } | 309 } |
309 | 310 |
310 HashSet<SVGElement*>* SVGDocumentExtensions::setOfElementsReferencingTarget(SVGE
lement* referencedElement) const | 311 WeakSVGElementSet* SVGDocumentExtensions::setOfElementsReferencingTarget(SVGElem
ent* referencedElement) const |
311 { | 312 { |
312 ASSERT(referencedElement); | 313 ASSERT(referencedElement); |
313 const HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::const_iterator i
t = m_elementDependencies.find(referencedElement); | 314 const ElementDependenciesMap::const_iterator it = m_elementDependencies->fin
d(referencedElement); |
314 if (it == m_elementDependencies.end()) | 315 if (it == m_elementDependencies->end()) |
315 return 0; | 316 return 0; |
316 return it->value.get(); | 317 return it->value.get(); |
317 } | 318 } |
318 | 319 |
319 void SVGDocumentExtensions::addElementReferencingTarget(SVGElement* referencingE
lement, SVGElement* referencedElement) | 320 void SVGDocumentExtensions::addElementReferencingTarget(SVGElement* referencingE
lement, SVGElement* referencedElement) |
320 { | 321 { |
321 ASSERT(referencingElement); | 322 ASSERT(referencingElement); |
322 ASSERT(referencedElement); | 323 ASSERT(referencedElement); |
323 | 324 |
324 if (HashSet<SVGElement*>* elements = m_elementDependencies.get(referencedEle
ment)) { | 325 if (WeakSVGElementSet* elements = m_elementDependencies->get(referencedEleme
nt)) { |
325 elements->add(referencingElement); | 326 elements->add(referencingElement); |
326 return; | 327 return; |
327 } | 328 } |
328 | 329 |
329 OwnPtr<HashSet<SVGElement*> > elements = adoptPtr(new HashSet<SVGElement*>); | 330 OwnPtrWillBeRawPtr<WeakSVGElementSet> elements = adoptPtrWillBeNoop(new Weak
SVGElementSet); |
330 elements->add(referencingElement); | 331 elements->add(referencingElement); |
331 m_elementDependencies.set(referencedElement, elements.release()); | 332 m_elementDependencies->set(referencedElement, elements.release()); |
332 } | 333 } |
333 | 334 |
334 void SVGDocumentExtensions::removeAllTargetReferencesForElement(SVGElement* refe
rencingElement) | 335 void SVGDocumentExtensions::removeAllTargetReferencesForElement(SVGElement* refe
rencingElement) |
335 { | 336 { |
336 Vector<SVGElement*> toBeRemoved; | 337 WillBeHeapVector<RawPtrWillBeMember<SVGElement> > toBeRemoved; |
337 | 338 |
338 HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iterator end = m_eleme
ntDependencies.end(); | 339 ElementDependenciesMap::iterator end = m_elementDependencies->end(); |
339 for (HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iterator it = m_e
lementDependencies.begin(); it != end; ++it) { | 340 for (ElementDependenciesMap::iterator it = m_elementDependencies->begin(); i
t != end; ++it) { |
340 SVGElement* referencedElement = it->key; | 341 SVGElement* referencedElement = it->key; |
341 HashSet<SVGElement*>* referencingElements = it->value.get(); | 342 WeakSVGElementSet* referencingElements = it->value.get(); |
342 HashSet<SVGElement*>::iterator setIt = referencingElements->find(referen
cingElement); | 343 WeakSVGElementSet::iterator setIt = referencingElements->find(referencin
gElement); |
343 if (setIt == referencingElements->end()) | 344 if (setIt == referencingElements->end()) |
344 continue; | 345 continue; |
345 | 346 |
346 referencingElements->remove(setIt); | 347 referencingElements->remove(setIt); |
347 if (referencingElements->isEmpty()) | 348 if (referencingElements->isEmpty()) |
348 toBeRemoved.append(referencedElement); | 349 toBeRemoved.append(referencedElement); |
349 } | 350 } |
350 | 351 |
351 m_elementDependencies.removeAll(toBeRemoved); | 352 m_elementDependencies->removeAll(toBeRemoved); |
352 } | 353 } |
353 | 354 |
354 void SVGDocumentExtensions::rebuildAllElementReferencesForTarget(SVGElement* ref
erencedElement) | 355 void SVGDocumentExtensions::rebuildAllElementReferencesForTarget(SVGElement* ref
erencedElement) |
355 { | 356 { |
356 ASSERT(referencedElement); | 357 ASSERT(referencedElement); |
357 HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iterator it = m_elemen
tDependencies.find(referencedElement); | 358 ElementDependenciesMap::iterator it = m_elementDependencies->find(referenced
Element); |
358 if (it == m_elementDependencies.end()) | 359 if (it == m_elementDependencies->end()) |
359 return; | 360 return; |
360 ASSERT(it->key == referencedElement); | 361 ASSERT(it->key == referencedElement); |
361 Vector<SVGElement*> toBeNotified; | |
362 | 362 |
363 HashSet<SVGElement*>* referencingElements = it->value.get(); | 363 WillBeHeapVector<RawPtrWillBeMember<SVGElement> > toBeNotified; |
364 HashSet<SVGElement*>::iterator setEnd = referencingElements->end(); | 364 WeakSVGElementSet* referencingElements = it->value.get(); |
365 for (HashSet<SVGElement*>::iterator setIt = referencingElements->begin(); se
tIt != setEnd; ++setIt) | 365 copyToVector(*referencingElements, toBeNotified); |
366 toBeNotified.append(*setIt); | |
367 | 366 |
368 // Force rebuilding the referencingElement so it knows about this change. | 367 // Force rebuilding the referencingElement so it knows about this change. |
369 Vector<SVGElement*>::iterator vectorEnd = toBeNotified.end(); | 368 WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::iterator vectorEnd = toBe
Notified.end(); |
370 for (Vector<SVGElement*>::iterator vectorIt = toBeNotified.begin(); vectorIt
!= vectorEnd; ++vectorIt) { | 369 for (WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::iterator vectorIt =
toBeNotified.begin(); vectorIt != vectorEnd; ++vectorIt) { |
371 // Before rebuilding referencingElement ensure it was not removed from u
nder us. | 370 // Before rebuilding referencingElement ensure it was not removed from u
nder us. |
372 if (HashSet<SVGElement*>* referencingElements = setOfElementsReferencing
Target(referencedElement)) { | 371 if (WeakSVGElementSet* referencingElements = setOfElementsReferencingTar
get(referencedElement)) { |
373 if (referencingElements->contains(*vectorIt)) | 372 if (referencingElements->contains(*vectorIt)) |
374 (*vectorIt)->svgAttributeChanged(XLinkNames::hrefAttr); | 373 (*vectorIt)->svgAttributeChanged(XLinkNames::hrefAttr); |
375 } | 374 } |
376 } | 375 } |
377 } | 376 } |
378 | 377 |
379 void SVGDocumentExtensions::removeAllElementReferencesForTarget(SVGElement* refe
rencedElement) | 378 void SVGDocumentExtensions::removeAllElementReferencesForTarget(SVGElement* refe
rencedElement) |
380 { | 379 { |
381 ASSERT(referencedElement); | 380 ASSERT(referencedElement); |
382 HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iterator it = m_elemen
tDependencies.find(referencedElement); | 381 ElementDependenciesMap::iterator it = m_elementDependencies->find(referenced
Element); |
383 if (it == m_elementDependencies.end()) | 382 if (it == m_elementDependencies->end()) |
384 return; | 383 return; |
385 ASSERT(it->key == referencedElement); | 384 ASSERT(it->key == referencedElement); |
386 | 385 |
387 m_elementDependencies.remove(it); | 386 m_elementDependencies->remove(it); |
388 } | 387 } |
389 | 388 |
390 void SVGDocumentExtensions::addSVGRootWithRelativeLengthDescendents(SVGSVGElemen
t* svgRoot) | 389 void SVGDocumentExtensions::addSVGRootWithRelativeLengthDescendents(SVGSVGElemen
t* svgRoot) |
391 { | 390 { |
392 ASSERT(!m_inRelativeLengthSVGRootsInvalidation); | 391 ASSERT(!m_inRelativeLengthSVGRootsInvalidation); |
393 m_relativeLengthSVGRoots.add(svgRoot); | 392 m_relativeLengthSVGRoots.add(svgRoot); |
394 } | 393 } |
395 | 394 |
396 void SVGDocumentExtensions::removeSVGRootWithRelativeLengthDescendents(SVGSVGEle
ment* svgRoot) | 395 void SVGDocumentExtensions::removeSVGRootWithRelativeLengthDescendents(SVGSVGEle
ment* svgRoot) |
397 { | 396 { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 } | 472 } |
474 | 473 |
475 SVGSVGElement* SVGDocumentExtensions::rootElement() const | 474 SVGSVGElement* SVGDocumentExtensions::rootElement() const |
476 { | 475 { |
477 ASSERT(m_document); | 476 ASSERT(m_document); |
478 return rootElement(*m_document); | 477 return rootElement(*m_document); |
479 } | 478 } |
480 | 479 |
481 void SVGDocumentExtensions::trace(Visitor* visitor) | 480 void SVGDocumentExtensions::trace(Visitor* visitor) |
482 { | 481 { |
| 482 visitor->trace(m_document); |
483 visitor->trace(m_timeContainers); | 483 visitor->trace(m_timeContainers); |
484 visitor->trace(m_svgFontFaceElements); | 484 visitor->trace(m_svgFontFaceElements); |
485 visitor->trace(m_pendingSVGFontFaceElementsForRemoval); | 485 visitor->trace(m_pendingSVGFontFaceElementsForRemoval); |
| 486 visitor->trace(m_elementDependencies); |
486 } | 487 } |
487 | 488 |
488 } | 489 } |
OLD | NEW |