Skip to content

Commit

Permalink
create two layout pass reason flexLayout and flexMeasure instead of flex
Browse files Browse the repository at this point in the history
Summary:
We had flex as a reason for both layout and measure. Now creating separating reason flexLayout and flexMeasure in this diff.

Also changed ordering of items in Enum to group layout and measure reasons

Reviewed By: davidaurelio

Differential Revision: D16562350

fbshipit-source-id: 75501f9d4dde0974009193b3991a8acc97b02ad0
  • Loading branch information
SidharthGuglani-zz authored and facebook-github-bot committed Jul 31, 2019
1 parent 678d5f7 commit 6ce9854
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
26 changes: 14 additions & 12 deletions ReactAndroid/src/main/java/com/facebook/yoga/LayoutPassReason.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

public enum LayoutPassReason {
INITIAL(0),
MEASURE(1),
ABS_MEASURE(2),
FLEX(3),
ABS_LAYOUT(4),
STRETCH(5),
MULTILINE_STRETCH(6);
ABS_LAYOUT(1),
STRETCH(2),
MULTILINE_STRETCH(3),
FLEX_LAYOUT(4),
MEASURE(5),
ABS_MEASURE(6),
FLEX_MEASURE(7);

private final int mIntValue;

Expand All @@ -28,12 +29,13 @@ public int intValue() {
public static LayoutPassReason fromInt(int value) {
switch (value) {
case 0: return INITIAL;
case 1: return MEASURE;
case 2: return ABS_MEASURE;
case 3: return FLEX;
case 4: return ABS_LAYOUT;
case 5: return STRETCH;
case 6: return MULTILINE_STRETCH;
case 1: return ABS_LAYOUT;
case 2: return STRETCH;
case 3: return MULTILINE_STRETCH;
case 4: return FLEX_LAYOUT;
case 5: return MEASURE;
case 6: return ABS_MEASURE;
case 7: return FLEX_MEASURE;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}
Expand Down
6 changes: 4 additions & 2 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,7 @@ static float YGDistributeFreeSpaceSecondPass(
const YGMeasureMode childHeightMeasureMode =
!isMainAxisRow ? childMainMeasureMode : childCrossMeasureMode;

const bool isLayoutPass = performLayout && !requiresStretchLayout;
// Recursively call the layout algorithm for this child with the updated
// main size.
YGLayoutNodeInternal(
Expand All @@ -2196,8 +2197,9 @@ static float YGDistributeFreeSpaceSecondPass(
childHeightMeasureMode,
availableInnerWidth,
availableInnerHeight,
performLayout && !requiresStretchLayout,
LayoutPassReason::kFlex,
isLayoutPass,
isLayoutPass ? LayoutPassReason::kFlexLayout
: LayoutPassReason::kFlexMeasure,
config,
layoutMarkerData,
layoutContext,
Expand Down
14 changes: 8 additions & 6 deletions ReactCommon/yoga/yoga/event/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ const char* LayoutPassReasonToString(const LayoutPassReason value) {
switch (value) {
case LayoutPassReason::kInitial:
return "initial";
case LayoutPassReason::kMeasureChild:
return "measure";
case LayoutPassReason::kAbsMeasureChild:
return "abs_measure";
case LayoutPassReason::kFlex:
return "flex";
case LayoutPassReason::kAbsLayout:
return "abs_layout";
case LayoutPassReason::kStretch:
return "stretch";
case LayoutPassReason::kMultilineStretch:
return "multiline_stretch";
case LayoutPassReason::kFlexLayout:
return "flex_layout";
case LayoutPassReason::kMeasureChild:
return "measure";
case LayoutPassReason::kAbsMeasureChild:
return "abs_measure";
case LayoutPassReason::kFlexMeasure:
return "flex_measure";
default:
return "unknown";
}
Expand Down
13 changes: 7 additions & 6 deletions ReactCommon/yoga/yoga/event/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ struct LayoutData {

enum struct LayoutPassReason : int {
kInitial = 0,
kMeasureChild = 1,
kAbsMeasureChild = 2,
kFlex = 3,
kAbsLayout = 4,
kStretch = 5,
kMultilineStretch = 6
kAbsLayout = 1,
kStretch = 2,
kMultilineStretch = 3,
kFlexLayout = 4,
kMeasureChild = 5,
kAbsMeasureChild = 6,
kFlexMeasure = 7
};

const char* LayoutPassReasonToString(const LayoutPassReason value);
Expand Down

0 comments on commit 6ce9854

Please sign in to comment.