Bug 1259482 - Ensure that image loads are never dropped on the floor when queued for later. r=johns

This commit is contained in:
Josh Matthews 2016-03-30 12:39:59 -04:00
Родитель ea604f9f48
Коммит d43f85cd2a
5 изменённых файлов: 32 добавлений и 2 удалений

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

@ -98,6 +98,10 @@ public:
return NS_OK;
}
bool AlwaysLoad() {
return mAlwaysLoad;
}
private:
~ImageLoadTask() {}
RefPtr<HTMLImageElement> mElement;
@ -899,7 +903,13 @@ HTMLImageElement::QueueImageLoadTask(bool aAlwaysLoad)
return;
}
nsCOMPtr<nsIRunnable> task = new ImageLoadTask(this, aAlwaysLoad);
// Ensure that we don't overwrite a previous load request that requires
// a complete load to occur.
bool alwaysLoad = aAlwaysLoad;
if (mPendingImageLoadTask) {
alwaysLoad = alwaysLoad || mPendingImageLoadTask->AlwaysLoad();
}
RefPtr<ImageLoadTask> task = new ImageLoadTask(this, alwaysLoad);
// The task checks this to determine if it was the last
// queued event, and so earlier tasks are implicitly canceled.
mPendingImageLoadTask = task;

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

@ -22,6 +22,8 @@ namespace mozilla {
class EventChainPreVisitor;
namespace dom {
class ImageLoadTask;
class ResponsiveImageSelector;
class HTMLImageElement final : public nsGenericHTMLElement,
public nsImageLoadingContent,
@ -362,7 +364,7 @@ private:
nsRuleData* aData);
bool mInDocResponsiveContent;
nsCOMPtr<nsIRunnable> mPendingImageLoadTask;
RefPtr<ImageLoadTask> mPendingImageLoadTask;
};
} // namespace dom

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

@ -34,6 +34,8 @@ skip-if(Android||B2G) == 649134-2.html 649134-2-ref.html
== bug448564-4a.html bug448564-4b.html
== bug502168-1_malformed.html bug502168-1_well-formed.html
== responsive-image-load-shortcircuit.html responsive-image-load-shortcircuit-ref.html
# Test that image documents taken into account CSS properties like
# image-orientation when determining the size of the image.
# (Fuzzy necessary due to pixel-wise comparison of different JPEGs.

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

@ -0,0 +1 @@
<iframe srcdoc="<img src=pass.png>" width="300px"></iframe>

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

@ -0,0 +1,15 @@
<html class="reftest-wait">
<iframe srcdoc="<img srcset=red.png>" width="150px"></iframe>
<script>
var iframe = document.querySelector('iframe');
iframe.onload = function() {
var doc = iframe.contentDocument;
var img = doc.querySelector('img');
img.srcset = "pass.png";
iframe.width = "300px";
img.onload = function() {
document.documentElement.classList.remove('reftest-wait');
};
}
</script>
</html>