What is the issue with the HTML Standard?
This is a followup to #11287, specifically this comment:
#11287 (comment)
The patch there made the spec reflect reality in one way ("Make naturalWidth & naturalHeight return non-0 when the image lacks a dimension"), but the thing that I referred to in #11287 (comment) part (2) is still a spot where the spec doesn't match reality.
The spec still uses "density-corrected" to describe the width and height IDL attributes for images-that-are-not-being-rendered:
https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-width
The IDL attributes width and height must return [...text for images that are being rendered...]; or else the density-corrected natural width and height of the image, in CSS pixels, if the image has density-corrected natural width and height and is available but is not being rendered;
Browsers don't actually do density-correction in this case. You can see this using the testcase that I linked in #11287 (comment) part (2), and also in the WPT that we have for this area of behavior, specifically this section where we increase image density to 2 but decline-to-scale-up our expected width and height attributes for the not-rendered case:
https://github.com/web-platform-tests/wpt/blob/master/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.html#L331-L335
@annevk what do you think we should do here? Should we make a followup tweak to remove density-corrected from this line of spec text? (That term is linked, and I guess the link needs to change, too -- it doesn't quite make sense to link to https://html.spec.whatwg.org/multipage/images.html#density-corrected-intrinsic-width-and-height anymore. But also, there isn't a great new defined term that we can link to. Maybe we should still link to that section and just describe it as "density-corrected natural width and height, assuming a preferred density of 1", or something along those lines? That seems to be what we're doing...)
Alternately, maybe we should just fix browsers to do what the spec says here? I'm not sure if there's a good reason to not density-correct .width and .height for not-rendered images. Maybe we can change to remove this weird density-dependent difference between the .natural{Width/Height} and .{width/height} attributes...
What is the issue with the HTML Standard?
This is a followup to #11287, specifically this comment:
#11287 (comment)
The patch there made the spec reflect reality in one way ("Make naturalWidth & naturalHeight return non-0 when the image lacks a dimension"), but the thing that I referred to in #11287 (comment) part (2) is still a spot where the spec doesn't match reality.
The spec still uses "density-corrected" to describe the
widthandheightIDL attributes for images-that-are-not-being-rendered:https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-width
Browsers don't actually do density-correction in this case. You can see this using the testcase that I linked in #11287 (comment) part (2), and also in the WPT that we have for this area of behavior, specifically this section where we increase image density to 2 but decline-to-scale-up our expected
widthandheightattributes for the not-rendered case:https://github.com/web-platform-tests/wpt/blob/master/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.html#L331-L335
@annevk what do you think we should do here? Should we make a followup tweak to remove
density-correctedfrom this line of spec text? (That term is linked, and I guess the link needs to change, too -- it doesn't quite make sense to link to https://html.spec.whatwg.org/multipage/images.html#density-corrected-intrinsic-width-and-height anymore. But also, there isn't a great new defined term that we can link to. Maybe we should still link to that section and just describe it as "density-corrected natural width and height, assuming a preferred density of 1", or something along those lines? That seems to be what we're doing...)Alternately, maybe we should just fix browsers to do what the spec says here? I'm not sure if there's a good reason to not density-correct
.widthand.heightfor not-rendered images. Maybe we can change to remove this weird density-dependent difference between the.natural{Width/Height}and.{width/height}attributes...