OLD | NEW |
| (Empty) |
1 <html style="-webkit-writing-mode:vertical-lr"> | |
2 <style> | |
3 div.columns { | |
4 -webkit-columns: 2; | |
5 -webkit-column-gap: 0; | |
6 columns: 2; | |
7 column-gap: 0; | |
8 column-fill: auto; | |
9 height: 200px; | |
10 outline: 1px solid blue; | |
11 font-family: Ahem; | |
12 font-size: 10px; | |
13 margin: 5px; | |
14 overflow: hidden; | |
15 } | |
16 | |
17 div.float { | |
18 float: left; | |
19 height: 50px; | |
20 -webkit-margin-before: 5px; | |
21 color: silver; | |
22 } | |
23 </style> | |
24 <div id="tests"> | |
25 <div class="columns" style="width: 80px;"> | |
26 one line two lines three lines | |
27 <div class="float" id="f1"> | |
28 three line float | |
29 </div> | |
30 text runs here next to the float | |
31 </div> | |
32 <!-- In this case, the float fits, but then the main content causes the brea
k | |
33 to occur earlier and the float gets split. --> | |
34 <div class="columns" style="width: 75px;"> | |
35 one line two lines three lines | |
36 <div class="float" id="f2"> | |
37 three line float | |
38 </div> | |
39 text runs here next to the float | |
40 </div> | |
41 <!-- In this case, the float paginates after its second line. --> | |
42 <div class="columns" style="width: 70px;"> | |
43 one line two lines three lines | |
44 <div class="float" id="f3"> | |
45 three line float | |
46 </div> | |
47 text runs here next to the float | |
48 </div> | |
49 <!-- In this case, the float paginates after its first line. --> | |
50 <div class="columns" style="width: 70px;"> | |
51 one line two lines three lines and some more | |
52 <div class="float" id="f4"> | |
53 three line float | |
54 </div> | |
55 text runs here next to the float | |
56 </div> | |
57 <!-- In this case, the float paginates after its third line. --> | |
58 <div class="columns" style="width: 45px;"> | |
59 one line | |
60 <div class="float" id="f5"> | |
61 and one five line float | |
62 </div> | |
63 text runs here next to the float | |
64 </div> | |
65 </div> | |
66 <pre id="result"></pre> | |
67 <script> | |
68 function floatOffset(float) | |
69 { | |
70 var range = document.createRange(); | |
71 range.setStart(float, 0); | |
72 range.setEnd(float, 0); | |
73 range.expand("word"); | |
74 var rect = range.getBoundingClientRect(); | |
75 var parentRect = float.parentNode.getBoundingClientRect(); | |
76 return { width: rect.left - parentRect.left, height: rect.top - parentRe
ct.top }; | |
77 } | |
78 | |
79 var tests = [ | |
80 ["f1", 45, 0], | |
81 ["f2", 45, 0], | |
82 ["f3", 45, 0], | |
83 ["f4", 55, 0], | |
84 ["f5", 15, 0] | |
85 ]; | |
86 | |
87 var test; | |
88 var failures = 0; | |
89 while (test = tests.shift()) { | |
90 var float = document.getElementById(test[0]); | |
91 var result = floatOffset(float); | |
92 var passed = result.width === test[1] && result.height === test[2] | |
93 float.style.color = passed ? "green" : "red"; | |
94 if (!passed) { | |
95 failures++ | |
96 alert(result.width + " " + result.height) | |
97 } | |
98 } | |
99 | |
100 if (window.testRunner) { | |
101 testRunner.dumpAsText(); | |
102 document.getElementById("tests").style.display = "none"; | |
103 } | |
104 | |
105 document.getElementById("result").innerText = failures ? "FAIL: " + failures
+ " cases failed" : "PASS"; | |
106 </script> | |
OLD | NEW |