Skip to content
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

[css-sizing] Does an indefinite intrinsic block size transfer to inline axis when stretch would do so? #11387

Open
Loirooriol opened this issue Dec 17, 2024 · 2 comments
Labels

Comments

@Loirooriol
Copy link
Contributor

See the testcase below.

There is an abspos with top: 0; bottom: 0. By default it stretches to fill the containing block, and this block size is used to compute its inline min/max-content sizes thru the aspect ratio of its contents.

However, what happens if the abspos gets height: max-content? At this point the block min/max-content sizes are undefined, since they depend on the inline size. So what to do?

  • Treat height: max-content as indefinite. Then contents can't resolve their percentage. This is what Firefox and Chrome do.
  • Treat height: max-content as height: auto. Then it stretches, and since the stretch size is definite, contents can resolve their percentage. This is what WebKit does.

Servo is currently like WebKit, but I think I prefer Blink's behavior.

<!DOCTYPE html>
<style>
.wrapper { position: relative; width: 50px; height: 50px; border: solid; margin: 5px }
.abspos { position: absolute; top: 0; bottom: 0; }
canvas { background: cyan; height: 100% }
</style>
<div class="wrapper">
  <div class="abspos">
    <canvas width="25" height="25"></canvas>
  </div>
</div>
<div class="wrapper">
  <div class="abspos" style="height: -moz-available; height: -webkit-fill-available; height: stretch">
    <canvas width="25" height="25"></canvas>
  </div>
</div>
<div class="wrapper">
  <div class="abspos" style="height: min-content">
    <canvas width="25" height="25"></canvas>
  </div>
</div>
<div class="wrapper">
  <div class="abspos" style="height: max-content">
    <canvas width="25" height="25"></canvas>
  </div>
</div>
Firefox Chrome WebKit
@Loirooriol
Copy link
Contributor Author

Similar testcase, not much conclusive since only Chrome supports align-self: stretch on replaced abspos.

<!DOCTYPE html>
<style>
.wrapper { position: relative; width: 50px; height: 50px; border: solid; margin: 5px }
canvas { position: absolute; top: 0; bottom: 0; align-self: stretch; background: cyan; }
</style>
<div class="wrapper">
  <canvas width="25" height="25"></canvas>
</div>
<div class="wrapper">
  <canvas width="25" height="25" style="height: -moz-available; height: -webkit-fill-available; height: stretch"></canvas>
</div>
<div class="wrapper">
  <canvas width="25" height="25" style="height: min-content"></canvas>
</div>
<div class="wrapper">
  <canvas width="25" height="25" style="height: max-content"></canvas>
</div>
Firefox Chrome WebKit Servo
image image

@Loirooriol
Copy link
Contributor Author

Similar question: what about min-height: min-content, should we treat it as min-height: 0 or min-height: initial?

Browsers seem to do the latter.

<!DOCTYPE html>
<style>
.wrapper { display: flex; flex-flow: column; width: 50px; height: 50px; border: solid; margin: 5px }
.item { flex-basis: 10px; align-self: center }
canvas { background: cyan; height: 100% }
</style>
<div class="wrapper">
  <div class="item" style="min-height: 0">
    <canvas width="25" height="25"></canvas>
  </div>
</div>
<div class="wrapper">
  <div class="item" style="min-height: auto">
    <canvas width="25" height="25"></canvas>
  </div>
</div>
<div class="wrapper">
  <div class="item" style="min-height: min-content">
    <canvas width="25" height="25"></canvas>
  </div>
</div>
<div class="wrapper">
  <div class="item" style="min-height: max-content">
    <canvas width="25" height="25"></canvas>
  </div>
</div>
Firefox Blink WebKit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant