Honor "object-fit" and "object-position" for nsLayoutUtils::DrawSingleImage() code-paths for replaced elements (<svg:image>, <xul:image>)

NEW
Unassigned

Status

()

Core
Layout
4 years ago
3 years ago

People

(Reporter: dholbert, Unassigned, NeedInfo)

Tracking

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(URL)

nsLayoutUtils::DrawSingleImage() is an all-in-one "draw me this image" function, which we use in a few places for different things.

My patches for bug 624647 will not make this particular function aware of "object-fit" & "object-position" -- I'm punting that to this bug.

Specifically, we only want to honor these properties in DrawSingleImage() *if we're drawing a replaced element*.

Based on http://mxr.mozilla.org/mozilla-central/search?string=drawsingleimage , it looks like there are only three DrawSingleImage() callers for replaced elements:
  a) The SVG <image> element
  b) The XUL <image> element
  c) The HTML <img> element's alt-feedback icon.
..and then a two callers that are not for replaced elements (for bullets & border-images).

I'm pretty sure we should honor "object-fit" on the SVG & XUL <image> elements.  I'm not as sure about (c), though -- the <img> element's alt feedback (for e.g. image-failed-to-load icons); that's not as useful of a behavior to expose, and it might be surprising/unexpected if author styling affected the rendering of that icon.
(In reply to Daniel Holbert [:dholbert] from comment #0)
> I'm not as sure about (c), though -- the <img> element's alt
> feedback (for e.g. image-failed-to-load icons); that's not as useful of a
> behavior to expose, and it might be surprising/unexpected if author styling
> affected the rendering of that icon.

For comparison, it looks like Chrome doesn't honor "object-fit" on <img> alt feedback icons, judging by the lack of icon-scaling in this example:
data:text/html,<img src="data:" style="width: 300px; height: 300px; object-fit: fill">
Summary: Honor "object-fit" and "object-position" for nsLayoutUtils::DrawSingleImage() code-paths → Honor "object-fit" and "object-position" for nsLayoutUtils::DrawSingleImage() code-paths for replaced elements (<svg:image>, <xul:image>)
Duplicate of this bug: 1125572
Flags: needinfo?(dholbert)

Comment 3

3 years ago
(In reply to Daniel Holbert [:dholbert] from comment #1)
> (In reply to Daniel Holbert [:dholbert] from comment #0)
> > I'm not as sure about (c), though -- the <img> element's alt
> > feedback (for e.g. image-failed-to-load icons); that's not as useful of a
> > behavior to expose, and it might be surprising/unexpected if author styling
> > affected the rendering of that icon.
> 
> For comparison, it looks like Chrome doesn't honor "object-fit" on <img> alt
> feedback icons, judging by the lack of icon-scaling in this example:
> data:text/html,<img src="data:" style="width: 300px; height: 300px;
> object-fit: fill">

Does that feedback icon actually count as being the content there?  It seems to me part and parcel of the "content to be replaced"; the placeholder for the image.  In that case, it would make sense that object-fit wouldn't apply to it.
Yeah, I agree; it doesn't seem like these properties should apply to placeholder images.

(If they did apply, it'd probably just cause trouble/confusion. e.g. If an author had a specific "object-*" configuration to position a particular part of a photo in an <img>'s content-box, and the photo is missing or has errors, then it would look pretty broken if we just showed the comparable part of the feedback-icon -- which is sort of what would happen if we let these properties apply.)

So I think <xul:image> and <svg:image> are the only things needing fixing here.

Comment 5

3 years ago
Soooo, anyone got any progress on this one?  I could really use this working with <xul:image>.
Depends on: 1170052
You need to log in before you can comment on or make changes to this bug.