зеркало из https://github.com/mozilla/pjs.git
Bug 455590, use new drag and drop api with trees, r=neil,sr=smaug
This commit is contained in:
Родитель
bb66497432
Коммит
20b3683604
|
@ -1257,6 +1257,15 @@ public:
|
|||
*/
|
||||
static already_AddRefed<nsIDragSession> GetDragSession();
|
||||
|
||||
/*
|
||||
* Initialize and set the dataTransfer field of an nsDragEvent.
|
||||
*/
|
||||
static nsresult SetDataTransferInEvent(nsDragEvent* aDragEvent);
|
||||
|
||||
// filters the drag and drop action to fit within the effects allowed and
|
||||
// returns it.
|
||||
static PRUint32 FilterDropEffect(PRUint32 aAction, PRUint32 aEffectAllowed);
|
||||
|
||||
/**
|
||||
* Return true if aURI is a local file URI (i.e. file://).
|
||||
*/
|
||||
|
|
|
@ -162,6 +162,8 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
|||
#include "nsCPrefetchService.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIMIMEHeaderParam.h"
|
||||
#include "nsIDOMDragEvent.h"
|
||||
#include "nsDOMDataTransfer.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIBidiKeyboard.h"
|
||||
|
@ -4528,6 +4530,115 @@ nsContentUtils::GetDragSession()
|
|||
return dragSession;
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult
|
||||
nsContentUtils::SetDataTransferInEvent(nsDragEvent* aDragEvent)
|
||||
{
|
||||
if (aDragEvent->dataTransfer || !NS_IS_TRUSTED_EVENT(aDragEvent))
|
||||
return NS_OK;
|
||||
|
||||
// For draggesture and dragstart events, the data transfer object is
|
||||
// created before the event fires, so it should already be set. For other
|
||||
// drag events, get the object from the drag session.
|
||||
NS_ASSERTION(aDragEvent->message != NS_DRAGDROP_GESTURE &&
|
||||
aDragEvent->message != NS_DRAGDROP_START,
|
||||
"draggesture event created without a dataTransfer");
|
||||
|
||||
nsCOMPtr<nsIDragSession> dragSession = GetDragSession();
|
||||
NS_ENSURE_TRUE(dragSession, NS_OK); // no drag in progress
|
||||
|
||||
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer;
|
||||
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
|
||||
if (!initialDataTransfer) {
|
||||
// A dataTransfer won't exist when a drag was started by some other
|
||||
// means, for instance calling the drag service directly, or a drag
|
||||
// from another application. In either case, a new dataTransfer should
|
||||
// be created that reflects the data. Pass true to the constructor for
|
||||
// the aIsExternal argument, so that only system access is allowed.
|
||||
PRUint32 action = 0;
|
||||
dragSession->GetDragAction(&action);
|
||||
initialDataTransfer =
|
||||
new nsDOMDataTransfer(aDragEvent->message, action);
|
||||
NS_ENSURE_TRUE(initialDataTransfer, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// now set it in the drag session so we don't need to create it again
|
||||
dragSession->SetDataTransfer(initialDataTransfer);
|
||||
}
|
||||
|
||||
// each event should use a clone of the original dataTransfer.
|
||||
nsCOMPtr<nsIDOMNSDataTransfer> initialDataTransferNS =
|
||||
do_QueryInterface(initialDataTransfer);
|
||||
NS_ENSURE_TRUE(initialDataTransferNS, NS_ERROR_FAILURE);
|
||||
initialDataTransferNS->Clone(aDragEvent->message, aDragEvent->userCancelled,
|
||||
getter_AddRefs(aDragEvent->dataTransfer));
|
||||
NS_ENSURE_TRUE(aDragEvent->dataTransfer, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// for the dragenter and dragover events, initialize the drop effect
|
||||
// from the drop action, which platform specific widget code sets before
|
||||
// the event is fired based on the keyboard state.
|
||||
if (aDragEvent->message == NS_DRAGDROP_ENTER ||
|
||||
aDragEvent->message == NS_DRAGDROP_OVER) {
|
||||
nsCOMPtr<nsIDOMNSDataTransfer> newDataTransfer =
|
||||
do_QueryInterface(aDragEvent->dataTransfer);
|
||||
NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_FAILURE);
|
||||
|
||||
PRUint32 action, effectAllowed;
|
||||
dragSession->GetDragAction(&action);
|
||||
newDataTransfer->GetEffectAllowedInt(&effectAllowed);
|
||||
newDataTransfer->SetDropEffectInt(FilterDropEffect(action, effectAllowed));
|
||||
}
|
||||
else if (aDragEvent->message == NS_DRAGDROP_DROP ||
|
||||
aDragEvent->message == NS_DRAGDROP_DRAGDROP ||
|
||||
aDragEvent->message == NS_DRAGDROP_END) {
|
||||
// For the drop and dragend events, set the drop effect based on the
|
||||
// last value that the dropEffect had. This will have been set in
|
||||
// nsEventStateManager::PostHandleEvent for the last dragenter or
|
||||
// dragover event.
|
||||
nsCOMPtr<nsIDOMNSDataTransfer> newDataTransfer =
|
||||
do_QueryInterface(aDragEvent->dataTransfer);
|
||||
NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_FAILURE);
|
||||
|
||||
PRUint32 dropEffect;
|
||||
initialDataTransferNS->GetDropEffectInt(&dropEffect);
|
||||
newDataTransfer->SetDropEffectInt(dropEffect);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
PRUint32
|
||||
nsContentUtils::FilterDropEffect(PRUint32 aAction, PRUint32 aEffectAllowed)
|
||||
{
|
||||
// It is possible for the drag action to include more than one action, but
|
||||
// the widget code which sets the action from the keyboard state should only
|
||||
// be including one. If multiple actions were set, we just consider them in
|
||||
// the following order:
|
||||
// copy, link, move
|
||||
if (aAction & nsIDragService::DRAGDROP_ACTION_COPY)
|
||||
aAction = nsIDragService::DRAGDROP_ACTION_COPY;
|
||||
else if (aAction & nsIDragService::DRAGDROP_ACTION_LINK)
|
||||
aAction = nsIDragService::DRAGDROP_ACTION_LINK;
|
||||
else if (aAction & nsIDragService::DRAGDROP_ACTION_MOVE)
|
||||
aAction = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
|
||||
// Filter the action based on the effectAllowed. If the effectAllowed
|
||||
// doesn't include the action, then that action cannot be done, so adjust
|
||||
// the action to something that is allowed. For a copy, adjust to move or
|
||||
// link. For a move, adjust to copy or link. For a link, adjust to move or
|
||||
// link. Otherwise, use none.
|
||||
if (aAction & aEffectAllowed ||
|
||||
aEffectAllowed == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED)
|
||||
return aAction;
|
||||
if (aEffectAllowed & nsIDragService::DRAGDROP_ACTION_MOVE)
|
||||
return nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
if (aEffectAllowed & nsIDragService::DRAGDROP_ACTION_COPY)
|
||||
return nsIDragService::DRAGDROP_ACTION_COPY;
|
||||
if (aEffectAllowed & nsIDragService::DRAGDROP_ACTION_LINK)
|
||||
return nsIDragService::DRAGDROP_ACTION_LINK;
|
||||
return nsIDragService::DRAGDROP_ACTION_NONE;
|
||||
}
|
||||
|
||||
/* static */
|
||||
PRBool
|
||||
nsContentUtils::URIIsLocalFile(nsIURI *aURI)
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
|
||||
friend class nsDOMDragEvent;
|
||||
friend class nsEventStateManager;
|
||||
friend class nsContentUtils;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -118,6 +118,10 @@ nsDOMDragEvent::InitDragEventNS(const nsAString & aNamespaceURIArg,
|
|||
NS_IMETHODIMP
|
||||
nsDOMDragEvent::GetDataTransfer(nsIDOMDataTransfer** aDataTransfer)
|
||||
{
|
||||
// the dataTransfer field of the event caches the DataTransfer associated
|
||||
// with the drag. It is initialized when an attempt is made to retrieve it
|
||||
// rather that when the event is created to avoid duplicating the data when
|
||||
// no listener ever uses it.
|
||||
*aDataTransfer = nsnull;
|
||||
|
||||
if (!mEvent || mEvent->eventStructType != NS_DRAG_EVENT) {
|
||||
|
@ -125,125 +129,17 @@ nsDOMDragEvent::GetDataTransfer(nsIDOMDataTransfer** aDataTransfer)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// the dataTransfer field of the event caches the DataTransfer associated
|
||||
// with the drag. It is initialized when an attempt is made to retrieve it
|
||||
// rather that when the event is created to avoid duplicating the data when
|
||||
// no listener ever uses it.
|
||||
nsDragEvent* dragEvent = static_cast<nsDragEvent*>(mEvent);
|
||||
if (dragEvent->dataTransfer) {
|
||||
CallQueryInterface(dragEvent->dataTransfer, aDataTransfer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// for synthetic events, just use the supplied data transfer object
|
||||
if (mEventIsInternal) {
|
||||
NS_IF_ADDREF(*aDataTransfer = dragEvent->dataTransfer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// For draggesture and dragstart events, the data transfer object is
|
||||
// created before the event fires, so it should already be set. For other
|
||||
// drag events, get the object from the drag session.
|
||||
NS_ASSERTION(mEvent->message != NS_DRAGDROP_GESTURE &&
|
||||
mEvent->message != NS_DRAGDROP_START,
|
||||
"draggesture event created without a dataTransfer");
|
||||
|
||||
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
|
||||
NS_ENSURE_TRUE(dragSession, NS_OK); // no drag in progress
|
||||
|
||||
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer;
|
||||
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
|
||||
if (!initialDataTransfer) {
|
||||
// A dataTransfer won't exist when a drag was started by some other
|
||||
// means, for instance calling the drag service directly, or a drag
|
||||
// from another application. In either case, a new dataTransfer should
|
||||
// be created that reflects the data. Pass true to the constructor for
|
||||
// the aIsExternal argument, so that only system access is allowed.
|
||||
PRUint32 action = 0;
|
||||
dragSession->GetDragAction(&action);
|
||||
initialDataTransfer =
|
||||
new nsDOMDataTransfer(mEvent->message, action);
|
||||
NS_ENSURE_TRUE(initialDataTransfer, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// now set it in the drag session so we don't need to create it again
|
||||
dragSession->SetDataTransfer(initialDataTransfer);
|
||||
}
|
||||
|
||||
// each event should use a clone of the original dataTransfer.
|
||||
nsCOMPtr<nsIDOMNSDataTransfer> initialDataTransferNS =
|
||||
do_QueryInterface(initialDataTransfer);
|
||||
NS_ENSURE_TRUE(initialDataTransferNS, NS_ERROR_FAILURE);
|
||||
initialDataTransferNS->Clone(mEvent->message, dragEvent->userCancelled,
|
||||
getter_AddRefs(dragEvent->dataTransfer));
|
||||
NS_ENSURE_TRUE(dragEvent->dataTransfer, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// for the dragenter and dragover events, initialize the drop effect
|
||||
// from the drop action, which platform specific widget code sets before
|
||||
// the event is fired based on the keyboard state.
|
||||
if (mEvent->message == NS_DRAGDROP_ENTER ||
|
||||
mEvent->message == NS_DRAGDROP_OVER) {
|
||||
nsCOMPtr<nsIDOMNSDataTransfer> newDataTransfer =
|
||||
do_QueryInterface(dragEvent->dataTransfer);
|
||||
NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_FAILURE);
|
||||
|
||||
PRUint32 action, effectAllowed;
|
||||
dragSession->GetDragAction(&action);
|
||||
newDataTransfer->GetEffectAllowedInt(&effectAllowed);
|
||||
newDataTransfer->SetDropEffectInt(FilterDropEffect(action, effectAllowed));
|
||||
}
|
||||
else if (mEvent->message == NS_DRAGDROP_DROP ||
|
||||
mEvent->message == NS_DRAGDROP_DRAGDROP ||
|
||||
mEvent->message == NS_DRAGDROP_END) {
|
||||
// For the drop and dragend events, set the drop effect based on the
|
||||
// last value that the dropEffect had. This will have been set in
|
||||
// nsEventStateManager::PostHandleEvent for the last dragenter or
|
||||
// dragover event.
|
||||
nsCOMPtr<nsIDOMNSDataTransfer> newDataTransfer =
|
||||
do_QueryInterface(dragEvent->dataTransfer);
|
||||
NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_FAILURE);
|
||||
|
||||
PRUint32 dropEffect;
|
||||
initialDataTransferNS->GetDropEffectInt(&dropEffect);
|
||||
newDataTransfer->SetDropEffectInt(dropEffect);
|
||||
// for synthetic events, just use the supplied data transfer object even if null
|
||||
if (!mEventIsInternal) {
|
||||
nsresult rv = nsContentUtils::SetDataTransferInEvent(dragEvent);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aDataTransfer = dragEvent->dataTransfer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
PRUint32
|
||||
nsDOMDragEvent::FilterDropEffect(PRUint32 aAction, PRUint32 aEffectAllowed)
|
||||
{
|
||||
// It is possible for the drag action to include more than one action, but
|
||||
// the widget code which sets the action from the keyboard state should only
|
||||
// be including one. If multiple actions were set, we just consider them in
|
||||
// the following order:
|
||||
// copy, link, move
|
||||
if (aAction & nsIDragService::DRAGDROP_ACTION_COPY)
|
||||
aAction = nsIDragService::DRAGDROP_ACTION_COPY;
|
||||
else if (aAction & nsIDragService::DRAGDROP_ACTION_LINK)
|
||||
aAction = nsIDragService::DRAGDROP_ACTION_LINK;
|
||||
else if (aAction & nsIDragService::DRAGDROP_ACTION_MOVE)
|
||||
aAction = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
|
||||
// Filter the action based on the effectAllowed. If the effectAllowed
|
||||
// doesn't include the action, then that action cannot be done, so adjust
|
||||
// the action to something that is allowed. For a copy, adjust to move or
|
||||
// link. For a move, adjust to copy or link. For a link, adjust to move or
|
||||
// link. Otherwise, use none.
|
||||
if (aAction & aEffectAllowed ||
|
||||
aEffectAllowed == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED)
|
||||
return aAction;
|
||||
if (aEffectAllowed & nsIDragService::DRAGDROP_ACTION_MOVE)
|
||||
return nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
if (aEffectAllowed & nsIDragService::DRAGDROP_ACTION_COPY)
|
||||
return nsIDragService::DRAGDROP_ACTION_COPY;
|
||||
if (aEffectAllowed & nsIDragService::DRAGDROP_ACTION_LINK)
|
||||
return nsIDragService::DRAGDROP_ACTION_LINK;
|
||||
return nsIDragService::DRAGDROP_ACTION_NONE;
|
||||
}
|
||||
|
||||
nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
nsPresContext* aPresContext,
|
||||
nsDragEvent *aEvent)
|
||||
|
|
|
@ -57,9 +57,6 @@ public:
|
|||
NS_DECL_NSIDOMDRAGEVENT
|
||||
|
||||
NS_FORWARD_TO_NSDOMMOUSEEVENT
|
||||
|
||||
// filters the action to fit within the effects allowed and returns it.
|
||||
static PRUint32 FilterDropEffect(PRUint32 aAction, PRUint32 aEffectAllowed);
|
||||
};
|
||||
|
||||
nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
|
|
|
@ -2838,7 +2838,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
|||
|
||||
// filter the drop effect based on the action. Use UNINITIALIZED as
|
||||
// any effect is allowed.
|
||||
dropEffect = nsDOMDragEvent::FilterDropEffect(action,
|
||||
dropEffect = nsContentUtils::FilterDropEffect(action,
|
||||
nsIDragService::DRAGDROP_ACTION_UNINITIALIZED);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ interface nsIXULTemplateRuleFilter;
|
|||
interface nsIXULTemplateQueryProcessor;
|
||||
interface nsIRDFResource;
|
||||
interface nsIRDFCompositeDataSource;
|
||||
interface nsIDOMDataTransfer;
|
||||
|
||||
/**
|
||||
* A template builder, given an input source of data, a template, and a
|
||||
|
@ -354,7 +355,7 @@ interface nsIXULTemplateBuilder : nsISupports
|
|||
* specific handling of specific nsITreeView methods that
|
||||
* XULTreeBuilder does not implement.
|
||||
*/
|
||||
[scriptable, uuid(a5480e0d-ac7c-42e5-aca5-d7f0bbffa207)]
|
||||
[scriptable, uuid(57CED9A7-EC0B-4A0E-8AEB-5DA32EBE951C)]
|
||||
interface nsIXULTreeBuilderObserver : nsISupports
|
||||
{
|
||||
const long DROP_BEFORE = -1;
|
||||
|
@ -366,13 +367,13 @@ interface nsIXULTreeBuilderObserver : nsISupports
|
|||
* items, such as the mailNews folder pane, always return false whe
|
||||
* the orientation is not DROP_ON.
|
||||
*/
|
||||
boolean canDrop(in long index, in long orientation);
|
||||
boolean canDrop(in long index, in long orientation, in nsIDOMDataTransfer dataTransfer);
|
||||
|
||||
/**
|
||||
* Called when the user drops something on this view. The |orientation| param
|
||||
* specifies before/on/after the given |row|.
|
||||
*/
|
||||
void onDrop(in long row, in long orientation);
|
||||
void onDrop(in long row, in long orientation, in nsIDOMDataTransfer dataTransfer);
|
||||
|
||||
/**
|
||||
* Called when an item is opened or closed.
|
||||
|
|
|
@ -1890,7 +1890,8 @@ nsXULTreeBuilder::SortSubtree(nsTreeRows::Subtree* aSubtree)
|
|||
|
||||
/* boolean canDrop (in long index, in long orientation); */
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeBuilder::CanDrop(PRInt32 index, PRInt32 orientation, PRBool *_retval)
|
||||
nsXULTreeBuilder::CanDrop(PRInt32 index, PRInt32 orientation,
|
||||
nsIDOMDataTransfer* dataTransfer, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
if (mObservers) {
|
||||
|
@ -1899,7 +1900,7 @@ nsXULTreeBuilder::CanDrop(PRInt32 index, PRInt32 orientation, PRBool *_retval)
|
|||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIXULTreeBuilderObserver> observer = do_QueryElementAt(mObservers, i);
|
||||
if (observer) {
|
||||
observer->CanDrop(index, orientation, _retval);
|
||||
observer->CanDrop(index, orientation, dataTransfer, _retval);
|
||||
if (*_retval)
|
||||
break;
|
||||
}
|
||||
|
@ -1910,7 +1911,7 @@ nsXULTreeBuilder::CanDrop(PRInt32 index, PRInt32 orientation, PRBool *_retval)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeBuilder::Drop(PRInt32 row, PRInt32 orient)
|
||||
nsXULTreeBuilder::Drop(PRInt32 row, PRInt32 orient, nsIDOMDataTransfer* dataTransfer)
|
||||
{
|
||||
if (mObservers) {
|
||||
PRUint32 count;
|
||||
|
@ -1919,9 +1920,9 @@ nsXULTreeBuilder::Drop(PRInt32 row, PRInt32 orient)
|
|||
nsCOMPtr<nsIXULTreeBuilderObserver> observer = do_QueryElementAt(mObservers, i);
|
||||
if (observer) {
|
||||
PRBool canDrop = PR_FALSE;
|
||||
observer->CanDrop(row, orient, &canDrop);
|
||||
observer->CanDrop(row, orient, dataTransfer, &canDrop);
|
||||
if (canDrop)
|
||||
observer->OnDrop(row, orient);
|
||||
observer->OnDrop(row, orient, dataTransfer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -660,14 +660,15 @@ inDOMView::IsSorted(PRBool *_retval)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMView::CanDrop(PRInt32 index, PRInt32 orientation, PRBool *_retval)
|
||||
inDOMView::CanDrop(PRInt32 index, PRInt32 orientation,
|
||||
nsIDOMDataTransfer* aDataTransfer, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMView::Drop(PRInt32 row, PRInt32 orientation)
|
||||
inDOMView::Drop(PRInt32 row, PRInt32 orientation, nsIDOMDataTransfer* aDataTransfer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
|
||||
interface nsITreeSelection;
|
||||
interface nsITreeColumn;
|
||||
interface nsIDOMDataTransfer;
|
||||
|
||||
[scriptable, uuid(637276b5-58c0-4eff-89ea-c7f3c5bf0b54)]
|
||||
[scriptable, uuid(C06DC4D3-63A2-4422-A0A3-5F2EDDECA8C1)]
|
||||
interface nsITreeView : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -107,14 +108,14 @@ interface nsITreeView : nsISupports
|
|||
* items, such as the mailNews folder pane, always return false when
|
||||
* the orientation is not DROP_ON.
|
||||
*/
|
||||
boolean canDrop(in long index, in long orientation);
|
||||
|
||||
boolean canDrop(in long index, in long orientation, in nsIDOMDataTransfer dataTransfer);
|
||||
|
||||
/**
|
||||
* Called when the user drops something on this view. The |orientation| param
|
||||
* specifies before/on/after the given |row|.
|
||||
*/
|
||||
void drop(in long row, in long orientation);
|
||||
|
||||
void drop(in long row, in long orientation, in nsIDOMDataTransfer dataTransfer);
|
||||
|
||||
/**
|
||||
* Methods used by the tree to draw thread lines in the tree.
|
||||
* getParentIndex is used to obtain the index of a parent row.
|
||||
|
|
|
@ -84,6 +84,7 @@ EXPORTS = \
|
|||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir) \
|
||||
-I$(srcdir)/../../../../../../content/events/src \
|
||||
-I$(srcdir)/../../../../base/src \
|
||||
-I$(srcdir)/../../../../../base \
|
||||
-I$(srcdir)/../../../../../generic \
|
||||
|
|
|
@ -2718,9 +2718,14 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(aEvent->eventStructType == NS_DRAG_EVENT, "wrong event type");
|
||||
nsDragEvent* dragEvent = static_cast<nsDragEvent*>(aEvent);
|
||||
nsContentUtils::SetDataTransferInEvent(dragEvent);
|
||||
|
||||
PRBool canDropAtNewLocation = PR_FALSE;
|
||||
mView->CanDrop(mSlots->mDropRow, mSlots->mDropOrient, &canDropAtNewLocation);
|
||||
|
||||
mView->CanDrop(mSlots->mDropRow, mSlots->mDropOrient,
|
||||
dragEvent->dataTransfer, &canDropAtNewLocation);
|
||||
|
||||
if (canDropAtNewLocation) {
|
||||
// Invalidate row at the new location.
|
||||
mSlots->mDropAllowed = canDropAtNewLocation;
|
||||
|
@ -2749,7 +2754,11 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
rv = mView->GetParentIndex(parentIndex, &parentIndex);
|
||||
}
|
||||
|
||||
mView->Drop(mSlots->mDropRow, mSlots->mDropOrient);
|
||||
NS_ASSERTION(aEvent->eventStructType == NS_DRAG_EVENT, "wrong event type");
|
||||
nsDragEvent* dragEvent = static_cast<nsDragEvent*>(aEvent);
|
||||
nsContentUtils::SetDataTransferInEvent(dragEvent);
|
||||
|
||||
mView->Drop(mSlots->mDropRow, mSlots->mDropOrient, dragEvent->dataTransfer);
|
||||
mSlots->mDropRow = -1;
|
||||
mSlots->mDropOrient = -1;
|
||||
*aEventStatus = nsEventStatus_eConsumeNoDefault; // already handled the drop
|
||||
|
|
|
@ -335,7 +335,8 @@ nsTreeContentView::IsSorted(PRBool *_retval)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeContentView::CanDrop(PRInt32 aIndex, PRInt32 aOrientation, PRBool *_retval)
|
||||
nsTreeContentView::CanDrop(PRInt32 aIndex, PRInt32 aOrientation,
|
||||
nsIDOMDataTransfer* aDataTransfer, PRBool *_retval)
|
||||
{
|
||||
NS_PRECONDITION(aIndex >= 0 && aIndex < PRInt32(mRows.Length()), "bad index");
|
||||
if (aIndex < 0 || aIndex >= PRInt32(mRows.Length()))
|
||||
|
@ -347,7 +348,7 @@ nsTreeContentView::CanDrop(PRInt32 aIndex, PRInt32 aOrientation, PRBool *_retval
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeContentView::Drop(PRInt32 aRow, PRInt32 aOrientation)
|
||||
nsTreeContentView::Drop(PRInt32 aRow, PRInt32 aOrientation, nsIDOMDataTransfer* aDataTransfer)
|
||||
{
|
||||
NS_PRECONDITION(aRow >= 0 && aRow < PRInt32(mRows.Length()), "bad row");
|
||||
if (aRow < 0 || aRow >= PRInt32(mRows.Length()))
|
||||
|
|
|
@ -451,7 +451,8 @@ nsNSSASN1Tree::PerformActionOnCell(const PRUnichar *action, PRInt32 row,
|
|||
//
|
||||
// CanDrop
|
||||
//
|
||||
NS_IMETHODIMP nsNSSASN1Tree::CanDrop(PRInt32 index, PRInt32 orientation, PRBool *_retval)
|
||||
NS_IMETHODIMP nsNSSASN1Tree::CanDrop(PRInt32 index, PRInt32 orientation,
|
||||
nsIDOMDataTransfer* aDataTransfer, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
@ -463,7 +464,7 @@ NS_IMETHODIMP nsNSSASN1Tree::CanDrop(PRInt32 index, PRInt32 orientation, PRBool
|
|||
//
|
||||
// Drop
|
||||
//
|
||||
NS_IMETHODIMP nsNSSASN1Tree::Drop(PRInt32 row, PRInt32 orient)
|
||||
NS_IMETHODIMP nsNSSASN1Tree::Drop(PRInt32 row, PRInt32 orient, nsIDOMDataTransfer* aDataTransfer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1441,7 +1441,8 @@ nsCertTree::dumpMap()
|
|||
//
|
||||
// CanDrop
|
||||
//
|
||||
NS_IMETHODIMP nsCertTree::CanDrop(PRInt32 index, PRInt32 orientation, PRBool *_retval)
|
||||
NS_IMETHODIMP nsCertTree::CanDrop(PRInt32 index, PRInt32 orientation,
|
||||
nsIDOMDataTransfer* aDataTransfer, PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
@ -1453,7 +1454,7 @@ NS_IMETHODIMP nsCertTree::CanDrop(PRInt32 index, PRInt32 orientation, PRBool *_r
|
|||
//
|
||||
// Drop
|
||||
//
|
||||
NS_IMETHODIMP nsCertTree::Drop(PRInt32 row, PRInt32 orient)
|
||||
NS_IMETHODIMP nsCertTree::Drop(PRInt32 row, PRInt32 orient, nsIDOMDataTransfer* aDataTransfer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -921,13 +921,14 @@ nsAutoCompleteController::IsSorted(PRBool *_retval)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoCompleteController::CanDrop(PRInt32 index, PRInt32 orientation, PRBool *_retval)
|
||||
nsAutoCompleteController::CanDrop(PRInt32 index, PRInt32 orientation,
|
||||
nsIDOMDataTransfer* dataTransfer, PRBool *_retval)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAutoCompleteController::Drop(PRInt32 row, PRInt32 orientation)
|
||||
nsAutoCompleteController::Drop(PRInt32 row, PRInt32 orientation, nsIDOMDataTransfer* dataTransfer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@
|
|||
|
||||
#include "nsWildCard.h"
|
||||
|
||||
class nsIDOMDataTransfer;
|
||||
|
||||
#define NS_FILECOMPLETE_CID { 0xcb60980e, 0x18a5, 0x4a77, \
|
||||
{ 0x91, 0x10, 0x81, 0x46, 0x61, 0x4c, 0xa7, 0xf0 } }
|
||||
#define NS_FILECOMPLETE_CONTRACTID "@mozilla.org/autocomplete/search;1?name=file"
|
||||
|
@ -673,14 +675,15 @@ nsFileView::IsSorted(PRBool* aIsSorted)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileView::CanDrop(PRInt32 aIndex, PRInt32 aOrientation, PRBool* aCanDrop)
|
||||
nsFileView::CanDrop(PRInt32 aIndex, PRInt32 aOrientation,
|
||||
nsIDOMDataTransfer* dataTransfer, PRBool* aCanDrop)
|
||||
{
|
||||
*aCanDrop = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileView::Drop(PRInt32 aRow, PRInt32 aOrientation)
|
||||
nsFileView::Drop(PRInt32 aRow, PRInt32 aOrientation, nsIDOMDataTransfer* dataTransfer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче