Skip to content

[css-sizing] Should aspect-ratio: <ratio> obey box-sizing on replaced elements with auto preferred sizes? #11093

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

Closed
Loirooriol opened this issue Oct 25, 2024 · 3 comments

Comments

@Loirooriol
Copy link
Contributor

So my understanding from #4951 and https://drafts.csswg.org/css-sizing-4/#valdef-aspect-ratio-ratio is that these tests are wrong:

Since aspect-ratio doesn't have auto, then it should obey box-sizing.

But of course the tests are part of interop-2021 and all browsers are passing them.

I'm not sure if there has been some amendment to align with browsers.

@Loirooriol
Copy link
Contributor Author

So to be specific, https://drafts.csswg.org/css-sizing-4/#valdef-aspect-ratio-ratio says

The tests have the default min-width: auto that behaves as 0, which is floored to 80px to avoid a negative content width, then this is transferred to a min border-box height of 80px / (20/50) = 200px. But the tests expects 100px instead.

Browsers are passing the tests for different reasons:

  • Gecko totally ignores aspect-ratio: <ratio> (treats it as auto) on replaced elements with width: auto; height: auto.

  • WebKit obeys aspect-ratio: <ratio>, but on replaced elements with width: auto; height: auto it applies the ratio to the content-box regardless of box-sizing, e.g.

    <style>canvas { aspect-ratio: 10/25; background: green; padding-right: 40px; padding-bottom: 25px; box-sizing: border-box }</style>
    <canvas width="10" height="25" style="min-width: 40px; width: auto"></canvas>
    <canvas width="10" height="25" style="min-width: 40px; width: 0px"></canvas>

    imatge

  • Blink obeys aspect-ratio: <ratio> and respects box-sizing, but only when a min/max constraint is violated, e.g.

    <style>canvas { aspect-ratio: 10/25; background: green; padding-right: 40px; padding-bottom: 25px; box-sizing: border-box; }</style>
    <canvas width="10" height="25" style="min-width: 50px"></canvas>
    <canvas width="10" height="25" style="min-width: 51px"></canvas>

    imatge

Agenda+ to ratify the spec or align with some browser.

@Loirooriol Loirooriol changed the title [css-sizing] Has #4951 been amended by a later resolution? [css-sizing] Should aspect-ratio: <ratio> obey box-sizing on replaced elements with auto preferred sizes? Oct 27, 2024
@astearns astearns moved this to FTF agenda items in CSSWG January 2025 meeting Jan 22, 2025
@astearns astearns moved this from FTF agenda items to Regular agenda items in CSSWG January 2025 meeting Jan 22, 2025
@astearns astearns moved this from Regular agenda items to Friday morning in CSSWG January 2025 meeting Jan 28, 2025
@Loirooriol
Copy link
Contributor Author

So the tests claimed

Replaced elements should always use content-box sizing for the purpose of aspect ratio

Which is clearly not what the spec says. And Blink would fail these wrong tests after the fix for #11236, so they will be amended in web-platform-tests/wpt#51409

Then I think there isn't anything else to discuss here.

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-sizing] Should `aspect-ratio: <ratio>` obey `box-sizing` on replaced elements with auto preferred sizes?.

The full IRC log of that discussion <TabAtkins> oriol: I closed this issue, I think it's done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Friday morning
Development

No branches or pull requests

2 participants