Use only 4 edges for margin, padding, border in YGLayout

Summary:
We were using four edges for margin, padding and border. This diff changes the array size in YGLayout for margin, padding, border to reduce YGNode size and corresponding changes while we are setting values in YGLayout.
Reduces the YGNode size by 24 bytes

Reviewed By: davidaurelio

Differential Revision: D14892666

fbshipit-source-id: 94013d5183ee869901267c4c9941fd94fa05d848
This commit is contained in:
Sidharth Guglani
2019-04-15 05:20:44 -07:00
committed by Facebook Github Bot
parent fcfb19e9cf
commit ffce716557
2 changed files with 18 additions and 18 deletions

View File

@@ -14,9 +14,9 @@ constexpr std::array<float, 2> kYGDefaultDimensionValues = {
struct YGLayout {
std::array<float, 4> position = {};
std::array<float, 2> dimensions = kYGDefaultDimensionValues;
std::array<float, 6> margin = {};
std::array<float, 6> border = {};
std::array<float, 6> padding = {};
std::array<float, 4> margin = {};
std::array<float, 4> border = {};
std::array<float, 4> padding = {};
YGDirection direction : 2;
bool didUseLegacyFlag : 1;
bool doesLegacyStretchFlagAffectsLayout : 1;

View File

@@ -665,19 +665,19 @@ struct DimensionProp {
edge <= YGEdgeEnd, \
"Cannot get layout properties of multi-edge shorthands"); \
\
if (edge == YGEdgeLeft) { \
if (edge == YGEdgeStart) { \
if (node->getLayout().direction == YGDirectionRTL) { \
return node->getLayout().instanceName[YGEdgeEnd]; \
return node->getLayout().instanceName[YGEdgeRight]; \
} else { \
return node->getLayout().instanceName[YGEdgeStart]; \
return node->getLayout().instanceName[YGEdgeLeft]; \
} \
} \
\
if (edge == YGEdgeRight) { \
if (edge == YGEdgeEnd) { \
if (node->getLayout().direction == YGDirectionRTL) { \
return node->getLayout().instanceName[YGEdgeStart]; \
return node->getLayout().instanceName[YGEdgeLeft]; \
} else { \
return node->getLayout().instanceName[YGEdgeEnd]; \
return node->getLayout().instanceName[YGEdgeRight]; \
} \
} \
\
@@ -2674,12 +2674,13 @@ static void YGNodelayoutImpl(
const YGFlexDirection flexColumnDirection =
YGResolveFlexDirection(YGFlexDirectionColumn, direction);
const YGEdge startEdge =
direction == YGDirectionLTR ? YGEdgeLeft : YGEdgeRight;
const YGEdge endEdge = direction == YGDirectionLTR ? YGEdgeRight : YGEdgeLeft;
node->setLayoutMargin(
node->getLeadingMargin(flexRowDirection, ownerWidth).unwrap(),
YGEdgeStart);
node->getLeadingMargin(flexRowDirection, ownerWidth).unwrap(), startEdge);
node->setLayoutMargin(
node->getTrailingMargin(flexRowDirection, ownerWidth).unwrap(),
YGEdgeEnd);
node->getTrailingMargin(flexRowDirection, ownerWidth).unwrap(), endEdge);
node->setLayoutMargin(
node->getLeadingMargin(flexColumnDirection, ownerWidth).unwrap(),
YGEdgeTop);
@@ -2687,18 +2688,17 @@ static void YGNodelayoutImpl(
node->getTrailingMargin(flexColumnDirection, ownerWidth).unwrap(),
YGEdgeBottom);
node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), YGEdgeStart);
node->setLayoutBorder(node->getTrailingBorder(flexRowDirection), YGEdgeEnd);
node->setLayoutBorder(node->getLeadingBorder(flexRowDirection), startEdge);
node->setLayoutBorder(node->getTrailingBorder(flexRowDirection), endEdge);
node->setLayoutBorder(node->getLeadingBorder(flexColumnDirection), YGEdgeTop);
node->setLayoutBorder(
node->getTrailingBorder(flexColumnDirection), YGEdgeBottom);
node->setLayoutPadding(
node->getLeadingPadding(flexRowDirection, ownerWidth).unwrap(),
YGEdgeStart);
startEdge);
node->setLayoutPadding(
node->getTrailingPadding(flexRowDirection, ownerWidth).unwrap(),
YGEdgeEnd);
node->getTrailingPadding(flexRowDirection, ownerWidth).unwrap(), endEdge);
node->setLayoutPadding(
node->getLeadingPadding(flexColumnDirection, ownerWidth).unwrap(),
YGEdgeTop);