Changed TriggerLink() to release its reference to the nsILinkHandler interface,

and I changed HandleEvent() to make nsIURL interface returned by the call to
GetDocumentURL() is released
This commit is contained in:
troy%netscape.com 1999-01-30 00:34:06 +00:00
parent 9e482a5454
commit bb2686580f
2 changed files with 16 additions and 16 deletions

View File

@ -744,6 +744,7 @@ nsImageFrame::TriggerLink(nsIPresContext& aPresContext,
else {
handler->OnOverLink(mContent, aURLSpec, aTargetSpec);
}
NS_RELEASE(handler);
}
}
@ -782,14 +783,6 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
case NS_MOUSE_MOVE:
map = GetImageMap();
if ((nsnull != map) || IsServerImageMap()) {
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
if (nsnull != doc) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
}
// Ask map if the x,y coordinates are in a clickable area
float t2p = aPresContext.GetTwipsToPixels();
nsAutoString absURL, target, altText;
@ -815,6 +808,13 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
PRInt32 x = NSTwipsToIntPixels((aEvent->point.x - inner.x), t2p);
PRInt32 y = NSTwipsToIntPixels((aEvent->point.y - inner.y), t2p);
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
if (nsnull != doc) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
}
PRBool inside = map->IsInside(x, y, docURL, absURL, target, altText,
&suppress);
NS_IF_RELEASE(docURL);

View File

@ -744,6 +744,7 @@ nsImageFrame::TriggerLink(nsIPresContext& aPresContext,
else {
handler->OnOverLink(mContent, aURLSpec, aTargetSpec);
}
NS_RELEASE(handler);
}
}
@ -782,14 +783,6 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
case NS_MOUSE_MOVE:
map = GetImageMap();
if ((nsnull != map) || IsServerImageMap()) {
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
if (nsnull != doc) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
}
// Ask map if the x,y coordinates are in a clickable area
float t2p = aPresContext.GetTwipsToPixels();
nsAutoString absURL, target, altText;
@ -815,6 +808,13 @@ nsImageFrame::HandleEvent(nsIPresContext& aPresContext,
PRInt32 x = NSTwipsToIntPixels((aEvent->point.x - inner.x), t2p);
PRInt32 y = NSTwipsToIntPixels((aEvent->point.y - inner.y), t2p);
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
if (nsnull != doc) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
}
PRBool inside = map->IsInside(x, y, docURL, absURL, target, altText,
&suppress);
NS_IF_RELEASE(docURL);