Closed Bug 1965114 Opened 12 days ago Closed 11 days ago

Add an imgIContainer API to return pixel-valued height/width together, with failure differentiated from missing intrinsic size

Categories

(Core :: Graphics: ImageLib, task)

task

Tracking

()

RESOLVED FIXED
140 Branch
Tracking Status
firefox140 --- fixed

People

(Reporter: dholbert, Assigned: dholbert)

References

Details

Attachments

(3 files)

In bug 1935269, HTMLImageElement::NaturalSize() needs to query for an image's intrinsic height and width in a fallible way (i.e. with graceful fallback when an attribute is missing), and we need to differentiate between "the image lacks an intrinsic size in that axis" vs. "the image is in an error state".

Right now, GetWidth and GetHeight don't let us differentiate between those states, so I'm filing this bug to add a new API that does let us differentiate between them (and return both dimensions together so that we don't need to redundantly check for error states etc.)

Depends on: 1965115
Depends on: 1965282

This patch doesn't change behavior; it just refactors out some commont logic
into a helper (so that we can add another call to this same helper in a later
patch in this series).

This is mostly just a convenience shorthand to avoid running the same
boilerplate/error-checking code in the implementation of the 'width' and
'height' attributes, for the benefit of callers that need both sizes. But,
beyond that convenience: this also lets us elegantly express the case where an
image simply lacks an intrinsic width and/or height (not due to any error, but
simply because it's e.g. an SVG that has no preferred size in either or both of
its axes). This is a state we'll need to be able to detect and give special
treatment to in a forthcoming patch for bug 1935269.

Pushed by dholbert@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/617bee1ed840 part 1: Refactor out a static helper from VectorImage::GetWidth/GetHeight. r=tnikkel https://hg.mozilla.org/integration/autoland/rev/b2e62e739ed4 part 2: Add a new imgIContainer.intrinsicSize attr as a shorthand for getting width & height. r=tnikkel https://hg.mozilla.org/integration/autoland/rev/dc95348f17c0 part 3: Use new imgIContainer intrinsicSize getter in place of width/height in a few places. r=tnikkel
Status: ASSIGNED → RESOLVED
Closed: 11 days ago
Resolution: --- → FIXED
Target Milestone: --- → 140 Branch
Duplicate of this bug: 1966133
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: