зеркало из https://github.com/mozilla/gecko-dev.git
Bug 296528 - Dragging file from Windows Explorer FTP into Firefox deletes the file. r=emaijala
This commit is contained in:
Родитель
9d078fb5c9
Коммит
c05f662cbb
|
@ -50,6 +50,7 @@
|
||||||
#include "nsDataObj.h"
|
#include "nsDataObj.h"
|
||||||
#include "nsIClipboardOwner.h"
|
#include "nsIClipboardOwner.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
#include "nsNativeCharsetUtils.h"
|
||||||
#include "nsIFormatConverter.h"
|
#include "nsIFormatConverter.h"
|
||||||
#include "nsITransferable.h"
|
#include "nsITransferable.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
#include "nsWidgetsCID.h"
|
#include "nsWidgetsCID.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
|
#include "nsEscape.h"
|
||||||
|
|
||||||
#include "nsIImage.h"
|
#include "nsIImage.h"
|
||||||
|
|
||||||
|
@ -819,6 +821,29 @@ nsClipboard :: FindURLFromNativeURL ( IDataObject* inDataObject, UINT inIndex, v
|
||||||
nsMemory::Free(tempOutData);
|
nsMemory::Free(tempOutData);
|
||||||
dataFound = PR_TRUE;
|
dataFound = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
loadResult = GetNativeDataOffClipboard(inDataObject, inIndex, ::RegisterClipboardFormat(CFSTR_INETURLA), &tempOutData, &tempDataLen);
|
||||||
|
if ( NS_SUCCEEDED(loadResult) && tempOutData ) {
|
||||||
|
// CFSTR_INETURLA is (currently) equal to CFSTR_SHELLURL which is equal to CF_TEXT
|
||||||
|
// which is by definition ANSI encoded.
|
||||||
|
nsCString urlUnescapedA;
|
||||||
|
PRBool unescaped = NS_UnescapeURL(static_cast<char*>(tempOutData), tempDataLen, esc_OnlyNonASCII | esc_SkipControl, urlUnescapedA);
|
||||||
|
|
||||||
|
nsString urlString;
|
||||||
|
if (unescaped)
|
||||||
|
NS_CopyNativeToUnicode(urlUnescapedA, urlString);
|
||||||
|
else
|
||||||
|
NS_CopyNativeToUnicode(nsDependentCString(static_cast<char*>(tempOutData), tempDataLen), urlString);
|
||||||
|
|
||||||
|
// the internal mozilla URL format, text/x-moz-url, contains
|
||||||
|
// URL\ntitle. Since we don't actually have a title here,
|
||||||
|
// just repeat the URL to fake it.
|
||||||
|
*outData = ToNewUnicode(urlString + NS_LITERAL_STRING("\n") + urlString);
|
||||||
|
*outDataLen = nsCRT::strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);
|
||||||
|
nsMemory::Free(tempOutData);
|
||||||
|
dataFound = PR_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return dataFound;
|
return dataFound;
|
||||||
} // FindURLFromNativeURL
|
} // FindURLFromNativeURL
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
#include "nsIWidget.h"
|
#include "nsIWidget.h"
|
||||||
#include "nsWindow.h"
|
#include "nsWindow.h"
|
||||||
|
#include "nsClipboard.h"
|
||||||
|
|
||||||
#if (_MSC_VER == 1100)
|
#if (_MSC_VER == 1100)
|
||||||
#define INITGUID
|
#define INITGUID
|
||||||
|
@ -158,9 +159,11 @@ nsNativeDragTarget::GetGeckoDragAction(LPDATAOBJECT pData, DWORD grfKeyState,
|
||||||
|
|
||||||
// Default is move if we can, in fact drop here,
|
// Default is move if we can, in fact drop here,
|
||||||
// and if the drop source supports a move operation.
|
// and if the drop source supports a move operation.
|
||||||
if (mCanMove) {
|
// If move is not preferred (mMovePreferred is false)
|
||||||
*pdwEffect = DROPEFFECT_MOVE;
|
// move only when the shift key is down.
|
||||||
|
if (mCanMove && (mMovePreferred || (grfKeyState & MK_SHIFT))) {
|
||||||
*aGeckoAction = nsIDragService::DRAGDROP_ACTION_MOVE;
|
*aGeckoAction = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||||
|
*pdwEffect = DROPEFFECT_MOVE;
|
||||||
} else {
|
} else {
|
||||||
*aGeckoAction = nsIDragService::DRAGDROP_ACTION_COPY;
|
*aGeckoAction = nsIDragService::DRAGDROP_ACTION_COPY;
|
||||||
*pdwEffect = DROPEFFECT_COPY;
|
*pdwEffect = DROPEFFECT_COPY;
|
||||||
|
@ -286,6 +289,20 @@ nsNativeDragTarget::DragEnter(LPDATAOBJECT pIDataSource,
|
||||||
// Remember if this operation allows a move.
|
// Remember if this operation allows a move.
|
||||||
mCanMove = (*pdwEffect) & DROPEFFECT_MOVE;
|
mCanMove = (*pdwEffect) & DROPEFFECT_MOVE;
|
||||||
|
|
||||||
|
void* tempOutData = nsnull;
|
||||||
|
PRUint32 tempDataLen = 0;
|
||||||
|
nsresult loadResult = nsClipboard::GetNativeDataOffClipboard(
|
||||||
|
pIDataSource, 0, ::RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT), &tempOutData, &tempDataLen);
|
||||||
|
if (NS_SUCCEEDED(loadResult) && tempOutData) {
|
||||||
|
NS_ASSERTION(tempDataLen == 2, "Expected word size");
|
||||||
|
WORD preferredEffect = *((WORD*)tempOutData);
|
||||||
|
|
||||||
|
// Mask effect coming from function call with effect preferred by the source.
|
||||||
|
mMovePreferred = (preferredEffect & DROPEFFECT_MOVE) != 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mMovePreferred = mCanMove;
|
||||||
|
|
||||||
// Set the native data object into drag service
|
// Set the native data object into drag service
|
||||||
//
|
//
|
||||||
// This cast is ok because in the constructor we created a
|
// This cast is ok because in the constructor we created a
|
||||||
|
|
|
@ -113,6 +113,7 @@ protected:
|
||||||
ULONG m_cRef; // reference count
|
ULONG m_cRef; // reference count
|
||||||
HWND mHWnd;
|
HWND mHWnd;
|
||||||
PRBool mCanMove;
|
PRBool mCanMove;
|
||||||
|
PRBool mMovePreferred;
|
||||||
|
|
||||||
// Gecko Stuff
|
// Gecko Stuff
|
||||||
nsIWidget * mWindow;
|
nsIWidget * mWindow;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче