Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Edge Resolution #42254

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
public enum YogaErrata {
NONE(0),
STRETCH_FLEX_BASIS(1),
STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION(2),
POSITION_STATIC_BEHAVES_LIKE_RELATIVE(4),
ABSOLUTE_POSITIONING(8),
POSITION_STATIC_BEHAVES_LIKE_RELATIVE(2),
ABSOLUTE_POSITIONING(4),
ALL(2147483647),
CLASSIC(2147483646);

Expand All @@ -32,9 +31,8 @@ public static YogaErrata fromInt(int value) {
switch (value) {
case 0: return NONE;
case 1: return STRETCH_FLEX_BASIS;
case 2: return STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION;
case 4: return POSITION_STATIC_BEHAVES_LIKE_RELATIVE;
case 8: return ABSOLUTE_POSITIONING;
case 2: return POSITION_STATIC_BEHAVES_LIKE_RELATIVE;
case 4: return ABSOLUTE_POSITIONING;
case 2147483647: return ALL;
case 2147483646: return CLASSIC;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
Expand Down
2 changes: 0 additions & 2 deletions packages/react-native/ReactCommon/yoga/yoga/YGEnums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ const char* YGErrataToString(const YGErrata value) {
return "none";
case YGErrataStretchFlexBasis:
return "stretch-flex-basis";
case YGErrataStartingEndingEdgeFromFlexDirection:
return "starting-ending-edge-from-flex-direction";
case YGErrataPositionStaticBehavesLikeRelative:
return "position-static-behaves-like-relative";
case YGErrataAbsolutePositioning:
Expand Down
5 changes: 2 additions & 3 deletions packages/react-native/ReactCommon/yoga/yoga/YGEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ YG_ENUM_DECL(
YGErrata,
YGErrataNone = 0,
YGErrataStretchFlexBasis = 1,
YGErrataStartingEndingEdgeFromFlexDirection = 2,
YGErrataPositionStaticBehavesLikeRelative = 4,
YGErrataAbsolutePositioning = 8,
YGErrataPositionStaticBehavesLikeRelative = 2,
YGErrataAbsolutePositioning = 4,
YGErrataAll = 2147483647,
YGErrataClassic = 2147483646)
YG_DEFINE_ENUM_FLAG_OPERATORS(YGErrata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,13 +920,9 @@ static void justifyMainAxis(
const auto& style = node->getStyle();

const float leadingPaddingAndBorderMain =
node->hasErrata(Errata::StartingEndingEdgeFromFlexDirection)
? node->getInlineStartPaddingAndBorder(mainAxis, direction, ownerWidth)
: node->getFlexStartPaddingAndBorder(mainAxis, direction, ownerWidth);
node->getFlexStartPaddingAndBorder(mainAxis, direction, ownerWidth);
const float trailingPaddingAndBorderMain =
node->hasErrata(Errata::StartingEndingEdgeFromFlexDirection)
? node->getInlineEndPaddingAndBorder(mainAxis, direction, ownerWidth)
: node->getFlexEndPaddingAndBorder(mainAxis, direction, ownerWidth);
node->getFlexEndPaddingAndBorder(mainAxis, direction, ownerWidth);

const float gap = node->getGapForAxis(mainAxis);
// If we are using "at most" rules in the main axis, make sure that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,32 +99,6 @@ inline Edge inlineEndEdge(
return Edge::Bottom;
}

/**
* The physical edges that Edge::Start and Edge::End correspond to (e.g.
* left/right) are soley dependent on the direction. However, there are cases
* where we want the flex start/end edge (i.e. which edge is the start/end
* for laying out flex items), which can be distinct from the corresponding
* inline edge. In these cases we need to know which "relative edge"
* (Edge::Start/Edge::End) corresponds to the said flex start/end edge as these
* relative edges can be used instead of physical ones when defining certain
* attributes like border or padding.
*/
inline Edge flexStartRelativeEdge(
FlexDirection flexDirection,
Direction direction) {
const Edge leadLayoutEdge = inlineStartEdge(flexDirection, direction);
const Edge leadFlexItemEdge = flexStartEdge(flexDirection);
return leadLayoutEdge == leadFlexItemEdge ? Edge::Start : Edge::End;
}

inline Edge flexEndRelativeEdge(
FlexDirection flexDirection,
Direction direction) {
const Edge trailLayoutEdge = inlineEndEdge(flexDirection, direction);
const Edge trailFlexItemEdge = flexEndEdge(flexDirection);
return trailLayoutEdge == trailFlexItemEdge ? Edge::End : Edge::Start;
}

inline Dimension dimension(const FlexDirection flexDirection) {
switch (flexDirection) {
case FlexDirection::Column:
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/ReactCommon/yoga/yoga/enums/Errata.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace facebook::yoga {
enum class Errata : uint32_t {
None = YGErrataNone,
StretchFlexBasis = YGErrataStretchFlexBasis,
StartingEndingEdgeFromFlexDirection = YGErrataStartingEndingEdgeFromFlexDirection,
PositionStaticBehavesLikeRelative = YGErrataPositionStaticBehavesLikeRelative,
AbsolutePositioning = YGErrataAbsolutePositioning,
All = YGErrataAll,
Expand Down
Loading
Loading