Scale outer border radii against the outer box, fixes fully rounded shapes on bordered boxes#962
Open
geforcefan wants to merge 1 commit into
Open
Conversation
The outer radii lie on the border box, so resolving the corner overlap against the inner size makes a fully rounded shape impossible on any bordered box: the outer radius can never reach half the border box and flat sections remain on every edge. CSS resolves corner overlap against the border box (css-backgrounds-3, corner-overlap). The inner radii still derive as outer minus edge, so if the outer radii fit the outer box, the inner radii fit the inner box by construction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While styling a slider thumb (16px box, 2px border ring, border-radius at half the border box) I noticed you can never get a fully round shape on an element that has a border. The overlap clamp in
GeometryBackgroundBorder::ComputeBorderMetricsscales the outer radii againstinner_size, so on a bordered box the outer radius always ends up short of half the border box and you keep flat sections on every edge, no matter how big you make the radius.The outer radii live on the border box though, so the overlap should be resolved against the outer size. That is also what CSS specifies for corner overlap: https://www.w3.org/TR/css-backgrounds-3/#corner-overlap ("If the sum of any two adjacent border radii exceeds the size of the border box..."). The spec even spells out the reduction as a formula: f = min(Li/Si), with Ltop = Lbottom = the width of the box and Lleft = Lright = the height of the box, the box being the border box. That is exactly what
scale_factorcomputes here, just with the inner size as L.This cannot introduce overlapping inner curves: the inner radii still derive as outer minus edge, and if
r1 + r2 <= outer_edgethen(r1 - e1) + (r2 - e2) <= outer_edge - e1 - e2 = inner_edge, so whenever the outer radii fit the outer box the inner radii fit the inner box by construction.Repro:
Border box is 20px, radius 10px, so this should render as a circle. Before it renders with radius 8 (scaled by 16 / 20) and visible straight edges, after the fix it is a circle:
@mikke89 would be great if you could take a look when you find the time.