-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[layout] Accept 'stretch' keyword as a width/height
One of our goals is for `-webkit-fill-available` and `stretch` to have identical layout behavior. Feature is not yet ready to ship. Remaining work: * support stretch in flex-basis * add abspos tests with one inset specified * add aspect ratio test and fix if necessary * ditto with fixed table layout as mentioned in w3c/csswg-drafts#4028 (comment) * serialization? * Test that auto margins are treated as 0 * fix block-height-2.html behavior and/or decide to change the spec * Add margin tests and fix our behavior for the cases discussed in w3c/csswg-drafts#11044 Change-Id: I8c773eb3fe964e58877e0d7d8dbb6325580e0cda Bug: 41253915 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5884393 Reviewed-by: David Baron <dbaron@chromium.org> Commit-Queue: David Grogan <dgrogan@chromium.org> Cr-Commit-Position: refs/heads/main@{#1370209}
- Loading branch information
1 parent
bd4f74f
commit 9356370
Showing
10 changed files
with
300 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing"> | ||
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/4028"> | ||
<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: 100px; height: 100px; position: relative;"> | ||
<div style="position: absolute; width: stretch; height: 100px; background: green;"> | ||
</div> | ||
</div> |
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,22 @@ | ||
<!DOCTYPE html> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing"> | ||
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/4028"> | ||
<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: 100px; height: 200px; position: relative;"> | ||
<div | ||
style="width: 100%; height: stretch; position: absolute; bottom: 100px; background: green;"> | ||
</div> | ||
</div> |
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,23 @@ | ||
<!DOCTYPE html> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing"> | ||
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/4028"> | ||
<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:200px; margin-left: -100px;"> | ||
<div style="float: left; width: 100px; height: 100px;"></div> | ||
<div | ||
style="display: flow-root; width: stretch; height: 100px; background: green;"> | ||
</div> | ||
</div> |
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,128 @@ | ||
<!DOCTYPE html> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#propdef-width"> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script src="/resources/check-layout-th.js"></script> | ||
<meta name="assert" content="Checks the behaviour of stretch in various configurations."> | ||
<style> | ||
.content { | ||
width: 20px; | ||
height: 20px; | ||
background: lime; | ||
} | ||
.tall-content { | ||
width: 20px; | ||
height: 120px; | ||
background: lime; | ||
} | ||
</style> | ||
<body onload="checkLayout('[data-expected-height]')"> | ||
|
||
<div style="height: 100px;"> | ||
<div data-expected-height=100 style="display: block; height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100px;"> | ||
<div data-expected-height=100 style="display: flex; height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100px;"> | ||
<div data-expected-height=100 style="display: grid; height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<!-- As the height of the container is indefinite, stretch is treated as auto. --> | ||
<div style="height: 100%;"> | ||
<div data-expected-height=20 style="display: block; height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100%;"> | ||
<div data-expected-height=20 style="display: flex; height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100%;"> | ||
<div data-expected-height=20 style="display: grid; height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100px;"> | ||
<div data-expected-height=100 style="display: block; min-height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100px;"> | ||
<div data-expected-height=100 style="display: flex; min-height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100px;"> | ||
<div data-expected-height=100 style="display: grid; min-height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100%;"> | ||
<div data-expected-height=20 style="display: block; min-height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100%;"> | ||
<div data-expected-height=20 style="display: flex; min-height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100%;"> | ||
<div data-expected-height=20 style="display: grid; min-height: stretch;"> | ||
<div class=content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100px;"> | ||
<div data-expected-height=100 style="display: block; max-height: stretch;"> | ||
<div class=tall-content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100px;"> | ||
<div data-expected-height=100 style="display: flex; max-height: stretch;"> | ||
<div class=tall-content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100px;"> | ||
<div data-expected-height=100 style="display: grid; max-height: stretch;"> | ||
<div class=tall-content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100%;"> | ||
<div data-expected-height=120 style="display: block; max-height: stretch;"> | ||
<div class=tall-content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100%;"> | ||
<div data-expected-height=120 style="display: flex; max-height: stretch;"> | ||
<div class=tall-content></div> | ||
</div> | ||
</div> | ||
|
||
<div style="height: 100%;"> | ||
<div data-expected-height=120 style="display: grid; max-height: stretch;"> | ||
<div class=tall-content></div> | ||
</div> | ||
</div> |
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,31 @@ | ||
<!DOCTYPE html> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing"> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script src="/resources/check-layout-th.js"></script> | ||
<meta name="assert" content="Checks the behaviour of stretch in various configurations."> | ||
|
||
<body onload="checkLayout('[data-expected-height]')"> | ||
|
||
<div style="height: 200px; border: solid;"> | ||
<div style="height: stretch; margin: 10px;" data-expected-height="180"></div> | ||
</div> | ||
|
||
<!-- | ||
Chrome fails the following test, which is a variation of example 9 in the spec. Safari passes. | ||
From https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing, height:stretch for blocks behaves as | ||
""" | ||
100% but applying the resulting size to its margin box instead of the box indicated by box-sizing. For this purpose, auto margins are treated as zero, and furthermore, for block-level boxes in particular, if its block-start/block-end margin would be adjoining to its parent’s block-start/block-end margin if its parent’s sizing properties all had their initial values, then ***its block-start/block-end margin is treated as zero.*** | ||
""" | ||
So the spec demands that the child has 0px margins and as a corollary, has 300px inner and outer height. | ||
But Blink gives it an inner height of 200px and margins as specified (25px/75px). | ||
--> | ||
<div style="height: 300px; outline: 1px solid; margin: 10px 0px 10px 0px;"> | ||
<div | ||
style="height: stretch; margin: 25px 0px 75px 0px; outline: 2px dashed blue;" | ||
data-expected-height="300"></div> | ||
</div> |
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,7 @@ | ||
<!DOCTYPE html> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#propdef-width"> | ||
<link rel="match" href="../../reference/ref-filled-green-100px-square-only.html"> | ||
<p>Test passes if there is a filled green square.</p> | ||
<div style="width: 100px;"> | ||
<div style="width: 50px; min-width: stretch; height: 100px; background: green;"></div> | ||
</div> |
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,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>CSS Intrinsic & Extrinsic Sizing Test: parsing stretch value</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#sizing-values"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/css/support/parsing-testcommon.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
test_valid_value("width", "stretch"); | ||
test_valid_value("height", "stretch"); | ||
test_valid_value("max-width", "stretch"); | ||
test_valid_value("min-width", "stretch"); | ||
test_valid_value("max-height", "stretch"); | ||
test_valid_value("min-height", "stretch"); | ||
test_valid_value("inline-size", "stretch"); | ||
test_valid_value("block-size", "stretch"); | ||
test_valid_value("max-inline-size", "stretch"); | ||
test_valid_value("min-inline-size", "stretch"); | ||
test_valid_value("max-block-size", "stretch"); | ||
test_valid_value("min-block-size", "stretch"); | ||
test_valid_value("flex-basis", "stretch"); | ||
</script> | ||
</body> | ||
</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,20 @@ | ||
<!DOCTYPE html> | ||
<link rel="match" href="../../reference/ref-filled-green-100px-square-only.html"> | ||
<link rel="help" href="https://github.com/webcompat/web-bugs/issues/103641#issuecomment-1122414992"> | ||
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1324259"> | ||
<p>Test passes if there is a filled green square.</p> | ||
<style> | ||
#target { | ||
position: absolute; | ||
background: green; | ||
min-width: 50px; | ||
min-height: 25px; | ||
width: stretch; | ||
height: stretch; | ||
} | ||
</style> | ||
<div style="display: flow-root; position: relative; width: 150px; height: 150px; margin-top: -50px; margin-left: -50px;"> | ||
<div style="margin-left: 50px; margin-top: 50px;"> | ||
<div id="target"></div> | ||
</div> | ||
</div> |
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,18 @@ | ||
<!DOCTYPE html> | ||
<link rel="match" href="../../reference/ref-filled-green-100px-square-only.html"> | ||
<link rel="help" href="https://github.com/webcompat/web-bugs/issues/103641#issuecomment-1122414992"> | ||
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1324259"> | ||
<p>Test passes if there is a filled green square.</p> | ||
<style> | ||
canvas { | ||
position: absolute; | ||
background: green; | ||
width: stretch; | ||
height: stretch; | ||
} | ||
</style> | ||
<div style="display: flow-root; position: relative; width: 150px; height: 150px; margin-top: -50px; margin-left: -50px;"> | ||
<div style="margin-left: 50px; margin-top: 50px;"> | ||
<canvas width="50" height="25"></canvas> | ||
</div> | ||
</div> |
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