Commit 8146a1e9 authored by sullivan's avatar sullivan

Reviewed by Darin Adler.

        
        - fixed <rdar://problem/4566087> REGRESSION (420+): Crash occurs while completing a find again query at 
        http://www.apple.com/ (RenderObject::repaint(bool))
        
        This wasn't a new problem in the code, but the recent use of DocumentMarkers for find results brought
        it to the surface.

        * dom/Document.h:
        Use a RefPtr<Node> instead of a Node* in MarkerMap, so the node will be retained

        * dom/Document.cpp:
        (WebCore::Document::removeMarkers):
        Add a .get() to compensate for using RefPtr. Also, only repaint if this node actually had a marker
        removed.
        (WebCore::Document::repaintMarkers):
        Add a .get() to compensate for using RefPtr.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14748 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dc0160b8
2006-06-06 John Sullivan <sullivan@apple.com>
Reviewed by Darin Adler.
- fixed <rdar://problem/4566087> REGRESSION (420+): Crash occurs while completing a find again query at
http://www.apple.com/ (RenderObject::repaint(bool))
This wasn't a new problem in the code, but the recent use of DocumentMarkers for find results brought
it to the surface.
* dom/Document.h:
Use a RefPtr<Node> instead of a Node* in MarkerMap, so the node will be retained
* dom/Document.cpp:
(WebCore::Document::removeMarkers):
Add a .get() to compensate for using RefPtr. Also, only repaint if this node actually had a marker
removed.
(WebCore::Document::repaintMarkers):
Add a .get() to compensate for using RefPtr.
2006-06-06 Anders Carlsson <acarlsson@apple.com>
Reviewed by Darin.
......
......@@ -2827,7 +2827,8 @@ void Document::removeMarkers(DocumentMarker::MarkerType markerType)
MarkerMap markerMapCopy = m_markers;
MarkerMap::iterator end = markerMapCopy.end();
for (MarkerMap::iterator i = markerMapCopy.begin(); i != end; ++i) {
Node* node = i->first;
Node* node = i->first.get();
bool nodeNeedsRepaint = false;
// inner loop: process each marker in the current node
Vector<DocumentMarker> *markers = i->second;
......@@ -2843,16 +2844,21 @@ void Document::removeMarkers(DocumentMarker::MarkerType markerType)
// pitch the old marker
markers->remove(markerIterator - markers->begin());
nodeNeedsRepaint = true;
// markerIterator now points to the next node
}
// Redraw the node if it changed. Do this before the node is removed from m_markers, since
// m_markers might contain the last reference to the node.
if (nodeNeedsRepaint) {
RenderObject* renderer = node->renderer();
if (renderer)
renderer->repaint();
}
// delete the node's list if it is now empty
if (markers->isEmpty())
m_markers.remove(node);
// cause the node to be redrawn
if (RenderObject* renderer = node->renderer())
renderer->repaint();
}
}
......@@ -2861,7 +2867,7 @@ void Document::repaintMarkers(DocumentMarker::MarkerType markerType)
// outer loop: process each markered node in the document
MarkerMap::iterator end = m_markers.end();
for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) {
Node* node = i->first;
Node* node = i->first.get();
// inner loop: process each marker in the current node
Vector<DocumentMarker> *markers = i->second;
......
......@@ -657,7 +657,7 @@ protected:
RenderArena* m_renderArena;
typedef HashMap<Node*, Vector<DocumentMarker>*> MarkerMap;
typedef HashMap<RefPtr<Node>, Vector<DocumentMarker>*> MarkerMap;
MarkerMap m_markers;
mutable AccessibilityObjectCache* m_accCache;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment