3 <script src=
"../../../resources/js-test.js"></script>
4 <script src=
"../resources/subpixel-utils.js"></script>
7 font:
20px/
1 Ahem, sans-serif;
11 color: rgba(
0,
0,
200,
0.25);
13 background-color: grey;
18 border-top-left-radius:
100px
30px;
19 border-bottom-left-radius:
100px
30px;
20 shape-outside: border-box;
25 background-color: blue;
26 background-clip: border-box;
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>
40 <div id=
"console"></div>
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
);