Fire resize event instead of load event for `<img srcset sizes>` density change #835

Open
zcorpan opened this Issue Mar 8, 2016 · 0 comments

Projects

None yet

1 participant

@zcorpan
Member
zcorpan commented Mar 8, 2016

https://html.spec.whatwg.org/multipage/embedded-content.html#img-environment-changes

Consider http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3971

<!DOCTYPE html>
<img srcset="image 195w" sizes="50vw" onload="w(this.width)">

The img-environment-changes algorithm reruns when the user resizes the window, and the last step will fire a load event. It seems Gecko and Blink don't fire load on resize, but I think at least Blink did previously. @yoavweiss do you know if this changed in Blink?

I suggest we fire a resize event instead if it picks the same resource but the pixel density has changed, and only fire load if a different resource was loaded. Though maybe we don't need a resize event either? Maybe updating the pixel density should be done differently, like storing the sizes on the "image request" and have it update independently from img-environment-changes? (Right now per spec I think an image would "freeze" its size if img-environment-changes algorithm starts to load a new image, until the new image is loaded, which also seems sub-optimal.)

@zcorpan zcorpan self-assigned this Mar 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment