SVGElement::~SVGElement() { if (!hasSVGRareData()) ASSERT(!SVGElementRareData::rareDataMap().contains(this)); else { SVGElementRareData::SVGElementRareDataMap& rareDataMap = SVGElementRareData::rareDataMap(); SVGElementRareData::SVGElementRareDataMap::iterator it = rareDataMap.find(this); ASSERT(it != rareDataMap.end()); SVGElementRareData* rareData = it->value; rareData->destroyAnimatedSMILStyleProperties(); if (SVGCursorElement* cursorElement = rareData->cursorElement()) cursorElement->removeClient(this); if (CSSCursorImageValue* cursorImageValue = rareData->cursorImageValue()) cursorImageValue->removeReferencedElement(this); delete rareData; // The rare data cleanup may have caused other SVG nodes to be deleted, // modifying the rare data map. Do not rely on the existing iterator. ASSERT(rareDataMap.contains(this)); rareDataMap.remove(this); // Clear HasSVGRareData flag now so that we are in a consistent state when // calling rebuildAllElementReferencesForTarget() and // removeAllElementReferencesForTarget() below. clearHasSVGRareData(); } document().accessSVGExtensions()->rebuildAllElementReferencesForTarget(this); document().accessSVGExtensions()->removeAllElementReferencesForTarget(this); ASSERT(inDocument() || !hasRelativeLengths()); }
SVGElement::~SVGElement() { if (!hasSVGRareData()) ASSERT(!SVGElementRareData::rareDataMap().contains(this)); else { ASSERT(document()); SVGElementRareData::SVGElementRareDataMap& rareDataMap = SVGElementRareData::rareDataMap(); SVGElementRareData::SVGElementRareDataMap::iterator it = rareDataMap.find(this); ASSERT(it != rareDataMap.end()); SVGElementRareData* rareData = it->value; rareData->destroyAnimatedSMILStyleProperties(); if (SVGCursorElement* cursorElement = rareData->cursorElement()) cursorElement->removeClient(this); if (CSSCursorImageValue* cursorImageValue = rareData->cursorImageValue()) cursorImageValue->removeReferencedElement(this); delete rareData; // The rare data cleanup may have caused other SVG nodes to be deleted, // modifying the rare data map, so we must re-get the iterator here. it = rareDataMap.find(this); ASSERT(it != rareDataMap.end()); rareDataMap.remove(it); } ASSERT(document()); document()->accessSVGExtensions()->rebuildAllElementReferencesForTarget(this); document()->accessSVGExtensions()->removeAllElementReferencesForTarget(this); }
void SVGElement::setCursorElement(SVGCursorElement* cursorElement) { SVGElementRareData* rareData = ensureSVGRareData(); if (SVGCursorElement* oldCursorElement = rareData->cursorElement()) { if (cursorElement == oldCursorElement) return; oldCursorElement->removeReferencedElement(this); } rareData->setCursorElement(cursorElement); }