mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1503577 - Change CreateDataFromPrimitive aDataLen to out parameter with size of string in bytes. r=mstange
Right now CreateDataFromPrimitive doesn't use the aDataLen parameter, and after this change the out value should be the same as the value passed in, as long as we are dealing with strings. Differential Revision: https://phabricator.services.mozilla.com/D10718 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7b787afdfe
commit
3a8e0049b7
@ -570,13 +570,14 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
|
||||
}
|
||||
|
||||
void *primitive_data = nullptr;
|
||||
uint32_t dataLen = 0;
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive(nsDependentCString(target_name),
|
||||
item, &primitive_data, len);
|
||||
item, &primitive_data, &dataLen);
|
||||
|
||||
if (primitive_data) {
|
||||
gtk_selection_data_set(aSelectionData, selectionTarget,
|
||||
8, /* 8 bits in a unit */
|
||||
(const guchar *)primitive_data, len);
|
||||
(const guchar *)primitive_data, dataLen);
|
||||
free(primitive_data);
|
||||
}
|
||||
|
||||
|
@ -1675,14 +1675,12 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
|
||||
} else {
|
||||
actualFlavor = mimeFlavor.get();
|
||||
}
|
||||
|
||||
uint32_t tmpDataLen = 0;
|
||||
void *tmpData = nullptr;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupports> data;
|
||||
uint32_t len;
|
||||
rv = item->GetTransferData(actualFlavor,
|
||||
getter_AddRefs(data),
|
||||
&tmpDataLen);
|
||||
&len);
|
||||
|
||||
if (strcmp(actualFlavor, kFilePromiseMime) == 0) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -1694,8 +1692,10 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
void *tmpData = nullptr;
|
||||
uint32_t tmpDataLen = 0;
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive(
|
||||
nsDependentCString(actualFlavor), data, &tmpData, tmpDataLen);
|
||||
nsDependentCString(actualFlavor), data, &tmpData, &tmpDataLen);
|
||||
// if required, do the extra work to convert unicode to plain
|
||||
// text and replace the output values with the plain text.
|
||||
if (needToDoConversionToPlainText) {
|
||||
|
@ -125,13 +125,14 @@ nsPrimitiveHelpers :: CreatePrimitiveForCFHTML ( const void* aDataBuff,
|
||||
// parameter does not reflect that.
|
||||
//
|
||||
void
|
||||
nsPrimitiveHelpers :: CreateDataFromPrimitive ( const nsACString& aFlavor, nsISupports* aPrimitive,
|
||||
void** aDataBuff, uint32_t aDataLen )
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive(const nsACString& aFlavor, nsISupports* aPrimitive,
|
||||
void** aDataBuff, uint32_t* aDataLen)
|
||||
{
|
||||
if ( !aDataBuff )
|
||||
return;
|
||||
|
||||
*aDataBuff = nullptr;
|
||||
*aDataLen = 0;
|
||||
|
||||
if (aFlavor.EqualsLiteral(kTextMime) ||
|
||||
aFlavor.EqualsLiteral(kCustomTypesMime)) {
|
||||
@ -140,6 +141,7 @@ nsPrimitiveHelpers :: CreateDataFromPrimitive ( const nsACString& aFlavor, nsISu
|
||||
nsAutoCString data;
|
||||
plainText->GetData ( data );
|
||||
*aDataBuff = ToNewCString(data);
|
||||
*aDataLen = data.Length() * sizeof(char);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -148,6 +150,7 @@ nsPrimitiveHelpers :: CreateDataFromPrimitive ( const nsACString& aFlavor, nsISu
|
||||
nsAutoString data;
|
||||
doubleByteText->GetData ( data );
|
||||
*aDataBuff = ToNewUnicode(data);
|
||||
*aDataLen = data.Length() * sizeof(char16_t);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ public:
|
||||
// Given a nsISupports* primitive and the flavor it represents, creates a new data
|
||||
// buffer with the data in it. This data will be null terminated, but the length
|
||||
// parameter does not reflect that.
|
||||
static void CreateDataFromPrimitive ( const nsACString& aFlavor, nsISupports* aPrimitive,
|
||||
void** aDataBuff, uint32_t aDataLen ) ;
|
||||
static void CreateDataFromPrimitive(const nsACString& aFlavor, nsISupports* aPrimitive,
|
||||
void** aDataBuff, uint32_t* aDataLen);
|
||||
|
||||
}; // class nsPrimitiveHelpers
|
||||
|
||||
|
@ -126,9 +126,10 @@ DataStruct::WriteCache(nsISupports* aData, uint32_t aDataLen)
|
||||
|
||||
// write out the contents of the clipboard to the file
|
||||
void* buff = nullptr;
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive(mFlavor, aData, &buff, aDataLen);
|
||||
uint32_t dataLen = 0;
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive(mFlavor, aData, &buff, &dataLen);
|
||||
if (buff) {
|
||||
int32_t written = PR_Write(mCacheFD, buff, aDataLen);
|
||||
int32_t written = PR_Write(mCacheFD, buff, dataLen);
|
||||
free(buff);
|
||||
if (written) {
|
||||
return NS_OK;
|
||||
|
@ -1339,7 +1339,7 @@ HRESULT nsDataObj::GetText(const nsACString & aDataFlavor, FORMATETC& aFE, STGME
|
||||
if ( !len )
|
||||
return E_FAIL;
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive(
|
||||
nsDependentCString(flavorStr), genericDataWrapper, &data, len);
|
||||
nsDependentCString(flavorStr), genericDataWrapper, &data, &len);
|
||||
if ( !data )
|
||||
return E_FAIL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user