4 <link href="resources/grid.css" rel="stylesheet">
5 <script src="../../resources/check-layout.js"></script>
6 <style type="text/css">
8 -webkit-grid-auto-flow: row dense;
12 -webkit-grid-row: auto;
13 -webkit-grid-column: column;
17 -webkit-grid-row: row;
18 -webkit-grid-column: auto;
22 -webkit-grid-row: auto;
23 -webkit-grid-column: auto;
27 function testGridDefinitions(gridTemplateRows, gridTemplateColumns, firstGridItemData, secondGridItemData, thirdGridItemData)
29 var gridElement = document.getElementsByClassName("grid")[0];
30 gridElement.style.webkitGridTemplateRows = gridTemplateRows;
31 gridElement.style.webkitGridTemplateColumns = gridTemplateColumns;
33 var firstGridItem = document.getElementById("firstGridItem");
34 firstGridItem.setAttribute("data-expected-width", firstGridItemData.width);
35 firstGridItem.setAttribute("data-expected-height", firstGridItemData.height);
36 firstGridItem.setAttribute("data-offset-x", firstGridItemData.x);
37 firstGridItem.setAttribute("data-offset-y", firstGridItemData.y);
39 var secondGridItem = document.getElementById("secondGridItem");
40 secondGridItem.setAttribute("data-expected-width", secondGridItemData.width);
41 secondGridItem.setAttribute("data-expected-height", secondGridItemData.height);
42 secondGridItem.setAttribute("data-offset-x", secondGridItemData.x);
43 secondGridItem.setAttribute("data-offset-y", secondGridItemData.y);
45 var thirdGridItem = document.getElementById("thirdGridItem");
46 thirdGridItem.setAttribute("data-expected-width", thirdGridItemData.width);
47 thirdGridItem.setAttribute("data-expected-height", thirdGridItemData.height);
48 thirdGridItem.setAttribute("data-offset-x", thirdGridItemData.x);
49 thirdGridItem.setAttribute("data-offset-y", thirdGridItemData.y);
54 function testChangingGridDefinitions()
56 testGridDefinitions('10px (row) 20px', '30px (column)', { 'width': '0', 'height': '10', 'x': '30', 'y': '0' }, { 'width': '30', 'height': '20', 'x': '0', 'y': '10' }, { 'width': '30', 'height': '10', 'x': '0', 'y': '0' });
57 testGridDefinitions('10px (row) 20px', '30px', { 'width': '30', 'height': '10', 'x': '0', 'y': '0' }, { 'width': '30', 'height': '20', 'x': '0', 'y': '10' }, { 'width': '30', 'height': '0', 'x': '0', 'y': '30' });
58 testGridDefinitions('10px 20px (row)', '30px', { 'width': '30', 'height': '10', 'x': '0', 'y': '0' }, { 'width': '30', 'height': '0', 'x': '0', 'y': '30' }, { 'width': '30', 'height': '20', 'x': '0', 'y': '10' });
59 testGridDefinitions('10px 20px (row)', '30px (column)', { 'width': '0', 'height': '10', 'x': '30', 'y': '0' }, { 'width': '30', 'height': '0', 'x': '0', 'y': '30' }, { 'width': '30', 'height': '10', 'x': '0', 'y': '0' });
62 window.addEventListener("load", testChangingGridDefinitions, false);
66 <div>This test checks that updating the named grid lines definitions in grid-template-{rows|columns} recomputes the positions of automatically placed grid items.</div>
68 <div style="position: relative">
70 <div class="sizedToGridArea" id="firstGridItem"></div>
71 <div class="sizedToGridArea" id="secondGridItem"></div>
72 <div class="sizedToGridArea" id="thirdGridItem"></div>