Skip to content

Commit

Permalink
[css-sizing] Computed min/max width/height (web-platform-tests#18521)
Browse files Browse the repository at this point in the history
The computed value for the following properties is
as specified, with <length-percentage> values computed.
- min-width
- min-height
- max-width
- max-height

https://drafts.csswg.org/css-sizing-3/#min-size-properties
https://drafts.csswg.org/css-sizing-3/#max-size-properties
  • Loading branch information
ewilligers authored Aug 20, 2019
1 parent 071a2e4 commit a655237
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 0 deletions.
34 changes: 34 additions & 0 deletions css/css-sizing/parsing/max-height-computed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS basic box model: getComputedStyle().maxHeight</title>
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#propdef-max-height">
<meta name="assert" content="max-height computed value is as specified, with <length-percentage> values computed">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<style>
#target {
font-size: 40px;
}
</style>
</head>
<body>
<div id="target"></div>
<script>
test_computed_value("max-height", "none");
test_computed_value("max-height", "min-content");
test_computed_value("max-height", "max-content");

test_computed_value("max-height", "10px");
test_computed_value("max-height", "20%");

test_computed_value('max-height', 'calc(10% + 40px)');
test_computed_value('max-height', 'calc(10px - 0.5em)', '0px');
test_computed_value('max-height', 'calc(10px + 0.5em)', '30px');

// fit-content not yet tested
</script>
</body>
</html>
34 changes: 34 additions & 0 deletions css/css-sizing/parsing/max-width-computed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS basic box model: getComputedStyle().maxWidth</title>
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#propdef-max-width">
<meta name="assert" content="max-width computed value is as specified, with <length-percentage> values computed">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<style>
#target {
font-size: 40px;
}
</style>
</head>
<body>
<div id="target"></div>
<script>
test_computed_value("max-width", "none");
test_computed_value("max-width", "min-content");
test_computed_value("max-width", "max-content");

test_computed_value("max-width", "10px");
test_computed_value("max-width", "20%");

test_computed_value('max-width', 'calc(10% + 40px)');
test_computed_value('max-width', 'calc(10px - 0.5em)', '0px');
test_computed_value('max-width', 'calc(10px + 0.5em)', '30px');

// fit-content not yet tested
</script>
</body>
</html>
33 changes: 33 additions & 0 deletions css/css-sizing/parsing/min-height-computed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS basic box model: getComputedStyle().minHeight</title>
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#propdef-min-height">
<meta name="assert" content="min-height computed value is as specified, with <length-percentage> values computed">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<style>
#target {
font-size: 40px;
}
</style>
</head>
<body>
<div id="target"></div>
<script>
test_computed_value("min-height", "min-content");
test_computed_value("min-height", "max-content");

test_computed_value("min-height", "10px");
test_computed_value("min-height", "20%");

test_computed_value('min-height', 'calc(10% + 40px)');
test_computed_value('min-height', 'calc(10px - 0.5em)', '0px');
test_computed_value('min-height', 'calc(10px + 0.5em)', '30px');

// fit-content not yet tested
</script>
</body>
</html>
33 changes: 33 additions & 0 deletions css/css-sizing/parsing/min-width-computed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS basic box model: getComputedStyle().minWidth</title>
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#propdef-min-width">
<meta name="assert" content="min-width computed value is as specified, with <length-percentage> values computed">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<style>
#target {
font-size: 40px;
}
</style>
</head>
<body>
<div id="target"></div>
<script>
test_computed_value("min-width", "min-content");
test_computed_value("min-width", "max-content");

test_computed_value("min-width", "10px");
test_computed_value("min-width", "20%");

test_computed_value('min-width', 'calc(10% + 40px)');
test_computed_value('min-width', 'calc(10px - 0.5em)', '0px');
test_computed_value('min-width', 'calc(10px + 0.5em)', '30px');

// fit-content not yet tested
</script>
</body>
</html>

0 comments on commit a655237

Please sign in to comment.