diff --git a/widget/src/windows/nsClipboard.cpp b/widget/src/windows/nsClipboard.cpp index 84601349a9aa..57ca39dfad8f 100644 --- a/widget/src/windows/nsClipboard.cpp +++ b/widget/src/windows/nsClipboard.cpp @@ -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(tempOutData), tempDataLen, esc_OnlyNonASCII | esc_SkipControl, urlUnescapedA); + + nsString urlString; + if (unescaped) + NS_CopyNativeToUnicode(urlUnescapedA, urlString); + else + NS_CopyNativeToUnicode(nsDependentCString(static_cast(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(*outData)) * sizeof(PRUnichar); + nsMemory::Free(tempOutData); + dataFound = PR_TRUE; + } + } return dataFound; } // FindURLFromNativeURL diff --git a/widget/src/windows/nsNativeDragTarget.cpp b/widget/src/windows/nsNativeDragTarget.cpp index 335b009a103c..6c1259956cf4 100644 --- a/widget/src/windows/nsNativeDragTarget.cpp +++ b/widget/src/windows/nsNativeDragTarget.cpp @@ -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 diff --git a/widget/src/windows/nsNativeDragTarget.h b/widget/src/windows/nsNativeDragTarget.h index 4d3eadd61f99..d86cab6c3b27 100644 --- a/widget/src/windows/nsNativeDragTarget.h +++ b/widget/src/windows/nsNativeDragTarget.h @@ -113,6 +113,7 @@ protected: ULONG m_cRef; // reference count HWND mHWnd; PRBool mCanMove; + PRBool mMovePreferred; // Gecko Stuff nsIWidget * mWindow;