Bug 720697 - Provide internal API to get canvas image data as nsIInputStream; r=khuey

This commit is contained in:
Tim Taubert 2012-02-01 01:13:44 +01:00
Родитель f0a2b56387
Коммит 97bb2ea404
3 изменённых файлов: 29 добавлений и 1 удалений

Просмотреть файл

@ -216,6 +216,28 @@ nsHTMLCanvasElement::ToDataURL(const nsAString& aType, nsIVariant* aParams,
return ToDataURLImpl(aType, aParams, aDataURL);
}
// nsHTMLCanvasElement::mozFetchAsStream
NS_IMETHODIMP
nsHTMLCanvasElement::MozFetchAsStream(nsIInputStreamCallback *aCallback,
const nsAString& aType)
{
if (!nsContentUtils::IsCallerChrome())
return NS_ERROR_FAILURE;
nsresult rv;
bool fellBackToPNG = false;
nsCOMPtr<nsIInputStream> inputData;
rv = ExtractData(aType, EmptyString(), getter_AddRefs(inputData), fellBackToPNG);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAsyncInputStream> asyncData = do_QueryInterface(inputData, &rv);
NS_ENSURE_SUCCESS(rv, rv);
return aCallback->OnInputStreamReady(asyncData);
}
nsresult
nsHTMLCanvasElement::ExtractData(const nsAString& aType,
const nsAString& aOptions,

Просмотреть файл

@ -54,6 +54,7 @@
interface nsIDOMFile;
interface nsIVariant;
interface nsIInputStreamCallback;
[scriptable, uuid(8cddbc86-f384-40ac-835b-fe3e00630cad)]
interface nsIDOMHTMLCanvasElement : nsIDOMHTMLElement
@ -82,5 +83,10 @@ interface nsIDOMHTMLCanvasElement : nsIDOMHTMLElement
// A Mozilla-only extension to get a canvas context backed by double-buffered
// shared memory. Only privileged callers can call this.
nsISupports MozGetIPCContext(in DOMString contextId);
// A Mozilla-only extension that returns the canvas' image data as a data
// stream in the desired image format.
void mozFetchAsStream(in nsIInputStreamCallback callback,
[optional] in DOMString type);
};

Просмотреть файл

@ -124,7 +124,7 @@ interface nsIAsyncInputStream : nsIInputStream
/**
* This is a companion interface for nsIAsyncInputStream::asyncWait.
*/
[scriptable, uuid(d1f28e94-3a6e-4050-a5f5-2e81b1fc2a43)]
[function, scriptable, uuid(d1f28e94-3a6e-4050-a5f5-2e81b1fc2a43)]
interface nsIInputStreamCallback : nsISupports
{
/**