зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1383682 - Part 3. Prevent imgRequestProxy from leaking the current state when validating. r=tnikkel
There are two other means from which a caller can get the current state which originally ignored validation -- GetImageStatus and StartDecodingWithResult. These methods are used by layout in some circumstances to decide whether or not the image is ready to display. As observed in some web platform tests, in particular css/css-backgrounds-3/background-size-031.html, we may actually validate and purge the cache for images under test. The state given by the aforementioned methods was misleading, because validation changed it. Now they take into account validation, and do not imply any particular state while validation is in progress.
This commit is contained in:
Родитель
b1c05068b8
Коммит
e68d0fd3d2
|
@ -560,8 +560,11 @@ imgRequestProxy::CancelAndForgetObserver(nsresult aStatus)
|
|||
NS_IMETHODIMP
|
||||
imgRequestProxy::StartDecoding(uint32_t aFlags)
|
||||
{
|
||||
// Flag this, so we know to transfer the request if our owner changes
|
||||
mDecodeRequested = true;
|
||||
// Flag this, so we know to request after validation if pending.
|
||||
if (IsValidating()) {
|
||||
mDecodeRequested = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<Image> image = GetImage();
|
||||
if (image) {
|
||||
|
@ -578,8 +581,11 @@ imgRequestProxy::StartDecoding(uint32_t aFlags)
|
|||
bool
|
||||
imgRequestProxy::StartDecodingWithResult(uint32_t aFlags)
|
||||
{
|
||||
// Flag this, so we know to transfer the request if our owner changes
|
||||
mDecodeRequested = true;
|
||||
// Flag this, so we know to request after validation if pending.
|
||||
if (IsValidating()) {
|
||||
mDecodeRequested = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<Image> image = GetImage();
|
||||
if (image) {
|
||||
|
@ -736,8 +742,16 @@ imgRequestProxy::GetImage(imgIContainer** aImage)
|
|||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetImageStatus(uint32_t* aStatus)
|
||||
{
|
||||
RefPtr<ProgressTracker> progressTracker = GetProgressTracker();
|
||||
*aStatus = progressTracker->GetImageStatus();
|
||||
if (IsValidating()) {
|
||||
// We are currently validating the image, and so our status could revert if
|
||||
// we discard the cache. We should also be deferring notifications, such
|
||||
// that the caller will be notified when validation completes. Rather than
|
||||
// risk misleading the caller, return nothing.
|
||||
*aStatus = imgIRequest::STATUS_NONE;
|
||||
} else {
|
||||
RefPtr<ProgressTracker> progressTracker = GetProgressTracker();
|
||||
*aStatus = progressTracker->GetImageStatus();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче