CSS calc() percentage post-layout offset support (#56170)#56170
Open
MazinZ wants to merge 1 commit intofacebook:mainfrom
Open
CSS calc() percentage post-layout offset support (#56170)#56170MazinZ wants to merge 1 commit intofacebook:mainfrom
MazinZ wants to merge 1 commit intofacebook:mainfrom
Conversation
Summary:
Add native support for CSS calc() expressions containing percentages (e.g., `calc(50% - 20px)`). The JS side produces `{__rsdCalc: true, percent, offset}` objects; this diff adds the C++ side that consumes them.
**YogaStylableProps:**
- `CalcPropId` enum for width/height/min/max dimension properties
- `calcOffsets[]` array storing point offsets indexed by CalcPropId
- `trySetCalcDimension()` parses `__rsdCalc` map objects from RawValue, sets percentage on Yoga and stores point offset
- Width/height/min/max cases in `setProp` call `trySetCalcDimension` before falling back to standard handling
**YogaLayoutableShadowNode:**
- `applyCalcOffsets()` adjusts layout metrics after Yoga layout, adding point offsets to percentage-resolved dimensions
- Called in `layout()` after `layoutMetricsFromYogaNode` when `hasCalcOffsets()` is true
**LayoutTest:**
- `CalcOffsetTest` verifies calc(50% - 20px) in 200px parent → 80px child width
- Verifies calc(100% - 64px) → 136px height
Changelog:
[General][Added] - Added initial support for calc CSS property
Differential Revision: D97422357
5763782 to
ffcdbae
Compare
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:
Add native support for CSS calc() expressions containing percentages (e.g.,
calc(50% - 20px)). The JS side produces{__rsdCalc: true, percent, offset}objects; this diff adds the C++ side that consumes them.YogaStylableProps:
CalcPropIdenum for width/height/min/max dimension propertiescalcOffsets[]array storing point offsets indexed by CalcPropIdtrySetCalcDimension()parses__rsdCalcmap objects from RawValue, sets percentage on Yoga and stores point offsetsetPropcalltrySetCalcDimensionbefore falling back to standard handlingYogaLayoutableShadowNode:
applyCalcOffsets()adjusts layout metrics after Yoga layout, adding point offsets to percentage-resolved dimensionslayout()afterlayoutMetricsFromYogaNodewhenhasCalcOffsets()is trueLayoutTest:
CalcOffsetTestverifies calc(50% - 20px) in 200px parent → 80px child widthChangelog:
[General][Added] - Added initial support for calc CSS property
Differential Revision: D97422357