Bug 1102048 - Make image/src files comply with the Mozilla Coding Style Guide. r=seth

This commit is contained in:
Glenn Randers-Pehrson 2014-12-05 15:58:00 -08:00
parent 219d9e1072
commit 86d650039c
5 changed files with 48 additions and 27 deletions

View File

@ -31,7 +31,8 @@ MOZ_END_ENUM_CLASS(Flip)
*/ */
struct Orientation struct Orientation
{ {
explicit Orientation(Angle aRotation = Angle::D0, Flip mFlip = Flip::Unflipped) explicit Orientation(Angle aRotation = Angle::D0,
Flip mFlip = Flip::Unflipped)
: rotation(aRotation) : rotation(aRotation)
, flip(mFlip) , flip(mFlip)
{ } { }

View File

@ -141,12 +141,13 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
gfxUtils::DrawPixelSnapped(ctx, drawable, size, gfxUtils::DrawPixelSnapped(ctx, drawable, size,
ImageRegion::Create(size), ImageRegion::Create(size),
surfaceFormat, GraphicsFilter::FILTER_FAST); surfaceFormat, GraphicsFilter::FILTER_FAST);
return target->Snapshot(); return target->Snapshot();
} }
NS_IMETHODIMP NS_IMETHODIMP
OrientedImage::GetImageContainer(LayerManager* aManager, ImageContainer** _retval) OrientedImage::GetImageContainer(LayerManager* aManager,
ImageContainer** _retval)
{ {
// XXX(seth): We currently don't have a way of orienting the result of // XXX(seth): We currently don't have a way of orienting the result of
// GetImageContainer. We work around this by always returning null, but if it // GetImageContainer. We work around this by always returning null, but if it
@ -168,7 +169,8 @@ struct MatrixBuilder
gfxMatrix Build() { return mMatrix; } gfxMatrix Build() { return mMatrix; }
void Scale(gfxFloat aX, gfxFloat aY) { void Scale(gfxFloat aX, gfxFloat aY)
{
if (mInvert) { if (mInvert) {
mMatrix *= gfxMatrix::Scaling(1.0 / aX, 1.0 / aY); mMatrix *= gfxMatrix::Scaling(1.0 / aX, 1.0 / aY);
} else { } else {
@ -176,7 +178,8 @@ struct MatrixBuilder
} }
} }
void Rotate(gfxFloat aPhi) { void Rotate(gfxFloat aPhi)
{
if (mInvert) { if (mInvert) {
mMatrix *= gfxMatrix::Rotation(-aPhi); mMatrix *= gfxMatrix::Rotation(-aPhi);
} else { } else {
@ -184,7 +187,8 @@ struct MatrixBuilder
} }
} }
void Translate(gfxPoint aDelta) { void Translate(gfxPoint aDelta)
{
if (mInvert) { if (mInvert) {
mMatrix *= gfxMatrix::Translation(-aDelta); mMatrix *= gfxMatrix::Translation(-aDelta);
} else { } else {
@ -310,11 +314,13 @@ OrientedImage::Draw(gfxContext* aContext,
} }
nsIntSize nsIntSize
OrientedImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame, OrientedImage::OptimalImageSizeForDest(const gfxSize& aDest,
uint32_t aWhichFrame,
GraphicsFilter aFilter, uint32_t aFlags) GraphicsFilter aFilter, uint32_t aFlags)
{ {
if (!mOrientation.SwapsWidthAndHeight()) { if (!mOrientation.SwapsWidthAndHeight()) {
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter, aFlags); return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter,
aFlags);
} }
// Swap the size for the calculation, then swap it back for the caller. // Swap the size for the calculation, then swap it back for the caller.

View File

@ -45,12 +45,13 @@ public:
GraphicsFilter aFilter, GraphicsFilter aFilter,
const Maybe<SVGImageContext>& aSVGContext, const Maybe<SVGImageContext>& aSVGContext,
uint32_t aFlags) MOZ_OVERRIDE; uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD_(nsIntRect) GetImageSpaceInvalidationRect(const nsIntRect& aRect) MOZ_OVERRIDE; NS_IMETHOD_(nsIntRect) GetImageSpaceInvalidationRect(
const nsIntRect& aRect) MOZ_OVERRIDE;
nsIntSize OptimalImageSizeForDest(const gfxSize& aDest, nsIntSize OptimalImageSizeForDest(const gfxSize& aDest,
uint32_t aWhichFrame, uint32_t aWhichFrame,
GraphicsFilter aFilter, GraphicsFilter aFilter,
uint32_t aFlags) MOZ_OVERRIDE; uint32_t aFlags) MOZ_OVERRIDE;
protected: protected:
OrientedImage(Image* aImage, Orientation aOrientation) OrientedImage(Image* aImage, Orientation aOrientation)
: ImageWrapper(aImage) : ImageWrapper(aImage)

View File

@ -107,7 +107,8 @@ ProgressTracker::ResetImage()
mImage = nullptr; mImage = nullptr;
} }
void ProgressTracker::SetIsMultipart() void
ProgressTracker::SetIsMultipart()
{ {
if (mProgress & FLAG_IS_MULTIPART) { if (mProgress & FLAG_IS_MULTIPART) {
return; return;
@ -218,9 +219,11 @@ ProgressTracker::Notify(imgRequestProxy* proxy)
nsRefPtr<ImageURL> uri(mImage->GetURI()); nsRefPtr<ImageURL> uri(mImage->GetURI());
nsAutoCString spec; nsAutoCString spec;
uri->GetSpec(spec); uri->GetSpec(spec);
LOG_FUNC_WITH_PARAM(GetImgLog(), "ProgressTracker::Notify async", "uri", spec.get()); LOG_FUNC_WITH_PARAM(GetImgLog(),
"ProgressTracker::Notify async", "uri", spec.get());
} else { } else {
LOG_FUNC_WITH_PARAM(GetImgLog(), "ProgressTracker::Notify async", "uri", "<unknown>"); LOG_FUNC_WITH_PARAM(GetImgLog(),
"ProgressTracker::Notify async", "uri", "<unknown>");
} }
#endif #endif
@ -283,7 +286,8 @@ ProgressTracker::NotifyCurrentState(imgRequestProxy* proxy)
proxy->GetURI(getter_AddRefs(uri)); proxy->GetURI(getter_AddRefs(uri));
nsAutoCString spec; nsAutoCString spec;
uri->GetSpec(spec); uri->GetSpec(spec);
LOG_FUNC_WITH_PARAM(GetImgLog(), "ProgressTracker::NotifyCurrentState", "uri", spec.get()); LOG_FUNC_WITH_PARAM(GetImgLog(),
"ProgressTracker::NotifyCurrentState", "uri", spec.get());
#endif #endif
proxy->SetNotificationsDeferred(true); proxy->SetNotificationsDeferred(true);
@ -311,31 +315,38 @@ ProgressTracker::SyncNotifyInternal(ProxyArray& aProxies,
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (aProgress & FLAG_SIZE_AVAILABLE) if (aProgress & FLAG_SIZE_AVAILABLE) {
NOTIFY_IMAGE_OBSERVERS(aProxies, OnSizeAvailable()); NOTIFY_IMAGE_OBSERVERS(aProxies, OnSizeAvailable());
}
if (aProgress & FLAG_DECODE_STARTED) if (aProgress & FLAG_DECODE_STARTED) {
NOTIFY_IMAGE_OBSERVERS(aProxies, OnStartDecode()); NOTIFY_IMAGE_OBSERVERS(aProxies, OnStartDecode());
}
if (aProgress & FLAG_ONLOAD_BLOCKED) if (aProgress & FLAG_ONLOAD_BLOCKED) {
NOTIFY_IMAGE_OBSERVERS(aProxies, BlockOnload()); NOTIFY_IMAGE_OBSERVERS(aProxies, BlockOnload());
}
if (aHasImage) { if (aHasImage) {
// OnFrameUpdate // OnFrameUpdate
// If there's any content in this frame at all (always true for // If there's any content in this frame at all (always true for
// vector images, true for raster images that have decoded at // vector images, true for raster images that have decoded at
// least one frame) then send OnFrameUpdate. // least one frame) then send OnFrameUpdate.
if (!aDirtyRect.IsEmpty()) if (!aDirtyRect.IsEmpty()) {
NOTIFY_IMAGE_OBSERVERS(aProxies, OnFrameUpdate(&aDirtyRect)); NOTIFY_IMAGE_OBSERVERS(aProxies, OnFrameUpdate(&aDirtyRect));
}
if (aProgress & FLAG_FRAME_COMPLETE) if (aProgress & FLAG_FRAME_COMPLETE) {
NOTIFY_IMAGE_OBSERVERS(aProxies, OnFrameComplete()); NOTIFY_IMAGE_OBSERVERS(aProxies, OnFrameComplete());
}
if (aProgress & FLAG_HAS_TRANSPARENCY) if (aProgress & FLAG_HAS_TRANSPARENCY) {
NOTIFY_IMAGE_OBSERVERS(aProxies, OnImageHasTransparency()); NOTIFY_IMAGE_OBSERVERS(aProxies, OnImageHasTransparency());
}
if (aProgress & FLAG_IS_ANIMATED) if (aProgress & FLAG_IS_ANIMATED) {
NOTIFY_IMAGE_OBSERVERS(aProxies, OnImageIsAnimated()); NOTIFY_IMAGE_OBSERVERS(aProxies, OnImageIsAnimated());
}
} }
// Send UnblockOnload before OnStopDecode and OnStopRequest. This allows // Send UnblockOnload before OnStopDecode and OnStopRequest. This allows
@ -358,7 +369,8 @@ ProgressTracker::SyncNotifyInternal(ProxyArray& aProxies,
void void
ProgressTracker::SyncNotifyProgress(Progress aProgress, ProgressTracker::SyncNotifyProgress(Progress aProgress,
const nsIntRect& aInvalidRect /* = nsIntRect() */) const nsIntRect& aInvalidRect
/* = nsIntRect() */)
{ {
MOZ_ASSERT(NS_IsMainThread(), "Use mConsumers on main thread only"); MOZ_ASSERT(NS_IsMainThread(), "Use mConsumers on main thread only");
@ -390,7 +402,8 @@ ProgressTracker::SyncNotify(imgRequestProxy* proxy)
proxy->GetURI(getter_AddRefs(uri)); proxy->GetURI(getter_AddRefs(uri));
nsAutoCString spec; nsAutoCString spec;
uri->GetSpec(spec); uri->GetSpec(spec);
LOG_SCOPE_WITH_PARAM(GetImgLog(), "ProgressTracker::SyncNotify", "uri", spec.get()); LOG_SCOPE_WITH_PARAM(GetImgLog(),
"ProgressTracker::SyncNotify", "uri", spec.get());
#endif #endif
nsIntRect r; nsIntRect r;

View File

@ -103,7 +103,7 @@ public:
// Get the current Progress. // Get the current Progress.
Progress GetProgress() const { return mProgress; } Progress GetProgress() const { return mProgress; }
// Schedule an asynchronous "replaying" of all the notifications that would // Schedule an asynchronous "replaying" of all the notifications that would
// have to happen to put us in the current state. // have to happen to put us in the current state.
// We will also take note of any notifications that happen between the time // We will also take note of any notifications that happen between the time
@ -164,9 +164,9 @@ public:
return mConsumers.Length(); return mConsumers.Length();
} }
// This is intentionally non-general because its sole purpose is to support an // This is intentionally non-general because its sole purpose is to support
// some obscure network priority logic in imgRequest. That stuff could probably // some obscure network priority logic in imgRequest. That stuff could
// be improved, but it's too scary to mess with at the moment. // probably be improved, but it's too scary to mess with at the moment.
bool FirstConsumerIs(imgRequestProxy* aConsumer); bool FirstConsumerIs(imgRequestProxy* aConsumer);
void AdoptConsumers(ProgressTracker* aTracker) { void AdoptConsumers(ProgressTracker* aTracker) {