Bug 1084136 (Part 8) - Treat receiving the last part of a multipart image as an image state. r=tn

--HG--
extra : rebase_source : 136af95415b6756b9d4c5c667d2287da77557a23
This commit is contained in:
Seth Fowler 2014-11-06 17:33:59 -08:00
Родитель 10014ce732
Коммит c26f9ade1c
2 изменённых файлов: 14 добавлений и 20 удалений

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

@ -146,7 +146,6 @@ imgStatusTracker::imgStatusTracker(Image* aImage)
: mImage(aImage),
mState(0),
mImageStatus(imgIRequest::STATUS_NONE),
mHadLastPart(false),
mHasBeenDecoded(false)
{
mTrackerObserver = new imgStatusTrackerObserver(this);
@ -157,7 +156,6 @@ imgStatusTracker::imgStatusTracker(const imgStatusTracker& aOther)
: mImage(aOther.mImage),
mState(aOther.mState),
mImageStatus(aOther.mImageStatus),
mHadLastPart(aOther.mHadLastPart),
mHasBeenDecoded(aOther.mHasBeenDecoded)
// Note: we explicitly don't copy several fields:
// - mRequestRunnable, because it won't be nulled out when the
@ -366,7 +364,7 @@ imgStatusTracker::NotifyCurrentState(imgRequestProxy* proxy)
/* static */ void
imgStatusTracker::SyncNotifyState(ProxyArray& proxies,
bool hasImage, uint32_t state,
nsIntRect& dirtyRect, bool hadLastPart)
nsIntRect& dirtyRect)
{
MOZ_ASSERT(NS_IsMainThread());
// OnStartRequest
@ -414,7 +412,7 @@ imgStatusTracker::SyncNotifyState(ProxyArray& proxies,
}
if (state & FLAG_REQUEST_STOPPED) {
NOTIFY_IMAGE_OBSERVERS(OnStopRequest(hadLastPart));
NOTIFY_IMAGE_OBSERVERS(OnStopRequest(state & FLAG_MULTIPART_STOPPED));
}
}
@ -426,8 +424,6 @@ imgStatusTracker::Difference(imgStatusTracker* aOther) const
diff.diffState = ~mState & aOther->mState & ~FLAG_REQUEST_STARTED;
diff.diffImageStatus = ~mImageStatus & aOther->mImageStatus;
diff.foundLastPart = !mHadLastPart && aOther->mHadLastPart;
diff.gotDecoded = !mHasBeenDecoded && aOther->mHasBeenDecoded;
// Only record partial invalidations if we haven't been decoded before.
@ -471,7 +467,6 @@ imgStatusTracker::ApplyDifference(const ImageStatusDiff& aDiff)
// Synchronize our state.
mState |= aDiff.diffState | loadState;
mHadLastPart = mHadLastPart || aDiff.foundLastPart;
mHasBeenDecoded = mHasBeenDecoded || aDiff.gotDecoded;
// Update the image status. There are some subtle points which are handled below.
@ -486,7 +481,7 @@ imgStatusTracker::SyncNotifyDifference(const ImageStatusDiff& diff)
nsIntRect invalidRect = mInvalidRect.Union(diff.invalidRect);
SyncNotifyState(mConsumers, !!mImage, diff.diffState, invalidRect, mHadLastPart);
SyncNotifyState(mConsumers, !!mImage, diff.diffState, invalidRect);
mInvalidRect.SetEmpty();
@ -525,7 +520,7 @@ imgStatusTracker::SyncNotify(imgRequestProxy* proxy)
ProxyArray array;
array.AppendElement(proxy);
SyncNotifyState(array, !!mImage, mState, r, mHadLastPart);
SyncNotifyState(array, !!mImage, mState, r);
}
void
@ -609,9 +604,10 @@ void
imgStatusTracker::RecordLoaded()
{
NS_ABORT_IF_FALSE(mImage, "RecordLoaded called before we have an Image");
mState |= FLAG_REQUEST_STARTED | FLAG_HAS_SIZE | FLAG_REQUEST_STOPPED;
mImageStatus |= imgIRequest::STATUS_SIZE_AVAILABLE | imgIRequest::STATUS_LOAD_COMPLETE;
mHadLastPart = true;
mState |= FLAG_REQUEST_STARTED | FLAG_HAS_SIZE |
FLAG_REQUEST_STOPPED | FLAG_MULTIPART_STOPPED;
mImageStatus |= imgIRequest::STATUS_SIZE_AVAILABLE |
imgIRequest::STATUS_LOAD_COMPLETE;
}
void
@ -826,8 +822,10 @@ void
imgStatusTracker::RecordStopRequest(bool aLastPart,
nsresult aStatus)
{
mHadLastPart = aLastPart;
mState |= FLAG_REQUEST_STOPPED;
if (aLastPart) {
mState |= FLAG_MULTIPART_STOPPED;
}
// If we were successful in loading, note that the image is complete.
if (NS_SUCCEEDED(aStatus)) {

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

@ -38,7 +38,8 @@ enum {
FLAG_ONLOAD_BLOCKED = 1u << 6,
FLAG_ONLOAD_UNBLOCKED = 1u << 7,
FLAG_IS_ANIMATED = 1u << 8,
FLAG_IS_MULTIPART = 1u << 9
FLAG_IS_MULTIPART = 1u << 9,
FLAG_MULTIPART_STOPPED = 1u << 10
};
struct ImageStatusDiff
@ -47,7 +48,6 @@ struct ImageStatusDiff
: invalidRect()
, diffState(0)
, diffImageStatus(0)
, foundLastPart(false)
, gotDecoded(false)
{ }
@ -59,7 +59,6 @@ struct ImageStatusDiff
return aOther.invalidRect == invalidRect
&& aOther.diffState == diffState
&& aOther.diffImageStatus == diffImageStatus
&& aOther.foundLastPart == foundLastPart
&& aOther.gotDecoded == gotDecoded;
}
@ -67,14 +66,12 @@ struct ImageStatusDiff
invalidRect = invalidRect.Union(aOther.invalidRect);
diffState |= aOther.diffState;
diffImageStatus |= aOther.diffImageStatus;
foundLastPart = foundLastPart || aOther.foundLastPart;
gotDecoded = gotDecoded || aOther.gotDecoded;
}
nsIntRect invalidRect;
uint32_t diffState;
uint32_t diffImageStatus;
bool foundLastPart : 1;
bool gotDecoded : 1;
};
@ -294,7 +291,7 @@ private:
// thread, and mConsumers is not threadsafe.
static void SyncNotifyState(ProxyArray& proxies,
bool hasImage, uint32_t state,
nsIntRect& dirtyRect, bool hadLastPart);
nsIntRect& dirtyRect);
nsCOMPtr<nsIRunnable> mRequestRunnable;
@ -314,7 +311,6 @@ private:
uint32_t mState;
uint32_t mImageStatus;
bool mHadLastPart : 1;
bool mHasBeenDecoded : 1;
};