Open Bug 2052914 Opened 1 month ago Updated 1 month ago

Density-correct image width/height attributes' return values, regardless of whether image is rendered

Categories

(Core :: Layout: Images, Video, and HTML Frames, defect)

defect

Tracking

()

ASSIGNED

People

(Reporter: dholbert, Assigned: dholbert)

References

(Depends on 1 open bug)

Details

There's a WPT with updated expectations here: https://github.com/web-platform-tests/wpt/pull/61080

Previously, the WPT was expecting (and all browsers implemented) a weird behavior where the width and height attributes would return not-density-corrected values when the image was not rendered (unlike naturalHeight and naturalWidth).

The spec calls for them to be density-corrected, though, and now the test expects that as well (and I think we've got cross-browser alignment on making that change).

I think the relevant code is this bit from bug 1965560:
https://searchfox.org/firefox-main/rev/d154a3eb431156b2bd63d3d5f96c82655b4e782d/dom/base/nsImageLoadingContent.cpp#1465-1472

// Note that the spec says to use the "density-corrected natural width and
// height of the image", but we don't do that -- we specifically request
// the NaturalSize *without* density-correction here.  This handles a case
// where browsers deviate from the spec in an interoperable way, which
// hopefully we'll address in the spec soon. See case (2) in this comment
// for more:
// https://github.com/whatwg/html/issues/11287#issuecomment-2923467541
size = NaturalSize(DoDensityCorrection::No);

We've got alignment to not-deviate from the spec (from annevk and me and fsoder at least), and it might be as simple as just changing ::No to ::Yes there.

Bug 2033633 is also changing this area of code (de-indenting it as part of removing a pref-check), so this bug should probably wait for that bug's patch to land, to avoid introducing a merge conflict.

Depends on: 2033633
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
You need to log in before you can comment on or make changes to this bug.