mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Backed out changeset f9900ac6071c (bug 571074) for failing clipboard at browser/base/content/test/general/browser_clipboard.js on a CLOSED TREE
This commit is contained in:
parent
6e35b01f91
commit
987516303f
@ -241,9 +241,7 @@ nsContentAreaDragDropDataProvider::GetFlavorData(nsITransferable *aTransferable,
|
||||
// get the URI from the kFilePromiseURLMime flavor
|
||||
NS_ENSURE_ARG(aTransferable);
|
||||
nsCOMPtr<nsISupports> tmp;
|
||||
rv = aTransferable->GetTransferData(kFilePromiseURLMime,
|
||||
getter_AddRefs(tmp));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aTransferable->GetTransferData(kFilePromiseURLMime, getter_AddRefs(tmp));
|
||||
nsCOMPtr<nsISupportsString> supportsString =
|
||||
do_QueryInterface(tmp);
|
||||
if (!supportsString)
|
||||
@ -258,9 +256,8 @@ nsContentAreaDragDropDataProvider::GetFlavorData(nsITransferable *aTransferable,
|
||||
rv = NS_NewURI(getter_AddRefs(sourceURI), sourceURLString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = aTransferable->GetTransferData(kFilePromiseDestFilename,
|
||||
getter_AddRefs(tmp));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aTransferable->GetTransferData(kFilePromiseDestFilename,
|
||||
getter_AddRefs(tmp));
|
||||
supportsString = do_QueryInterface(tmp);
|
||||
if (!supportsString)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -278,9 +275,8 @@ nsContentAreaDragDropDataProvider::GetFlavorData(nsITransferable *aTransferable,
|
||||
// because sandboxing blocks access to MIME-handler info from
|
||||
// content processes.
|
||||
if (XRE_IsParentProcess()) {
|
||||
rv = aTransferable->GetTransferData(kImageRequestMime,
|
||||
getter_AddRefs(tmp));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aTransferable->GetTransferData(kImageRequestMime,
|
||||
getter_AddRefs(tmp));
|
||||
supportsString = do_QueryInterface(tmp);
|
||||
if (!supportsString)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -328,9 +324,8 @@ nsContentAreaDragDropDataProvider::GetFlavorData(nsITransferable *aTransferable,
|
||||
// get the target directory from the kFilePromiseDirectoryMime
|
||||
// flavor
|
||||
nsCOMPtr<nsISupports> dirPrimitive;
|
||||
rv = aTransferable->GetTransferData(kFilePromiseDirectoryMime,
|
||||
getter_AddRefs(dirPrimitive));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aTransferable->GetTransferData(kFilePromiseDirectoryMime,
|
||||
getter_AddRefs(dirPrimitive));
|
||||
nsCOMPtr<nsIFile> destDirectory = do_QueryInterface(dirPrimitive);
|
||||
if (!destDirectory)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -8110,10 +8110,7 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> data;
|
||||
if (NS_FAILED(aTransferable->GetTransferData(flavorStr.get(),
|
||||
getter_AddRefs(data)))) {
|
||||
continue;
|
||||
}
|
||||
aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(data));
|
||||
|
||||
nsCOMPtr<nsISupportsString> text = do_QueryInterface(data);
|
||||
nsCOMPtr<nsISupportsCString> ctext = do_QueryInterface(data);
|
||||
|
@ -1595,11 +1595,8 @@ HTMLEditor::PasteInternal(int32_t aClipboardType,
|
||||
contextTransferable->Init(nullptr);
|
||||
contextTransferable->AddDataFlavor(kHTMLContext);
|
||||
clipboard->GetData(contextTransferable, aClipboardType);
|
||||
rv = contextTransferable->GetTransferData(kHTMLContext,
|
||||
getter_AddRefs(contextDataObj));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
contextTransferable->GetTransferData(kHTMLContext,
|
||||
getter_AddRefs(contextDataObj));
|
||||
|
||||
nsCOMPtr<nsITransferable> infoTransferable =
|
||||
do_CreateInstance("@mozilla.org/widget/transferable;1");
|
||||
@ -1609,11 +1606,8 @@ HTMLEditor::PasteInternal(int32_t aClipboardType,
|
||||
infoTransferable->Init(nullptr);
|
||||
infoTransferable->AddDataFlavor(kHTMLInfo);
|
||||
clipboard->GetData(infoTransferable, aClipboardType);
|
||||
rv = infoTransferable->GetTransferData(kHTMLInfo,
|
||||
getter_AddRefs(infoDataObj));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
infoTransferable->GetTransferData(kHTMLInfo,
|
||||
getter_AddRefs(infoDataObj));
|
||||
|
||||
if (contextDataObj) {
|
||||
textDataObj = do_QueryInterface(contextDataObj);
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
@ -6257,8 +6256,8 @@ provideDataForType:(NSString*)aType
|
||||
// Now request the kFilePromiseMime data, which will invoke the data
|
||||
// provider. If successful, the file will have been created.
|
||||
nsCOMPtr<nsISupports> fileDataPrimitive;
|
||||
Unused << item->GetTransferData(kFilePromiseMime,
|
||||
getter_AddRefs(fileDataPrimitive));
|
||||
item->GetTransferData(kFilePromiseMime,
|
||||
getter_AddRefs(fileDataPrimitive));
|
||||
}
|
||||
CFRelease(urlRef);
|
||||
CFRelease(pboardRef);
|
||||
|
@ -562,10 +562,7 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
|
||||
flavorStr.EqualsLiteral(kJPGImageMime) || flavorStr.EqualsLiteral(kGIFImageMime) ||
|
||||
flavorStr.EqualsLiteral(kNativeImageMime)) {
|
||||
nsCOMPtr<nsISupports> transferSupports;
|
||||
rv = aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(transferSupports));
|
||||
if (NS_FAILED(rv)) {
|
||||
continue;
|
||||
}
|
||||
aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(transferSupports));
|
||||
|
||||
nsCOMPtr<imgIContainer> image(do_QueryInterface(transferSupports));
|
||||
if (!image) {
|
||||
|
@ -482,9 +482,8 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
|
||||
// the transferable for this clipboard and try to get the
|
||||
// text/unicode type for it.
|
||||
rv = trans->GetTransferData("text/unicode", getter_AddRefs(item));
|
||||
if (NS_FAILED(rv) || !item) {
|
||||
if (!item || NS_FAILED(rv))
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsString> wideString;
|
||||
wideString = do_QueryInterface(item);
|
||||
@ -534,7 +533,7 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
|
||||
|
||||
if (selectionTarget == gdk_atom_intern(kHTMLMime, FALSE)) {
|
||||
rv = trans->GetTransferData(kHTMLMime, getter_AddRefs(item));
|
||||
if (NS_FAILED(rv) || !item) {
|
||||
if (!item || NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -565,7 +564,7 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
|
||||
|
||||
rv = trans->GetTransferData(target_name, getter_AddRefs(item));
|
||||
// nothing found?
|
||||
if (NS_FAILED(rv) || !item) {
|
||||
if (!item || NS_FAILED(rv)) {
|
||||
g_free(target_name);
|
||||
return;
|
||||
}
|
||||
|
@ -1739,16 +1739,11 @@ nsDragService::SourceBeginDrag(GdkDragContext *aContext)
|
||||
for (uint32_t i = 0; i < flavors.Length(); ++i) {
|
||||
if (flavors[i].EqualsLiteral(kFilePromiseDestFilename)) {
|
||||
nsCOMPtr<nsISupports> data;
|
||||
rv = transferable->GetTransferData(kFilePromiseDestFilename,
|
||||
getter_AddRefs(data));
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
transferable->GetTransferData(kFilePromiseDestFilename,
|
||||
getter_AddRefs(data));
|
||||
nsCOMPtr<nsISupportsString> fileName = do_QueryInterface(data);
|
||||
if (!fileName) {
|
||||
if (!fileName)
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString fileNameStr;
|
||||
fileName->GetData(fileNameStr);
|
||||
|
@ -131,7 +131,7 @@ interface nsITransferable : nsISupports
|
||||
* @param aData the data. Some variant of class in nsISupportsPrimitives.idl
|
||||
* @param aDataLen the length of the data
|
||||
*/
|
||||
[must_use] void getTransferData(in string aFlavor, out nsISupports aData);
|
||||
void getTransferData(in string aFlavor, out nsISupports aData);
|
||||
|
||||
/**
|
||||
* Returns the best flavor in the transferable, given those that have
|
||||
|
@ -897,67 +897,65 @@ nsDataObj::GetDib(const nsACString& inFlavor,
|
||||
FORMATETC &aFormat,
|
||||
STGMEDIUM & aSTG)
|
||||
{
|
||||
ULONG result = E_FAIL;
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
if (NS_FAILED(mTransferable->GetTransferData(PromiseFlatCString(inFlavor).get(),
|
||||
getter_AddRefs(genericDataWrapper)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
mTransferable->GetTransferData(PromiseFlatCString(inFlavor).get(), getter_AddRefs(genericDataWrapper));
|
||||
nsCOMPtr<imgIContainer> image ( do_QueryInterface(genericDataWrapper) );
|
||||
if ( image ) {
|
||||
nsCOMPtr<imgITools> imgTools = do_CreateInstance("@mozilla.org/image/tools;1");
|
||||
|
||||
nsCOMPtr<imgIContainer> image = do_QueryInterface(genericDataWrapper);
|
||||
if (!image) {
|
||||
return E_FAIL;
|
||||
}
|
||||
nsAutoString options;
|
||||
if (aFormat.cfFormat == CF_DIBV5) {
|
||||
options.AppendLiteral("version=5");
|
||||
} else {
|
||||
options.AppendLiteral("version=3");
|
||||
}
|
||||
|
||||
nsCOMPtr<imgITools> imgTools = do_CreateInstance("@mozilla.org/image/tools;1");
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsresult rv = imgTools->EncodeImage(image, NS_LITERAL_CSTRING(IMAGE_BMP),
|
||||
options, getter_AddRefs(inputStream));
|
||||
if (NS_FAILED(rv) || !inputStream) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
nsAutoString options;
|
||||
if (aFormat.cfFormat == CF_DIBV5) {
|
||||
options.AppendLiteral("version=5");
|
||||
nsCOMPtr<imgIEncoder> encoder = do_QueryInterface(inputStream);
|
||||
if (!encoder) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
uint32_t size = 0;
|
||||
rv = encoder->GetImageBufferUsed(&size);
|
||||
if (NS_FAILED(rv) || size <= BFH_LENGTH) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
char *src = nullptr;
|
||||
rv = encoder->GetImageBuffer(&src);
|
||||
if (NS_FAILED(rv) || !src) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// We don't want the file header.
|
||||
src += BFH_LENGTH;
|
||||
size -= BFH_LENGTH;
|
||||
|
||||
HGLOBAL glob = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, size);
|
||||
if (!glob) {
|
||||
DWORD err = ::GetLastError();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
char *dst = (char*) ::GlobalLock(glob);
|
||||
::CopyMemory(dst, src, size);
|
||||
::GlobalUnlock(glob);
|
||||
|
||||
aSTG.hGlobal = glob;
|
||||
aSTG.tymed = TYMED_HGLOBAL;
|
||||
result = S_OK;
|
||||
} else {
|
||||
options.AppendLiteral("version=3");
|
||||
NS_WARNING ( "Definitely not an image on clipboard" );
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsresult rv = imgTools->EncodeImage(image, NS_LITERAL_CSTRING(IMAGE_BMP),
|
||||
options, getter_AddRefs(inputStream));
|
||||
if (NS_FAILED(rv) || !inputStream) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
nsCOMPtr<imgIEncoder> encoder = do_QueryInterface(inputStream);
|
||||
if (!encoder) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
uint32_t size = 0;
|
||||
rv = encoder->GetImageBufferUsed(&size);
|
||||
if (NS_FAILED(rv) || size <= BFH_LENGTH) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
char *src = nullptr;
|
||||
rv = encoder->GetImageBuffer(&src);
|
||||
if (NS_FAILED(rv) || !src) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// We don't want the file header.
|
||||
src += BFH_LENGTH;
|
||||
size -= BFH_LENGTH;
|
||||
|
||||
HGLOBAL glob = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, size);
|
||||
if (!glob) {
|
||||
DWORD err = ::GetLastError();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
char *dst = (char*) ::GlobalLock(glob);
|
||||
::CopyMemory(dst, src, size);
|
||||
::GlobalUnlock(glob);
|
||||
|
||||
aSTG.hGlobal = glob;
|
||||
aSTG.tymed = TYMED_HGLOBAL;
|
||||
return S_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -1376,11 +1374,9 @@ HRESULT nsDataObj::GetText(const nsACString & aDataFlavor, FORMATETC& aFE, STGME
|
||||
|
||||
// NOTE: CreateDataFromPrimitive creates new memory, that needs to be deleted
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
nsresult rv = mTransferable->GetTransferData(flavorStr,
|
||||
getter_AddRefs(genericDataWrapper));
|
||||
if (NS_FAILED(rv) || !genericDataWrapper) {
|
||||
mTransferable->GetTransferData(flavorStr, getter_AddRefs(genericDataWrapper));
|
||||
if ( !genericDataWrapper )
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
uint32_t len;
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive(
|
||||
@ -1488,9 +1484,7 @@ HRESULT nsDataObj::DropFile(FORMATETC& aFE, STGMEDIUM& aSTG)
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
|
||||
if (NS_FAILED(mTransferable->GetTransferData(kFileMime, getter_AddRefs(genericDataWrapper)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
mTransferable->GetTransferData(kFileMime, getter_AddRefs(genericDataWrapper));
|
||||
nsCOMPtr<nsIFile> file ( do_QueryInterface(genericDataWrapper) );
|
||||
if (!file)
|
||||
return E_FAIL;
|
||||
@ -1543,10 +1537,7 @@ HRESULT nsDataObj::DropImage(FORMATETC& aFE, STGMEDIUM& aSTG)
|
||||
if (!mCachedTempFile) {
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
|
||||
if (NS_FAILED(mTransferable->GetTransferData(kNativeImageMime,
|
||||
getter_AddRefs(genericDataWrapper)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
mTransferable->GetTransferData(kNativeImageMime, getter_AddRefs(genericDataWrapper));
|
||||
nsCOMPtr<imgIContainer> image(do_QueryInterface(genericDataWrapper));
|
||||
if (!image)
|
||||
return E_FAIL;
|
||||
@ -2105,8 +2096,7 @@ HRESULT nsDataObj::GetDownloadDetails(nsIURI **aSourceURI,
|
||||
|
||||
// get the URI from the kFilePromiseURLMime flavor
|
||||
nsCOMPtr<nsISupports> urlPrimitive;
|
||||
nsresult rv = mTransferable->GetTransferData(kFilePromiseURLMime, getter_AddRefs(urlPrimitive));
|
||||
NS_ENSURE_SUCCESS(rv, E_FAIL);
|
||||
mTransferable->GetTransferData(kFilePromiseURLMime, getter_AddRefs(urlPrimitive));
|
||||
nsCOMPtr<nsISupportsString> srcUrlPrimitive = do_QueryInterface(urlPrimitive);
|
||||
NS_ENSURE_TRUE(srcUrlPrimitive, E_FAIL);
|
||||
|
||||
@ -2119,8 +2109,7 @@ HRESULT nsDataObj::GetDownloadDetails(nsIURI **aSourceURI,
|
||||
|
||||
nsAutoString srcFileName;
|
||||
nsCOMPtr<nsISupports> fileNamePrimitive;
|
||||
rv = mTransferable->GetTransferData(kFilePromiseDestFilename, getter_AddRefs(fileNamePrimitive));
|
||||
NS_ENSURE_SUCCESS(rv, E_FAIL);
|
||||
mTransferable->GetTransferData(kFilePromiseDestFilename, getter_AddRefs(fileNamePrimitive));
|
||||
nsCOMPtr<nsISupportsString> srcFileNamePrimitive = do_QueryInterface(fileNamePrimitive);
|
||||
if (srcFileNamePrimitive) {
|
||||
srcFileNamePrimitive->GetData(srcFileName);
|
||||
|
Loading…
Reference in New Issue
Block a user