mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 19:41:49 +00:00
Bug 1030844 - Get rid of nsIDOMWindowUtils.getFile/getBlob, r=janv
This commit is contained in:
parent
b69b3e65ed
commit
2584466941
@ -2941,91 +2941,6 @@ nsDOMWindowUtils::AreDialogsEnabled(bool* aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsIDOMBlob*
|
||||
GetXPConnectNative(JSContext* aCx, JSObject* aObj) {
|
||||
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(
|
||||
nsContentUtils::XPConnect()->GetNativeOfWrapper(aCx, aObj));
|
||||
return blob;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetFileOrBlob(const nsAString& aName, JS::Handle<JS::Value> aBlobParts,
|
||||
JS::Handle<JS::Value> aParameters, JSContext* aCx,
|
||||
uint8_t aOptionalArgCount, nsISupports** aResult)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsISupports> file;
|
||||
|
||||
if (aName.IsVoid()) {
|
||||
rv = DOMMultipartFileImpl::NewBlob(getter_AddRefs(file));
|
||||
}
|
||||
else {
|
||||
rv = DOMMultipartFileImpl::NewFile(aName, getter_AddRefs(file));
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(file);
|
||||
MOZ_ASSERT(blob);
|
||||
|
||||
nsRefPtr<DOMFile> domFile = static_cast<DOMFile*>(blob.get());
|
||||
|
||||
DOMFileImpl* fileImpl = domFile->Impl();
|
||||
MOZ_ASSERT(fileImpl);
|
||||
|
||||
DOMMultipartFileImpl* domFileImpl =
|
||||
static_cast<DOMMultipartFileImpl*>(fileImpl);
|
||||
|
||||
JS::AutoValueArray<2> args(aCx);
|
||||
args[0].set(aBlobParts);
|
||||
args[1].set(aParameters);
|
||||
|
||||
rv = domFileImpl->InitBlob(aCx, aOptionalArgCount, args.begin(),
|
||||
GetXPConnectNative);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
file.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetFile(const nsAString& aName, JS::Handle<JS::Value> aBlobParts,
|
||||
JS::Handle<JS::Value> aParameters, JSContext* aCx,
|
||||
uint8_t aOptionalArgCount, nsIDOMFile** aResult)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
|
||||
|
||||
nsCOMPtr<nsISupports> file;
|
||||
nsresult rv = GetFileOrBlob(aName, aBlobParts, aParameters, aCx,
|
||||
aOptionalArgCount, getter_AddRefs(file));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMFile> result = do_QueryInterface(file);
|
||||
result.forget(aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetBlob(JS::Handle<JS::Value> aBlobParts,
|
||||
JS::Handle<JS::Value> aParameters, JSContext* aCx,
|
||||
uint8_t aOptionalArgCount, nsIDOMBlob** aResult)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
|
||||
|
||||
nsCOMPtr<nsISupports> blob;
|
||||
nsresult rv = GetFileOrBlob(NullString(), aBlobParts, aParameters, aCx,
|
||||
aOptionalArgCount, getter_AddRefs(blob));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> result = do_QueryInterface(blob);
|
||||
result.forget(aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetFileId(JS::Handle<JS::Value> aFile, JSContext* aCx,
|
||||
int64_t* aResult)
|
||||
|
@ -40,14 +40,9 @@ function getRandomView(size)
|
||||
return view;
|
||||
}
|
||||
|
||||
function getBlob(type, view)
|
||||
{
|
||||
return SpecialPowers.unwrap(utils.getBlob([view], {type: type}));
|
||||
}
|
||||
|
||||
function getRandomBlob(size)
|
||||
{
|
||||
return getBlob("binary/random", getRandomView(size));
|
||||
return new Blob([getRandomView(size)], { type: "binary/random" });
|
||||
}
|
||||
|
||||
function compareBuffers(buffer1, buffer2)
|
||||
|
@ -194,14 +194,9 @@ function compareBuffers(buffer1, buffer2)
|
||||
return true;
|
||||
}
|
||||
|
||||
function getBlob(type, buffer)
|
||||
{
|
||||
return SpecialPowers.unwrap(utils.getBlob([buffer], {type: type}));
|
||||
}
|
||||
|
||||
function getRandomBlob(size)
|
||||
{
|
||||
return getBlob("binary/random", getRandomBuffer(size));
|
||||
return new Blob([getRandomBuffer(size)], { type: "binary/random" });
|
||||
}
|
||||
|
||||
function getFileId(blob)
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
var testBuffer = getRandomBuffer(100000);
|
||||
|
||||
var testBlob = getBlob("binary/random", testBuffer);
|
||||
var testBlob = new Blob([testBuffer], {type: "binary/random"});
|
||||
|
||||
for each (let fileStorage in fileStorages) {
|
||||
let request = getMutableFile(fileStorage.key, "test.txt");
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
var testBuffer = getRandomBuffer(100000);
|
||||
|
||||
var testBlob = getBlob("binary/random", testBuffer);
|
||||
var testBlob = new Blob([testBuffer], {type: "binary/random"});
|
||||
|
||||
for each (let fileStorage in fileStorages) {
|
||||
let request = getMutableFile(fileStorage.key, "test.txt");
|
||||
|
@ -49,12 +49,12 @@ function compareBuffers(buffer1, buffer2)
|
||||
|
||||
function getBlob(type, view)
|
||||
{
|
||||
return SpecialPowers.unwrap(utils.getBlob([view], {type: type}));
|
||||
return new Blob([view], {type: type});
|
||||
}
|
||||
|
||||
function getFile(name, type, view)
|
||||
{
|
||||
return SpecialPowers.unwrap(utils.getFile(name, [view], {type: type}));
|
||||
return new File([view], name, {type: type});
|
||||
}
|
||||
|
||||
function getRandomBlob(size)
|
||||
|
@ -48,7 +48,7 @@ interface nsIRunnable;
|
||||
interface nsICompositionStringSynthesizer;
|
||||
interface nsITranslationNodeList;
|
||||
|
||||
[scriptable, uuid(75b7674b-3e6e-4fac-931b-8fd3c4e4e8d2)]
|
||||
[scriptable, uuid(6f10cbf8-bd4e-4c56-8a5a-35641efcf286)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
@ -1438,24 +1438,6 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
*/
|
||||
boolean checkAndClearPaintedState(in nsIDOMElement aElement);
|
||||
|
||||
/**
|
||||
* Internal file constructor intended for testing of File objects.
|
||||
* Example of constructor usage:
|
||||
* getFile("myfile.txt", [b1, "foo"], { type: "text/plain" })
|
||||
*/
|
||||
[optional_argc, implicit_jscontext]
|
||||
nsIDOMFile getFile(in DOMString aName, [optional] in jsval aBlobParts,
|
||||
[optional] in jsval aParameters);
|
||||
|
||||
/**
|
||||
* Internal blob constructor intended for testing of Blob objects.
|
||||
* Example of constructor usage:
|
||||
* getBlob([b1, "foo"], { type: "text/plain" })
|
||||
*/
|
||||
[optional_argc, implicit_jscontext]
|
||||
nsIDOMBlob getBlob([optional] in jsval aBlobParts,
|
||||
[optional] in jsval aParameters);
|
||||
|
||||
/**
|
||||
* Get internal id of the stored blob, file or file handle.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user