Skip to content

Commit

Permalink
Remove alias props for inset, insetInline, insetBlock (facebook…
Browse files Browse the repository at this point in the history
…#41612)

Summary:

We never use the position edges for Yoga style. We should not keep extra props, and instead just parse directly into the Yoga style.

Previously included in D50998164

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D51508217
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Nov 22, 2023
1 parent 4e92016 commit eb0d0cd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,6 @@ void YogaLayoutableShadowNode::updateYogaProps() {
yoga::Style result{baseStyle};

// Aliases with precedence
if (!props.inset.isUndefined()) {
result.position()[YGEdgeAll] = props.inset;
}
if (!props.insetBlock.isUndefined()) {
result.position()[YGEdgeVertical] = props.insetBlock;
}
if (!props.insetInline.isUndefined()) {
result.position()[YGEdgeHorizontal] = props.insetInline;
}
if (!props.insetInlineEnd.isUndefined()) {
result.position()[YGEdgeEnd] = props.insetInlineEnd;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ static inline T const getFieldValue(
REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeRight, "right"); \
REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeBottom, "bottom"); \
REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeStart, "start"); \
REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeEnd, "end");
REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeEnd, "end"); \
REBUILD_YG_FIELD_SWITCH_CASE_INDEXED( \
position, YGEdgeHorizontal, "insetInline"); \
REBUILD_YG_FIELD_SWITCH_CASE_INDEXED( \
position, YGEdgeVertical, "insetBlock"); \
REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(position, YGEdgeAll, "inset");

void YogaStylableProps::setProp(
const PropsParserContext& context,
Expand Down Expand Up @@ -267,11 +272,8 @@ void YogaStylableProps::setProp(
REBUILD_FIELD_YG_EDGES(border, "border", "Width");

// Aliases
RAW_SET_PROP_SWITCH_CASE(inset, "inset");
RAW_SET_PROP_SWITCH_CASE(insetBlock, "insetBlock");
RAW_SET_PROP_SWITCH_CASE(insetBlockEnd, "insetBlockEnd");
RAW_SET_PROP_SWITCH_CASE(insetBlockStart, "insetBlockStart");
RAW_SET_PROP_SWITCH_CASE(insetInline, "insetInline");
RAW_SET_PROP_SWITCH_CASE(insetInlineEnd, "insetInlineEnd");
RAW_SET_PROP_SWITCH_CASE(insetInlineStart, "insetInlineStart");
RAW_SET_PROP_SWITCH_CASE(marginInline, "marginInline");
Expand Down Expand Up @@ -387,18 +389,6 @@ void YogaStylableProps::convertRawPropAliases(
const PropsParserContext& context,
const YogaStylableProps& sourceProps,
const RawProps& rawProps) {
inset = convertRawProp(
context,
rawProps,
"inset",
sourceProps.inset,
CompactValue::ofUndefined());
insetBlock = convertRawProp(
context,
rawProps,
"insetBlock",
sourceProps.insetBlock,
CompactValue::ofUndefined());
insetBlockEnd = convertRawProp(
context,
rawProps,
Expand All @@ -411,12 +401,6 @@ void YogaStylableProps::convertRawPropAliases(
"insetBlockStart",
sourceProps.insetBlockStart,
CompactValue::ofUndefined());
insetInline = convertRawProp(
context,
rawProps,
"insetInline",
sourceProps.insetInline,
CompactValue::ofUndefined());
insetInlineEnd = convertRawProp(
context,
rawProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ class YogaStylableProps : public Props {

// Duplicates of existing properties with different names, taking
// precedence. E.g. "marginBlock" instead of "marginVertical"
CompactValue inset;
CompactValue insetInline;
CompactValue insetInlineEnd;
CompactValue insetInlineStart;
CompactValue insetInlineEnd;

CompactValue marginInline;
CompactValue marginInlineStart;
Expand All @@ -59,9 +57,8 @@ class YogaStylableProps : public Props {
// BlockEnd/BlockStart map to top/bottom (no writing mode), but we preserve
// Yoga's precedence and prefer specific edges (e.g. top) to ones which are
// flow relative (e.g. blockStart).
CompactValue insetBlock;
CompactValue insetBlockEnd;
CompactValue insetBlockStart;
CompactValue insetBlockEnd;

CompactValue marginBlockStart;
CompactValue marginBlockEnd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,24 @@ static inline yoga::Style::Edges convertRawProp(
"end",
sourceValue[YGEdgeEnd],
defaultValue[YGEdgeEnd]);
result[YGEdgeHorizontal] = convertRawProp(
context,
rawProps,
"insetInline",
sourceValue[YGEdgeHorizontal],
defaultValue[YGEdgeHorizontal]);
result[YGEdgeVertical] = convertRawProp(
context,
rawProps,
"insetBlock",
sourceValue[YGEdgeVertical],
defaultValue[YGEdgeVertical]);
result[YGEdgeAll] = convertRawProp(
context,
rawProps,
"inset",
sourceValue[YGEdgeAll],
defaultValue[YGEdgeAll]);
return result;
}

Expand Down

0 comments on commit eb0d0cd

Please sign in to comment.