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

Remove yoga::Style::BitfieldRef #41393

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 @@ -133,7 +133,7 @@ - (void)setUp
auto &props = *sharedProps;
props.accessible = true;
auto &yogaStyle = props.yogaStyle;
yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(0));
yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(0));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200));
Expand Down Expand Up @@ -213,7 +213,7 @@ - (void)setUp
auto &props = *sharedProps;
props.accessible = true;
auto &yogaStyle = props.yogaStyle;
yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(0));
yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(30));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200));
Expand Down Expand Up @@ -257,7 +257,7 @@ - (void)setUp
auto &props = *sharedProps;
props.accessible = true;
auto &yogaStyle = props.yogaStyle;
yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(0));
yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(90));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200));
Expand Down Expand Up @@ -431,7 +431,7 @@ - (void)testEntireParagraphLink
props.accessible = true;
props.accessibilityTraits = AccessibilityTraits::Link;
auto &yogaStyle = props.yogaStyle;
yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(0));
yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(90));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(200));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void YogaLayoutableShadowNode::setPositionType(
ensureUnsealed();

auto style = yogaNode_.getStyle();
style.positionType() = yoga::scopedEnum(positionType);
style.setPositionType(yoga::scopedEnum(positionType));
yogaNode_.setStyle(style);
yogaNode_.setDirty(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ static inline T const getFieldValue(
return defaultValue;
}

#define REBUILD_FIELD_SWITCH_CASE2(field, fieldName) \
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
yogaStyle.field() = getFieldValue(context, value, ygDefaults.field()); \
return; \
#define REBUILD_FIELD_SWITCH_CASE2(field, setter, fieldName) \
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
yogaStyle.setter(getFieldValue(context, value, ygDefaults.field())); \
return; \
}

// @lint-ignore CLANGTIDY cppcoreguidelines-macro-usage
#define REBUILD_FIELD_SWITCH_CASE_YSP(field) \
REBUILD_FIELD_SWITCH_CASE2(field, #field)
#define REBUILD_FIELD_SWITCH_CASE_YSP(field, setter) \
REBUILD_FIELD_SWITCH_CASE2(field, setter, #field)

#define REBUILD_YG_FIELD_SWITCH_CASE_INDEXED(field, setter, index, fieldName) \
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
Expand Down Expand Up @@ -132,22 +131,22 @@ void YogaStylableProps::setProp(
Props::setProp(context, hash, propName, value);

switch (hash) {
REBUILD_FIELD_SWITCH_CASE_YSP(direction);
REBUILD_FIELD_SWITCH_CASE_YSP(flexDirection);
REBUILD_FIELD_SWITCH_CASE_YSP(justifyContent);
REBUILD_FIELD_SWITCH_CASE_YSP(alignContent);
REBUILD_FIELD_SWITCH_CASE_YSP(alignItems);
REBUILD_FIELD_SWITCH_CASE_YSP(alignSelf);
REBUILD_FIELD_SWITCH_CASE_YSP(flexWrap);
REBUILD_FIELD_SWITCH_CASE_YSP(overflow);
REBUILD_FIELD_SWITCH_CASE_YSP(display);
REBUILD_FIELD_SWITCH_CASE_YSP(flex);
REBUILD_FIELD_SWITCH_CASE_YSP(flexGrow);
REBUILD_FIELD_SWITCH_CASE_YSP(flexShrink);
REBUILD_FIELD_SWITCH_CASE_YSP(flexBasis);
REBUILD_FIELD_SWITCH_CASE2(positionType, "position");
REBUILD_FIELD_SWITCH_CASE_YSP(direction, setDirection);
REBUILD_FIELD_SWITCH_CASE_YSP(flexDirection, setFlexDirection);
REBUILD_FIELD_SWITCH_CASE_YSP(justifyContent, setJustifyContent);
REBUILD_FIELD_SWITCH_CASE_YSP(alignContent, setAlignContent);
REBUILD_FIELD_SWITCH_CASE_YSP(alignItems, setAlignItems);
REBUILD_FIELD_SWITCH_CASE_YSP(alignSelf, setAlignSelf);
REBUILD_FIELD_SWITCH_CASE_YSP(flexWrap, setFlexWrap);
REBUILD_FIELD_SWITCH_CASE_YSP(overflow, setOverflow);
REBUILD_FIELD_SWITCH_CASE_YSP(display, setDisplay);
REBUILD_FIELD_SWITCH_CASE_YSP(flex, setFlex);
REBUILD_FIELD_SWITCH_CASE_YSP(flexGrow, setFlexGrow);
REBUILD_FIELD_SWITCH_CASE_YSP(flexShrink, setFlexShrink);
REBUILD_FIELD_SWITCH_CASE_YSP(flexBasis, setFlexBasis);
REBUILD_FIELD_SWITCH_CASE2(positionType, setPositionType, "position");
REBUILD_FIELD_YG_GUTTER(gap, setGap, "rowGap", "columnGap", "gap");
REBUILD_FIELD_SWITCH_CASE_YSP(aspectRatio);
REBUILD_FIELD_SWITCH_CASE_YSP(aspectRatio, setAspectRatio);
REBUILD_FIELD_YG_DIMENSION(dimension, setDimension, "width", "height");
REBUILD_FIELD_YG_DIMENSION(
minDimension, setMinDimension, "minWidth", "minHeight");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,82 +23,100 @@ static inline yoga::Style convertRawProp(
const RawProps& rawProps,
const yoga::Style& sourceValue) {
yoga::Style yogaStyle{};
yogaStyle.direction() = convertRawProp(

yogaStyle.setDirection(convertRawProp(
context,
rawProps,
"direction",
sourceValue.direction(),
yogaStyle.direction());
yogaStyle.flexDirection() = convertRawProp(
yogaStyle.direction()));

yogaStyle.setFlexDirection(convertRawProp(
context,
rawProps,
"flexDirection",
sourceValue.flexDirection(),
yogaStyle.flexDirection());
yogaStyle.justifyContent() = convertRawProp(
yogaStyle.flexDirection()));

yogaStyle.setJustifyContent(convertRawProp(
context,
rawProps,
"justifyContent",
sourceValue.justifyContent(),
yogaStyle.justifyContent());
yogaStyle.alignContent() = convertRawProp(
yogaStyle.justifyContent()));

yogaStyle.setAlignContent(convertRawProp(
context,
rawProps,
"alignContent",
sourceValue.alignContent(),
yogaStyle.alignContent());
yogaStyle.alignItems() = convertRawProp(
yogaStyle.alignContent()));

yogaStyle.setAlignItems(convertRawProp(
context,
rawProps,
"alignItems",
sourceValue.alignItems(),
yogaStyle.alignItems());
yogaStyle.alignSelf() = convertRawProp(
yogaStyle.alignItems()));

yogaStyle.setAlignSelf(convertRawProp(
context,
rawProps,
"alignSelf",
sourceValue.alignSelf(),
yogaStyle.alignSelf());
yogaStyle.positionType() = convertRawProp(
yogaStyle.alignSelf()));

yogaStyle.setPositionType(convertRawProp(
context,
rawProps,
"position",
sourceValue.positionType(),
yogaStyle.positionType());
yogaStyle.flexWrap() = convertRawProp(
yogaStyle.positionType()));

yogaStyle.setFlexWrap(convertRawProp(
context,
rawProps,
"flexWrap",
sourceValue.flexWrap(),
yogaStyle.flexWrap());
yogaStyle.overflow() = convertRawProp(
yogaStyle.flexWrap()));

yogaStyle.setOverflow(convertRawProp(
context,
rawProps,
"overflow",
sourceValue.overflow(),
yogaStyle.overflow());
yogaStyle.display() = convertRawProp(
context, rawProps, "display", sourceValue.display(), yogaStyle.display());
yogaStyle.flex() = convertRawProp(
context, rawProps, "flex", sourceValue.flex(), yogaStyle.flex());
yogaStyle.flexGrow() = convertRawProp(
yogaStyle.overflow()));

yogaStyle.setDisplay(convertRawProp(
context,
rawProps,
"display",
sourceValue.display(),
yogaStyle.display()));

yogaStyle.setFlex(convertRawProp(
context, rawProps, "flex", sourceValue.flex(), yogaStyle.flex()));

yogaStyle.setFlexGrow(convertRawProp(
context,
rawProps,
"flexGrow",
sourceValue.flexGrow(),
yogaStyle.flexGrow());
yogaStyle.flexShrink() = convertRawProp(
yogaStyle.flexGrow()));

yogaStyle.setFlexShrink(convertRawProp(
context,
rawProps,
"flexShrink",
sourceValue.flexShrink(),
yogaStyle.flexShrink());
yogaStyle.flexBasis() = convertRawProp(
yogaStyle.flexShrink()));

yogaStyle.setFlexBasis(convertRawProp(
context,
rawProps,
"flexBasis",
sourceValue.flexBasis(),
yogaStyle.flexBasis());
yogaStyle.flexBasis()));

yogaStyle.setMargin(
yoga::Edge::Left,
Expand Down Expand Up @@ -459,6 +477,7 @@ static inline yoga::Style convertRawProp(
"width",
sourceValue.dimension(yoga::Dimension::Width),
{}));

yogaStyle.setDimension(
yoga::Dimension::Height,
convertRawProp(
Expand All @@ -476,6 +495,7 @@ static inline yoga::Style convertRawProp(
"minWidth",
sourceValue.minDimension(yoga::Dimension::Width),
{}));

yogaStyle.setMinDimension(
yoga::Dimension::Height,
convertRawProp(
Expand All @@ -493,6 +513,7 @@ static inline yoga::Style convertRawProp(
"maxWidth",
sourceValue.maxDimension(yoga::Dimension::Width),
{}));

yogaStyle.setMaxDimension(
yoga::Dimension::Height,
convertRawProp(
Expand All @@ -502,12 +523,12 @@ static inline yoga::Style convertRawProp(
sourceValue.maxDimension(yoga::Dimension::Height),
{}));

yogaStyle.aspectRatio() = convertRawProp(
yogaStyle.setAspectRatio(convertRawProp(
context,
rawProps,
"aspectRatio",
sourceValue.aspectRatio(),
yogaStyle.aspectRatio());
yogaStyle.aspectRatio()));

return yogaStyle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class LayoutTest : public ::testing::Test {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;
yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(50));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::value::points(50));
return sharedProps;
Expand All @@ -102,7 +102,7 @@ class LayoutTest : public ::testing::Test {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;
yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(10));
yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(10));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(30));
Expand Down Expand Up @@ -132,10 +132,10 @@ class LayoutTest : public ::testing::Test {
auto &yogaStyle = props.yogaStyle;

if (testCase == CLIPPING) {
yogaStyle.overflow() = yoga::Overflow::Hidden;
yogaStyle.setOverflow(yoga::Overflow::Hidden);
}

yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(10));
yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(10));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(110));
Expand All @@ -150,7 +150,7 @@ class LayoutTest : public ::testing::Test {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;
yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(70));
yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(-50));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(30));
Expand All @@ -165,7 +165,7 @@ class LayoutTest : public ::testing::Test {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
auto &props = *sharedProps;
auto &yogaStyle = props.yogaStyle;
yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::value::points(-60));
yogaStyle.setPosition(yoga::Edge::Top, yoga::value::points(50));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::value::points(70));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class YogaDirtyFlagTest : public ::testing::Test {
auto &props = *mutableViewProps;
props.nativeId = "native Id";
props.opacity = 0.5;
props.yogaStyle.alignContent() = yoga::Align::Baseline;
props.yogaStyle.flexDirection() = yoga::FlexDirection::RowReverse;
props.yogaStyle.setAlignContent(yoga::Align::Baseline);
props.yogaStyle.setFlexDirection(yoga::FlexDirection::RowReverse);
return mutableViewProps;
}),
Element<ViewShadowNode>()
Expand Down Expand Up @@ -136,8 +136,8 @@ TEST_F(YogaDirtyFlagTest, changingLayoutSubPropsMustDirtyYogaNode) {
auto viewProps = std::make_shared<ViewShadowNodeProps>();
auto& props = *viewProps;

props.yogaStyle.alignContent() = yoga::Align::Baseline;
props.yogaStyle.display() = yoga::Display::None;
props.yogaStyle.setAlignContent(yoga::Align::Baseline);
props.yogaStyle.setDisplay(yoga::Display::None);

return oldShadowNode.clone(ShadowNodeFragment{viewProps});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithZIndex) {
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
sharedProps->zIndex = 1;
auto &yogaStyle = sharedProps->yogaStyle;
yogaStyle.positionType() = yoga::PositionType::Absolute;
yogaStyle.setPositionType(yoga::PositionType::Absolute);
return sharedProps;
})
.finalize([](ViewShadowNode &shadowNode){
Expand Down
Loading