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

Side by Side Diff: LayoutTests/fast/writing-mode/text-orientation-mongolian-phagspa.html

Issue 1206883002: Fix default text orientation that do not conform Unicode Technical Report #50 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <style>
4 @font-face {
5 font-family:cssot-h;
6 src:url(../../third_party/adobe-fonts/CSSHWOrientationTest.otf);
7 }
8 #container {
9 font-family:cssot-h;
10 }
11 .v {
12 -webkit-writing-mode:vertical-lr;
13 }
14 #s {
15 -webkit-text-orientation:sideways;
16 }
17 #u {
18 -webkit-text-orientation:upright;
19 }
20 </style>
21 <div id="container">
22 <pre><span id="h"></span></pre>
23 <div class="v">
24 <div>A</div>
25 <div id="v"></div>
26 <div id="u"></div>
27 <div id="s"></div>
28 </div>
29 </div>
30 <script>
31 (function () {
32 description('Confirms Mongolian and Phags-Pa are oriented correctly in verti cal flow.');
33 jsTestIsAsync = true;
34 window.onload = function () {
35 testRange('Mongolian', 0x1800, 0x18AF, [0x180B, 0x180C, 0x180D, 0x180E, 0x18A9]);
36 testRange('Phags-Pa', 0xA840, 0xA87F);
37 finishJSTest();
38 };
39
40 function testRange(name, start, end, allowed_inconclusives) {
41 list = [];
42 for (var code = start; code <= end; ++code)
43 list.push(dataFromCode(code));
44 var failed = 0;
45 allowed_inconclusives = allowed_inconclusives || [];
46 inconclusives = {};
47 allowed_inconclusives.forEach(function (code) { inconclusives[code] = tr ue; });
48 for (var i = 0; i < list.length; ++i) {
49 var data = list[i];
50 if (!testData(data, inconclusives))
51 ++failed;
52 }
53 if (!failed)
54 testPassed(name + ': U+' + start.toString(16) + '-' + end.toString(1 6));
55 clean();
56 }
57
58 var horizontal = document.getElementById('h');
59 var vertical = document.getElementById('v');
60 var sideways = document.getElementById('s');
61 var upright = document.getElementById('u');
62
63 function dataFromCode(code) {
64 var ch = String.fromCharCode(code);
65 return {
66 code:code,
67 h:spanFromText(ch, horizontal),
68 v:spanFromText(ch, vertical),
69 u:spanFromText(ch, upright),
70 s:spanFromText(ch, sideways),
71 };
72 }
73
74 function spanFromText(text, parent) {
75 var node = document.createElement('span');
76 node.innerText = text;
77 parent.appendChild(node);
78 return node;
79 }
80
81 function testData(data, inconclusives) {
82 var v = data.v.getBoundingClientRect(),
83 u = data.u.getBoundingClientRect(),
84 s = data.s.getBoundingClientRect(),
85 isUpright = v.width == u.width && v.height == u.height,
86 isSideways = v.width == s.width && v.height == s.height;
87 if ((isUpright && isSideways) || (!isUpright && !isSideways)) {
88 if (data.code in inconclusives) {
89 testPassed('Inconclusive U+' + dataToString(data));
90 return true;
91 }
92 testFailed('Inconclusive ' + dataToString(data));
93 return false;
94 }
95 if (isSideways)
96 return true;
97 testFailed('Is upright ' + dataToString(data));
98 return false;
99 }
100
101 function dataToString(data) {
102 return 'U+' + data.code.toString(16) + ': vertical=' + sizeToString(data .v) + ', upright=' + sizeToString(data.u) + ', sideways=' + sizeToString(data.s) ;
103 }
104
105 function sizeToString(size) {
106 size = size.getBoundingClientRect();
107 return size.width + 'x' + size.height;
108 }
109
110 function clean() {
111 removeAllChildren(horizontal);
112 removeAllChildren(vertical);
113 removeAllChildren(sideways);
114 removeAllChildren(upright);
115 }
116
117 function removeAllChildren(parent) {
118 var child;
119 while (child = parent.lastChild)
120 parent.removeChild(child);
121 }
122 })();
123 </script>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/fast/writing-mode/text-orientation-mongolian-phagspa-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698