Don't store or use a widget in the delayed caret data; it's not important, and it might have been destroyed. b=307989 r+sr=roc

This commit is contained in:
dbaron%dbaron.org 2005-12-16 04:58:33 +00:00
parent 18647b7ec2
commit 8c711f30bc
2 changed files with 12 additions and 6 deletions

View File

@ -1697,14 +1697,22 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsPresContext* aPresContext,
if (NS_SUCCEEDED(result) && !mouseDown && me && me->clickCount < 2)
{
// We are doing this to simulate what we would have done on HandlePress
// We are doing this to simulate what we would have done on HandlePress.
// We didn't do it there to give the user an opportunity to drag
// the text, but since they didn't drag, we want to place the
// caret.
// However, we'll use the mouse position from the release, since:
// * it's easier
// * that's the normal click position to use (although really, in
// the normal case, small movements that don't count as a drag
// can do selection)
result = frameselection->SetMouseDownState( PR_TRUE );
nsCOMPtr<nsIContent> content;
PRInt32 startOffset = 0, endOffset = 0;
PRBool beginFrameContent = PR_FALSE;
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(me, this);
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
result = GetContentAndOffsetsFromPoint(aPresContext, pt,
getter_AddRefs(content),
startOffset, endOffset,

View File

@ -4183,10 +4183,8 @@ nsSelection::SetDelayedCaretData(nsMouseEvent *aMouseEvent)
mDelayedMouseEventValid = PR_TRUE;
mDelayedMouseEvent = *aMouseEvent;
// XXX: Hmmm, should we AddRef mDelayedMouseEvent->widget?
// Doing so might introduce a leak if things in the app
// are not released in the correct order though, so for now
// don't do anything.
// Don't cache the widget. We don't need it and it could go away.
mDelayedMouseEvent.widget = nsnull;
}
else
mDelayedMouseEventValid = PR_FALSE;