Closed sefeng211 closed 2 years ago
Thanks for reporting!
I agree that getting the naturalWidth and naturalHeight through the getters is very <img>
specific, and that processing model makes no sense for background images.
The point of using the naturalSize to displaySize ratio is one that I think still makes sense for background images, although the parameters that go into the displaySize may be more complex, as you mention. Do you know if CSS background images have such concepts that we can point at directly?
Emilio, do you have suggestions of what the spec should be? @emilio
I mean, there's a lot that can influence how a background image is displayed (background size, background-repeat, other backgrounds occluding it...). What's the intention of the displaySize
? Presumably the "rendered size" of the image? If so something like this plus accounting for repeat and so could do...
The intention is indeed the "rendered size".
I think the natural/intrinsic size still makes sense for background images, and is not different from a regular img
that's displayed with custom width/height.
A large photo and a repeating tile with some pattern should behave differently.
How does it make sense? It makes no sense to me that background-image: url(giant-image.png); background-size: 10px;
would report giant display size.
How does it make sense? It makes no sense to me that
background-image: url(giant-image.png); background-size: 10px;
would report giant display size.
How is that different from img src=giant.png width=1 height=1 or img src=giant.png style="transform: scale(.000001)">?
Well, right, the spec as-is would return 1x1 for at least your first example wouldn't it? You're right it wouldn't for the second tho.
Well, right, the spec as-is would return 1x1 for at least your first example wouldn't it? You're right it wouldn't for the second tho.
Or to other examples like object-size. This is actually not an easy problem to solve, I am merely stating that it's not specific to css images.
Researching this a bit, I think we can use the CSS terms concrete object size and natural dimensions, which apply to regular images and to background images, as well as to video etc.
We get the idea that the spec uses
naturalSize
for reporting the actual rendered size of the images, however thenaturalSize
concept doesn't make sense for CSS images.And there are many things to effect the final rendered size of a CSS image, and getting the intrinsic size doesn't mean that's the rendered size.
I think we should need to define a better description for CSS images.
cc @emilio