mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Merge pull request #1580 from egrs/image-complete
add HTMLImageElement.complete property
This commit is contained in:
@@ -98,6 +98,22 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script id="complete">
|
||||||
|
{
|
||||||
|
// Image with no src is complete per spec
|
||||||
|
const img = document.createElement('img');
|
||||||
|
testing.expectEqual(true, img.complete);
|
||||||
|
|
||||||
|
// Image with src is also complete (headless browser, no actual fetch)
|
||||||
|
img.src = 'test.png';
|
||||||
|
testing.expectEqual(true, img.complete);
|
||||||
|
|
||||||
|
// Image constructor also complete
|
||||||
|
const img2 = new Image();
|
||||||
|
testing.expectEqual(true, img2.complete);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<script id="load-trigger-event">
|
<script id="load-trigger-event">
|
||||||
{
|
{
|
||||||
const img = document.createElement("img");
|
const img = document.createElement("img");
|
||||||
|
|||||||
@@ -112,6 +112,14 @@ pub fn getNaturalHeight(_: *const Image) u32 {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn getComplete(_: *const Image) bool {
|
||||||
|
// Per spec, complete is true when: no src/srcset, src is empty,
|
||||||
|
// image is fully available, or image is broken (with no pending request).
|
||||||
|
// Since we never fetch images, they are in the "broken" state, which has
|
||||||
|
// complete=true. This is consistent with naturalWidth/naturalHeight=0.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
pub const JsApi = struct {
|
pub const JsApi = struct {
|
||||||
pub const bridge = js.Bridge(Image);
|
pub const bridge = js.Bridge(Image);
|
||||||
|
|
||||||
@@ -131,6 +139,7 @@ pub const JsApi = struct {
|
|||||||
pub const loading = bridge.accessor(Image.getLoading, Image.setLoading, .{});
|
pub const loading = bridge.accessor(Image.getLoading, Image.setLoading, .{});
|
||||||
pub const naturalWidth = bridge.accessor(Image.getNaturalWidth, null, .{});
|
pub const naturalWidth = bridge.accessor(Image.getNaturalWidth, null, .{});
|
||||||
pub const naturalHeight = bridge.accessor(Image.getNaturalHeight, null, .{});
|
pub const naturalHeight = bridge.accessor(Image.getNaturalHeight, null, .{});
|
||||||
|
pub const complete = bridge.accessor(Image.getComplete, null, .{});
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Build = struct {
|
pub const Build = struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user