зеркало из https://github.com/mozilla/pjs.git
Bug 428876: ondrop gets wrong results when dragging multiple files, patch by Michael Ventnor <ventnor.bugzilla@yahoo.com.au>, r+sr=roc, a=beltzner
This commit is contained in:
Родитель
dd5729063b
Коммит
843a05e5d7
|
@ -466,22 +466,29 @@ nsDragService::GetData(nsITransferable * aTransferable,
|
|||
GetTargetDragData(gdkFlavor);
|
||||
if (mTargetDragData) {
|
||||
const char* text = static_cast<char*>(mTargetDragData);
|
||||
NS_ConvertUTF8toUTF16 fileUrl = NS_ConvertUTF8toUTF16(text);
|
||||
if (StringBeginsWith(fileUrl, NS_LITERAL_STRING("file://")))
|
||||
fileUrl.Cut(0, strlen("file://"));
|
||||
PRUnichar* convertedText = nsnull;
|
||||
PRInt32 convertedTextLen = 0;
|
||||
|
||||
// Sometimes there are linebreaks in the file URLs. Yes, linebreaks in the file URLs.
|
||||
fileUrl.StripChars("\r\n");
|
||||
GetTextUriListItem(text, mTargetDragDataLen, aItemIndex,
|
||||
&convertedText, &convertedTextLen);
|
||||
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
nsresult rv = NS_NewLocalFile(fileUrl, PR_TRUE, getter_AddRefs(file));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// The common wrapping code at the end of this function assumes the data is text
|
||||
// and calls text-specific operations.
|
||||
// Make a secret hideout here for nsILocalFile objects and return early.
|
||||
aTransferable->SetTransferData(flavorStr, file,
|
||||
fileUrl.Length() * sizeof(PRUnichar));
|
||||
return NS_OK;
|
||||
if (convertedText) {
|
||||
nsDependentString fileUrl = nsDependentString(convertedText);
|
||||
if (StringBeginsWith(fileUrl, NS_LITERAL_STRING("file://")))
|
||||
fileUrl.Cut(0, strlen("file://"));
|
||||
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
nsresult rv = NS_NewLocalFile(fileUrl, PR_TRUE, getter_AddRefs(file));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// The common wrapping code at the end of this function assumes the data is text
|
||||
// and calls text-specific operations.
|
||||
// Make a secret hideout here for nsILocalFile objects and return early.
|
||||
aTransferable->SetTransferData(flavorStr, file,
|
||||
fileUrl.Length() * sizeof(PRUnichar));
|
||||
g_free(convertedText);
|
||||
return NS_OK;
|
||||
}
|
||||
g_free(convertedText);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче