Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1312588 - Part 5: Implement the intrinsic size contribution for f…
…it-content(). r=TYLin,emilio We simplified to just rely on the behavior of the plain argument. That is, width: fit-content(50%) behaves the same as width: 50%; in all circumstances, just clamped by min/max-content. Note: for block axis, we treat fit-content() as initial value its minimal and maximal value are identical and equal to the initial value in block axis. From: w3c/csswg-drafts#3731 (comment) Note: this patch doesn't include any update on flex and grid layout. We may have to come back to check it. Differential Revision: https://phabricator.services.mozilla.com/D113199
- Loading branch information
1 parent
6092a52
commit c0f286b
Showing
9 changed files
with
347 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
testing/web-platform/tests/css/css-sizing/fit-content-length-percentage-011.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<title>CSS fit-content(): min-content contribution</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#valdef-width-fit-content-length-percentage"> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic-contribution"> | ||
<link rel="match" href="../reference/ref-filled-green-100px-square.xht" /> | ||
<style> | ||
#reference-overlapped-red { | ||
position: absolute; | ||
background-color: red; | ||
width: 100px; | ||
height: 100px; | ||
z-index: -1; | ||
} | ||
</style> | ||
|
||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
|
||
<div id="reference-overlapped-red"></div> | ||
|
||
<div style="width: min-content; height: 50px; background: green;"> | ||
<div style="width: fit-content(100px);"> | ||
<div style="display: inline-block; width: 60px;"></div> | ||
<div style="display: inline-block; width: 60px;"></div> | ||
</div> | ||
</div> | ||
|
||
<!-- Cyclic percentage intrinsic size contribution, we treat width as the | ||
initial value (i.e. auto) for min content contribution --> | ||
<div style="width: min-content; height: 50px; background: green;"> | ||
<div style="width: fit-content(50%);"> | ||
<div style="display: inline-block; width: 100px;"></div> | ||
<div style="display: inline-block; width: 100px;"></div> | ||
</div> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
testing/web-platform/tests/css/css-sizing/fit-content-length-percentage-012.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<title>CSS fit-content(): min-content contribution for min-size</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#valdef-width-fit-content-length-percentage"> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic-contribution"> | ||
<link rel="match" href="../reference/ref-filled-green-100px-square.xht" /> | ||
<style> | ||
#reference-overlapped-red { | ||
position: absolute; | ||
background-color: red; | ||
width: 100px; | ||
height: 100px; | ||
z-index: -1; | ||
} | ||
</style> | ||
|
||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
|
||
<div id="reference-overlapped-red"></div> | ||
|
||
<div style="width: min-content; height: 50px; background: green;"> | ||
<div style="width: 50px; min-width: fit-content(100px);"> | ||
<div style="display: inline-block; width: 60px;"></div> | ||
<div style="display: inline-block; width: 60px;"></div> | ||
</div> | ||
</div> | ||
|
||
<!-- Cyclic percentage intrinsic size contribution, we treat min-width as 0 | ||
for min content contribution. However, fit-content() should be clamped by | ||
min-content size and max-content size, so the result min-width is equal to | ||
min-content size here --> | ||
<div style="width: min-content; height: 50px; background: green;"> | ||
<div style="width: 50px; min-width: fit-content(50%);"> | ||
<div style="display: inline-block; width: 100px;"></div> | ||
<div style="display: inline-block; width: 100px;"></div> | ||
</div> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
testing/web-platform/tests/css/css-sizing/fit-content-length-percentage-013.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<title>CSS fit-content(): min-content contribution for max-size</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#valdef-width-fit-content-length-percentage"> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic-contribution"> | ||
<link rel="match" href="../reference/ref-filled-green-100px-square.xht" /> | ||
<style> | ||
#reference-overlapped-red { | ||
position: absolute; | ||
background-color: red; | ||
width: 100px; | ||
height: 100px; | ||
z-index: -1; | ||
} | ||
</style> | ||
|
||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
|
||
<div id="reference-overlapped-red"></div> | ||
|
||
<div style="width: min-content; height: 50px; background: green;"> | ||
<div style="width: 200px; max-width: fit-content(100px);"> | ||
<div style="display: inline-block; width: 60px;"></div> | ||
<div style="display: inline-block; width: 60px;"></div> | ||
</div> | ||
</div> | ||
|
||
<!-- Cyclic percentage intrinsic size contribution, we treat max-width as the | ||
initial value for min content contribution. The initial value is None and | ||
fit-content() should be clamped by min-content size and max-content size, so | ||
the result max-width is equal to max-content size here --> | ||
<div style="width: min-content; height: 50px; background: green;"> | ||
<div style="width: 200px; max-width: fit-content(50%); font-size: 0;"> | ||
<div style="display: inline-block; width: 50px;"></div> | ||
<div style="display: inline-block; width: 50px;"></div> | ||
</div> | ||
</div> |
34 changes: 34 additions & 0 deletions
34
testing/web-platform/tests/css/css-sizing/fit-content-length-percentage-014.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<title>CSS fit-content(): max-content contribution</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#valdef-width-fit-content-length-percentage"> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic-contribution"> | ||
<link rel="match" href="../reference/ref-filled-green-100px-square.xht" /> | ||
<style> | ||
#reference-overlapped-red { | ||
position: absolute; | ||
background-color: red; | ||
width: 100px; | ||
height: 100px; | ||
z-index: -1; | ||
} | ||
</style> | ||
|
||
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> | ||
|
||
<div id="reference-overlapped-red"></div> | ||
|
||
<div style="width: max-content; height: 50px; background: green;"> | ||
<div style="width: fit-content(100px);"> | ||
<div style="display: inline-block; width: 60px;"></div> | ||
<div style="display: inline-block; width: 60px;"></div> | ||
</div> | ||
</div> | ||
|
||
<!-- Cyclic percentage intrinsic size contribution, we treat width as the | ||
initial value (i.e. auto) for max content contribution --> | ||
<div style="width: max-content; height: 50px; background: green;"> | ||
<div style="width: fit-content(50%); font-size: 0;"> | ||
<div style="display: inline-block; width: 50px;"></div> | ||
<div style="display: inline-block; width: 50px;"></div> | ||
</div> | ||
</div> |
Oops, something went wrong.