Commit 306677ee authored by bzbarsky%mit.edu's avatar bzbarsky%mit.edu
Browse files

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
parent f83f433b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
+21 −30
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ public:

  nsSplitterFrame* mOuter;
  PRBool mDidDrag;
  nscoord mDragStartPx;
  PRInt32 mDragStartPx;
  nscoord mCurrentPos;
  nsIBox* mParentBox;
  PRBool mPressed;
@@ -520,36 +520,27 @@ 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 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?");

    // 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;
        }
      }
    nsIView* rootView;
    aPresContext->GetViewManager()->GetRootView(rootView);
    NS_ASSERTION(rootView, "No root view?");
    
      nsRect r = parent->GetRect();
      isHorizontal ? start -= r.x : start -= r.y;
      parent = parent->GetParent();
    }
    nsPoint eventCoordViewOffset = eventCoordView->GetOffsetTo(rootView);
    
    start -= (isHorizontal ? eventCoordViewOffset.x : eventCoordViewOffset.y);
    
    // take our current position and substract the start location
    pos -= start;