OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../../../resources/js-test.js"></script> | |
5 <script src="../resources/subpixel-utils.js"></script> | |
6 <style> | |
7 #shape-inside { | |
8 position: relative; | |
9 width: 594px; | |
10 height: 500px; | |
11 shape-inside: polygon(1.58% 1.42%, 99.42% 1.42%, 98.83% 33.33%, 50.67% 3
4.08%, 99.50% 66.62%, 98.83% 99.48%, 2.25% 99.07%); | |
12 font: 14.5px/1 Ahem, sans-serif; | |
13 color: green; | |
14 } | |
15 | |
16 #shape-outline { | |
17 position: absolute; | |
18 display: block; | |
19 top: 0px; | |
20 left: 0px; | |
21 width: 594px; | |
22 height: 500px; | |
23 } | |
24 </style> | |
25 </head> | |
26 <body> | |
27 <body> | |
28 <div id="shape-inside"> | |
29 <svg id="shape-outline" viewbox="0 0 100 100" preserveAspectRatio="none"
xmlns="http://www.w3.org/2000/svg"> | |
30 <polygon id="shape-polygon" points="1.58,1.42 99.42,1.42 98.83,33.33
50.67,34.08 99.50,66.62, 98.83,99.48 2.25,99.07" stroke="blue" vector-effect="n
on-scaling-stroke" stroke-width="1" fill="none"/> | |
31 </svg> | |
32 <span id="a">X</span><br/> | |
33 <span id="b">X</span><br/> | |
34 <span id="c">X</span><br/> | |
35 <span id="d">X</span><br/> | |
36 </div> | |
37 <div id="console"></div> | |
38 </body> | |
39 <script> | |
40 function shapeInsideRect(elementId) | |
41 { | |
42 var s = document.getElementById("shape-inside").getBoundingClientRect(); | |
43 var r = document.getElementById(elementId).getBoundingClientRect(); | |
44 return {left: r.left - s.left, top: r.top - s.top, width: r.width, height:
r.height}; | |
45 } | |
46 | |
47 // The top of the polygon is a horzontal edge at y=1.42%, and its parent's hei
ght is 500px. The top of | |
48 // the first line, span "a", will align with the top of the polygon. The Exclu
sionShape::firstIncludedIntervalLogicalTop() | |
49 // methods use ceiledLayoutUnit() to ensure that their return value is within
the shape. | |
50 | |
51 var lineATop = Math.floor(SubPixelLayout.ceilToLayoutUnit(.0142 * 500)); | |
52 | |
53 // Verify that all four one-character lines are vertically adjacent and 15 pix
els high. | |
54 var quiet = true; // PASS output depends on SubPixelLayout.isEnabled() | |
55 shouldBe("shapeInsideRect('a').top", String(lineATop), quiet); | |
56 shouldBe("shapeInsideRect('b').top", String(lineATop + 15), quiet); | |
57 shouldBe("shapeInsideRect('c').top", String(lineATop + 30), quiet); | |
58 shouldBe("shapeInsideRect('d').top", String(lineATop + 45), quiet); | |
59 </script> | |
60 </html> | |
OLD | NEW |