summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-grid/layout-algorithm/baseline-alignment-affects-intrinsic-size-002.html
blob: c48bedccd5ab1303be060b88d04aacd927585f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Grid Layout Test: evaluate how the baseline affects the grid intrinsic size</title>
<link rel="author" title="Javier Fernandez" href="mailto:jfernandez@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-grid/#alignment">
<link rel="help" href="https://drafts.csswg.org/css-align-3/#baseline-align-self">
<link rel="help" href="https://drafts.csswg.org/css-align-3/#align-by-baseline">
<link rel="stylesheet" href="/fonts/ahem.css">
<link rel="stylesheet" href="/css/support/alignment.css">
<link rel="stylesheet" href="/css/support/grid.css">
<meta name="assert" content="The grid intrinsic size is comptuted correctly, considering the effect of baseline alignment in the size of the column tracks" />
<style>
.grid {
   position: relative;
   background: grey;
   float: left;
   margin: 5px;
   text-orientation: sideways;
   height: 350px;
   font-family: Ahem;
   line-height: 1;
   grid-auto-flow: row;
}
.grid > :nth-child(1) { font-size:20px; }
.grid > :nth-child(2) { font-size:30px; }
.grid > :nth-child(3) { font-size:50px; }
.grid > :nth-child(4) { font-size:60px; }
.item {
   border-width: 2px 5px 3px 4px;
   border-style: solid;
   padding: 6px 3px 7px 8px;
   margin: 10px 6px 4px 12px;
}
.extraLeftPadding { padding-left: 50px; }
.extraRightPadding { padding-right: 50px; }
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
  setup({ explicit_done: true });
</script>

<body onload="document.fonts.ready.then(() => { runTests(); })">

<p>4x1 with orthogonal items.</p>
<div id="grid1" class="grid contentStart itemsBaseline" data-expected-width="98">
    <div class="item verticalLR"                   data-offset-x="20" data-offset-y="10"  data-expected-width="40" data-expected-height="38">É</div>
    <div class="item verticalLR"                   data-offset-x="18" data-offset-y="62"  data-expected-width="50" data-expected-height="48">É</div>
    <div class="item verticalLR"                   data-offset-x="14" data-offset-y="124" data-expected-width="70" data-expected-height="68">É</div>
    <div class="item verticalLR"                   data-offset-x="12" data-offset-y="206" data-expected-width="80" data-expected-height="78">É</div>
</div>
<div id="grid2" class="grid contentStart itemsBaseline" data-expected-width="149">
    <div class="item verticalLR extraRightPadding" data-offset-x="56" data-offset-y="10"  data-expected-width="87" data-expected-height="38">É</div>
    <div class="item verticalLR extraLeftPadding"  data-offset-x="12" data-offset-y="62"  data-expected-width="92" data-expected-height="48">É</div>
    <div class="item verticalLR"                   data-offset-x="50" data-offset-y="124" data-expected-width="70" data-expected-height="68">É</div>
    <div class="item verticalLR"                   data-offset-x="48" data-offset-y="206" data-expected-width="80" data-expected-height="78">É</div>
</div>
<div id="grid3" class="grid contentStart itemsBaseline" data-expected-width="98">
    <div class="item verticalRL"                   data-offset-x="20" data-offset-y="10"  data-expected-width="40" data-expected-height="38">É</div>
    <div class="item verticalRL"                   data-offset-x="18" data-offset-y="62"  data-expected-width="50" data-expected-height="48">É</div>
    <div class="item verticalRL"                   data-offset-x="14" data-offset-y="124" data-expected-width="70" data-expected-height="68">É</div>
    <div class="item verticalRL"                   data-offset-x="12" data-offset-y="206" data-expected-width="80" data-expected-height="78">É</div>
</div>
<div id="grid4" class="grid contentStart itemsBaseline" data-expected-width="149">
    <div class="item verticalRL extraRightPadding" data-offset-x="56" data-offset-y="10"  data-expected-width="87" data-expected-height="38">É</div>
    <div class="item verticalRL extraLeftPadding"  data-offset-x="12" data-offset-y="62"  data-expected-width="92" data-expected-height="48">É</div>
    <div class="item verticalRL"                   data-offset-x="50" data-offset-y="124" data-expected-width="70" data-expected-height="68">É</div>
    <div class="item verticalRL"                   data-offset-x="48" data-offset-y="206" data-expected-width="80" data-expected-height="78">É</div>
</div>

<br clear="all">

<script>
    "use strict";
    function runTests() {

        let values = [ "auto", "min-content", "max-content" ];
        let minValues = values.concat([ "0px" ]);

        var grid1 = document.getElementById("grid1");
        var grid2 = document.getElementById("grid2");
        var grid3 = document.getElementById("grid3");
        var grid4 = document.getElementById("grid4");

        minValues.forEach(function (minValue) {
            values.forEach(function (maxValue) {

                grid1.id = "grid1-" + minValue + "-" + maxValue
                grid2.id = "grid2-" + minValue + "-" + maxValue
                grid3.id = "grid3-" + minValue + "-" + maxValue
                grid4.id = "grid4-" + minValue + "-" + maxValue

                grid1.style.gridTemplateColumns = "minmax(" + minValue + ", " + maxValue + ")";
                grid2.style.gridTemplateColumns = "minmax(" + minValue + ", " + maxValue + ")";
                grid3.style.gridTemplateColumns = "minmax(" + minValue + ", " + maxValue + ")";
                grid4.style.gridTemplateColumns = "minmax(" + minValue + ", " + maxValue + ")";

                checkLayout("#" + grid1.id, false);
                checkLayout("#" + grid2.id, false);
                checkLayout("#" + grid3.id, false);
                checkLayout("#" + grid4.id, false);
            });
        });

        done();
    }
</script>

</body>