Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / text / line-break-after-inline-latin1.html
blob485222786ca5fc0f2cf6e36cbb48cabdaf21d77d
1 <html>
2 <head>
3 <title>Line breaks after span inlines - Latin1</title>
4 </head>
5 <body>
6 <meta charset=utf-8>
7 <div>
8 <p>With span inline on first word, Latin1 in second position of second word.</p>
9 <p style="font-family:courier; font-size:15px; width: 25px"><span>xx</span> xéx</p>
10 <p>With span inline on first word, Latin1 in first position of second word.</p>
11 <p style="font-family:courier; font-size:15px; width: 25px"><span>xx</span> éxx</p>
12 <p>With span inline on first word, no Latin1 in second word.</p>
13 <p style="font-family:courier; font-size:15px; width: 25px"><span>xx</span> xxx</p>
14 <p>Without span, Latin1 in second position of second word.</p>
15 <p style="font-family:courier; font-size:15px; width: 25px">xx xéx</p>
16 <p>Without span, Latin1 in first position of second word.</p>
17 <p style="font-family:courier; font-size:15px; width: 25px">xx éxx</p>
18 <p>Without span, no Latin1 in second word.</p>
19 <p style="font-family:courier; font-size:15px; width: 25px">xx xxx</p>
20 </div>
21 <div><pre id=results></pre></div>
22 <script>
23 if (window.testRunner)
24 testRunner.dumpAsText();
26 function mergeRect(rects, rect) {
27 var newRects = [];
28 if (!rects.length)
29 newRects.push(rect);
30 else {
31 for (var i = 0; i < rects.length; ++i) {
32 var r = rects[i];
33 if (!rect)
34 newRects.push(r);
35 else if (rect.top < r.top) {
36 newRects.push(rect);
37 newRects.push(r);
38 rect = null;
39 } else if (rect.top == r.top) {
40 if (rect.left + rect.width > r.left + r.width)
41 r.width = rect.left + rect.width - r.left;
42 newRects.push(r);
43 rect = null;
44 } else
45 newRects.push(r);
47 if (rect)
48 newRects.push(rect);
50 return newRects;
53 function mergeRects(rects, newRects) {
54 for (var i = 0; i < newRects.length; ++i)
55 rects = mergeRect(rects, newRects[i]);
56 return rects;
59 function getLineRects(paragraphNumber) {
60 var range = document.createRange();
61 var paragraphs = document.getElementsByTagName("p");
62 var p = paragraphs[paragraphNumber];
63 var rects = [];
64 for (var i = 0; i < p.childNodes.length; ++i) {
65 range.setStart(p, i);
66 range.setEnd(p, i + 1);
67 rects = mergeRects(rects, range.getClientRects());
69 return rects;
72 function appendResults(results, newResults) {
73 if (newResults.length) {
74 if (results.length)
75 results += '\n'
76 results += newResults;
78 return results;
81 function compareParagraphLineRects(paragraphNumber1, paragraphNumber2, results) {
82 var rects1 = getLineRects(paragraphNumber1);
83 var rects2 = getLineRects(paragraphNumber2);
84 if (rects1.length != rects2.length)
85 results = appendResults(results, 'FAIL: different number of lines, got ' + rects1.length + ', expected ' + rects2.length);
86 else {
87 for (var i = 0; i < rects1.length; ++i) {
88 if (rects2[i].width != rects1[i].width) {
89 results = appendResults(results,
90 'FAIL: para[' + paragraphNumber1 + '] line[' + i + '] width differs from para[' + paragraphNumber2 + '] line[' + i + ']' +
91 ', got ' + rects1[i].width + ', expected ' + rects2[i].width);
95 return results;
98 var results = '';
99 for (var i = 0; i < 3; i++ )
100 results = compareParagraphLineRects(i*2 + 1, i*2 + 1 + 6, results);
101 if (!results.length)
102 results = 'PASS';
103 document.getElementById("results").innerText = results;
104 </script>
105 </body>
106 </html>