Repository navigation
feat(ios): -ios-corner-shape alias for the continuous corner curve - #11453
edusperoni wants to merge 2 commits into
Conversation
corner-shape: squircle mapped to kCACornerCurveContinuous, but Apple's continuous corner and the CSS superellipse(2) are different curves. corner-shape now follows the CSS Borders Level 4 keywords, and Apple's curve is exposed through -ios-corner-shape: continuous. -ios-corner-shape is a platform alias of corner-shape: a one-longhand shorthand whose converter forwards on Apple and returns nothing elsewhere, so it cascades in place like a vendor-prefixed property on the web and normal source order and specificity decide between the two. On iOS, `continuous` selects the continuous cornerCurve on the uniform border fast path. `squircle` no longer renders natively; it is routed through the path mask branch, where the superellipse curve itself is left for #11451 to draw. BREAKING CHANGE: corner-shape: squircle no longer renders Apple's continuous corner. Apps that used it for the iOS system look should switch to -ios-corner-shape: continuous. Refs #11452
|
View your CI Pipeline Execution ↗ for commit db8c714
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
The corner-shape converter picks its grammar when the property is declared, so specs could not flip the platform flag to exercise the non-Apple path. It now reads the flag per value, and the specs run the alias and the strict grammar with __ANDROID__ set.
NathanWalker
left a comment
There was a problem hiding this comment.
The alias approach is clean and works as described: shorthands expand at parse time so source order and specificity are real, pseudo-class toggles fall back correctly, inline order works, -ios-corner-shape: initial resolves to round, and all three CSS parsers keep the name. drawsCornersNatively is used consistently across draw, clear, shadow path and mask setup, and runtime switching adds/removes the mask in both directions.
Verified: core vitest passes on the PR head and on PR + origin/main; tsc and prettier clean. The conflict with main is only in style-scope.spec.ts (main added a styledWithParent helper at the same spot); keep both sides. background.ios.ts hasn't changed on main since the PR's base, and the tests pass against the shorthand changes in #11553 / #11593 / #11520.
Requesting changes mainly on timing:
Shipping this before #11451 is a visible regression with nothing gained yet. corner-shape: squircle is in stable 9.1.3/9.1.4, and main is currently publishing 9.1.5-next.x. Merged alone, squircle users go from continuous to circular corners, every uniform-radius squircle view gets a CAShapeLayer mask (off-screen rendering), and shared-element transitions lose the rounding because the snapshot copies layer.cornerRadius, which is now 0. I'd land this together with a rebased #11451 in 9.2 (or hold it until then). The migration note should also mention the mask cost, transitions, and clip-path (with a uniform radius, the single mask slot goes to clip-path, so squircle corners come out square inside the clip).
Two code items inline. Minor nits: onAndroid() is duplicated verbatim in style-properties.spec.ts and style-scope.spec.ts, no spec covers var() with the alias (works by hand: continuous on iOS, dropped on Android), and -ios-corner-shape would be the first leading-dash vendor property in core (precedent is android-elevation), worth a conscious naming call.
| * @returns True when no path mask is needed for the corners. | ||
| */ | ||
| export function drawsCornersNatively(background: BackgroundDefinition): boolean { | ||
| return background.hasUniformBorder() && background.cornerShape !== CoreTypes.CornerShape.squircle; |
There was a problem hiding this comment.
This returns false for any squircle even with no radius. With corner-shape: squircle, a uniform border-width and radius 0, the border goes down the shape-layer path sized at draw time, but _onSizeChanged (core/view/index.ios.ts) doesn't redraw it since the border is uniform and there's no radius, so it's stale after a resize (text change, rotation, flex). It also adds an unneeded shape layer + scroll listener to every radius-less squircle view, which a theme-wide corner-shape: squircle rule would hit broadly.
return background.hasUniformBorder() && (background.cornerShape !== CoreTypes.CornerShape.squircle || !background.hasBorderRadius());| defaultValue: CoreTypes.CornerShape.round, | ||
| valueConverter: CoreTypes.CornerShape.parse, | ||
| // Only CALayer can draw `continuous`; other platforms keep the spec grammar. | ||
| valueConverter: (value) => (__APPLE__ ? CoreTypes.IOSCornerShape.parse(value) : CoreTypes.CornerShape.parse(value)), |
There was a problem hiding this comment.
continuous leaks into corner-shape on Apple only, while the type (IOSCornerShapeType on Style.cornerShape) allows it everywhere. On Android, style.cornerShape = 'continuous' throws Invalid value: continuous even though TS accepts it, and corner-shape: continuous in shared CSS logs "Failed to apply property". People will write it on iOS and only find out on Android.
Either (a) accept continuous on Android and treat it as round (Android renders round anyway, so no cascade change), or (b) keep Style.cornerShape typed to the spec keywords so TS steers people to iosCornerShape.
| * The curve used to round the corners: 'round' (circular arcs, the default) | ||
| * or 'squircle' (Apple's continuous corner curve). iOS only; Android always | ||
| * renders circular corners. | ||
| * or 'squircle' (the CSS superellipse). On Apple platforms it also accepts |
There was a problem hiding this comment.
Until #11451 lands, squircle isn't "the CSS superellipse" yet (it renders circular through the mask). Another reason to land the two together.
PR Checklist
What is the current behavior?
corner-shape: squircle(#11365) maps tokCACornerCurveContinuous. As measured in #11452, Apple's continuous corner and the CSSsuperellipse(2)are different curves (max gap ~0.19 r), so the property does not render what the CSS Borders Level 4 spec defines, and there is no way to ask for Apple's curve explicitly.What is the new behavior?
corner-shapefollows the spec keywords.roundis unchanged.squircleno longer selects the continuouscornerCurve; it is routed through the path-mask branch on every combination, including uniform radii, because CALayer cannot draw it. The superellipse path itself is not part of this PR: the path generators are untouched so that #11451 can rebase on top and draw the curve. Until then,squirclerenders circular corners through the mask.-ios-corner-shape: continuousexposes Apple's curve. It is implemented as a platform alias ofcorner-shape, the same way browsers treat vendor-prefixed names: a one-longhand shorthand whose converter forwards tocorner-shapeon Apple and expands to nothing elsewhere. It cascades in place, so normal source order and specificity decide:This replaces point 3 of #11452 ("
-ios-corner-shapewins"). A platform-override precedence has no web equivalent, and ordering gives the same migration story with no new engine concept. There are no changes toCssPropertyor the cascade.continuousis also accepted bycorner-shapeitself on Apple platforms, since the property engine re-runs the longhand converter on string values. Android keeps the strict spec grammar.iOS rendering.
continuousselectskCACornerCurveContinuouson the uniform fast path. A newios.drawsCornersNatively(background)is the single predicate deciding native corners vs. path mask, used by draw, clear, mask setup and shadow path generation.continuouswith non-uniform radii, borders or shadows still falls back to circular arcs in the path branches, assquircledid before; the three-cubic Apple path from #11452 is a follow-up once #11451 lands.Tests. Property round-trips through
Background, alias grammar, and cascade behaviour of the alias (later declaration wins either way, specificity, unset on rule removal, inline style).Manual test scenarios (need a device/simulator): uniform radius with
-ios-corner-shape: continuoussetslayer.cornerCurveto continuous; uniform radius withcorner-shape: squirclegets aCAShapeLayermask andcornerRadius0; switching between them at runtime adds/removes the mask.Refs #11452. Related: #11451 (spec squircle in the path generators, to be rebased on this).
BREAKING CHANGES:
corner-shape: squircleno longer renders Apple's continuous corner on iOS. It renders the spec shape once #11451 lands, and circular corners through a mask until then.Migration steps:
Replace
corner-shape: squirclewith-ios-corner-shape: continuouswhere the iOS system look was intended. Both can be combined, with the iOS alias declared last.