void RenderCounter::destroyCounterNodes(RenderObject* owner) { CounterMaps& maps = counterMaps(); CounterMaps::iterator mapsIterator = maps.find(owner); if (mapsIterator == maps.end()) return; CounterMap* map = mapsIterator->value.get(); CounterMap::const_iterator end = map->end(); for (CounterMap::const_iterator it = map->begin(); it != end; ++it) { destroyCounterNodeWithoutMapRemoval(it->key, it->value.get()); } maps.remove(mapsIterator); owner->setHasCounterNodeMap(false); }
void RenderCounter::destroyCounterNodes(RenderObject* owner) { CounterMaps& maps = counterMaps(); CounterMaps::iterator mapsIterator = maps.find(owner); if (mapsIterator == maps.end()) return; CounterMap* map = mapsIterator->second; CounterMap::const_iterator end = map->end(); for (CounterMap::const_iterator it = map->begin(); it != end; ++it) { AtomicString identifier(it->first.get()); destroyCounterNodeWithoutMapRemoval(identifier, it->second.get()); } maps.remove(mapsIterator); delete map; owner->setHasCounterNodeMap(false); }
void RenderCounter::destroyCounterNode(RenderObject* owner, const AtomicString& identifier) { CounterMap* map = counterMaps().get(owner); if (!map) return; CounterMap::iterator mapIterator = map->find(identifier); if (mapIterator == map->end()) return; destroyCounterNodeWithoutMapRemoval(identifier, mapIterator->value.get()); map->remove(mapIterator); // We do not delete "map" here even if empty because we expect to reuse // it soon. In order for a renderer to lose all its counters permanently, // a style change for the renderer involving removal of all counter // directives must occur, in which case, RenderCounter::destroyCounterNodes() // must be called. // The destruction of the Renderer (possibly caused by the removal of its // associated DOM node) is the other case that leads to the permanent // destruction of all counters attached to a Renderer. In this case // RenderCounter::destroyCounterNodes() must be and is now called, too. // RenderCounter::destroyCounterNodes() handles destruction of the counter // map associated with a renderer, so there is no risk in leaking the map. }