зеркало из https://github.com/mozilla/gecko-dev.git
take into account the scroll position of the tree's view when computing frame-relative mouse coordinates. r=damn bug 43405
This commit is contained in:
Родитель
32cbe86ba8
Коммит
5cf9105b70
|
@ -36,6 +36,7 @@
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIPresShell.h"
|
#include "nsIPresShell.h"
|
||||||
#include "nsIDOMEventTarget.h"
|
#include "nsIDOMEventTarget.h"
|
||||||
|
#include "nsIView.h"
|
||||||
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsTreeItemDragCapturer)
|
NS_IMPL_ADDREF(nsTreeItemDragCapturer)
|
||||||
|
@ -138,7 +139,7 @@ nsTreeItemDragCapturer :: ComputeDropPosition ( nsIDOMEvent* aDragEvent, nscoord
|
||||||
mTreeItem->FirstChild(mPresContext, nsnull, &rowFrame);
|
mTreeItem->FirstChild(mPresContext, nsnull, &rowFrame);
|
||||||
NS_ASSERTION ( rowFrame, "couldn't get rowGroup's row frame" );
|
NS_ASSERTION ( rowFrame, "couldn't get rowGroup's row frame" );
|
||||||
rowFrame->GetRect(rowRect);
|
rowFrame->GetRect(rowRect);
|
||||||
|
|
||||||
// compute the offset to top level in twips
|
// compute the offset to top level in twips
|
||||||
float t2p;
|
float t2p;
|
||||||
mPresContext->GetTwipsToPixels(&t2p);
|
mPresContext->GetTwipsToPixels(&t2p);
|
||||||
|
@ -154,10 +155,20 @@ nsTreeItemDragCapturer :: ComputeDropPosition ( nsIDOMEvent* aDragEvent, nscoord
|
||||||
} // until we reach the top
|
} // until we reach the top
|
||||||
|
|
||||||
// subtract the offset from the mouse coord to put it into row relative coordinates.
|
// subtract the offset from the mouse coord to put it into row relative coordinates.
|
||||||
xp -= frameOffsetX;
|
|
||||||
yp -= frameOffsetY;
|
|
||||||
nsPoint pnt(xp, yp);
|
nsPoint pnt(xp, yp);
|
||||||
|
pnt.MoveBy ( -frameOffsetX, -frameOffsetY );
|
||||||
|
|
||||||
|
// Find the tree's view and take it's scroll position into account
|
||||||
|
nsIView *containingView = nsnull;
|
||||||
|
nsPoint unusedOffset(0,0);
|
||||||
|
mTreeItem->GetOffsetFromView(mPresContext, unusedOffset, &containingView);
|
||||||
|
NS_ASSERTION(containingView, "No containing view!");
|
||||||
|
if ( !containingView )
|
||||||
|
return;
|
||||||
|
nscoord viewOffsetToParentX = 0, viewOffsetToParentY = 0;
|
||||||
|
containingView->GetPosition ( &viewOffsetToParentX, &viewOffsetToParentY );
|
||||||
|
pnt.MoveBy ( -viewOffsetToParentX, -viewOffsetToParentY );
|
||||||
|
|
||||||
// now check if item is a container
|
// now check if item is a container
|
||||||
PRBool isContainer = PR_FALSE;
|
PRBool isContainer = PR_FALSE;
|
||||||
nsCOMPtr<nsIContent> treeItemContent;
|
nsCOMPtr<nsIContent> treeItemContent;
|
||||||
|
@ -170,7 +181,7 @@ nsTreeItemDragCapturer :: ComputeDropPosition ( nsIDOMEvent* aDragEvent, nscoord
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
NS_WARNING("Not a DOM element");
|
NS_WARNING("Not a DOM element");
|
||||||
|
|
||||||
// if we have a container, the area is broken up into 3 pieces (top, middle, bottom). If
|
// if we have a container, the area is broken up into 3 pieces (top, middle, bottom). If
|
||||||
// it isn't it's only broken up into two (top and bottom)
|
// it isn't it's only broken up into two (top and bottom)
|
||||||
if ( isContainer ) {
|
if ( isContainer ) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче