From 0b82618f71d5f27aa6e390c214d327ba8b1f955f Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Fri, 16 Dec 2005 04:58:33 +0000 Subject: [PATCH] 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 git-svn-id: svn://10.0.0.236/trunk@186150 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsFrame.cpp | 12 ++++++++++-- mozilla/layout/generic/nsSelection.cpp | 6 ++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 003bc8b467e..3f1d1c6d65e 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -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 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, diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index a42dddcef48..7bd64dceb14 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -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;