fix: decimal values in transformOrigin string parser - #57487
fix: decimal values in transformOrigin string parser#57487MayankSharma-2812 wants to merge 3 commits into
Conversation
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thanks for the review! I checked the native parsing path and found that decimal numeric tokens are handled through CSSTokenizer::consumeNumber using fast_float::from_chars_advanced. I’ve added equivalent coverage for decimal pixel (12.5px 7.5px) and percentage (50.5% 30.2%) values in CSSTransformOriginTest.cpp |
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D111240577. |
|
Thanks for the approval! I noticed the Facebook Internal - Linter check is failing, but the failure details are only available internally on Phabricator. Could you please let me know if there’s anything I need to update on my side? @javache |
Summary: The numeric tokenizer updated in #57487 still starts at the first digit when a percentage or pixel value is negative. This silently changes values such as `-12.5px -7.5px` into `[12.5, 7.5, 0]`. Allow a leading minus in numeric tokens so negative percentages, pixel offsets, and leading-dot decimals retain their sign. The pattern is intentionally limited to the failing negative case and leaves leading-plus values unchanged. ## Changelog: [GENERAL] [FIXED] - Preserve negative values in `transformOrigin` strings. Pull Request resolved: #57691 Test Plan: - Added Fantom regression coverage for negative percentages, x/y/z pixel offsets, and leading-dot decimals in `processTransformOrigin-itest.js` - `./node_modules/.bin/prettier --check packages/react-native/Libraries/StyleSheet/processTransformOrigin.js packages/react-native/Libraries/StyleSheet/__tests__/processTransformOrigin-itest.js` - `./node_modules/.bin/eslint --max-warnings 0 packages/react-native/Libraries/StyleSheet/processTransformOrigin.js packages/react-native/Libraries/StyleSheet/__tests__/processTransformOrigin-itest.js` - Ran focused runtime checks against the Flow-stripped parser for the new negative cases and existing leading-plus behavior Reviewed By: javache Differential Revision: D113756417 Pulled By: fabriziocucci fbshipit-source-id: a1506ada24adbeb81892a7c1d821e03ccd388de2
Summary:
Fixes incorrect parsing of decimal percentage and pixel values in the string form of
transformOrigin.The current tokenizer only matches integer numeric values followed by
%orpx. As a result, decimal pixel values are silently corrupted. For example:currently returns:
instead of:
Decimal percentage values are also incorrectly tokenized. For example,
50.5% 30.2%is split into partial matches instead of preserving the decimal values.This updates the numeric token pattern from
\d+(?:%|px)to\d*\.?\d+(?:%|px), supporting decimal values such as12.5px,50.5%, and leading-dot decimal values such as.5%.Regression coverage is added for decimal percentages, decimal pixels, and leading-dot decimal values.
Changelog:
[GENERAL] [FIXED] - Fix
transformOriginstring parsing for decimal percentage and pixel values.Test Plan:
Added regression coverage in
processTransformOrigin-itest.jsfor:50.5% 30.2%12.5px 7.5px.5% .5pxA focused local execution against
processTransformOriginconfirmed:Also attempted the targeted Fantom integration test with:
The Fantom test could not complete locally because Metro failed to resolve a generated runtime setup path containing Windows path separators.