Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Side by Side Diff: LayoutTests/fast/css-grid-layout/resources/grid-item-column-row-parsing-utils.js

Issue 17601010: [CSS Grid Layout] Rename grid placement properties (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: missing webposed/ changes Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 (function() { 1 (function() {
2 2
3 function checkColumnRowValues(gridItem, columnValue, rowValue) 3 function checkColumnRowValues(gridItem, columnValue, rowValue)
4 { 4 {
5 this.gridItem = gridItem; 5 this.gridItem = gridItem;
6 this.gridColumnValue = columnValue; 6 this.gridColumnValue = columnValue;
7 this.gridRowValue = rowValue; 7 this.gridRowValue = rowValue;
8 8
9 var gridStartEndValues = columnValue.split("/") 9 var gridColumnStartEndValues = columnValue.split("/")
10 this.gridStartValue = gridStartEndValues[0].trim(); 10 this.gridColumnStartValue = gridColumnStartEndValues[0].trim();
11 this.gridEndValue = gridStartEndValues[1].trim(); 11 this.gridColumnEndValue = gridColumnStartEndValues[1].trim();
12 12
13 var gridBeforeAfterValues = rowValue.split("/") 13 var gridRowStartEndValues = rowValue.split("/")
14 this.gridBeforeValue = gridBeforeAfterValues[0].trim(); 14 this.gridRowStartValue = gridRowStartEndValues[0].trim();
15 this.gridAfterValue = gridBeforeAfterValues[1].trim(); 15 this.gridRowEndValue = gridRowStartEndValues[1].trim();
16 16
17 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-column')", " gridColumnValue"); 17 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-column')", " gridColumnValue");
18 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-start')", "g ridStartValue"); 18 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-column-start ')", "gridColumnStartValue");
19 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-end')", "gri dEndValue"); 19 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-column-end') ", "gridColumnEndValue");
20 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-row')", "gri dRowValue"); 20 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-row')", "gri dRowValue");
21 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-before')", " gridBeforeValue"); 21 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-row-start')" , "gridRowStartValue");
22 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-after')", "g ridAfterValue"); 22 shouldBe("getComputedStyle(gridItem, '').getPropertyValue('grid-row-end')", "gridRowEndValue");
23 } 23 }
24 24
25 window.testColumnRowCSSParsing = function(id, columnValue, rowValue) 25 window.testColumnRowCSSParsing = function(id, columnValue, rowValue)
26 { 26 {
27 var gridItem = document.getElementById(id); 27 var gridItem = document.getElementById(id);
28 checkColumnRowValues(gridItem, columnValue, rowValue); 28 checkColumnRowValues(gridItem, columnValue, rowValue);
29 } 29 }
30 30
31 window.testColumnRowJSParsing = function(columnValue, rowValue, expectedColumnVa lue, expectedRowValue) 31 window.testColumnRowJSParsing = function(columnValue, rowValue, expectedColumnVa lue, expectedRowValue)
32 { 32 {
33 var gridItem = document.createElement("div"); 33 var gridItem = document.createElement("div");
34 document.body.appendChild(gridItem); 34 document.body.appendChild(gridItem);
35 gridItem.style.gridColumn = columnValue; 35 gridItem.style.gridColumn = columnValue;
36 gridItem.style.gridRow = rowValue; 36 gridItem.style.gridRow = rowValue;
37 37
38 checkColumnRowValues(gridItem, expectedColumnValue ? expectedColumnValue : c olumnValue, expectedRowValue ? expectedRowValue : rowValue); 38 checkColumnRowValues(gridItem, expectedColumnValue ? expectedColumnValue : c olumnValue, expectedRowValue ? expectedRowValue : rowValue);
39 39
40 document.body.removeChild(gridItem); 40 document.body.removeChild(gridItem);
41 } 41 }
42 42
43 window.testStartBeforeJSParsing = function(startValue, beforeValue, expectedStar tValue, expectedBeforeValue) 43 window.testColumnStartRowStartJSParsing = function(columnStartValue, rowStartVal ue, expectedColumnStartValue, expectedRowStartValue)
44 { 44 {
45 var gridItem = document.createElement("div"); 45 var gridItem = document.createElement("div");
46 document.body.appendChild(gridItem); 46 document.body.appendChild(gridItem);
47 gridItem.style.gridStart = startValue; 47 gridItem.style.gridColumnStart = columnStartValue;
48 gridItem.style.gridBefore = beforeValue; 48 gridItem.style.gridRowStart = rowStartValue;
49 49
50 if (expectedStartValue === undefined) 50 if (expectedColumnStartValue === undefined)
51 expectedStartValue = startValue; 51 expectedColumnStartValue = columnStartValue;
52 if (expectedBeforeValue === undefined) 52 if (expectedRowStartValue === undefined)
53 expectedBeforeValue = beforeValue; 53 expectedRowStartValue = rowStartValue;
54 54
55 checkColumnRowValues(gridItem, expectedStartValue + " / auto", expectedBefor eValue + " / auto"); 55 checkColumnRowValues(gridItem, expectedColumnStartValue + " / auto", expecte dRowStartValue + " / auto");
56 56
57 document.body.removeChild(gridItem); 57 document.body.removeChild(gridItem);
58 } 58 }
59 59
60 window.testEndAfterJSParsing = function(endValue, afterValue, expectedEndValue, expectedAfterValue) 60 window.testColumnEndRowEndJSParsing = function(columnEndValue, rowEndValue, expe ctedColumnEndValue, expectedRowEndValue)
61 { 61 {
62 var gridItem = document.createElement("div"); 62 var gridItem = document.createElement("div");
63 document.body.appendChild(gridItem); 63 document.body.appendChild(gridItem);
64 gridItem.style.gridEnd = endValue; 64 gridItem.style.gridColumnEnd = columnEndValue;
65 gridItem.style.gridAfter = afterValue; 65 gridItem.style.gridRowEnd = rowEndValue;
66 66
67 if (expectedEndValue === undefined) 67 if (expectedColumnEndValue === undefined)
68 expectedEndValue = endValue; 68 expectedColumnEndValue = columnEndValue;
69 if (expectedAfterValue === undefined) 69 if (expectedRowEndValue === undefined)
70 expectedAfterValue = afterValue; 70 expectedRowEndValue = rowEndValue;
71 71
72 checkColumnRowValues(gridItem, "auto / " + expectedEndValue, "auto / " + exp ectedAfterValue); 72 checkColumnRowValues(gridItem, "auto / " + expectedColumnEndValue, "auto / " + expectedRowEndValue);
73 73
74 document.body.removeChild(gridItem); 74 document.body.removeChild(gridItem);
75 } 75 }
76 76
77 window.testColumnRowInvalidJSParsing = function(columnValue, rowValue) 77 window.testColumnRowInvalidJSParsing = function(columnValue, rowValue)
78 { 78 {
79 var gridItem = document.createElement("div"); 79 var gridItem = document.createElement("div");
80 document.body.appendChild(gridItem); 80 document.body.appendChild(gridItem);
81 gridItem.style.gridColumn = columnValue; 81 gridItem.style.gridColumn = columnValue;
82 gridItem.style.gridRow = rowValue; 82 gridItem.style.gridRow = rowValue;
83 83
84 checkColumnRowValues(gridItem, "auto / auto", "auto / auto"); 84 checkColumnRowValues(gridItem, "auto / auto", "auto / auto");
85 85
86 document.body.removeChild(gridItem); 86 document.body.removeChild(gridItem);
87 } 87 }
88 88
89 var placeholderParentStartValueForInherit = "6"; 89 var placeholderParentColumnStartValueForInherit = "6";
90 var placeholderParentEndValueForInherit = "span 2"; 90 var placeholderParentColumnEndValueForInherit = "span 2";
91 var placeholderParentColumnValueForInherit = placeholderParentStartValueForInher it + " / " + placeholderParentEndValueForInherit; 91 var placeholderParentColumnValueForInherit = placeholderParentColumnStartValueFo rInherit + " / " + placeholderParentColumnEndValueForInherit;
92 var placeholderParentBeforeValueForInherit = "span 1"; 92 var placeholderParentRowStartValueForInherit = "span 1";
93 var placeholderParentAfterValueForInherit = "7"; 93 var placeholderParentRowEndValueForInherit = "7";
94 var placeholderParentRowValueForInherit = placeholderParentBeforeValueForInherit + " / " + placeholderParentAfterValueForInherit; 94 var placeholderParentRowValueForInherit = placeholderParentRowStartValueForInher it + " / " + placeholderParentRowEndValueForInherit;
95 95
96 var placeholderStartValueForInitial = "1"; 96 var placeholderColumnStartValueForInitial = "1";
97 var placeholderEndValueForInitial = "span 2"; 97 var placeholderColumnEndValueForInitial = "span 2";
98 var placeholderColumnValueForInitial = placeholderStartValueForInitial + " / " + placeholderEndValueForInitial; 98 var placeholderColumnValueForInitial = placeholderColumnStartValueForInitial + " / " + placeholderColumnEndValueForInitial;
99 var placeholderBeforeValueForInitial = "span 3"; 99 var placeholderRowStartValueForInitial = "span 3";
100 var placeholderAfterValueForInitial = "5"; 100 var placeholderRowEndValueForInitial = "5";
101 var placeholderRowValueForInitial = placeholderBeforeValueForInitial + " / " + p laceholderAfterValueForInitial; 101 var placeholderRowValueForInitial = placeholderRowStartValueForInitial + " / " + placeholderRowEndValueForInitial;
102 102
103 function setupInheritTest() 103 function setupInheritTest()
104 { 104 {
105 var parentElement = document.createElement("div"); 105 var parentElement = document.createElement("div");
106 document.body.appendChild(parentElement); 106 document.body.appendChild(parentElement);
107 parentElement.style.gridColumn = placeholderParentColumnValueForInherit; 107 parentElement.style.gridColumn = placeholderParentColumnValueForInherit;
108 parentElement.style.gridRow = placeholderParentRowValueForInherit; 108 parentElement.style.gridRow = placeholderParentRowValueForInherit;
109 109
110 var gridItem = document.createElement("div"); 110 var gridItem = document.createElement("div");
111 parentElement.appendChild(gridItem); 111 parentElement.appendChild(gridItem);
(...skipping 16 matching lines...) Expand all
128 var parentElement = setupInheritTest(); 128 var parentElement = setupInheritTest();
129 var gridItem = parentElement.firstChild; 129 var gridItem = parentElement.firstChild;
130 gridItem.style.gridColumn = columnValue; 130 gridItem.style.gridColumn = columnValue;
131 gridItem.style.gridRow = rowValue; 131 gridItem.style.gridRow = rowValue;
132 132
133 checkColumnRowValues(gridItem, columnValue !== "inherit" ? columnValue : pla ceholderParentColumnValueForInherit, rowValue !== "inherit" ? rowValue : placeho lderParentRowValueForInherit); 133 checkColumnRowValues(gridItem, columnValue !== "inherit" ? columnValue : pla ceholderParentColumnValueForInherit, rowValue !== "inherit" ? rowValue : placeho lderParentRowValueForInherit);
134 134
135 document.body.removeChild(parentElement); 135 document.body.removeChild(parentElement);
136 } 136 }
137 137
138 window.testStartBeforeInheritJSParsing = function(startValue, beforeValue) 138 window.testColumnStartRowStartInheritJSParsing = function(columnStartValue, rowS tartValue)
139 { 139 {
140 var parentElement = setupInheritTest(); 140 var parentElement = setupInheritTest();
141 var gridItem = parentElement.firstChild; 141 var gridItem = parentElement.firstChild;
142 gridItem.style.gridStart = startValue; 142 gridItem.style.gridColumnStart = columnStartValue;
143 gridItem.style.gridBefore = beforeValue; 143 gridItem.style.gridRowStart = rowStartValue;
144 144
145 // Initial value is 'auto' but we shouldn't touch the opposite grid line. 145 // Initial value is 'auto' but we shouldn't touch the opposite grid line.
146 var columnValueForInherit = (startValue !== "inherit" ? startValue : placeho lderParentStartValueForInherit) + " / auto"; 146 var columnValueForInherit = (columnStartValue !== "inherit" ? columnStartVal ue : placeholderParentColumnStartValueForInherit) + " / auto";
147 var rowValueForInherit = (beforeValue !== "inherit" ? beforeValue : placehol derParentBeforeValueForInherit) + " / auto"; 147 var rowValueForInherit = (rowStartValue !== "inherit" ? rowStartValue : plac eholderParentRowStartValueForInherit) + " / auto";
148 checkColumnRowValues(parentElement.firstChild, columnValueForInherit, rowVal ueForInherit); 148 checkColumnRowValues(parentElement.firstChild, columnValueForInherit, rowVal ueForInherit);
149 149
150 document.body.removeChild(parentElement); 150 document.body.removeChild(parentElement);
151 } 151 }
152 152
153 window.testEndAfterInheritJSParsing = function(endValue, afterValue) 153 window.testColumnEndRowEndInheritJSParsing = function(columnEndValue, rowEndValu e)
154 { 154 {
155 var parentElement = setupInheritTest(); 155 var parentElement = setupInheritTest();
156 var gridItem = parentElement.firstChild; 156 var gridItem = parentElement.firstChild;
157 gridItem.style.gridEnd = endValue; 157 gridItem.style.gridColumnEnd = columnEndValue;
158 gridItem.style.gridAfter = afterValue; 158 gridItem.style.gridRowEnd = rowEndValue;
159 159
160 // Initial value is 'auto' but we shouldn't touch the opposite grid line. 160 // Initial value is 'auto' but we shouldn't touch the opposite grid line.
161 var columnValueForInherit = "auto / " + (endValue !== "inherit" ? endValue : placeholderParentEndValueForInherit); 161 var columnValueForInherit = "auto / " + (columnEndValue !== "inherit" ? colu mnEndValue : placeholderParentColumnEndValueForInherit);
162 var rowValueForInherit = "auto / " + (afterValue !== "inherit" ? afterValue : placeholderParentAfterValueForInherit); 162 var rowValueForInherit = "auto / " + (rowEndValue !== "inherit" ? rowEndValu e : placeholderParentRowEndValueForInherit);
163 checkColumnRowValues(parentElement.firstChild, columnValueForInherit, rowVal ueForInherit); 163 checkColumnRowValues(parentElement.firstChild, columnValueForInherit, rowVal ueForInherit);
164 164
165 document.body.removeChild(parentElement); 165 document.body.removeChild(parentElement);
166 } 166 }
167 167
168 window.testColumnRowInitialJSParsing = function() 168 window.testColumnRowInitialJSParsing = function()
169 { 169 {
170 var gridItem = setupInitialTest(); 170 var gridItem = setupInitialTest();
171 171
172 gridItem.style.gridColumn = "initial"; 172 gridItem.style.gridColumn = "initial";
173 checkColumnRowValues(gridItem, "auto / auto", placeholderRowValueForInitial) ; 173 checkColumnRowValues(gridItem, "auto / auto", placeholderRowValueForInitial) ;
174 174
175 gridItem.style.gridRow = "initial"; 175 gridItem.style.gridRow = "initial";
176 checkColumnRowValues(gridItem, "auto / auto", "auto / auto"); 176 checkColumnRowValues(gridItem, "auto / auto", "auto / auto");
177 177
178 document.body.removeChild(gridItem); 178 document.body.removeChild(gridItem);
179 } 179 }
180 180
181 window.testStartBeforeInitialJSParsing = function() 181 window.testColumnStartRowStartInitialJSParsing = function()
182 { 182 {
183 var gridItem = setupInitialTest(); 183 var gridItem = setupInitialTest();
184 184
185 gridItem.style.gridStart = "initial"; 185 gridItem.style.gridColumnStart = "initial";
186 checkColumnRowValues(gridItem, "auto / " + placeholderEndValueForInitial, pl aceholderRowValueForInitial); 186 checkColumnRowValues(gridItem, "auto / " + placeholderColumnEndValueForIniti al, placeholderRowValueForInitial);
187 187
188 gridItem.style.gridBefore = "initial"; 188 gridItem.style.gridRowStart = "initial";
189 checkColumnRowValues(gridItem, "auto / " + placeholderEndValueForInitial, " auto / " + placeholderAfterValueForInitial); 189 checkColumnRowValues(gridItem, "auto / " + placeholderColumnEndValueForInit ial, "auto / " + placeholderRowEndValueForInitial);
190 190
191 document.body.removeChild(gridItem); 191 document.body.removeChild(gridItem);
192 } 192 }
193 193
194 window.testEndAfterInitialJSParsing = function() 194 window.testEndAfterInitialJSParsing = function()
195 { 195 {
196 var gridItem = setupInitialTest(); 196 var gridItem = setupInitialTest();
197 197
198 gridItem.style.gridEnd = "initial"; 198 gridItem.style.gridColumnEnd = "initial";
199 checkColumnRowValues(gridItem, placeholderStartValueForInitial + " / auto", placeholderRowValueForInitial); 199 checkColumnRowValues(gridItem, placeholderColumnStartValueForInitial + " / a uto", placeholderRowValueForInitial);
200 200
201 gridItem.style.gridAfter = "initial"; 201 gridItem.style.gridRowEnd = "initial";
202 checkColumnRowValues(gridItem, placeholderStartValueForInitial + " / auto", placeholderBeforeValueForInitial + " / auto"); 202 checkColumnRowValues(gridItem, placeholderColumnStartValueForInitial + " / a uto", placeholderRowStartValueForInitial + " / auto");
203 203
204 document.body.removeChild(gridItem); 204 document.body.removeChild(gridItem);
205 } 205 }
206 206
207 })(); 207 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698