Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / shapes / shape-outside-floats / shape-outside-floats-ellipse-margin-right.html
blobeb7248e338b09cdc191111483832e36e53e53d63
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 #container-border {
8 border: 1px solid black;
9 margin: 10px;
10 width: 500px;
13 #container {
14 font: 20px/1 Ahem, sans-serif;
15 width: 500px;
16 height: 300px;
17 text-align: right;
20 #float-right {
21 float: right;
22 position: relative;
23 overflow: visible;
24 shape-outside: ellipse(200px 100px at 225px 125px);
25 shape-margin: 25px;
26 width: 450px;
27 height: 250px;
30 #svg-shape-ellipse {
31 position: absolute;
32 display:block;
33 top: 0px;
34 left: 0px;
35 width: 500px;
36 height: 300px;
38 </style>
40 <body>
41 <p>The right edges of the three black squares should follow the outer ellipse boundary and each square should appear on a subsequent line.</p>
42 <div id="container-border">
43 <div id="container">
44 <div id="float-right">
45 <svg id="svg-shape-ellipse" xmlns="http://www.w3.org/2000/">
46 <ellipse cx="225" cy="125" rx="200" ry="100" fill="green"></ellipse>
47 <ellipse cx="225" cy="125" rx="225" ry="125" fill="none" stroke="green"></ellipse>
48 </svg>
49 </div>
50 <span id="s1">X</span></br><span id="s2">X</span><br/><span id="s3">X</span>
51 </div>
52 </div>
53 <div id="console"></div>
54 </body>
55 <script>
56 function elementRect(elementId)
58 var s = document.getElementById("container").getBoundingClientRect();
59 var r = document.getElementById(elementId).getBoundingClientRect();
60 return {right: (r.left - s.left) + r.width, top: r.top - s.top, width: r.width, height: r.height};
63 // You'll find the equation for the X intercept of an elliptical arc here (among other places):
64 // http://hansmuller-webkit.blogspot.com/2012/07/computing-horizonal-rounded-rectangle.html
66 function marginEllipseRightXIntercept(y, cx, rx, ry)
68 var containerWidth = document.getElementById("container").getBoundingClientRect().width;
69 var f = SubPixelLayout.snapToLayoutUnit(containerWidth - (cx + rx * Math.sqrt(1 - Math.pow((ry - y) / ry, 2))));
70 return String( Math.floor(f) );
73 // In the ".right" tests below, it's the lower edge of the 20px Ahem glyph that that defines the element rect's left edge.
74 // That's why the Y coordinate in each of those tests is 20 greater than the ".top" test.
76 var quiet = true; // PASS output depends on SubPixelLayout.isEnabled()
78 shouldBe("elementRect('s1').top", "0");
79 shouldBe("elementRect('s1').right", marginEllipseRightXIntercept(20, 225, 225, 125), quiet);
81 shouldBe("elementRect('s2').top", "20");
82 shouldBe("elementRect('s2').right", marginEllipseRightXIntercept(40, 225, 225, 125), quiet);
84 shouldBe("elementRect('s3').top", "40");
85 shouldBe("elementRect('s3').right", marginEllipseRightXIntercept(60, 225, 225, 125), quiet);
87 </script>
88 </html>