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

Side by Side Diff: LayoutTests/imported/csswg-test/css-writing-modes-3/support/text-orientation.js

Issue 1157103007: update-w3c-deps import using blink b712b6ce0eb599d90d890aa609f596c7852fb824 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Skip swfsoures Created 5 years, 6 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 function OrientationTester(container, orientation) { 2 function OrientationTester(container, orientation) {
3 this.container = container; 3 this.container = container;
4 this.setOrientation(orientation); 4 this.setOrientation(orientation);
5 } 5 }
6 extend(OrientationTester.prototype, { 6 extend(OrientationTester.prototype, {
7 setOrientation: function (orientation) { 7 setOrientation: function (orientation) {
8 this.orientation = orientation; 8 this.orientation = orientation;
9 }, 9 },
10 measure: function (results) { 10 measure: function (results) {
11 this.results = results; 11 this.results = results;
12 this._measureNode(this.container); 12 this._measureNode(this.container);
13 }, 13 },
14 _measureNode: function (node) { 14 _measureNode: function (node, block) {
15 switch (node.nodeType) { 15 switch (node.nodeType) {
16 case Node.ELEMENT_NODE: 16 case Node.ELEMENT_NODE:
17 var blockOverride = node.dataset.block;
18 if (blockOverride)
19 block = blockOverride;
17 var nodes = node.childNodes; 20 var nodes = node.childNodes;
18 for (var i = 0; i < nodes.length; i++) 21 for (var i = 0; i < nodes.length; i++)
19 this._measureNode(nodes[i]); 22 this._measureNode(nodes[i], block);
20 return; 23 return;
21 case Node.TEXT_NODE: 24 case Node.TEXT_NODE:
22 break; 25 break;
23 default: 26 default:
24 return; 27 return;
25 } 28 }
26 29
27 if (this.orientation == "R") { 30 if (this.orientation == "R") {
28 var advanceExpected = 8; 31 var advanceExpected = 8;
29 var advanceFailed = 4; 32 var advanceFailed = 4;
(...skipping 18 matching lines...) Expand all
48 } 51 }
49 range.setEnd(node, ich + 1); 52 range.setEnd(node, ich + 1);
50 rect = range.getBoundingClientRect(); 53 rect = range.getBoundingClientRect();
51 if (rect.width == 16) { 54 if (rect.width == 16) {
52 if (rect.height == advanceExpected) { 55 if (rect.height == advanceExpected) {
53 this.results.passCount++; 56 this.results.passCount++;
54 continue; 57 continue;
55 } 58 }
56 //log("U+" + stringFromUnicode(code) + " " + rect.width + "x " + rect.height); 59 //log("U+" + stringFromUnicode(code) + " " + rect.width + "x " + rect.height);
57 if (rect.height == advanceFailed) { 60 if (rect.height == advanceFailed) {
58 this.results.failed(this, code); 61 this.results.failed(this, code, block);
59 continue; 62 continue;
60 } 63 }
61 } 64 }
62 this.results.inconclusive(this, code, rect); 65 this.results.inconclusive(this, code, block, rect);
63 } 66 }
64 }}); 67 }});
65 68
66 function Results(name) { 69 function Results(name) {
67 var block = document.createElement("details"); 70 var block = document.createElement("details");
68 this.summary = appendChildElement(block, "summary"); 71 this.summary = appendChildElement(block, "summary");
69 this.summary.textContent = name; 72 this.summary.textContent = name;
70 var typeList = appendChildElement(block, "ul"); 73 var typeList = appendChildElement(block, "ul");
71 this.failList = appendChildElement(appendChildElement(typeList, "li", "F ailures"), "ol"); 74 this.failList = appendChildElement(appendChildElement(typeList, "li", "F ailures"), "ol");
72 this.inconclusiveList = appendChildElement(appendChildElement(typeList, "li", "Inconclusives"), "ol"); 75 this.inconclusiveList = appendChildElement(appendChildElement(typeList, "li", "Inconclusives"), "ol");
73 details.appendChild(block); 76 details.appendChild(block);
74 this.passCount = 0; 77 this.passCount = 0;
75 this.failCount = 0; 78 this.failCount = 0;
76 this.inconclusiveCount = 0; 79 this.inconclusiveCount = 0;
77 } 80 }
78 extend(Results.prototype, { 81 extend(Results.prototype, {
79 failed: function (test, code) { 82 failed: function (test, code, block) {
80 this.failCount++; 83 this.failCount++;
81 this.append(this.failList, test, code); 84 this.append(this.failList, test, code, block);
82 }, 85 },
83 inconclusive: function (test, code, rect) { 86 inconclusive: function (test, code, block, rect) {
84 this.inconclusiveCount++; 87 this.inconclusiveCount++;
85 this.append(this.inconclusiveList, test, code, " but inconclusive (r endered as " + rect.width + "x" + rect.height + ")"); 88 this.append(this.inconclusiveList, test, code, block, " but inconclu sive (rendered as " + rect.width + "x" + rect.height + ")");
86 }, 89 },
87 append: function (list, test, code, message) { 90 append: function (list, test, code, block, message) {
88 var text = stringFromUnicode(code) + " should be " + test.orientatio n; 91 var text = stringFromUnicode(code) + " should be " + test.orientatio n;
92 if (block)
93 text = block + ": " + text;
89 if (message) 94 if (message)
90 text += message; 95 text += message;
91 appendChildElement(list, "li", text); 96 appendChildElement(list, "li", text);
92 }, 97 },
93 done: function (test) { 98 done: function (test) {
94 this.summary.textContent += " (" + this.passCount + " passes, " + 99 this.summary.textContent += " (" + this.passCount + " passes, " +
95 this.failCount + " fails, " + 100 this.failCount + " fails, " +
96 this.inconclusiveCount + " inconclusives)"; 101 this.inconclusiveCount + " inconclusives)";
97 assert_equals(this.failCount, 0, "Fail count"); 102 assert_equals(this.failCount, 0, "Fail count");
98 assert_greater_than(this.passCount, 0, "Pass count"); 103 assert_greater_than(this.passCount, 0, "Pass count");
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 var tester = me.testers[i]; 146 var tester = me.testers[i];
142 tester.setOrientation(orientation); 147 tester.setOrientation(orientation);
143 tester.measure(results); 148 tester.measure(results);
144 } 149 }
145 results.done(test); 150 results.done(test);
146 }) 151 })
147 container.classList.remove(orientation); 152 container.classList.remove(orientation);
148 }}); 153 }});
149 154
150 setup({explicit_done:true, explicit_timeout:true}); 155 setup({explicit_done:true, explicit_timeout:true});
151 var blocks = arrayFromRangesByValue(rangesByBlock);
152 var runner = new Runner(); 156 var runner = new Runner();
153 window.onload = function () { 157 window.onload = function () {
154 if (window.location.search == "?wait") { 158 if (window.location.search == "?wait") {
155 log("Sleeping 5 secs for debug purpose"); 159 log("Sleeping 5 secs for debug purpose");
156 return setTimeout(run, 5000); 160 return setTimeout(run, 5000);
157 } 161 }
158 run(); 162 run();
159 } 163 }
160 164
161 function run() { 165 function run() {
(...skipping 24 matching lines...) Expand all
186 } 190 }
187 return array; 191 return array;
188 }; 192 };
189 193
190 function stringFromUnicode(code) { 194 function stringFromUnicode(code) {
191 var hex = code.toString(16).toUpperCase(); 195 var hex = code.toString(16).toUpperCase();
192 if (hex.length < 4) { 196 if (hex.length < 4) {
193 hex = "0000" + hex; 197 hex = "0000" + hex;
194 hex = hex.substr(hex.length - 4); 198 hex = hex.substr(hex.length - 4);
195 } 199 }
196 return blocks[code] + ": " + hex + ' "' + String.fromCharCode(code) + '" '; 200 return hex + ' "' + String.fromCharCode(code) + '"';
197 } 201 }
198 202
199 function appendChildElement(parent, tag, text) { 203 function appendChildElement(parent, tag, text) {
200 var node = document.createElement(tag); 204 var node = document.createElement(tag);
201 if (text) 205 if (text)
202 node.textContent = text; 206 node.textContent = text;
203 parent.appendChild(node); 207 parent.appendChild(node);
204 return node; 208 return node;
205 } 209 }
206 210
207 function extend(target, dict) { 211 function extend(target, dict) {
208 for (var key in dict) 212 for (var key in dict)
209 target[key] = dict[key]; 213 target[key] = dict[key];
210 } 214 }
211 215
212 function log(text) { 216 function log(text) {
213 console.log(text); 217 console.log(text);
214 } 218 }
215 })(); 219 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698