зеркало из https://github.com/mozilla/gecko-dev.git
b=497498 move drag event dispatch logic from nsWindow to nsDragService r=roc
--HG-- extra : rebase_source : ec52cbad0d1efff13c989e8b5061f7fc3445b92b
This commit is contained in:
Родитель
c42f5a3887
Коммит
657ea8347a
|
@ -1829,7 +1829,18 @@ gboolean
|
||||||
nsDragService::RunScheduledTask()
|
nsDragService::RunScheduledTask()
|
||||||
{
|
{
|
||||||
if (mTargetWindow && mTargetWindow != mPendingWindow) {
|
if (mTargetWindow && mTargetWindow != mPendingWindow) {
|
||||||
mTargetWindow->OnDragLeave();
|
PR_LOG(sDragLm, PR_LOG_DEBUG,
|
||||||
|
("nsDragService: dispatch drag leave (%p)\n",
|
||||||
|
mTargetWindow.get()));
|
||||||
|
mTargetWindow->
|
||||||
|
DispatchDragEvent(NS_DRAGDROP_EXIT, mTargetWindowPoint, 0);
|
||||||
|
|
||||||
|
if (!mSourceNode) {
|
||||||
|
// The drag that was initiated in a different app. End the drag
|
||||||
|
// session, since we're done with it for now (until the user drags
|
||||||
|
// back into this app).
|
||||||
|
EndDragSession(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is possible that the pending state has been updated during dispatch
|
// It is possible that the pending state has been updated during dispatch
|
||||||
|
@ -1889,8 +1900,7 @@ nsDragService::RunScheduledTask()
|
||||||
// protocol is used.
|
// protocol is used.
|
||||||
if (task == eDragTaskMotion || positionHasChanged) {
|
if (task == eDragTaskMotion || positionHasChanged) {
|
||||||
nsWindow::UpdateDragStatus(mTargetDragContext, this);
|
nsWindow::UpdateDragStatus(mTargetDragContext, this);
|
||||||
mTargetWindow->
|
DispatchMotionEvents();
|
||||||
DispatchDragMotionEvents(this, mTargetWindowPoint, mTargetTime);
|
|
||||||
|
|
||||||
if (task == eDragTaskMotion) {
|
if (task == eDragTaskMotion) {
|
||||||
// Reply to tell the source whether we can drop and what
|
// Reply to tell the source whether we can drop and what
|
||||||
|
@ -1900,8 +1910,7 @@ nsDragService::RunScheduledTask()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (task == eDragTaskDrop) {
|
if (task == eDragTaskDrop) {
|
||||||
gboolean success = mTargetWindow->
|
gboolean success = DispatchDropEvent();
|
||||||
DispatchDragDropEvent(this, mTargetWindowPoint, mTargetTime);
|
|
||||||
|
|
||||||
// Perhaps we should set the del parameter to TRUE when the drag
|
// Perhaps we should set the del parameter to TRUE when the drag
|
||||||
// action is move, but we don't know whether the data was successfully
|
// action is move, but we don't know whether the data was successfully
|
||||||
|
@ -1932,3 +1941,31 @@ nsDragService::RunScheduledTask()
|
||||||
mTaskSource = 0;
|
mTaskSource = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsDragService::DispatchMotionEvents()
|
||||||
|
{
|
||||||
|
mCanDrop = false;
|
||||||
|
|
||||||
|
FireDragEventAtSource(NS_DRAGDROP_DRAG);
|
||||||
|
|
||||||
|
mTargetWindow->
|
||||||
|
DispatchDragEvent(NS_DRAGDROP_OVER, mTargetWindowPoint, mTargetTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if the drop was successful
|
||||||
|
gboolean
|
||||||
|
nsDragService::DispatchDropEvent()
|
||||||
|
{
|
||||||
|
// We need to check IsDestroyed here because the nsRefPtr
|
||||||
|
// only protects this from being deleted, it does NOT protect
|
||||||
|
// against nsView::~nsView() calling Destroy() on it, bug 378273.
|
||||||
|
if (mTargetWindow->IsDestroyed())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
PRUint32 msg = mCanDrop ? NS_DRAGDROP_DROP : NS_DRAGDROP_EXIT;
|
||||||
|
|
||||||
|
mTargetWindow->DispatchDragEvent(msg, mTargetWindowPoint, mTargetTime);
|
||||||
|
|
||||||
|
return mCanDrop;
|
||||||
|
}
|
||||||
|
|
|
@ -244,6 +244,8 @@ private:
|
||||||
// Callback for g_idle_add_full() to run mScheduledTask.
|
// Callback for g_idle_add_full() to run mScheduledTask.
|
||||||
static gboolean TaskDispatchCallback(gpointer data);
|
static gboolean TaskDispatchCallback(gpointer data);
|
||||||
gboolean RunScheduledTask();
|
gboolean RunScheduledTask();
|
||||||
|
void DispatchMotionEvents();
|
||||||
|
gboolean DispatchDropEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsDragService_h__
|
#endif // nsDragService_h__
|
||||||
|
|
|
@ -3303,37 +3303,6 @@ nsWindow::ThemeChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
nsWindow::DispatchDragMotionEvents(nsDragService *aDragService,
|
|
||||||
const nsIntPoint& aWindowPoint, guint aTime)
|
|
||||||
{
|
|
||||||
aDragService->SetCanDrop(false);
|
|
||||||
|
|
||||||
aDragService->FireDragEventAtSource(NS_DRAGDROP_DRAG);
|
|
||||||
|
|
||||||
DispatchDragEvent(NS_DRAGDROP_OVER, aWindowPoint, aTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the drop was successful
|
|
||||||
gboolean
|
|
||||||
nsWindow::DispatchDragDropEvent(nsDragService *aDragService,
|
|
||||||
const nsIntPoint& aWindowPoint, guint aTime)
|
|
||||||
{
|
|
||||||
// We need to check mIsDestroyed here because the nsRefPtr
|
|
||||||
// only protects this from being deleted, it does NOT protect
|
|
||||||
// against nsView::~nsView() calling Destroy() on it, bug 378670.
|
|
||||||
if (mIsDestroyed)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
bool canDrop;
|
|
||||||
aDragService->GetCanDrop(&canDrop);
|
|
||||||
PRUint32 msg = canDrop ? NS_DRAGDROP_DROP : NS_DRAGDROP_EXIT;
|
|
||||||
|
|
||||||
DispatchDragEvent(msg, aWindowPoint, aTime);
|
|
||||||
|
|
||||||
return canDrop;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsWindow::DispatchDragEvent(PRUint32 aMsg, const nsIntPoint& aRefPoint,
|
nsWindow::DispatchDragEvent(PRUint32 aMsg, const nsIntPoint& aRefPoint,
|
||||||
guint aTime)
|
guint aTime)
|
||||||
|
@ -3371,34 +3340,6 @@ nsWindow::OnDragDataReceivedEvent(GtkWidget *aWidget,
|
||||||
aSelectionData, aInfo, aTime);
|
aSelectionData, aInfo, aTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
nsWindow::OnDragLeave(void)
|
|
||||||
{
|
|
||||||
LOGDRAG(("nsWindow::OnDragLeave(%p)\n", (void*)this));
|
|
||||||
|
|
||||||
DispatchDragEvent(NS_DRAGDROP_EXIT, nsIntPoint(0, 0), 0);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
|
|
||||||
|
|
||||||
if (dragService) {
|
|
||||||
nsCOMPtr<nsIDragSession> currentDragSession;
|
|
||||||
dragService->GetCurrentSession(getter_AddRefs(currentDragSession));
|
|
||||||
|
|
||||||
if (currentDragSession) {
|
|
||||||
nsCOMPtr<nsIDOMNode> sourceNode;
|
|
||||||
currentDragSession->GetSourceNode(getter_AddRefs(sourceNode));
|
|
||||||
|
|
||||||
if (!sourceNode) {
|
|
||||||
// We're leaving a window while doing a drag that was
|
|
||||||
// initiated in a different app. End the drag session,
|
|
||||||
// since we're done with it for now (until the user
|
|
||||||
// drags back into mozilla).
|
|
||||||
dragService->EndDragSession(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
GetBrandName(nsXPIDLString& brandName)
|
GetBrandName(nsXPIDLString& brandName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -245,7 +245,6 @@ public:
|
||||||
guint aInfo,
|
guint aInfo,
|
||||||
guint aTime,
|
guint aTime,
|
||||||
gpointer aData);
|
gpointer aData);
|
||||||
void OnDragLeave(void);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void NativeResize(PRInt32 aWidth,
|
void NativeResize(PRInt32 aWidth,
|
||||||
|
@ -300,12 +299,6 @@ public:
|
||||||
void DispatchDragEvent(PRUint32 aMsg,
|
void DispatchDragEvent(PRUint32 aMsg,
|
||||||
const nsIntPoint& aRefPoint,
|
const nsIntPoint& aRefPoint,
|
||||||
guint aTime);
|
guint aTime);
|
||||||
void DispatchDragMotionEvents(nsDragService *aDragService,
|
|
||||||
const nsIntPoint& aPoint,
|
|
||||||
guint aTime);
|
|
||||||
gboolean DispatchDragDropEvent(nsDragService *aDragService,
|
|
||||||
const nsIntPoint& aWindowPoint,
|
|
||||||
guint aTime);
|
|
||||||
static void UpdateDragStatus (GdkDragContext *aDragContext,
|
static void UpdateDragStatus (GdkDragContext *aDragContext,
|
||||||
nsIDragService *aDragService);
|
nsIDragService *aDragService);
|
||||||
// If this dispatched the keydown event actually, this returns TRUE,
|
// If this dispatched the keydown event actually, this returns TRUE,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче