зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1317367 part 1. Get rid of the XPCOM MozGet/SetFileNameArray methods on HTMLInputElement. r=smaug
This commit is contained in:
Родитель
bc74bb03f3
Коммит
452b292356
|
@ -2573,39 +2573,6 @@ HTMLInputElement::MozGetFileNameArray(nsTArray<nsString>& aArray,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
HTMLInputElement::MozGetFileNameArray(uint32_t* aLength, char16_t*** aFileNames)
|
|
||||||
{
|
|
||||||
if (!nsContentUtils::IsCallerChrome()) {
|
|
||||||
// Since this function returns full paths it's important that normal pages
|
|
||||||
// can't call it.
|
|
||||||
return NS_ERROR_DOM_SECURITY_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorResult rv;
|
|
||||||
nsTArray<nsString> array;
|
|
||||||
MozGetFileNameArray(array, rv);
|
|
||||||
if (NS_WARN_IF(rv.Failed())) {
|
|
||||||
return rv.StealNSResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
*aLength = array.Length();
|
|
||||||
char16_t** ret =
|
|
||||||
static_cast<char16_t**>(moz_xmalloc(*aLength * sizeof(char16_t*)));
|
|
||||||
if (!ret) {
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < *aLength; ++i) {
|
|
||||||
ret[i] = NS_strdup(array[i].get());
|
|
||||||
}
|
|
||||||
|
|
||||||
*aFileNames = ret;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
HTMLInputElement::MozSetFileArray(const Sequence<OwningNonNull<File>>& aFiles)
|
HTMLInputElement::MozSetFileArray(const Sequence<OwningNonNull<File>>& aFiles)
|
||||||
{
|
{
|
||||||
|
@ -2672,30 +2639,6 @@ HTMLInputElement::MozSetFileNameArray(const Sequence<nsString>& aFileNames,
|
||||||
SetFilesOrDirectories(files, true);
|
SetFilesOrDirectories(files, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
HTMLInputElement::MozSetFileNameArray(const char16_t** aFileNames,
|
|
||||||
uint32_t aLength)
|
|
||||||
{
|
|
||||||
if (!nsContentUtils::IsCallerChrome()) {
|
|
||||||
// setting the value of a "FILE" input widget requires chrome privilege
|
|
||||||
return NS_ERROR_DOM_SECURITY_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
Sequence<nsString> list;
|
|
||||||
nsString* names = list.AppendElements(aLength, fallible);
|
|
||||||
if (!names) {
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
for (uint32_t i = 0; i < aLength; ++i) {
|
|
||||||
const char16_t* filename = aFileNames[i];
|
|
||||||
names[i].Rebind(filename, nsCharTraits<char16_t>::length(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorResult rv;
|
|
||||||
MozSetFileNameArray(list, rv);
|
|
||||||
return rv.StealNSResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
HTMLInputElement::MozSetDirectory(const nsAString& aDirectoryPath,
|
HTMLInputElement::MozSetDirectory(const nsAString& aDirectoryPath,
|
||||||
ErrorResult& aRv)
|
ErrorResult& aRv)
|
||||||
|
|
|
@ -96,12 +96,7 @@ interface nsIDOMHTMLInputElement : nsISupports
|
||||||
readonly attribute nsIControllers controllers;
|
readonly attribute nsIControllers controllers;
|
||||||
readonly attribute long textLength;
|
readonly attribute long textLength;
|
||||||
|
|
||||||
void mozGetFileNameArray([optional] out unsigned long aLength,
|
/**
|
||||||
[array,size_is(aLength), retval] out wstring aFileNames);
|
|
||||||
void mozSetFileNameArray([array,size_is(aLength)] in wstring aFileNames,
|
|
||||||
in unsigned long aLength);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This non-standard method prevents to check types manually to know if the
|
* This non-standard method prevents to check types manually to know if the
|
||||||
* element is a text field.
|
* element is a text field.
|
||||||
*/
|
*/
|
||||||
|
|
Загрузка…
Ссылка в новой задаче