4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/subpixel-utils.js"></script>
9 font:
20px/
1 Ahem, sans-serif;
18 shape-outside: polygon(
70px
20px,
120px
70px,
70px
120px,
20px
70px);
37 <svg id=
"svg-shape" xmlns=
"http://www.w3.org/2000/">
38 <polygon points=
"50,0 100,50 50,100 0,50" fill=
"rgba(0,150,0, 0.5)"/>
41 <span id=
"l1">X
</span></br><span id=
"l2">X
</span><br/><span id=
"l3">X
</span><br/><br/><span id=
"l4">X
</span><br/><span id=
"l5">X
</span><br/><span id=
"l6">X
</span>
43 <div id=
"console"></div>
46 function elementRect(elementId
)
48 var s
= document
.getElementById("container").getBoundingClientRect();
49 var r
= document
.getElementById(elementId
).getBoundingClientRect();
50 return {left
: r
.left
- s
.left
, top
: r
.top
- s
.top
, width
: r
.width
, height
: r
.height
};
53 // The shape-outside polygon's X and Y coordinates are 20, 70, 120, specified relative to the
54 // "float-left" element. Its shape-marign is 20px, which means that the X and Y limits of the
55 // margin boundary are 0, and 140. This is because the margin boundary has circular arc segments
56 // at the vertices, i.e. it's a rounded rectangle rotated by 45 degrees. None of the character
57 // positions in this test are defined by the arc segments.
59 // The left edge of the (20px square) Ahem character on the first "l1" line (y == 20) is:
60 // 20 + (20*sqrt(2) + 50) = 98.28. The second and third lines, "l2" and "l3" are similar, each
61 // one begins 20 pixels farther to the right. The left edges of "l4-l6" are the same as the first three,
62 // just in reverse order.
64 function marginLeftXIntercept(lineNumber
)
66 var f
= SubPixelLayout
.snapToLayoutUnit(lineNumber
* 20 + 20 * Math
.sqrt(2) + 50);
70 var quiet
= true; // PASS output depends on SubPixelLayout.isEnabled()
72 shouldBe("elementRect('l1').top", "0");
73 shouldBeCloseTo("elementRect('l1').left", marginLeftXIntercept(1), 1, quiet
);
75 shouldBe("elementRect('l2').top", "20");
76 shouldBeCloseTo("elementRect('l2').left", marginLeftXIntercept(2), 1, quiet
);
78 shouldBe("elementRect('l3').top", "40");
79 shouldBeCloseTo("elementRect('l3').left", marginLeftXIntercept(3), 1, quiet
);
81 shouldBe("elementRect('l4').top", "80");
82 shouldBeCloseTo("elementRect('l4').left", marginLeftXIntercept(3), 1, quiet
);
84 shouldBe("elementRect('l5').top", "100");
85 shouldBeCloseTo("elementRect('l5').left", marginLeftXIntercept(2), 1, quiet
);
87 shouldBe("elementRect('l6').top", "120");
88 shouldBeCloseTo("elementRect('l6').left", marginLeftXIntercept(1), 1, quiet
);