-
Notifications
You must be signed in to change notification settings - Fork 707
[css-sizing-4][css-contain] Clarify on specifying aspect-ratio and contain:size on replaced elements #5550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes I agree that it should be 100x100. This seems to be a bug in Blink. |
Hmm, I'm not sure... at least for the mapped ratio case (so |
Hm... @fantasai @bfgeek @tabatkins for input Also @dvoytenko do you have any thoughts on this? |
I also think it should be 100x100. Just based on the |
I believe in the example it's actually rendering as 100x0, not 0 x 0 (at least in my version of the browser): https://jsfiddle.net/fh6b17vp/ It could be that the UA is:
But who knows what's really going on behind-the-scenes there for each implementation? I'm not sure that the order of operations is well-defined for how the Containment Module applies itself yet... Also, I noticed on my version of Chromium that this still leaves a 1px tall interior to the box whereas there should have probably been nothing, whereas Firefox collapses the borders completely. Chromium also seems to apply this padding around the image, not just the resized box. However, https://drafts.csswg.org/css-images-3/#concrete-size-resolution says "CSS does not define how objects render when the concrete object size is different from the object’s intrinsic dimensions." and the Containment Module explicitly states that the layout for "Replaced elements must be treated as having an intrinsic width and height of 0." as @aethanyc mentioned. If concrete object size for the image has already been calculated prior to the object's intrinsic dimensions being treated as zero, the rendering of the image could end up being undefined by CSS, which could explain why Chromium has a gap and Firefox does not. https://drafts.csswg.org/css-contain/#containment-size also says "When calculating the size of the containing box, including when computing its intrinsic size, it must be treated as having no contents." and then it says "Then, its contents must then be laid out into the containing box's resolved size." What exactly is the "resolved size" here? I feel like this should be better defined, possibly including more information on how to handle replaced elements who end up getting replaced into their own box. |
@x-Jake-x Thanks for pointing this out. Both Firefox and Chrome do render the example as 100x0. I'll edit my original post. |
These are new tests added by mozilla, testing w3c/csswg-drafts#5550 R=futhark@chromium.org Bug: 1133835 Change-Id: Ifa3127600540d783f59c8ffe31fccb27d41de4ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2442376 Commit-Queue: Christian Biesinger <cbiesinger@chromium.org> Auto-Submit: Christian Biesinger <cbiesinger@chromium.org> Reviewed-by: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/master@{#812665}
Yes, There's a related question of how the This isn't correct per-spec right now, but whatwg/html#5907 has been filed to fix this. |
@tabatkins So is my interpretation correct that "auto 1/2" should also be used in case of contain:size? |
@cbiesinger I'm a little confused, but I'm assuming you're asking, unrelated to any of the above discussion, about an element that has Yes, the (I've opened #5585 now to cover the fact that aspect-ratio isn't actually mentioned in relation to |
Right, so #5585 deals with implicit aspect ratios, and whatwg/html#5907 will handle the mapping of the width / height attributes into an explicit aspect ratio. I don't see any reason it should, so the original If we agree, I think we can leave the spec unchanged, but should write a test. |
web-platform-tests/wpt#25860 added some testcases when both |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> Topic: contain:size and 'aspect-ratio'<fantasai> github: https://github.com//issues/5550 <fantasai> TYLin: Issue is replaced elements with intrinsic aspect ratio <fantasai> TYLin: Specify contain:size and aspect-ratio, what size should it be? <fantasai> TYLin: Discussion in the issue, should use expliti 'aspect-ratio' and otherwise none <florian> q? <fantasai> florian: My impression is that spec was confusing because we didn't say anything at all, but if we clarify as we did in the earlier issue, do we need to say anything else to make this work? <fantasai> TabAtkins: It does fall out, but might be worth an example <fantasai> fantasai: I think it falls out <fantasai> TYLin: added testcase <fantasai> astearns: so proposal is to add an example <fantasai> astearns: any objections? <fantasai> RESOLVED: Add an exampe, but no change to normative prose |
Both that link and the testcases from web-platform-tests/wpt#25860 pass in Chrome now; either we accidentally fixed it or the test was without the experimental web platform features flag enabled. |
Per 3.1. Size Containment,
I read above as the replaced element should be treated as having no intrinsic aspect ratio as well. So if a replaced element has both
aspect-ratio
andcontain:size
, what size should it be? An example:Here a link to the above example. https://jsfiddle.net/tL3xh6qo/2/ (Currently, both Firefox and Google Chrome render the example as
0x0, 100x0.)I would think the image size should be 100x100, not
0x0100x0, becausecontain:size
affects only intrinsic aspect ratio, andaspect-ratio
property provides a preferred aspect-ratio, which should be used to determine the size.[edit: Changed the size of the example currently rendered on browsers from 0x0 to 100x0.]
CC @cbiesinger, @fantasai, @BorisChiou, @emilio
The text was updated successfully, but these errors were encountered: