зеркало из 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 "nsIClipboardOwner.h"
|
||||
#include "nsString.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsIFormatConverter.h"
|
||||
#include "nsITransferable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -65,6 +66,7 @@
|
|||
#include "nsWidgetsCID.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
#include "nsIImage.h"
|
||||
|
||||
|
@ -819,6 +821,29 @@ nsClipboard :: FindURLFromNativeURL ( IDataObject* inDataObject, UINT inIndex, v
|
|||
nsMemory::Free(tempOutData);
|
||||
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;
|
||||
} // FindURLFromNativeURL
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "nsIWidget.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsClipboard.h"
|
||||
|
||||
#if (_MSC_VER == 1100)
|
||||
#define INITGUID
|
||||
|
@ -158,9 +159,11 @@ nsNativeDragTarget::GetGeckoDragAction(LPDATAOBJECT pData, DWORD grfKeyState,
|
|||
|
||||
// Default is move if we can, in fact drop here,
|
||||
// and if the drop source supports a move operation.
|
||||
if (mCanMove) {
|
||||
*pdwEffect = DROPEFFECT_MOVE;
|
||||
// If move is not preferred (mMovePreferred is false)
|
||||
// move only when the shift key is down.
|
||||
if (mCanMove && (mMovePreferred || (grfKeyState & MK_SHIFT))) {
|
||||
*aGeckoAction = nsIDragService::DRAGDROP_ACTION_MOVE;
|
||||
*pdwEffect = DROPEFFECT_MOVE;
|
||||
} else {
|
||||
*aGeckoAction = nsIDragService::DRAGDROP_ACTION_COPY;
|
||||
*pdwEffect = DROPEFFECT_COPY;
|
||||
|
@ -286,6 +289,20 @@ nsNativeDragTarget::DragEnter(LPDATAOBJECT pIDataSource,
|
|||
// Remember if this operation allows a 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
|
||||
//
|
||||
// This cast is ok because in the constructor we created a
|
||||
|
|
|
@ -113,6 +113,7 @@ protected:
|
|||
ULONG m_cRef; // reference count
|
||||
HWND mHWnd;
|
||||
PRBool mCanMove;
|
||||
PRBool mMovePreferred;
|
||||
|
||||
// Gecko Stuff
|
||||
nsIWidget * mWindow;
|
||||
|
|
Загрузка…
Ссылка в новой задаче