diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 3ba1093ae0eb..cea60a18bae9 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -1833,8 +1833,14 @@ nsFrame::HandlePress(nsPresContext* aPresContext, // NS_STYLE_USER_SELECT_TOGGLE, need to change this logic PRBool useFrameSelection = (selectStyle == NS_STYLE_USER_SELECT_TEXT); - if (!IsMouseCaptured(aPresContext)) - CaptureMouse(aPresContext, PR_TRUE); + nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this); + ContentOffsets offsets = GetContentOffsetsFromPoint(pt); + + if (!IsMouseCaptured(aPresContext) && offsets.content) { + nsIFrame* capturingFrame = shell->GetPrimaryFrameFor(offsets.content); + if (capturingFrame) + capturingFrame->CaptureMouse(aPresContext, PR_TRUE); + } // XXX This is screwy; it really should use the selection frame, not the // event frame @@ -1863,9 +1869,6 @@ nsFrame::HandlePress(nsPresContext* aPresContext, return HandleMultiplePress(aPresContext, aEvent, aEventStatus); } - nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this); - ContentOffsets offsets = GetContentOffsetsFromPoint(pt); - if (!offsets.content) return NS_ERROR_FAILURE;