Bug 483776 - Update original data transfer mozCursor state during drags. r=bz.

This commit is contained in:
Jim Mathies 2009-10-06 21:51:02 -05:00
Родитель 243d32f0ea
Коммит e87cfe5946
2 изменённых файлов: 48 добавлений и 1 удалений

Просмотреть файл

@ -3051,6 +3051,12 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
nsCOMPtr<nsIDOMNSDataTransfer> initialDataTransferNS =
do_QueryInterface(initialDataTransfer);
nsDragEvent *dragEvent = (nsDragEvent*)aEvent;
// collect any changes to moz cursor settings stored in the event's
// data transfer.
UpdateDragDataTransfer(dragEvent);
// cancelling a dragenter or dragover event means that a drop should be
// allowed, so update the dropEffect and the canDrop state to indicate
// that a drag is allowed. If the event isn't cancelled, a drop won't be
@ -3063,7 +3069,6 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
PRUint32 dropEffect = nsIDragService::DRAGDROP_ACTION_NONE;
if (nsEventStatus_eConsumeNoDefault == *aStatus) {
// if the event has a dataTransfer set, use it.
nsDragEvent *dragEvent = (nsDragEvent*)aEvent;
if (dragEvent->dataTransfer) {
// get the dataTransfer and the dropEffect that was set on it
dataTransfer = do_QueryInterface(dragEvent->dataTransfer);
@ -3852,6 +3857,12 @@ nsEventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext,
if (status == nsEventStatus_eConsumeNoDefault || aMsg == NS_DRAGDROP_EXIT)
SetContentState((aMsg == NS_DRAGDROP_ENTER) ? aTargetContent : nsnull,
NS_EVENT_STATE_DRAGOVER);
// collect any changes to moz cursor settings stored in the event's
// data transfer.
if (aMsg == NS_DRAGDROP_LEAVE_SYNTH || aMsg == NS_DRAGDROP_EXIT_SYNTH ||
aMsg == NS_DRAGDROP_ENTER)
UpdateDragDataTransfer(&event);
}
// Finally dispatch the event to the frame
@ -3859,6 +3870,36 @@ nsEventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext,
aTargetFrame->HandleEvent(aPresContext, &event, &status);
}
void
nsEventStateManager::UpdateDragDataTransfer(nsDragEvent* dragEvent)
{
NS_ASSERTION(dragEvent, "drag event is null in UpdateDragDataTransfer!");
if (!dragEvent->dataTransfer)
return;
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
if (dragSession) {
// the initial dataTransfer is the one from the dragstart event that
// was set on the dragSession when the drag began.
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer;
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
// grab the interface that has GetMozCursor.
nsCOMPtr<nsIDOMNSDataTransfer> initialDataTransferNS =
do_QueryInterface(initialDataTransfer);
nsCOMPtr<nsIDOMNSDataTransfer> eventTransferNS =
do_QueryInterface(dragEvent->dataTransfer);
if (initialDataTransferNS && eventTransferNS) {
// retrieve the current moz cursor setting and save it.
nsAutoString mozCursor;
eventTransferNS->GetMozCursor(mozCursor);
initialDataTransferNS->SetMozCursor(mozCursor);
}
}
}
nsresult
nsEventStateManager::SetClickCount(nsPresContext* aPresContext,
nsMouseEvent *aEvent,

Просмотреть файл

@ -199,6 +199,12 @@ protected:
nsIContent* aRelatedTarget,
nsIContent* aTargetContent,
nsWeakFrame& aTargetFrame);
/**
* Update the initial drag session data transfer with any changes that occur
* on cloned data transfer objects used for events.
*/
void UpdateDragDataTransfer(nsDragEvent* dragEvent);
nsresult SetClickCount(nsPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
nsresult CheckForAndDispatchClick(nsPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
void EnsureDocument(nsPresContext* aPresContext);