mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:57:35 +00:00
LibWeb: Implement HTMLImageElement.complete
This was fairly straightforward, although a small part had to be ad-hoc since we don't yet load images through Fetch. With this, we can now see annotation labels on deskto.ps :^)
This commit is contained in:
parent
9749eda09f
commit
0455af4441
3 changed files with 27 additions and 0 deletions
|
@ -179,4 +179,26 @@ unsigned HTMLImageElement::natural_height() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete
|
||||||
|
bool HTMLImageElement::complete() const
|
||||||
|
{
|
||||||
|
// The IDL attribute complete must return true if any of the following conditions is true:
|
||||||
|
|
||||||
|
// - Both the src attribute and the srcset attribute are omitted.
|
||||||
|
if (!has_attribute(HTML::AttributeNames::src) && !has_attribute(HTML::AttributeNames::srcset))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// - The srcset attribute is omitted and the src attribute's value is the empty string.
|
||||||
|
if (!has_attribute(HTML::AttributeNames::srcset) && attribute(HTML::AttributeNames::src) == ""sv)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// - The img element's current request's state is completely available and its pending request is null.
|
||||||
|
// - The img element's current request's state is broken and its pending request is null.
|
||||||
|
// FIXME: This is ad-hoc and should be updated once we are loading images via the Fetch mechanism.
|
||||||
|
if (m_image_loader.has_loaded_or_failed())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ public:
|
||||||
unsigned natural_width() const;
|
unsigned natural_width() const;
|
||||||
unsigned natural_height() const;
|
unsigned natural_height() const;
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete
|
||||||
|
bool complete() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLImageElement(DOM::Document&, DOM::QualifiedName);
|
HTMLImageElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
|
|
@ -18,4 +18,6 @@ interface HTMLImageElement : HTMLElement {
|
||||||
readonly attribute unsigned long naturalWidth;
|
readonly attribute unsigned long naturalWidth;
|
||||||
readonly attribute unsigned long naturalHeight;
|
readonly attribute unsigned long naturalHeight;
|
||||||
|
|
||||||
|
readonly attribute boolean complete;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue