void SVGDocumentExtensions::removeAllElementReferencesForTarget(SVGElement* referencedElement) { ASSERT(referencedElement); HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iterator it = m_elementDependencies.find(referencedElement); if (it == m_elementDependencies.end()) return; ASSERT(it->key == referencedElement); Vector<SVGElement*> toBeNotified; HashSet<SVGElement*>* referencingElements = it->value.get(); HashSet<SVGElement*>::iterator setEnd = referencingElements->end(); for (HashSet<SVGElement*>::iterator setIt = referencingElements->begin(); setIt != setEnd; ++setIt) toBeNotified.append(*setIt); // Force rebuilding the referencingElement so it knows about this change. Vector<SVGElement*>::iterator vectorEnd = toBeNotified.end(); for (Vector<SVGElement*>::iterator vectorIt = toBeNotified.begin(); vectorIt != vectorEnd; ++vectorIt) { // Before rebuilding referencingElement ensure it was not removed from under us. if (HashSet<SVGElement*>* referencingElements = setOfElementsReferencingTarget(referencedElement)) { if (referencingElements->contains(*vectorIt)) (*vectorIt)->svgAttributeChanged(XLinkNames::hrefAttr); } } m_elementDependencies.remove(referencedElement); }
void SVGDocumentExtensions::rebuildAllElementReferencesForTarget(SVGElement* referencedElement) { ASSERT(referencedElement); ElementDependenciesMap::iterator it = m_elementDependencies.find(referencedElement); if (it == m_elementDependencies.end()) return; ASSERT(it->key == referencedElement); WillBeHeapVector<RawPtrWillBeMember<SVGElement> > toBeNotified; SVGElementSet* referencingElements = it->value.get(); copyToVector(*referencingElements, toBeNotified); // Force rebuilding the referencingElement so it knows about this change. WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::iterator vectorEnd = toBeNotified.end(); for (WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::iterator vectorIt = toBeNotified.begin(); vectorIt != vectorEnd; ++vectorIt) { // Before rebuilding referencingElement ensure it was not removed from under us. if (SVGElementSet* referencingElements = setOfElementsReferencingTarget(referencedElement)) { if (referencingElements->contains(*vectorIt)) (*vectorIt)->svgAttributeChanged(XLinkNames::hrefAttr); } } }