Bug 1387790 - Remove [deprecated] decodeImageData from imgITools. r=tnikkel

MozReview-Commit-ID: GZBYTPanHH6

--HG--
extra : rebase_source : f6ccc1a661533f7bdba8bb33bc9a85855b51ffae
This commit is contained in:
Masatoshi Kimura 2017-08-06 10:54:14 +09:00
Родитель 3a780753fe
Коммит 6815cee2bd
10 изменённых файлов: 15 добавлений и 55 удалений

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

@ -150,7 +150,7 @@ exports.set = function(aData, aDataType) {
case "image/png":
let image = options.data;
let container = {};
let container;
try {
let input = Cc["@mozilla.org/io/string-input-stream;1"].
@ -158,7 +158,7 @@ exports.set = function(aData, aDataType) {
input.setData(image, image.length);
imageTools.decodeImageData(input, flavor, container);
container = imageTools.decodeImage(input, flavor);
}
catch (e) {
throw new Error("Unable to decode data given in a valid image.");
@ -171,7 +171,7 @@ exports.set = function(aData, aDataType) {
var imgPtr = Cc["@mozilla.org/supports-interface-pointer;1"].
createInstance(Ci.nsISupportsInterfacePointer);
imgPtr.data = container.value;
imgPtr.data = container;
xferable.addDataFlavor(flavor);
xferable.setTransferData(flavor, imgPtr, -1);

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

@ -151,7 +151,7 @@ exports["test Set Image Type Not Supported"] = function(assert) {
};
// Notice that `imageTools.decodeImageData`, used by `clipboard.set` method for
// Notice that `imageTools.decodeImage`, used by `clipboard.set` method for
// images, write directly to the javascript console the error in case the image
// is corrupt, even if the error is catched.
//

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

@ -87,9 +87,8 @@ function _imageFromURI(uri, privateMode, callback) {
if (!Components.isSuccessCode(resultCode))
return;
try {
let out_img = { value: null };
imgTools.decodeImageData(inputStream, channel.contentType, out_img);
callback(out_img.value);
let out_img = imgTools.decodeImage(inputStream, channel.contentType);
callback(out_img);
} catch (e) {
// We failed, so use the default favicon (only if this wasn't the default
// favicon).

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

@ -383,12 +383,11 @@ function saveToClipboard(context, reply) {
const imgTools = Cc["@mozilla.org/image/tools;1"]
.getService(Ci.imgITools);
const container = {};
imgTools.decodeImageData(input, channel.contentType, container);
const container = imgTools.decodeImage(input, channel.contentType);
const wrapped = Cc["@mozilla.org/supports-interface-pointer;1"]
.createInstance(Ci.nsISupportsInterfacePointer);
wrapped.data = container.value;
wrapped.data = container;
const trans = Cc["@mozilla.org/widget/transferable;1"]
.createInstance(Ci.nsITransferable);

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

@ -31,28 +31,6 @@ interface imgITools : nsISupports
imgIContainer decodeImage(in nsIInputStream aStream,
in ACString aMimeType);
/**
* decodeImageData
* Caller provides an input stream and mimetype. We read from the stream
* and decompress it (according to the specified mime type) and return
* the resulting imgIContainer.
*
* This method is deprecated and will be removed at some time in the future;
* new code should use |decodeImage|.
*
* @param aStream
* An input stream for an encoded image file.
* @param aMimeType
* Type of image in the stream.
* @param aContainer
* An imgIContainer holding the decoded image will be returned via
* this parameter. It is an error to provide any initial value but
* |null|.
*/
[deprecated] void decodeImageData(in nsIInputStream aStream,
in ACString aMimeType,
inout imgIContainer aContainer);
/**
* encodeImage
* Caller provides an image container, and the mime type it should be

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

@ -46,17 +46,6 @@ imgTools::~imgTools()
/* destructor code */
}
NS_IMETHODIMP
imgTools::DecodeImageData(nsIInputStream* aInStr,
const nsACString& aMimeType,
imgIContainer** aContainer)
{
MOZ_ASSERT(*aContainer == nullptr,
"Cannot provide an existing image container to DecodeImageData");
return DecodeImage(aInStr, aMimeType, aContainer);
}
NS_IMETHODIMP
imgTools::DecodeImage(nsIInputStream* aInStr,
const nsACString& aMimeType,

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

@ -145,11 +145,7 @@ var imgFile = do_get_file(imgName);
var istream = getFileInputStream(imgFile);
do_check_eq(istream.available(), 8415);
// Use decodeImageData for this test even though it's deprecated to ensure that
// it correctly forwards to decodeImage and continues to work.
var outParam = { value: null };
imgTools.decodeImageData(istream, inMimeType, outParam);
var container = outParam.value;
var container = imgTools.decodeImage(istream, inMimeType);
// It's not easy to look at the pixel values from JS, so just
// check the container's size.

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

@ -825,8 +825,8 @@ nsFaviconService::OptimizeIconSizes(IconData& aIcon)
// decode image
nsCOMPtr<imgIContainer> container;
rv = GetImgTools()->DecodeImageData(stream, payload.mimeType,
getter_AddRefs(container));
rv = GetImgTools()->DecodeImage(stream, payload.mimeType,
getter_AddRefs(container));
NS_ENSURE_SUCCESS(rv, rv);
// For ICO files, we must evaluate each of the frames we care about.

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

@ -151,13 +151,13 @@ XPCOMUtils.defineLazyModuleGetter(ImageFile, "_netUtil",
var ImageTools = {
decode(aInputStream, aContentType) {
let outParam = {value: null};
let outParam = null;
try {
this._imgTools.decodeImageData(aInputStream, aContentType, outParam);
outParam = this._imgTools.decodeImage(aInputStream, aContentType);
} catch (e) {}
return outParam.value;
return outParam;
},
encode(aImage, aScreen, aOrigin, aContentType) {

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

@ -1295,8 +1295,7 @@ AsyncFaviconDataReady::OnComplete(nsIURI *aFaviconURI,
// Decode the image from the format it was returned to us in (probably PNG)
nsCOMPtr<imgIContainer> container;
nsCOMPtr<imgITools> imgtool = do_CreateInstance("@mozilla.org/image/tools;1");
rv = imgtool->DecodeImageData(stream, aMimeType,
getter_AddRefs(container));
rv = imgtool->DecodeImage(stream, aMimeType, getter_AddRefs(container));
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<SourceSurface> surface =