From 42816d03e026ad9675d2789a2fccd5d09d478885 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Mon, 18 Apr 2005 05:18:34 +0000 Subject: [PATCH] Make splitters use the right coord system for events, and fix up the review comment from bug 289792. Fixes bug 290464 and bug 290469 respectively. r+sr=roc, a=brendan git-svn-id: svn://10.0.0.236/trunk@172386 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsBlockFrame.cpp | 2 +- .../layout/xul/base/src/nsSplitterFrame.cpp | 47 ++++++++----------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 348530a3050..1faf5361e28 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -6545,7 +6545,7 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext, nsIView* resultFrameParentView; resultFrame->GetOffsetFromView(tmp, &resultFrameParentView); if (parentWithView != resultFrameParentView && resultFrameParentView) { - aEvent->point += resultFrameParentView->GetOffsetTo(parentWithView); + aEvent->point -= resultFrameParentView->GetOffsetTo(parentWithView); } if (NS_POSITION_BEFORE_TABLE == result) diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp index db2dcc6ca5c..f860199740e 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp @@ -161,7 +161,7 @@ public: nsSplitterFrame* mOuter; PRBool mDidDrag; - nscoord mDragStartPx; + PRInt32 mDragStartPx; nscoord mCurrentPos; nsIBox* mParentBox; PRBool mPressed; @@ -520,37 +520,28 @@ nsSplitterFrameInner::MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent) // convert coord to pixels nscoord pos = isHorizontal ? aEvent->point.x : aEvent->point.y; - // mDragStartPx is in pixels and is in our client areas coordinate system. - // so we need to first convert it so twips and then get it into our coordinate system. + // mDragStartPx is in pixels and is in our client area's coordinate system. + // so we need to first convert it so twips and then get it into our + // coordinate system. // convert start to twips - nscoord startpx = mDragStartPx; + nscoord start = aPresContext->IntScaledPixelsToTwips(mDragStartPx); - nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1); - nscoord start = startpx*onePixel; - - // get it into our coordintate system by subtracting our parents offsets. - nsIFrame* parent = mOuter; - while(parent != nsnull) - { - // if we hit a scrollable view make sure we take into account - // how much we are scrolled. - nsIView* view = parent->GetView(); - if (view) { - nsIScrollableView* scrollingView = view->ToScrollableView(); - if (scrollingView) { - nscoord xoff = 0; - nscoord yoff = 0; - scrollingView->GetScrollPosition(xoff, yoff); - isHorizontal ? start += xoff : start += yoff; - } - } - - nsRect r = parent->GetRect(); - isHorizontal ? start -= r.x : start -= r.y; - parent = parent->GetParent(); - } + // get it into our coordinate system (that is, the coordinate + // system that aEvent->point is in) + nsIView* eventCoordView; + nsPoint offsetFromView; + mOuter->GetOffsetFromView(offsetFromView, &eventCoordView); + NS_ASSERTION(eventCoordView, "No view?"); + nsIView* rootView; + aPresContext->GetViewManager()->GetRootView(rootView); + NS_ASSERTION(rootView, "No root view?"); + + nsPoint eventCoordViewOffset = eventCoordView->GetOffsetTo(rootView); + + start -= (isHorizontal ? eventCoordViewOffset.x : eventCoordViewOffset.y); + // take our current position and substract the start location pos -= start;