Bug 1578448 - Make img.complete align with spec; r=bzbarsky

If the img has srcset attribute and the current request isn't complete or broken,
the img.complete should return false per spec,
https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete.

We should check srcset or src attribute, checking only mCurrentRequest isn't
enough given that updating mCurrentRequest happens async.

Differential Revision: https://phabricator.services.mozilla.com/D44678
This commit is contained in:
Edgar Chen
2019-09-11 14:37:39 +00:00
parent 2096f323d0
commit a908d92ae5
2 changed files with 9 additions and 9 deletions

View File

@@ -164,11 +164,17 @@ bool HTMLImageElement::Draggable() const {
}
bool HTMLImageElement::Complete() {
if (!mCurrentRequest) {
return true;
// It is still not clear what value should img.complete return in various
// cases, see https://github.com/whatwg/html/issues/4884
if (!HasAttr(kNameSpaceID_None, nsGkAtoms::srcset)) {
nsAutoString src;
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::src, src) || src.IsEmpty()) {
return true;
}
}
if (mPendingRequest) {
if (!mCurrentRequest || mPendingRequest) {
return false;
}