Bug 1786455 - Clear the pending image load task after we destroy the image element. r=emilio

It doesn't make sense to load the selected image after we destroy the
image element because this is unnecessary and may cause unexpected behaviors.

We can reproduce this by running layout/style/test/test_bug418986-2.html
with xorigin, if we don't apply this patch.

Differential Revision: https://phabricator.services.mozilla.com/D155419
This commit is contained in:
Boris Chiou
2022-08-24 00:09:45 +00:00
parent 59f71035b4
commit 999914dcd3

View File

@@ -1261,6 +1261,10 @@ bool HTMLImageElement::SelectSourceForTagWithAttrs(
}
void HTMLImageElement::DestroyContent() {
// Clear mPendingImageLoadTask to avoid running LoadSelectedImage() after
// getting destroyed.
mPendingImageLoadTask = nullptr;
mResponsiveSelector = nullptr;
nsImageLoadingContent::Destroy();