2008-01-12 20:15:20 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-01-12 20:15:20 -08:00
|
|
|
|
|
|
|
#include "imgTools.h"
|
2013-03-17 00:55:15 -07:00
|
|
|
|
2014-04-15 11:02:23 -07:00
|
|
|
#include "gfxUtils.h"
|
2014-02-24 16:51:45 -08:00
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
2008-01-12 20:15:20 -08:00
|
|
|
#include "nsCOMPtr.h"
|
2013-03-17 00:55:15 -07:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2012-11-16 10:24:58 -08:00
|
|
|
#include "imgLoader.h"
|
2012-06-25 21:20:12 -07:00
|
|
|
#include "imgICache.h"
|
2008-01-12 20:15:20 -08:00
|
|
|
#include "imgIContainer.h"
|
|
|
|
#include "imgIEncoder.h"
|
2009-07-21 15:57:25 -07:00
|
|
|
#include "nsStreamUtils.h"
|
2012-06-25 21:20:12 -07:00
|
|
|
#include "nsContentUtils.h"
|
2012-12-17 17:35:07 -08:00
|
|
|
#include "ImageFactory.h"
|
2013-02-13 13:53:42 -08:00
|
|
|
#include "Image.h"
|
2012-10-12 09:11:22 -07:00
|
|
|
#include "ScriptedNotificationObserver.h"
|
|
|
|
#include "imgIScriptedNotificationObserver.h"
|
2013-10-15 18:00:31 -07:00
|
|
|
#include "gfxPlatform.h"
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2013-10-15 18:00:31 -07:00
|
|
|
using namespace mozilla;
|
2012-01-06 08:02:27 -08:00
|
|
|
using namespace mozilla::image;
|
2013-10-15 18:00:31 -07:00
|
|
|
using namespace mozilla::gfx;
|
2010-08-13 21:09:49 -07:00
|
|
|
|
2008-01-12 20:15:20 -08:00
|
|
|
/* ========== imgITools implementation ========== */
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(imgTools, imgITools)
|
2008-01-12 20:15:20 -08:00
|
|
|
|
|
|
|
imgTools::imgTools()
|
|
|
|
{
|
|
|
|
/* member initializers and constructor code */
|
|
|
|
}
|
|
|
|
|
|
|
|
imgTools::~imgTools()
|
|
|
|
{
|
|
|
|
/* destructor code */
|
|
|
|
}
|
|
|
|
|
2015-04-02 13:41:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
imgTools::DecodeImageData(nsIInputStream* aInStr,
|
|
|
|
const nsACString& aMimeType,
|
|
|
|
imgIContainer** aContainer)
|
2012-12-17 17:35:07 -08:00
|
|
|
{
|
2015-02-09 14:34:50 -08:00
|
|
|
MOZ_ASSERT(*aContainer == nullptr,
|
|
|
|
"Cannot provide an existing image container to DecodeImageData");
|
2012-12-17 17:35:07 -08:00
|
|
|
|
|
|
|
return DecodeImage(aInStr, aMimeType, aContainer);
|
|
|
|
}
|
|
|
|
|
2015-04-02 13:41:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
imgTools::DecodeImage(nsIInputStream* aInStr,
|
|
|
|
const nsACString& aMimeType,
|
|
|
|
imgIContainer** aContainer)
|
2008-01-12 20:15:20 -08:00
|
|
|
{
|
2015-07-31 18:10:31 -07:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2008-01-12 20:15:20 -08:00
|
|
|
nsresult rv;
|
|
|
|
|
2009-09-12 15:44:18 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aInStr);
|
2010-08-13 21:09:49 -07:00
|
|
|
|
2012-12-17 17:35:07 -08:00
|
|
|
// Create a new image container to hold the decoded data.
|
|
|
|
nsAutoCString mimeType(aMimeType);
|
2014-11-14 20:10:48 -08:00
|
|
|
nsRefPtr<image::Image> image = ImageFactory::CreateAnonymousImage(mimeType);
|
|
|
|
nsRefPtr<ProgressTracker> tracker = image->GetProgressTracker();
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2015-04-02 13:41:00 -07:00
|
|
|
if (image->HasError()) {
|
2012-12-17 17:35:07 -08:00
|
|
|
return NS_ERROR_FAILURE;
|
2015-04-02 13:41:00 -07:00
|
|
|
}
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2012-12-17 17:35:07 -08:00
|
|
|
// Prepare the input stream.
|
2009-07-21 15:57:25 -07:00
|
|
|
nsCOMPtr<nsIInputStream> inStream = aInStr;
|
|
|
|
if (!NS_InputStreamIsBuffered(aInStr)) {
|
|
|
|
nsCOMPtr<nsIInputStream> bufStream;
|
|
|
|
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream), aInStr, 1024);
|
2015-04-02 13:41:00 -07:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2009-07-21 15:57:25 -07:00
|
|
|
inStream = bufStream;
|
2015-04-02 13:41:00 -07:00
|
|
|
}
|
2009-07-21 15:57:25 -07:00
|
|
|
}
|
|
|
|
|
2012-12-17 17:35:07 -08:00
|
|
|
// Figure out how much data we've been passed.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t length;
|
2009-07-21 15:57:25 -07:00
|
|
|
rv = inStream->Available(&length);
|
2008-01-12 20:15:20 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-09-27 23:57:33 -07:00
|
|
|
NS_ENSURE_TRUE(length <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2012-12-17 17:35:07 -08:00
|
|
|
// Send the source data to the Image.
|
2015-04-02 13:41:00 -07:00
|
|
|
rv = image->OnImageDataAvailable(nullptr, nullptr, inStream, 0,
|
|
|
|
uint32_t(length));
|
2008-01-12 20:15:20 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2014-11-14 20:10:48 -08:00
|
|
|
|
2012-12-17 17:35:07 -08:00
|
|
|
// Let the Image know we've sent all the data.
|
2013-02-13 18:41:10 -08:00
|
|
|
rv = image->OnImageDataComplete(nullptr, nullptr, NS_OK, true);
|
2014-11-17 14:29:56 -08:00
|
|
|
tracker->SyncNotifyProgress(FLAG_LOAD_COMPLETE);
|
2009-09-12 15:44:18 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-12-17 17:35:07 -08:00
|
|
|
// All done.
|
|
|
|
NS_ADDREF(*aContainer = image.get());
|
2008-01-12 20:15:20 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
/**
|
|
|
|
* This takes a DataSourceSurface rather than a SourceSurface because some
|
|
|
|
* of the callers have a DataSourceSurface and we don't want to call
|
|
|
|
* GetDataSurface on such surfaces since that may incure a conversion to
|
|
|
|
* SurfaceType::DATA which we don't need.
|
|
|
|
*/
|
2015-04-02 13:41:00 -07:00
|
|
|
static nsresult
|
|
|
|
EncodeImageData(DataSourceSurface* aDataSurface,
|
|
|
|
const nsACString& aMimeType,
|
|
|
|
const nsAString& aOutputOptions,
|
|
|
|
nsIInputStream** aStream)
|
2014-02-24 16:51:45 -08:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aDataSurface->GetFormat() == SurfaceFormat::B8G8R8A8,
|
|
|
|
"We're assuming B8G8R8A8");
|
|
|
|
|
|
|
|
// Get an image encoder for the media type
|
|
|
|
nsAutoCString encoderCID(
|
|
|
|
NS_LITERAL_CSTRING("@mozilla.org/image/encoder;2?type=") + aMimeType);
|
|
|
|
|
|
|
|
nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(encoderCID.get());
|
2015-04-02 13:41:00 -07:00
|
|
|
if (!encoder) {
|
2014-02-24 16:51:45 -08:00
|
|
|
return NS_IMAGELIB_ERROR_NO_ENCODER;
|
2015-04-02 13:41:00 -07:00
|
|
|
}
|
2014-02-24 16:51:45 -08:00
|
|
|
|
|
|
|
DataSourceSurface::MappedSurface map;
|
2014-03-07 05:21:38 -08:00
|
|
|
if (!aDataSurface->Map(DataSourceSurface::MapType::READ, &map)) {
|
2014-02-24 16:51:45 -08:00
|
|
|
return NS_ERROR_FAILURE;
|
2014-03-07 05:21:38 -08:00
|
|
|
}
|
2014-02-24 16:51:45 -08:00
|
|
|
|
|
|
|
IntSize size = aDataSurface->GetSize();
|
|
|
|
uint32_t dataLength = map.mStride * size.height;
|
|
|
|
|
|
|
|
// Encode the bitmap
|
|
|
|
nsresult rv = encoder->InitFromData(map.mData,
|
|
|
|
dataLength,
|
|
|
|
size.width,
|
|
|
|
size.height,
|
|
|
|
map.mStride,
|
|
|
|
imgIEncoder::INPUT_FORMAT_HOSTARGB,
|
|
|
|
aOutputOptions);
|
2014-03-07 05:21:38 -08:00
|
|
|
aDataSurface->Unmap();
|
2014-02-24 16:51:45 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2015-03-12 10:20:29 -07:00
|
|
|
encoder.forget(aStream);
|
|
|
|
return NS_OK;
|
2014-02-24 16:51:45 -08:00
|
|
|
}
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2015-04-02 13:41:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
imgTools::EncodeImage(imgIContainer* aContainer,
|
|
|
|
const nsACString& aMimeType,
|
|
|
|
const nsAString& aOutputOptions,
|
|
|
|
nsIInputStream** aStream)
|
2008-01-12 20:15:20 -08:00
|
|
|
{
|
2012-07-02 23:22:10 -07:00
|
|
|
// Use frame 0 from the image container.
|
2014-04-15 11:02:23 -07:00
|
|
|
RefPtr<SourceSurface> frame =
|
|
|
|
aContainer->GetFrame(imgIContainer::FRAME_FIRST,
|
|
|
|
imgIContainer::FLAG_SYNC_DECODE);
|
2014-02-24 16:51:45 -08:00
|
|
|
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
|
|
|
|
2014-04-15 11:02:23 -07:00
|
|
|
RefPtr<DataSourceSurface> dataSurface;
|
|
|
|
|
|
|
|
if (frame->GetFormat() == SurfaceFormat::B8G8R8A8) {
|
|
|
|
dataSurface = frame->GetDataSurface();
|
|
|
|
} else {
|
|
|
|
// Convert format to SurfaceFormat::B8G8R8A8
|
|
|
|
dataSurface = gfxUtils::
|
|
|
|
CopySurfaceToDataSourceSurfaceWithFormat(frame,
|
|
|
|
SurfaceFormat::B8G8R8A8);
|
|
|
|
}
|
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
|
2012-07-02 23:22:10 -07:00
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
|
2008-01-12 20:15:20 -08:00
|
|
|
}
|
|
|
|
|
2015-04-02 13:41:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
imgTools::EncodeScaledImage(imgIContainer* aContainer,
|
|
|
|
const nsACString& aMimeType,
|
|
|
|
int32_t aScaledWidth,
|
|
|
|
int32_t aScaledHeight,
|
|
|
|
const nsAString& aOutputOptions,
|
|
|
|
nsIInputStream** aStream)
|
2008-01-12 20:15:20 -08:00
|
|
|
{
|
2012-07-02 23:22:10 -07:00
|
|
|
NS_ENSURE_ARG(aScaledWidth >= 0 && aScaledHeight >= 0);
|
2008-01-12 20:15:20 -08:00
|
|
|
|
|
|
|
// If no scaled size is specified, we'll just encode the image at its
|
|
|
|
// original size (no scaling).
|
|
|
|
if (aScaledWidth == 0 && aScaledHeight == 0) {
|
2012-07-02 23:22:10 -07:00
|
|
|
return EncodeImage(aContainer, aMimeType, aOutputOptions, aStream);
|
2008-01-12 20:15:20 -08:00
|
|
|
}
|
|
|
|
|
2012-07-02 23:22:10 -07:00
|
|
|
// Use frame 0 from the image container.
|
2014-04-15 11:02:23 -07:00
|
|
|
RefPtr<SourceSurface> frame =
|
|
|
|
aContainer->GetFrame(imgIContainer::FRAME_FIRST,
|
|
|
|
imgIContainer::FLAG_SYNC_DECODE);
|
2014-02-24 16:51:45 -08:00
|
|
|
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
int32_t frameWidth = frame->GetSize().width;
|
|
|
|
int32_t frameHeight = frame->GetSize().height;
|
2012-07-02 23:22:10 -07:00
|
|
|
|
|
|
|
// If the given width or height is zero we'll replace it with the image's
|
|
|
|
// original dimensions.
|
|
|
|
if (aScaledWidth == 0) {
|
|
|
|
aScaledWidth = frameWidth;
|
|
|
|
} else if (aScaledHeight == 0) {
|
|
|
|
aScaledHeight = frameHeight;
|
|
|
|
}
|
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
RefPtr<DataSourceSurface> dataSurface =
|
|
|
|
Factory::CreateDataSourceSurface(IntSize(aScaledWidth, aScaledHeight),
|
|
|
|
SurfaceFormat::B8G8R8A8);
|
2014-08-27 08:57:43 -07:00
|
|
|
if (NS_WARN_IF(!dataSurface)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
DataSourceSurface::MappedSurface map;
|
2014-03-07 05:21:38 -08:00
|
|
|
if (!dataSurface->Map(DataSourceSurface::MapType::WRITE, &map)) {
|
2014-02-24 16:51:45 -08:00
|
|
|
return NS_ERROR_FAILURE;
|
2014-03-07 05:21:38 -08:00
|
|
|
}
|
2012-07-02 23:22:10 -07:00
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
RefPtr<DrawTarget> dt =
|
|
|
|
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
|
|
|
map.mData,
|
|
|
|
dataSurface->GetSize(),
|
|
|
|
map.mStride,
|
|
|
|
SurfaceFormat::B8G8R8A8);
|
2015-03-09 12:48:20 -07:00
|
|
|
if (!dt) {
|
|
|
|
gfxWarning() << "imgTools::EncodeImage failed in CreateDrawTargetForData";
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
dt->DrawSurface(frame,
|
|
|
|
Rect(0, 0, aScaledWidth, aScaledHeight),
|
|
|
|
Rect(0, 0, frameWidth, frameHeight),
|
|
|
|
DrawSurfaceOptions(),
|
|
|
|
DrawOptions(1.0f, CompositionOp::OP_SOURCE));
|
|
|
|
|
2014-03-07 05:21:38 -08:00
|
|
|
dataSurface->Unmap();
|
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
|
2012-07-02 23:22:10 -07:00
|
|
|
}
|
|
|
|
|
2015-04-02 13:41:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
imgTools::EncodeCroppedImage(imgIContainer* aContainer,
|
|
|
|
const nsACString& aMimeType,
|
|
|
|
int32_t aOffsetX,
|
|
|
|
int32_t aOffsetY,
|
|
|
|
int32_t aWidth,
|
|
|
|
int32_t aHeight,
|
|
|
|
const nsAString& aOutputOptions,
|
|
|
|
nsIInputStream** aStream)
|
2012-07-02 23:22:10 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aOffsetX >= 0 && aOffsetY >= 0 && aWidth >= 0 && aHeight >= 0);
|
|
|
|
|
|
|
|
// Offsets must be zero when no width and height are given or else we're out
|
|
|
|
// of bounds.
|
|
|
|
NS_ENSURE_ARG(aWidth + aHeight > 0 || aOffsetX + aOffsetY == 0);
|
|
|
|
|
|
|
|
// If no size is specified then we'll preserve the image's original dimensions
|
|
|
|
// and don't need to crop.
|
|
|
|
if (aWidth == 0 && aHeight == 0) {
|
|
|
|
return EncodeImage(aContainer, aMimeType, aOutputOptions, aStream);
|
|
|
|
}
|
2008-01-12 20:15:20 -08:00
|
|
|
|
|
|
|
// Use frame 0 from the image container.
|
2014-04-15 11:02:23 -07:00
|
|
|
RefPtr<SourceSurface> frame =
|
|
|
|
aContainer->GetFrame(imgIContainer::FRAME_FIRST,
|
|
|
|
imgIContainer::FLAG_SYNC_DECODE);
|
2014-02-24 16:51:45 -08:00
|
|
|
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
int32_t frameWidth = frame->GetSize().width;
|
|
|
|
int32_t frameHeight = frame->GetSize().height;
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2012-07-02 23:22:10 -07:00
|
|
|
// If the given width or height is zero we'll replace it with the image's
|
|
|
|
// original dimensions.
|
|
|
|
if (aWidth == 0) {
|
|
|
|
aWidth = frameWidth;
|
|
|
|
} else if (aHeight == 0) {
|
|
|
|
aHeight = frameHeight;
|
|
|
|
}
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2012-07-02 23:22:10 -07:00
|
|
|
// Check that the given crop rectangle is within image bounds.
|
|
|
|
NS_ENSURE_ARG(frameWidth >= aOffsetX + aWidth &&
|
|
|
|
frameHeight >= aOffsetY + aHeight);
|
2008-01-12 20:15:20 -08:00
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
RefPtr<DataSourceSurface> dataSurface =
|
|
|
|
Factory::CreateDataSourceSurface(IntSize(aWidth, aHeight),
|
2014-09-10 14:54:16 -07:00
|
|
|
SurfaceFormat::B8G8R8A8,
|
|
|
|
/* aZero = */ true);
|
2014-08-27 08:57:43 -07:00
|
|
|
if (NS_WARN_IF(!dataSurface)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
DataSourceSurface::MappedSurface map;
|
2014-03-07 05:21:38 -08:00
|
|
|
if (!dataSurface->Map(DataSourceSurface::MapType::WRITE, &map)) {
|
2012-07-02 23:22:10 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2014-03-07 05:21:38 -08:00
|
|
|
}
|
2012-07-02 23:22:10 -07:00
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
RefPtr<DrawTarget> dt =
|
|
|
|
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
|
|
|
map.mData,
|
|
|
|
dataSurface->GetSize(),
|
|
|
|
map.mStride,
|
|
|
|
SurfaceFormat::B8G8R8A8);
|
2015-03-09 12:48:20 -07:00
|
|
|
if (!dt) {
|
2015-04-02 13:41:00 -07:00
|
|
|
gfxWarning() <<
|
|
|
|
"imgTools::EncodeCroppedImage failed in CreateDrawTargetForData";
|
2015-03-09 12:48:20 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2014-02-24 16:51:45 -08:00
|
|
|
dt->CopySurface(frame,
|
|
|
|
IntRect(aOffsetX, aOffsetY, aWidth, aHeight),
|
|
|
|
IntPoint(0, 0));
|
|
|
|
|
2014-03-07 05:21:38 -08:00
|
|
|
dataSurface->Unmap();
|
|
|
|
|
2014-02-24 16:51:45 -08:00
|
|
|
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
|
2012-07-02 23:22:10 -07:00
|
|
|
}
|
2012-06-25 21:20:12 -07:00
|
|
|
|
2015-04-02 13:41:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
imgTools::CreateScriptedObserver(imgIScriptedNotificationObserver* aInner,
|
|
|
|
imgINotificationObserver** aObserver)
|
2012-10-12 09:11:22 -07:00
|
|
|
{
|
|
|
|
NS_ADDREF(*aObserver = new ScriptedNotificationObserver(aInner));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-25 21:20:12 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
imgTools::GetImgLoaderForDocument(nsIDOMDocument* aDoc, imgILoader** aLoader)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
|
|
|
|
NS_IF_ADDREF(*aLoader = nsContentUtils::GetImgLoaderForDocument(doc));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
imgTools::GetImgCacheForDocument(nsIDOMDocument* aDoc, imgICache** aCache)
|
|
|
|
{
|
|
|
|
nsCOMPtr<imgILoader> loader;
|
|
|
|
nsresult rv = GetImgLoaderForDocument(aDoc, getter_AddRefs(loader));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
return CallQueryInterface(loader, aCache);
|
|
|
|
}
|