Uh oh!
There was an error while loading. Please reload this page.
Implement outline properties on iOS - #46444
Closed
jorge-cab wants to merge 1 commit into
Closed
Conversation
facebook-github-bot
commented
Sep 11, 2024
Contributor
This pull request was exported from Phabricator. Differential Revision: D62273339 |
facebook-github-bot
commented
Sep 11, 2024
Contributor
This pull request was exported from Phabricator. Differential Revision: D62273339 |
jorge-cabforce-pushed
the
export-D62273339
branch
from
September 11, 2024 21:30
1310681 to
113b1b3Comparefacebook-github-bot
commented
Sep 11, 2024
Contributor
This pull request was exported from Phabricator. Differential Revision: D62273339 |
jorge-cabforce-pushed
the
export-D62273339
branch
from
September 11, 2024 21:36
113b1b3 to
de0dbe5Comparefacebook-github-bot
commented
Sep 12, 2024
Contributor
This pull request was exported from Phabricator. Differential Revision: D62273339 |
jorge-cabforce-pushed
the
export-D62273339
branch
from
September 12, 2024 22:55
de0dbe5 to
6d604a3Comparefacebook-github-bot
commented
Sep 13, 2024
Contributor
This pull request was exported from Phabricator. Differential Revision: D62273339 |
jorge-cabforce-pushed
the
export-D62273339
branch
from
September 13, 2024 18:59
6d604a3 to
06b0c32CompareSummary: Pull Request resolved: react#46444 This diff adds: `outline-width`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-width `outline-color`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-color `outline-style`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-style `outline-offset`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-offset Using `BackgroundStyleApplicator` Changelog: [iOS] [Added] - Outline properties `outline-width`, `outline-color`, `outline-style` & `outline-offset` Differential Revision: D62273339
facebook-github-bot
commented
Sep 18, 2024
Contributor
This pull request was exported from Phabricator. Differential Revision: D62273339 |
jorge-cabforce-pushed
the
export-D62273339
branch
from
September 18, 2024 00:50
06b0c32 to
cc3bed7Comparefacebook-github-bot
commented
Sep 19, 2024
Contributor
This pull request has been merged in 1288e38. |
react-native-bot
commented
Sep 19, 2024
Collaborator
This pull request was successfully merged by @jorge-cab in 1288e38 When will my fix make it into a release? | How to file a pick request? |
meta-codesyncBot
pushed a commit
that referenced
this pull request
Aug 21, 2026
…dii (#58028) Summary: Fixes#57841. `outlineStyle: 'dotted'` and `'dashed'` render as solid on iOS. Android renders all three correctly, and the documented API lists all three values with no platform caveat. ### Root cause `-[RCTViewComponentView invalidateLayer]` draws the outline through one of two paths: - **Core Animation** — sets `_outlineLayer.borderWidth` / `.borderColor`. Cheap, but `CALayer` can only stroke a *solid* border. - **Core Graphics** — `RCTAddContourEffectToLayer`, which forwards `outlineStyle` to `RCTGetBorderImage` and does honour dotted/dashed. The branch choosing between them only looked at the border radii: ```objc if (areBorderRadiiCircular(borderMetrics.borderRadii) && borderMetrics.borderRadii.topLeft.horizontal == 0) { ``` Every view **without a border radius** therefore took the Core Animation path, and its `outlineStyle` was silently dropped. Rounded views fell through to Core Graphics — which is why a dotted or dashed outline starts working as soon as a `borderRadius` is set. The equivalent branch for *borders*, ~80 lines above, already gets this right: `useCoreAnimationBorderRendering` includes `borderMetrics.borderStyles.left == BorderStyle::Solid`, so a non-solid border falls through to Core Graphics. The outline branch never got the matching check when `outline` was implemented in #46444. ### Fix Add the missing `outlineStyle == OutlineStyle::Solid` term, so non-solid outlines fall through to Core Graphics exactly as non-solid borders already do. Solid outlines keep the cheaper Core Animation path, so there is no cost for the common case. ### Why it went unnoticed The only RNTester examples using `outlineStyle: 'dotted'` / `'dashed'` also set a `borderRadius`, so they only ever exercised the working path. This PR adds the square-cornered cases next to them, labelled, so all six combinations of `{square, rounded} × {solid, dashed, dotted}` are visible at once. ### Note on #57837#57837 (open) rewrites the two `UIColor *outlineColor = ...` lines in this same block to resolve dynamic colors against the trait collection. This change deliberately leaves those two lines untouched — it only adds a term to the surrounding `if` — so the two patches touch disjoint lines and should merge without conflict in either order. ## Changelog: [IOS] [FIXED] - Render `outlineStyle: 'dotted'` and `'dashed'` on views without border radii Pull Request resolved: #58028 Test Plan: ### Manual verification RNTester → Components → View → Outline, iPhone 17 Pro Simulator (iOS 26.1), New Architecture, built from source (`RCT_USE_PREBUILT_RNCORE=0`). | Before | After | | --- | --- | | <img src="https://raw.githubusercontent.com/neutronm/react-native/960889bd70d6cb18839f9d3586690908b0d8207d/assets/57841/before.png" width="420"> | <img src="https://raw.githubusercontent.com/neutronm/react-native/960889bd70d6cb18839f9d3586690908b0d8207d/assets/57841/after.png" width="420"> | | `square dashed` and `square dotted` render solid | all six render correctly | The rounded cases and every pre-existing example in the Outline screen are pixel-identical before and after; only the two square non-solid outlines change. ### Automated | Command | Result | | --- | --- | | `yarn jest` | 222/223 suites, 5713 tests pass | | `yarn flow-check` | `Found 0 errors` | | `yarn lint` (`eslint --max-warnings 0 .`) | clean | | `node ./scripts/clang-format.js <changed .mm files>` | no changes | | `yarn build-types --validate` | `PASS API snapshot is up to date.` | | `tsc -p packages/react-native/__typetests__/tsconfig.json` | clean | | `yarn test-ios` (`RNTesterUnitTests`) | `** TEST SUCCEEDED **` — 167 tests, 16 skipped, 0 failures | The one Jest suite that did not pass in the full run (`GenerateComponentDescriptorH-test.js`) was a worker `SIGSEGV`, not an assertion failure; it passes 18/18 when run on its own. ### Unit tests `React/Tests/Mounting/RCTViewComponentViewTests.mm` gains two cases next to the existing ones: - `testSquareSolidOutlineUsesCoreAnimationBorder` — a square solid outline still uses `CALayer.borderWidth` (the fast path is not regressed). - `testSquareDottedAndDashedOutlinesAreDrawnWithCoreGraphics` — square dotted and dashed outlines are drawn into `layer.contents` with `borderWidth == 0`. `React/Tests/**` is excluded from the `React-Core` podspec, so these are not built by the OSS `RNTesterUnitTests` target. They were verified to compile against the installed pod headers with `clang -fsyntax-only -x objective-c++ -std=c++20`. Reviewed By: cipolleschi Differential Revision: D116779403 Pulled By: javache fbshipit-source-id: b8d1f3508418016252ec9b1f9aaab7107c8f3b9f
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 freeto 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.
Summary:
This diff adds:
outline-width: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-widthoutline-color: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-coloroutline-style: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-styleoutline-offset: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-offsetUsing
BackgroundStyleApplicatorChangelog: [iOS] [Added] - Outline properties
outline-width,outline-color,outline-style&outline-offsetDifferential Revision: D62273339