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