Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / shapes / shape-outside-floats / shape-outside-floats-diamond-margin-polygon.html
blobe794255400622cbb4a507b7b97da8446ab68b896
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <script src="../resources/subpixel-utils.js"></script>
7 <style>
8 #container {
9 font: 20px/1 Ahem, sans-serif;
10 width: 200px;
11 height: 150px;
14 #float-left {
15 float: left;
16 position: relative;
17 overflow: visible;
18 shape-outside: polygon(70px 20px, 120px 70px, 70px 120px, 20px 70px);
19 shape-margin: 20px;
20 width: 140px;
21 height: 140px;
24 #svg-shape {
25 position: absolute;
26 display: block;
27 top: 0px;
28 left: 0px;
29 width: 100px;
30 height: 100px;
31 margin: 20px;
33 </style>
34 <body>
35 <div id="container">
36 <div id="float-left">
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)"/>
39 </svg>
40 </div>
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>
42 </div>
43 <div id="console"></div>
44 </body>
45 <script>
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.
58 //
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);
67 return Math.round(f);
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);
90 </script>
91 </html>