[css-borders-4] Handle rectangle, self-intersecting, and non-uniform outset corners in the contoured path algorithm - #14142
[css-borders-4] Handle rectangle, self-intersecting, and non-uniform outset corners in the contoured path algorithm#14142sb3nder wants to merge 10 commits into
Conversation
|
Thanks for working on this! The screen casts look like they fix the issue but it's hard for me to assess the formula without tests. Note that the current WPTs for corner-shape implement the spec'ed formula in JS using canvas, see https://github.com/web-platform-tests/wpt/blob/master/css/css-borders/corner-shape/resources/render-corner-shape.js So supplementing this PR with a WPT PR that does this and some test cases that fix the aforementioned issues would be very helpful. (Side note: IPR for this issue needs to be filled out) |
|
Thank you for the pointers. I've added WPTs to the todo list in the PR, and hopefully I'll be able to implement them. |
Let me know if you need any help. I also might try to get to trying this out. |
|
s it is a separate repo for WPT, adding tests should be a separate PR right? |
Yep, the todo list is mostly there to remind me what I still need to do for this PR. |
Since concave corners are now drawn as the symmetric of convex corners, update the explanation of why we don't interpolate linearly.
- fixed some typo in `normalized inner corner hull`. - moved `normalized inner corner hull` in `Constraining opposite radii` section. - fixed coordinate system mismatch in `opposite corner scale factor`, by defining mapping.
This comment was marked as outdated.
This comment was marked as outdated.
|
In the following case (positive non-uniform outsets): I think the corner should always be drawn without overflowing the blue area: Let me know if you agree (👍) or disagree (👎). cc @noamr |
|
@noamr no progress yet. I got sidetracked trying to handle non-uniform outsets and was considering giving that another try. |
Up to you! |
removed adjustedClipOutPath in favor or generalized handling in clip path. basically bevel corners are computed as the tangent to 2 circles with center at corner-start and corner-end, and radius the 2 signed insets.
|
This seems like really stellar work. Thanks a lot. We are testing it on the blink implementation/WPT and review it based on this |
|
Thanks! I really appreciate it. |
|
Do you plan to update the WPT JS to show the code? We'd like to review that, and see if it's different from what we've done in WebKit. |
|
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: a two-value border-radius such as 10px 50px had its aspect ratio normalised away when the offset direction was computed, so the corner offset at roughly 45° instead of following its own proportions. For that corner at bevel the offset should run at 78.7°. This replaces them with the single construction which scales the offset normal per-axis by the two corner radii so an elliptical corner keeps its shape when offset, and wires up the outset-adjusted border radius. Adopted algorithm from w3c/csswg-drafts#14142 New tests will be written in another commit * Source/WebCore/platform/graphics/CornerShapeUtilities.cpp: (WebCore::borderContourPath): * Source/WebCore/platform/graphics/GeometryUtilities.cpp: (WebCore::findSegmentLineIntersection): * Source/WebCore/platform/graphics/GeometryUtilities.h: * Source/WebCore/platform/graphics/LayoutRoundedRect.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): * 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:
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: a two-value border-radius such as 10px 50px had its aspect ratio normalised away when the offset direction was computed, so the corner offset at roughly 45° instead of following its own proportions. For that corner at bevel the offset should run at 78.7°. This replaces them with the single construction which scales the offset normal per-axis by the two corner radii so an elliptical corner keeps its shape when offset, and wires up the outset-adjusted border radius. Adopted algorithm from w3c/csswg-drafts#14142 New tests will be written in another commit * 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): * 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:
|
I reworked the test algorithm a bit, added some new test cases, and added support for |
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/platform/graphics/BezierUtilities.cpp: (WebCore::addCatmullRomBeziers): * Source/WebCore/rendering/BorderShape.h: (WebCore::BorderShape::shapeForOffsetRect): * Source/WebCore/rendering/OutlinePainter.cpp: (WebCore::OutlinePainter::paintOutline const): (WebCore::OutlinePainter::paintFocusRing const):
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/platform/graphics/BezierUtilities.cpp: (WebCore::addCatmullRomBeziers): * Source/WebCore/rendering/BorderShape.h: (WebCore::BorderShape::shapeForOffsetRect): * Source/WebCore/rendering/OutlinePainter.cpp: (WebCore::OutlinePainter::paintOutline const): (WebCore::OutlinePainter::paintFocusRing const):
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/platform/graphics/BezierUtilities.cpp: (WebCore::addCatmullRomBeziers): * Source/WebCore/rendering/BorderShape.h: (WebCore::BorderShape::shapeForOffsetRect): * Source/WebCore/rendering/OutlinePainter.cpp: (WebCore::OutlinePainter::paintOutline const): (WebCore::OutlinePainter::paintFocusRing const):
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/platform/graphics/BezierUtilities.cpp: (WebCore::addCatmullRomBeziers): * Source/WebCore/rendering/BorderShape.h: (WebCore::BorderShape::shapeForOffsetRect): * Source/WebCore/rendering/OutlinePainter.cpp: (WebCore::OutlinePainter::paintOutline const): (WebCore::OutlinePainter::paintFocusRing const):
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):
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):
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):


Refactored
border-aligned corner clip-out pathto:(note: in square corners this results in the same miter points as the control-point method. When the corner is not square: in concave corners the miter points diverge from the control-point method, in convex corners the miter points are almost the same as the control-point method.)
Refactored
Computing a contoured pathto:outset-adjusted border radiusfor round corner compat.Fixed by substituting the following algorithm:
with
adjustedInset, which calculates the inset from the adjusted radius, and by computing the borderRect outer point from the targetRect and the adjusted inset.Applied
opposite corner scale factorto the used value.Made various math fixes.
Updated explanation for non-linear interpolation.
Fixed some typos.
Fixes #13318
Fixes #14183
Fixes #14184
Fixes #14185
WPT tests:
Questions:
I fixed
normalized superellipse half cornerby calculating the geometric diagonal of the curve,though I wonder if it would be better to approximate it here by using the concave corner diagonal (
n=2^-abs(K)), to get0.25and0.75forscoopandround, respectively.[css-borders-4] Stroke/hull direction uses the normalized (signed) half corner, but implementations require the convex half corner for concave shapes #14157
[css-borders-4] How should outset_adjusted_border_radius apply to non-round corner shapes? #14270
[css-borders-4] Editorial: clarify "border-aligned corner clip-out path" (pre-clip path, curve intersection, keyword shapes #14158
graphs:
clip-out path
testing for clip-out path
half corner
half corner visual
screencasts:
current algorithm, chrome implementation:
screencast-2.mp4
circa proposed changes:
expected-behavior-2.mp4
chrome bugs:
https://issues.chromium.org/issues/532190484
https://issues.chromium.org/issues/532199267
https://issues.chromium.org/issues/532163949