Skip to content

Commit

Permalink
When computing inline intrinsic sizes, resolve with a 0 percentage ba…
Browse files Browse the repository at this point in the history
…sis rather than just resolving to zero if there's a percentage.

This matches other browsers, the spec
(https://drafts.csswg.org/css-sizing/#cyclic-percentage-contribution):

  For the min size properties, as well as for margins and paddings (and
  gutters), a cyclic percentage is resolved against zero for determining
  intrinsic size contributions.

And also what we do in SizeComputationInput::Compute{Margin,Padding}:

  https://searchfox.org/mozilla-central/rev/75e9d727ce5ba2c14653cf8fb0f1367f085271b7/layout/generic/ReflowInput.cpp#2811-2832
  https://searchfox.org/mozilla-central/rev/75e9d727ce5ba2c14653cf8fb0f1367f085271b7/layout/generic/ReflowInput.cpp#2861-2868

This fixes a compat issue with the menu alignment in lume.io:

  webcompat/web-bugs#88484 (comment)

It's also simpler.

Differential Revision: https://phabricator.services.mozilla.com/D127441

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1733952
gecko-commit: 1fd26f24025c3dcb4de967ee8bdc8a0ca9079e78
gecko-reviewers: jfkthame
  • Loading branch information
emilio authored and Gabisampaio committed Nov 18, 2021
1 parent e440e1f commit 7c14ea2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions css/css-sizing/inline-intrinsic-size-calc-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<title>Calc gets resolved with 0 percent basis for intrinsic size computation</title>
<style>
div {
background-color: green;
width: max-content;
}
span {
margin-left: 30px;
padding-left: 50px;
}
</style>
<div>
<span>ABCD</span>
</div>
20 changes: 20 additions & 0 deletions css/css-sizing/inline-intrinsic-size-calc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<title>Calc gets resolved with 0 percent basis for intrinsic size computation</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="match" href="inline-intrinsic-size-calc-ref.html">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1733952">
<link rel="help" href="https://drafts.csswg.org/css-sizing/#cyclic-percentage-contribution">
<style>
div {
background-color: green;
width: max-content;
}
span {
margin-left: calc(0% + 30px);
padding-left: calc(0% + 50px);
}
</style>
<div>
<span>ABCD</span>
</div>

0 comments on commit 7c14ea2

Please sign in to comment.