summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-item-change-order-auto-flow.html
blob: dcd57369078c6274b3b8ba6a87d1d9e6b4b60302 (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
<!DOCTYPE html>
<html>
<link href="resources/grid.css" rel="stylesheet">
<script src="../../resources/check-layout.js"></script>
<style>
.grid {
    grid-auto-flow: row;
    grid-template-rows: 50px 100px;
    grid-template-columns: 40px;
}

#firstGridItem {
    grid-row: auto;
    grid-column: 1;
}

#secondGridItem {
    grid-row: 1;
    grid-column: auto;
}

#thirdGridItem {
    grid-row: auto;
    grid-column: auto;
}
</style>
<script>
function testGridItemsOrder(firstGridItemData, secondGridItemData, thirdGridItemData)
{
    var firstGridItem = document.getElementById("firstGridItem");
    firstGridItem.style.order = firstGridItemData.order;
    firstGridItem.setAttribute("data-expected-width", firstGridItemData.width);
    firstGridItem.setAttribute("data-expected-height", firstGridItemData.height);
    firstGridItem.setAttribute("data-offset-x", firstGridItemData.x);
    firstGridItem.setAttribute("data-offset-y", firstGridItemData.y);

    var secondGridItem = document.getElementById("secondGridItem");
    secondGridItem.style.order = secondGridItemData.order;
    secondGridItem.setAttribute("data-expected-width", secondGridItemData.width);
    secondGridItem.setAttribute("data-expected-height", secondGridItemData.height);
    secondGridItem.setAttribute("data-offset-x", secondGridItemData.x);
    secondGridItem.setAttribute("data-offset-y", secondGridItemData.y);

    var thirdGridItem = document.getElementById("thirdGridItem");
    thirdGridItem.style.order = thirdGridItemData.order;
    thirdGridItem.setAttribute("data-expected-width", thirdGridItemData.width);
    thirdGridItem.setAttribute("data-expected-height", thirdGridItemData.height);
    thirdGridItem.setAttribute("data-offset-x", thirdGridItemData.x);
    thirdGridItem.setAttribute("data-offset-y", thirdGridItemData.y);

    checkLayout(".grid");
}

function testChangingGridItemsOrder()
{
    testGridItemsOrder({ 'order': '0', 'width': '40', 'height': '100', 'x': '0', 'y': '50' }, { 'order': '0', 'width': '40', 'height': '50', 'x': '0', 'y': '0' }, { 'order': '0', 'width': '40', 'height': '0', 'x': '0', 'y': '150' });
    testGridItemsOrder({ 'order': '0', 'width': '40', 'height': '100', 'x': '0', 'y': '50' }, { 'order': '-1', 'width': '40', 'height': '50', 'x': '0', 'y': '0' }, { 'order': '0', 'width': '40', 'height': '0', 'x': '0', 'y': '150' });
    testGridItemsOrder({ 'order': '1', 'width': '40', 'height': '0', 'x': '0', 'y': '150' }, { 'order': '-1', 'width': '40', 'height': '50', 'x': '0', 'y': '0' }, { 'order': '0', 'width': '40', 'height': '100', 'x': '0', 'y': '50' });
    testGridItemsOrder({ 'order': '1', 'width': '40', 'height': '100', 'x': '0', 'y': '50' }, { 'order': '-1', 'width': '40', 'height': '50', 'x': '0', 'y': '0' }, { 'order': '10', 'width': '40', 'height': '0', 'x': '0', 'y': '150' });
}

window.addEventListener("load", testChangingGridItemsOrder, false);
</script>
<body>
<div>This test checks that grid items' 'order' dynamic updates recomputes the positions of automatically placed grid items.</div>

<div style="position: relative">
    <div class="grid">
        <div class="sizedToGridArea" id="firstGridItem"></div>
        <div class="sizedToGridArea" id="secondGridItem"></div>
        <div class="sizedToGridArea" id="thirdGridItem"></div>
    </div>
</div>

</body>
</html>