mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1102048 (Part 30, imgTools) - Make image/src files comply with the Mozilla Coding Style Guide. r=seth
This commit is contained in:
parent
abf7e02404
commit
3eda954ef7
@ -45,7 +45,8 @@ imgTools::~imgTools()
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::DecodeImageData(nsIInputStream* aInStr,
|
||||
NS_IMETHODIMP
|
||||
imgTools::DecodeImageData(nsIInputStream* aInStr,
|
||||
const nsACString& aMimeType,
|
||||
imgIContainer** aContainer)
|
||||
{
|
||||
@ -55,7 +56,8 @@ NS_IMETHODIMP imgTools::DecodeImageData(nsIInputStream* aInStr,
|
||||
return DecodeImage(aInStr, aMimeType, aContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
NS_IMETHODIMP
|
||||
imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
const nsACString& aMimeType,
|
||||
imgIContainer** aContainer)
|
||||
{
|
||||
@ -68,17 +70,19 @@ NS_IMETHODIMP imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
nsRefPtr<image::Image> image = ImageFactory::CreateAnonymousImage(mimeType);
|
||||
nsRefPtr<ProgressTracker> tracker = image->GetProgressTracker();
|
||||
|
||||
if (image->HasError())
|
||||
if (image->HasError()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Prepare the input stream.
|
||||
nsCOMPtr<nsIInputStream> inStream = aInStr;
|
||||
if (!NS_InputStreamIsBuffered(aInStr)) {
|
||||
nsCOMPtr<nsIInputStream> bufStream;
|
||||
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream), aInStr, 1024);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
inStream = bufStream;
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out how much data we've been passed.
|
||||
uint64_t length;
|
||||
@ -87,7 +91,8 @@ NS_IMETHODIMP imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
NS_ENSURE_TRUE(length <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
|
||||
|
||||
// Send the source data to the Image.
|
||||
rv = image->OnImageDataAvailable(nullptr, nullptr, inStream, 0, uint32_t(length));
|
||||
rv = image->OnImageDataAvailable(nullptr, nullptr, inStream, 0,
|
||||
uint32_t(length));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Let the Image know we've sent all the data.
|
||||
@ -106,7 +111,8 @@ NS_IMETHODIMP imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
* GetDataSurface on such surfaces since that may incure a conversion to
|
||||
* SurfaceType::DATA which we don't need.
|
||||
*/
|
||||
static nsresult EncodeImageData(DataSourceSurface* aDataSurface,
|
||||
static nsresult
|
||||
EncodeImageData(DataSourceSurface* aDataSurface,
|
||||
const nsACString& aMimeType,
|
||||
const nsAString& aOutputOptions,
|
||||
nsIInputStream** aStream)
|
||||
@ -119,8 +125,9 @@ static nsresult EncodeImageData(DataSourceSurface* aDataSurface,
|
||||
NS_LITERAL_CSTRING("@mozilla.org/image/encoder;2?type=") + aMimeType);
|
||||
|
||||
nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(encoderCID.get());
|
||||
if (!encoder)
|
||||
if (!encoder) {
|
||||
return NS_IMAGELIB_ERROR_NO_ENCODER;
|
||||
}
|
||||
|
||||
DataSourceSurface::MappedSurface map;
|
||||
if (!aDataSurface->Map(DataSourceSurface::MapType::READ, &map)) {
|
||||
@ -145,7 +152,8 @@ static nsresult EncodeImageData(DataSourceSurface* aDataSurface,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::EncodeImage(imgIContainer *aContainer,
|
||||
NS_IMETHODIMP
|
||||
imgTools::EncodeImage(imgIContainer* aContainer,
|
||||
const nsACString& aMimeType,
|
||||
const nsAString& aOutputOptions,
|
||||
nsIInputStream** aStream)
|
||||
@ -172,7 +180,8 @@ NS_IMETHODIMP imgTools::EncodeImage(imgIContainer *aContainer,
|
||||
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::EncodeScaledImage(imgIContainer *aContainer,
|
||||
NS_IMETHODIMP
|
||||
imgTools::EncodeScaledImage(imgIContainer* aContainer,
|
||||
const nsACString& aMimeType,
|
||||
int32_t aScaledWidth,
|
||||
int32_t aScaledHeight,
|
||||
@ -238,7 +247,8 @@ NS_IMETHODIMP imgTools::EncodeScaledImage(imgIContainer *aContainer,
|
||||
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::EncodeCroppedImage(imgIContainer *aContainer,
|
||||
NS_IMETHODIMP
|
||||
imgTools::EncodeCroppedImage(imgIContainer* aContainer,
|
||||
const nsACString& aMimeType,
|
||||
int32_t aOffsetX,
|
||||
int32_t aOffsetY,
|
||||
@ -300,7 +310,8 @@ NS_IMETHODIMP imgTools::EncodeCroppedImage(imgIContainer *aContainer,
|
||||
map.mStride,
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
if (!dt) {
|
||||
gfxWarning() << "imgTools::EncodeCroppedImage failed in CreateDrawTargetForData";
|
||||
gfxWarning() <<
|
||||
"imgTools::EncodeCroppedImage failed in CreateDrawTargetForData";
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
dt->CopySurface(frame,
|
||||
@ -312,7 +323,8 @@ NS_IMETHODIMP imgTools::EncodeCroppedImage(imgIContainer *aContainer,
|
||||
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::CreateScriptedObserver(imgIScriptedNotificationObserver* aInner,
|
||||
NS_IMETHODIMP
|
||||
imgTools::CreateScriptedObserver(imgIScriptedNotificationObserver* aInner,
|
||||
imgINotificationObserver** aObserver)
|
||||
{
|
||||
NS_ADDREF(*aObserver = new ScriptedNotificationObserver(aInner));
|
||||
|
@ -4,6 +4,9 @@
|
||||
* 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/. */
|
||||
|
||||
#ifndef mozilla_image_src_imgITools_h
|
||||
#define mozilla_image_src_imgITools_h
|
||||
|
||||
#include "imgITools.h"
|
||||
|
||||
#define NS_IMGTOOLS_CID \
|
||||
@ -25,3 +28,4 @@ public:
|
||||
private:
|
||||
virtual ~imgTools();
|
||||
};
|
||||
#endif // mozilla_image_src_imgITools_h
|
||||
|
Loading…
Reference in New Issue
Block a user