Skip to content

Commit e548cac

Browse files
committed
corner-shape: adopt the revised contoured-path algorithm
https://bugs.webkit.org/show_bug.cgi?id=320753 rdar://183753095 Reviewed by NOBODY (OOPS!). Offsetting a shaped corner outward picked between several constructions based on the corner's shape, and they disagreed with one another. They coincided only for a plain round corner with a single radius, so the damage showed up on non-round shapes and on elliptical radii This replaces them with the single construction from the revised algorithm, which scales the offset normal per-axis by the two corner radii so an elliptical corner keeps its shape when offset. box-shadow spread now uses that same construction, so a shadow and an outline at the same distance stay parallel rather than pinching together at the corners. Adopted algorithm from w3c/csswg-drafts#14142 * Source/WebCore/platform/graphics/CornerShapeUtilities.cpp: (WebCore::borderContourPath): * Source/WebCore/platform/graphics/GeometryUtilities.cpp: (WebCore::findSegmentLineIntersection): * Source/WebCore/platform/graphics/GeometryUtilities.h: * Source/WebCore/rendering/BorderShape.cpp: (WebCore::BorderShape::shapeForOffsetRect): (WebCore::buildOutsetCornerInputs): (WebCore::addAreaExpansionOffsetContour): (WebCore::BorderShape::pathForOuterCornerShape const): (WebCore::BorderShape::pathForInnerCornerShape const): (WebCore::adjustedRadiusDimension): (WebCore::outsetAdjustedBorderRadius): (WebCore::expandRadiiForOutset): (WebCore::BorderShape::shapeWithBorderWidths const): * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-bevel-overflow.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-superellipse-convex.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-bevel.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-squircle.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-superellipse-bevel.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-superellipse-squircle.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-box-shadow-spread-bevel-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-box-shadow-spread-bevel-ref.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-box-shadow-spread-bevel.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-box-shadow-spread-elliptical-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-box-shadow-spread-elliptical-ref.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-box-shadow-spread-elliptical.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-outline-offset-bevel-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-outline-offset-bevel-ref.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-outline-offset-bevel.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-outline-offset-elliptical-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-outline-offset-elliptical-ref.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-outline-offset-elliptical.html: Added. * Source/WebCore/rendering/BorderShape.h: (WebCore::BorderShape::shapeForOffsetRect): * Source/WebCore/rendering/OutlinePainter.cpp: (WebCore::OutlinePainter::paintOutline const): (WebCore::OutlinePainter::paintFocusRing const):
1 parent 3ce5660 commit e548cac

24 files changed

Lines changed: 625 additions & 190 deletions

LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-bevel-overflow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<title>CSS Borders and Box Decorations 4: 'corner-shape' rendering with overflow</title>
33
<link rel="help" href="https://drafts.csswg.org/css-borders-4/#corner-shaping">
44
<link rel="match" href="corner-shape-bevel-overflow-ref.html">
5-
<meta name="fuzzy" content="maxDifference=0-32;totalPixels=0-256">
5+
<meta name="fuzzy" content="maxDifference=0-36;totalPixels=0-256">
66
<style>
77
.bevel {
88
background: red;

LayoutTests/imported/w3c/web-platform-tests/css/css-borders/corner-shape/corner-shape-bevel.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<title>CSS Borders and Box Decorations 4: 'corner-shape: bevel' on all corners</title>
44
<link rel="help" href="https://drafts.csswg.org/css-borders-4/#corner-shaping">
55
<link rel="match" href="corner-shape-bevel-ref.html">
6-
<meta name="fuzzy" content="maxDifference=0-13; totalPixels=0-135">
6+
<meta name="fuzzy" content="maxDifference=0-24; totalPixels=0-135">
77
<style>
88
.target {
99
background: green;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title>CSS Borders and Box Decorations 4: 'box-shadow' spread with elliptical 'corner-shape: bevel' corners — reference</title>
4+
<style>
5+
body { margin: 0; }
6+
.canvas { position: absolute; left: 0; top: 0; width: 160px; height: 160px; }
7+
.canvas > div { position: absolute; inset: 0; }
8+
.spread {
9+
background: green;
10+
clip-path: path("\
11+
M 123.524 25.000 L 126.494 36.135 L \
12+
134.494 66.135 L 135.000 68.034 L 135.000 \
13+
91.966 L 134.494 93.865 L 126.494 123.865 \
14+
L 123.524 135.000 L 36.476 135.000 L \
15+
33.506 123.865 L 25.506 93.865 L 25.000 \
16+
91.966 L 25.000 68.034 L 25.506 66.135 \
17+
L 33.506 36.135 L 36.476 25.000 Z");
18+
}
19+
.box {
20+
background: red;
21+
clip-path: path("\
22+
M 112.000 40.000 L 120.000 70.000 L \
23+
120.000 90.000 L 112.000 120.000 L 48.000 \
24+
120.000 L 40.000 90.000 L 40.000 70.000 \
25+
L 48.000 40.000 Z");
26+
}
27+
</style>
28+
</head>
29+
<div class=canvas><div class=spread></div><div class=box></div></div>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title>CSS Borders and Box Decorations 4: 'box-shadow' spread with elliptical 'corner-shape: bevel' corners — reference</title>
4+
<style>
5+
body { margin: 0; }
6+
.canvas { position: absolute; left: 0; top: 0; width: 160px; height: 160px; }
7+
.canvas > div { position: absolute; inset: 0; }
8+
.spread {
9+
background: green;
10+
clip-path: path("\
11+
M 123.524 25.000 L 126.494 36.135 L \
12+
134.494 66.135 L 135.000 68.034 L 135.000 \
13+
91.966 L 134.494 93.865 L 126.494 123.865 \
14+
L 123.524 135.000 L 36.476 135.000 L \
15+
33.506 123.865 L 25.506 93.865 L 25.000 \
16+
91.966 L 25.000 68.034 L 25.506 66.135 \
17+
L 33.506 36.135 L 36.476 25.000 Z");
18+
}
19+
.box {
20+
background: red;
21+
clip-path: path("\
22+
M 112.000 40.000 L 120.000 70.000 L \
23+
120.000 90.000 L 112.000 120.000 L 48.000 \
24+
120.000 L 40.000 90.000 L 40.000 70.000 \
25+
L 48.000 40.000 Z");
26+
}
27+
</style>
28+
</head>
29+
<div class=canvas><div class=spread></div><div class=box></div></div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title>CSS Borders and Box Decorations 4: 'box-shadow' spread with elliptical 'corner-shape: bevel' corners</title>
4+
<link rel="help" href="https://drafts.csswg.org/css-borders-4/#corner-shaping">
5+
<link rel="match" href="corner-shape-box-shadow-spread-bevel-ref.html">
6+
<meta name="fuzzy" content="maxDifference=0-64; totalPixels=0-336">
7+
<style>
8+
body { margin: 0; }
9+
.target {
10+
position: absolute;
11+
left: 40px;
12+
top: 40px;
13+
width: 80px;
14+
height: 80px;
15+
background: red;
16+
box-shadow: 0 0 0 15px green;
17+
border-radius: 8px / 30px;
18+
corner-shape: bevel;
19+
}
20+
</style>
21+
</head>
22+
<div class=target></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title>CSS Borders and Box Decorations 4: 'box-shadow' spread with an elliptical concave 'corner-shape' — reference</title>
4+
<style>
5+
body { margin: 0; }
6+
.canvas { position: absolute; left: 0; top: 0; width: 160px; height: 160px; }
7+
.canvas > div { position: absolute; inset: 0; }
8+
.spread {
9+
background: green;
10+
clip-path: path("\
11+
M 135.000 25.000 L 135.000 135.000 L \
12+
25.000 135.000 L 25.000 81.369 C 25.791 \
13+
80.348 27.077 79.810 28.083 79.023 C 29.088 \
14+
78.237 30.381 77.764 31.033 76.651 C 31.685 \
15+
75.537 31.743 73.844 31.994 72.342 C 32.244 \
16+
70.840 32.361 69.210 32.536 67.642 C 32.711 \
17+
66.074 32.879 64.505 33.043 62.934 C 33.207 \
18+
61.364 33.365 59.793 33.520 58.221 C 33.675 \
19+
56.649 33.830 55.077 33.974 53.503 C 34.118 \
20+
51.929 34.253 50.353 34.384 48.776 C 34.515 \
21+
47.200 34.646 45.623 34.759 44.043 C 34.872 \
22+
42.462 34.982 40.882 35.064 39.295 C 35.145 \
23+
37.708 35.179 36.112 35.249 34.523 C 35.319 \
24+
32.934 35.405 31.349 35.483 29.762 C 35.562 \
25+
28.174 35.645 26.587 35.718 25.000 Z");
26+
}
27+
.box {
28+
background: red;
29+
clip-path: path("\
30+
M 120.000 40.000 L 120.000 120.000 L \
31+
40.000 120.000 L 40.000 90.000 C 40.614 \
32+
90.000 43.179 85.360 46.125 70.627 C 49.072 \
33+
55.895 50.000 43.070 50.000 40.000 Z");
34+
}
35+
</style>
36+
</head>
37+
<div class=canvas><div class=spread></div><div class=box></div></div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title>CSS Borders and Box Decorations 4: 'box-shadow' spread with an elliptical concave 'corner-shape' — reference</title>
4+
<style>
5+
body { margin: 0; }
6+
.canvas { position: absolute; left: 0; top: 0; width: 160px; height: 160px; }
7+
.canvas > div { position: absolute; inset: 0; }
8+
.spread {
9+
background: green;
10+
clip-path: path("\
11+
M 135.000 25.000 L 135.000 135.000 L \
12+
25.000 135.000 L 25.000 81.369 C 25.791 \
13+
80.348 27.077 79.810 28.083 79.023 C 29.088 \
14+
78.237 30.381 77.764 31.033 76.651 C 31.685 \
15+
75.537 31.743 73.844 31.994 72.342 C 32.244 \
16+
70.840 32.361 69.210 32.536 67.642 C 32.711 \
17+
66.074 32.879 64.505 33.043 62.934 C 33.207 \
18+
61.364 33.365 59.793 33.520 58.221 C 33.675 \
19+
56.649 33.830 55.077 33.974 53.503 C 34.118 \
20+
51.929 34.253 50.353 34.384 48.776 C 34.515 \
21+
47.200 34.646 45.623 34.759 44.043 C 34.872 \
22+
42.462 34.982 40.882 35.064 39.295 C 35.145 \
23+
37.708 35.179 36.112 35.249 34.523 C 35.319 \
24+
32.934 35.405 31.349 35.483 29.762 C 35.562 \
25+
28.174 35.645 26.587 35.718 25.000 Z");
26+
}
27+
.box {
28+
background: red;
29+
clip-path: path("\
30+
M 120.000 40.000 L 120.000 120.000 L \
31+
40.000 120.000 L 40.000 90.000 C 40.614 \
32+
90.000 43.179 85.360 46.125 70.627 C 49.072 \
33+
55.895 50.000 43.070 50.000 40.000 Z");
34+
}
35+
</style>
36+
</head>
37+
<div class=canvas><div class=spread></div><div class=box></div></div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title>CSS Borders and Box Decorations 4: 'box-shadow' spread with an elliptical concave 'corner-shape'</title>
4+
<link rel="help" href="https://drafts.csswg.org/css-borders-4/#corner-shaping">
5+
<link rel="match" href="corner-shape-box-shadow-spread-elliptical-ref.html">
6+
<meta name="fuzzy" content="maxDifference=0-89; totalPixels=0-115">
7+
<style>
8+
body { margin: 0; }
9+
.target {
10+
position: absolute;
11+
left: 40px;
12+
top: 40px;
13+
width: 80px;
14+
height: 80px;
15+
background: red;
16+
box-shadow: 0 0 0 15px green;
17+
border-top-left-radius: 10px 50px;
18+
corner-top-left-shape: superellipse(-0.5);
19+
}
20+
</style>
21+
</head>
22+
<div class=target></div>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title>CSS Borders and Box Decorations 4: 'outline-offset' with elliptical 'corner-shape: bevel' corners — reference</title>
4+
<style>
5+
body { margin: 0; }
6+
.canvas { position: absolute; left: 0; top: 0; width: 160px; height: 160px; }
7+
.canvas > div { position: absolute; inset: 0; }
8+
.box {
9+
background: red;
10+
clip-path: path("\
11+
M 112.000 40.000 L 120.000 70.000 L \
12+
120.000 90.000 L 112.000 120.000 L 48.000 \
13+
120.000 L 40.000 90.000 L 40.000 70.000 \
14+
L 48.000 40.000 Z");
15+
}
16+
.outline {
17+
background: black;
18+
clip-path: path(evenodd, "\
19+
M 131.207 15.000 L 136.156 33.558 L \
20+
144.156 63.558 L 145.000 66.724 L 145.000 \
21+
93.276 L 144.156 96.442 L 136.156 126.442 \
22+
L 131.207 145.000 L 28.793 145.000 L \
23+
23.844 126.442 L 15.844 96.442 L 15.000 \
24+
93.276 L 15.000 66.724 L 15.844 63.558 \
25+
L 23.844 33.558 L 28.793 15.000 Z \
26+
M 127.366 20.000 L 131.325 34.847 L \
27+
139.325 64.847 L 140.000 67.379 L 140.000 \
28+
92.621 L 139.325 95.153 L 131.325 125.153 \
29+
L 127.366 140.000 L 32.634 140.000 L \
30+
28.675 125.153 L 20.675 95.153 L 20.000 \
31+
92.621 L 20.000 67.379 L 20.675 64.847 \
32+
L 28.675 34.847 L 32.634 20.000 Z");
33+
}
34+
</style>
35+
</head>
36+
<div class=canvas><div class=box></div><div class=outline></div></div>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title>CSS Borders and Box Decorations 4: 'outline-offset' with elliptical 'corner-shape: bevel' corners — reference</title>
4+
<style>
5+
body { margin: 0; }
6+
.canvas { position: absolute; left: 0; top: 0; width: 160px; height: 160px; }
7+
.canvas > div { position: absolute; inset: 0; }
8+
.box {
9+
background: red;
10+
clip-path: path("\
11+
M 112.000 40.000 L 120.000 70.000 L \
12+
120.000 90.000 L 112.000 120.000 L 48.000 \
13+
120.000 L 40.000 90.000 L 40.000 70.000 \
14+
L 48.000 40.000 Z");
15+
}
16+
.outline {
17+
background: black;
18+
clip-path: path(evenodd, "\
19+
M 131.207 15.000 L 136.156 33.558 L \
20+
144.156 63.558 L 145.000 66.724 L 145.000 \
21+
93.276 L 144.156 96.442 L 136.156 126.442 \
22+
L 131.207 145.000 L 28.793 145.000 L \
23+
23.844 126.442 L 15.844 96.442 L 15.000 \
24+
93.276 L 15.000 66.724 L 15.844 63.558 \
25+
L 23.844 33.558 L 28.793 15.000 Z \
26+
M 127.366 20.000 L 131.325 34.847 L \
27+
139.325 64.847 L 140.000 67.379 L 140.000 \
28+
92.621 L 139.325 95.153 L 131.325 125.153 \
29+
L 127.366 140.000 L 32.634 140.000 L \
30+
28.675 125.153 L 20.675 95.153 L 20.000 \
31+
92.621 L 20.000 67.379 L 20.675 64.847 \
32+
L 28.675 34.847 L 32.634 20.000 Z");
33+
}
34+
</style>
35+
</head>
36+
<div class=canvas><div class=box></div><div class=outline></div></div>

0 commit comments

Comments
 (0)