| <!DOCTYPE html> |
| <script src="../../../resources/js-test-pre.js"></script> |
| <script src="../resources/subpixel-utils.js"></script> |
| <style> |
| #container { |
| width: 300px; |
| font: 20px/1 Ahem; |
| color: green; |
| } |
| |
| #float { |
| float: left; |
| width: 100px; |
| height: 100px; |
| border-radius: 100px 0px; |
| background-color: blue; |
| background-clip: border-box; |
| -webkit-shape-outside: border-box; |
| } |
| </style> |
| <body> |
| <p>The green squares should follow the right side of the blue shape. They should not overlap the shape.</p> |
| <div id="container"> |
| <div id="float"></div> |
| <span id="a">X</span><br> |
| <span id="b">X</span><br> |
| <span id="c">X</span><br> |
| <span id="d">X</span><br> |
| <span id="e">X</span><br> |
| <span id="f">X</span> |
| </div> |
| <div id="console"></div> |
| </body> |
| <script> |
| function elementRect(elementId) |
| { |
| var s = document.getElementById("container").getBoundingClientRect(); |
| var r = document.getElementById(elementId).getBoundingClientRect(); |
| return {right: (r.left - s.left) + r.width, top: r.top - s.top, width: r.width, height: r.height}; |
| } |
| |
| function borderXIntercept(y) |
| { |
| var radiusSquared = 100 * 100; |
| var f = SubPixelLayout.snapToLayoutUnit(Math.sqrt(radiusSquared - y * y)); |
| return f + 20; // will be compared with the right edge of a 20x20 Ahem char cell |
| } |
| |
| var quiet = true; // PASS output depends on SubPixelLayout.isEnabled() |
| |
| shouldBe("elementRect('a').top", "0"); |
| shouldBe("elementRect('a').right", "120"); |
| |
| shouldBe("elementRect('b').top", "20"); |
| shouldBeCloseTo("elementRect('b').right", borderXIntercept(20), 1, quiet); |
| |
| shouldBe("elementRect('c').top", "40"); |
| shouldBeCloseTo("elementRect('c').right", borderXIntercept(40), 1, quiet); |
| |
| shouldBe("elementRect('d').top", "60"); |
| shouldBeCloseTo("elementRect('d').right", borderXIntercept(60), 1, quiet); |
| |
| shouldBe("elementRect('e').top", "80"); |
| shouldBeCloseTo("elementRect('e').right", borderXIntercept(80), 1, quiet); |
| |
| shouldBe("elementRect('f').top", "100"); |
| shouldBe("elementRect('f').right", "20"); |
| </script> |