зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1493292 - Remove len from nsIFormatConverter. r=smaug
Depends on D11204 Differential Revision: https://phabricator.services.mozilla.com/D11205 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e2f59a0c22
Коммит
2ab01e399b
|
@ -91,8 +91,7 @@ function convertHTMLToPlainText(html) {
|
|||
input.data = html.replace(/\n/g, "<br>");
|
||||
|
||||
var output = {};
|
||||
converter.convert("text/html", input, input.data.length, "text/unicode",
|
||||
output, {});
|
||||
converter.convert("text/html", input, "text/unicode", output);
|
||||
|
||||
if (output.value instanceof Ci.nsISupportsString)
|
||||
return output.value.data.replace(/\r\n/g, "\n");
|
||||
|
|
|
@ -102,15 +102,14 @@ nsHTMLFormatConverter::CanConvert(const char *aFromDataFlavor, const char *aToDa
|
|||
//XXX unicode out of the string. Lame lame lame.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFormatConverter::Convert(const char *aFromDataFlavor, nsISupports *aFromData, uint32_t aDataLen,
|
||||
const char *aToDataFlavor, nsISupports **aToData, uint32_t *aDataToLen)
|
||||
nsHTMLFormatConverter::Convert(const char *aFromDataFlavor, nsISupports *aFromData,
|
||||
const char *aToDataFlavor, nsISupports **aToData)
|
||||
{
|
||||
if ( !aToData || !aDataToLen )
|
||||
if ( !aToData )
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
*aToData = nullptr;
|
||||
*aDataToLen = 0;
|
||||
|
||||
if ( !nsCRT::strcmp(aFromDataFlavor, kHTMLMime) ) {
|
||||
nsAutoCString toFlavor ( aToDataFlavor );
|
||||
|
@ -132,16 +131,12 @@ nsHTMLFormatConverter::Convert(const char *aFromDataFlavor, nsISupports *aFromDa
|
|||
if (toFlavor.Equals(kHTMLMime)) {
|
||||
int32_t dataLen = dataStr.Length() * 2;
|
||||
nsPrimitiveHelpers::CreatePrimitiveForData ( toFlavor, dataStr.get(), dataLen, aToData );
|
||||
if ( *aToData )
|
||||
*aDataToLen = dataLen;
|
||||
} else {
|
||||
nsAutoString outStr;
|
||||
res = ConvertFromHTMLToUnicode(dataStr, outStr);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
int32_t dataLen = outStr.Length() * 2;
|
||||
nsPrimitiveHelpers::CreatePrimitiveForData ( toFlavor, outStr.get(), dataLen, aToData );
|
||||
if ( *aToData )
|
||||
*aDataToLen = dataLen;
|
||||
}
|
||||
}
|
||||
} // else if HTML or Unicode
|
||||
|
@ -150,8 +145,6 @@ nsHTMLFormatConverter::Convert(const char *aFromDataFlavor, nsISupports *aFromDa
|
|||
if ( NS_SUCCEEDED(ConvertFromHTMLToAOLMail(dataStr, outStr)) ) {
|
||||
int32_t dataLen = outStr.Length() * 2;
|
||||
nsPrimitiveHelpers::CreatePrimitiveForData ( toFlavor, outStr.get(), dataLen, aToData );
|
||||
if ( *aToData )
|
||||
*aDataToLen = dataLen;
|
||||
}
|
||||
} // else if AOL mail
|
||||
else {
|
||||
|
|
|
@ -39,8 +39,8 @@ interface nsIFormatConverter : nsISupports
|
|||
* @param aFromFormatConverter flavor to convert to (destination own the memory)
|
||||
* @returns returns NS_OK if it was converted
|
||||
*/
|
||||
void convert ( in string aFromDataFlavor, in nsISupports aFromData, in unsigned long aDataLen,
|
||||
in string aToDataFlavor, out nsISupports aToData, out unsigned long aDataToLen ) ;
|
||||
void convert ( in string aFromDataFlavor, in nsISupports aFromData,
|
||||
in string aToDataFlavor, out nsISupports aToData ) ;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -307,9 +307,8 @@ nsTransferable::GetTransferData(const char* aFlavor,
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t dataLen;
|
||||
return mFormatConv->Convert(data.GetFlavor().get(), dataBytes, 0,
|
||||
aFlavor, aData, &dataLen);
|
||||
return mFormatConv->Convert(data.GetFlavor().get(), dataBytes, aFlavor,
|
||||
aData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,13 +367,10 @@ nsTransferable::SetTransferData(const char* aFlavor,
|
|||
|
||||
if (canConvert) {
|
||||
nsCOMPtr<nsISupports> ConvertedData;
|
||||
uint32_t ConvertedLen;
|
||||
mFormatConv->Convert(aFlavor,
|
||||
aData,
|
||||
0,
|
||||
data.GetFlavor().get(),
|
||||
getter_AddRefs(ConvertedData),
|
||||
&ConvertedLen);
|
||||
getter_AddRefs(ConvertedData));
|
||||
data.SetData(ConvertedData, mPrivateData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче