Bug 1121947, Implement e10 cursor drag feedback on Mac, r=smaug

This commit is contained in:
Neil Deakin 2015-06-05 08:33:29 -04:00
parent f334bb6d6b
commit 68d7ad88b4
4 changed files with 48 additions and 13 deletions

View File

@ -3281,12 +3281,13 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
if (dispatchedToContentProcess) {
dragSession->SetCanDrop(true);
}
// now set the drop effect in the initial dataTransfer. This ensures
// that we can get the desired drop effect in the drop event.
if (initialDataTransfer)
} else if (initialDataTransfer) {
// Now set the drop effect in the initial dataTransfer. This ensures
// that we can get the desired drop effect in the drop event. For events
// dispatched to content, the content process will take care of setting
// this.
initialDataTransfer->SetDropEffectInt(dropEffect);
}
}
break;

View File

@ -5586,15 +5586,13 @@ static int32_t RoundUp(double aDouble)
// drag'n'drop stuff
#define kDragServiceContractID "@mozilla.org/widget/dragservice;1"
- (NSDragOperation)dragOperationForSession:(nsIDragSession*)aDragSession
- (NSDragOperation)dragOperationFromDragAction:(int32_t)aDragAction
{
uint32_t dragAction;
aDragSession->GetDragAction(&dragAction);
if (nsIDragService::DRAGDROP_ACTION_LINK & dragAction)
if (nsIDragService::DRAGDROP_ACTION_LINK & aDragAction)
return NSDragOperationLink;
if (nsIDragService::DRAGDROP_ACTION_COPY & dragAction)
if (nsIDragService::DRAGDROP_ACTION_COPY & aDragAction)
return NSDragOperationCopy;
if (nsIDragService::DRAGDROP_ACTION_MOVE & dragAction)
if (nsIDragService::DRAGDROP_ACTION_MOVE & aDragAction)
return NSDragOperationGeneric;
return NSDragOperationNone;
}
@ -5693,7 +5691,22 @@ static int32_t RoundUp(double aDouble)
switch (aMessage) {
case NS_DRAGDROP_ENTER:
case NS_DRAGDROP_OVER:
return [self dragOperationForSession:dragSession];
{
uint32_t dragAction;
dragSession->GetDragAction(&dragAction);
// If TakeChildProcessDragAction returns something other than
// DRAGDROP_ACTION_UNINITIALIZED, it means that the last event was sent
// to the child process and this event is also being sent to the child
// process. In this case, use the last event's action instead.
nsDragService* dragService = static_cast<nsDragService *>(mDragService);
int32_t childDragAction = dragService->TakeChildProcessDragAction();
if (childDragAction != nsIDragService::DRAGDROP_ACTION_UNINITIALIZED) {
dragAction = childDragAction;
}
return [self dragOperationFromDragAction:dragAction];
}
case NS_DRAGDROP_EXIT:
case NS_DRAGDROP_DROP: {
nsCOMPtr<nsIDOMNode> sourceNode;

View File

@ -55,7 +55,8 @@ nsBaseDragService::nsBaseDragService()
: mCanDrop(false), mOnlyChromeDrop(false), mDoingDrag(false),
mHasImage(false), mUserCancelled(false),
mDragEventDispatchedToChildProcess(false),
mDragAction(DRAGDROP_ACTION_NONE), mTargetSize(0,0),
mDragAction(DRAGDROP_ACTION_NONE),
mDragActionFromChildProcess(DRAGDROP_ACTION_UNINITIALIZED), mTargetSize(0,0),
mImageX(0), mImageY(0), mScreenX(-1), mScreenY(-1), mSuppressLevel(0),
mInputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
{
@ -332,6 +333,21 @@ nsBaseDragService::OpenDragPopup()
}
}
int32_t
nsBaseDragService::TakeChildProcessDragAction()
{
// If the last event was dispatched to the child process, use the drag action
// assigned from it instead and return it. DRAGDROP_ACTION_UNINITIALIZED is
// returned otherwise.
int32_t retval = DRAGDROP_ACTION_UNINITIALIZED;
if (TakeDragEventDispatchedToChildProcess() &&
mDragActionFromChildProcess != DRAGDROP_ACTION_UNINITIALIZED) {
retval = mDragActionFromChildProcess;
}
return retval;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP
nsBaseDragService::EndDragSession(bool aDoneDrag)
@ -720,6 +736,7 @@ nsBaseDragService::UserCancelled()
NS_IMETHODIMP
nsBaseDragService::UpdateDragEffect()
{
mDragActionFromChildProcess = mDragAction;
return NS_OK;
}

View File

@ -57,6 +57,8 @@ public:
uint16_t GetInputSource() { return mInputSource; }
int32_t TakeChildProcessDragAction();
protected:
virtual ~nsBaseDragService();
@ -132,6 +134,8 @@ protected:
bool mDragEventDispatchedToChildProcess;
uint32_t mDragAction;
uint32_t mDragActionFromChildProcess;
nsSize mTargetSize;
nsCOMPtr<nsIDOMNode> mSourceNode;
nsCOMPtr<nsIDOMDocument> mSourceDocument; // the document at the drag source. will be null