Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / shapes / shape-outside-floats / shape-outside-rounded-boxes-002.html
bloba337c8d8467fb2d17e11cf26017ae6e13f4dfe1e
1 <html>
2 <head>
3 <script src="../../../resources/js-test.js"></script>
4 <script src="../resources/subpixel-utils.js"></script>
5 <style>
6 #container {
7 font: 20px/1 Ahem, sans-serif;
8 text-align: right;
9 width: 200px;
10 height: 120px;
11 color: rgba(0,0,200, 0.25);
12 margin: 25px;
13 background-color: grey;
16 #right-border-box {
17 float: right;
18 border-top-left-radius: 100px 30px;
19 border-bottom-left-radius: 100px 30px;
20 shape-outside: border-box;
21 width: 100px;
22 height: 80px;
23 margin-top: 20px;
24 margin-bottom: 20px;
25 background-color: blue;
26 background-clip: border-box;
28 </style>
29 </head>
30 <body>
31 <div id="container">
32 <div id="right-border-box"></div>
33 <span id="a">X</span><br>
34 <span id="b">X</span><br>
35 <span id="c">X</span><br>
36 <span id="d">X</span><br>
37 <span id="e">X</span><br>
38 <span id="f">X</span>
39 </div>
40 <div id="console"></div>
41 </body>
42 <script>
43 function elementRect(elementId)
45 var s = document.getElementById("container").getBoundingClientRect();
46 var r = document.getElementById(elementId).getBoundingClientRect();
47 return {right: (r.left - s.left) + r.width, top: r.top - s.top, width: r.width, height: r.height};
50 // You'll find the equation for the X intercept of an elliptical arc here (among other places):
51 // http://hansmuller-webkit.blogspot.com/2012/07/computing-horizonal-rounded-rectangle.html
53 function cornerEllipseLeftXIntercept(y, cx, rx, ry)
55 var containerWidth = document.getElementById("container").getBoundingClientRect().width;
56 return SubPixelLayout.snapToLayoutUnit(containerWidth - (cx + rx * Math.sqrt(1 - Math.pow((ry - y) / ry, 2))));
59 // The layout implementation rounds up the width right of right floats. To account for that we compare truncated
60 // values for the right edge of spans b and e, since they intercept the box's rounded corners.
62 shouldBe("elementRect('a').top", "0");
63 shouldBe("elementRect('a').right", "200");
65 shouldBe("elementRect('b').top", "20");
66 shouldEvaluateTo("Math.floor(elementRect('b').right)", Math.floor(cornerEllipseLeftXIntercept(40, 0, 100, 30)));
68 shouldBe("elementRect('c').top", "40");
69 shouldBe("elementRect('c').right", "100");
71 shouldBe("elementRect('d').top", "60");
72 shouldBe("elementRect('d').right", "100");
74 shouldBe("elementRect('e').top", "80");
75 shouldEvaluateTo("Math.floor(elementRect('e').right)", Math.floor(cornerEllipseLeftXIntercept(40, 0, 100, 30)));
77 shouldBe("elementRect('f').top", "100");
78 shouldBe("elementRect('f').right", "200");
80 var container = document.getElementById("container");
81 container.parentNode.removeChild(container);
82 </script>
83 </html>