Skip to content

Commit

Permalink
Fix flooring of border (facebook#42411)
Browse files Browse the repository at this point in the history
Summary:

X-link: facebook/yoga#1562

I added a small regression D52605596, where negative border would not be correctly floored. This fixes that, and starts adding tests specifically targeting the computed style API, now decoupled from the yoga node.

Reviewed By: joevilches

Differential Revision: D52930827
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Jan 22, 2024
1 parent 212e795 commit ebcaf14
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/react-native/ReactCommon/yoga/yoga/style/Style.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,28 +312,32 @@ class YG_EXPORT Style {
}

float computeFlexStartBorder(FlexDirection axis, Direction direction) const {
return computeBorder(flexStartEdge(axis), direction)
.resolve(0.0f)
.unwrapOrDefault(0.0f);
return maxOrDefined(
computeBorder(flexStartEdge(axis), direction).resolve(0.0f).unwrap(),
0.0f);
}

float computeInlineStartBorder(FlexDirection axis, Direction direction)
const {
return computeBorder(inlineStartEdge(axis, direction), direction)
.resolve(0.0f)
.unwrapOrDefault(0.0f);
return maxOrDefined(
computeBorder(inlineStartEdge(axis, direction), direction)
.resolve(0.0f)
.unwrap(),
0.0f);
}

float computeFlexEndBorder(FlexDirection axis, Direction direction) const {
return computeBorder(flexEndEdge(axis), direction)
.resolve(0.0f)
.unwrapOrDefault(0.0f);
return maxOrDefined(
computeBorder(flexEndEdge(axis), direction).resolve(0.0f).unwrap(),
0.0f);
}

float computeInlineEndBorder(FlexDirection axis, Direction direction) const {
return computeBorder(inlineEndEdge(axis, direction), direction)
.resolve(0.0f)
.unwrapOrDefault(0.0f);
return maxOrDefined(
computeBorder(inlineEndEdge(axis, direction), direction)
.resolve(0.0f)
.unwrap(),
0.0f);
}

float computeFlexStartPadding(
Expand Down

0 comments on commit ebcaf14

Please sign in to comment.