Repository navigation
Support cover and contain in backgroundSize - #60218
Open
jkasprzyk17 wants to merge 1 commit into
Open
jkasprzyk17 wants to merge 1 commit into
jkasprzyk17 wants to merge 1 commit into
Conversation
A backgroundSize string holding cover or contain returned [], dropping every layer. Parse a lone cover or contain layer to the keyword string, as the array form passes it, and keep the other layers. A keyword next to another value in one layer stays invalid, per <bg-size>. Android's BackgroundSize.parse dropped keyword strings, so the sizes of the other layers shifted. Parse cover and contain there too. A gradient has no natural size, so both size it to the positioning area.
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
This branch has not been deployed
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.
Summary:
processBackgroundSizereturned[]for anybackgroundSizestring holdingcoverorcontain, sobackgroundSize: '10px auto, cover'dropped every layer,10px autoincluded. CSS<bg-size>accepts both keywords, and the C++ prop conversion already reads them.cover/containlayer now parses to the keyword string, the same output as the array form, and every other layer keeps its size. A keyword combined with another value in one layer (cover 10px,cover contain) stays invalid and returns[], like other invalid values.BackgroundSizeValuegets'cover' | 'contain'back (removed in fix(style)(backgroundSize) - Passing unsupported backgroundSize on android causes crash #55904), and the API snapshot is regenerated.BackgroundSize.parseread only the object form, so a keyword was dropped and the remaining sizes shifted to other layers. It now parsescoverandcontain. A gradient has no natural size or aspect ratio, so both size it to the background positioning area (CSS Images 3), the same as iOS does today.The crash fixed in #55904 can't come back: an empty size list is still mapped to
null.Fixes #60214
Changelog:
[General] [Fixed] -
backgroundSizestrings holdingcoverorcontainno longer drop every layerTest Plan:
yarn fantom packages/react-native/Libraries/StyleSheet/__tests__/processBackgroundSize-itest.js: 50 passed, 50 total./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests 'com.facebook.react.uimanager.style.BackgroundSizeTest' -PreactNativeArchitectures=arm64-v8a: 4 tests, 0 failuresyarn flow-check: Found 0 errorsyarn eslint --max-warnings 0andyarn prettier --checkon the changed JS files: cleanyarn format-check-kotlin: cleanyarn build-types: onlyBackgroundSizeValuechanged inReactNativeApi.d.ts(plus hashes)yarn test-generated-typescript: passedRNTester on Android (API 35 emulator), Playground with gradient layers (
linear-gradient(red, red), then green, then blue; the first layer is on top),experimental_backgroundRepeat: 'no-repeat'and theexperimental_backgroundSizeshown next to each box:Before, every string holding a keyword was dropped, so all layers filled the box. After,
40px 40px, coverdraws a 40×40 red tile over a blue layer that fills the box, and40px 40px, contain, 20px 20pxdraws a 40×40 red tile over a green layer that fills the box.