Skip to content

Commit 2781888

Browse files
joevilchesfacebook-github-bot
authored andcommitted
Back out "Modify private apis to set, store, and get intrinsic sizing keywords" (facebook#47895)
Summary: Pull Request resolved: facebook#47895 X-link: facebook/yoga#1750 These APIs were only added so that we could do TDD as we work on intrinsic sizing functionality. As of right now they do nothing. We are aiming on publishing a new version of Yoga soon so for the time being we are going to back these out so as not to confuse anyone with this new functionality. Ideally we get to a point where we have some temporary experimental header to stage these in but this is a bit time sensitive so just backing out for now Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D66332307 fbshipit-source-id: 1d596964e0c893091c541988506e8b80fa6d1957
1 parent 04e44f3 commit 2781888

File tree

21 files changed

+114
-419
lines changed

21 files changed

+114
-419
lines changed

packages/react-native/React/Tests/Text/RCTParagraphComponentViewTests.mm

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ - (void)setUp
121121
auto &props = *sharedProps;
122122
props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}};
123123
auto &yogaStyle = props.yogaStyle;
124-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
125-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
124+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
125+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
126126
return sharedProps;
127127
})
128128
.children({
@@ -136,8 +136,8 @@ - (void)setUp
136136
yogaStyle.setPositionType(yoga::PositionType::Absolute);
137137
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
138138
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(0));
139-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
140-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
139+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
140+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
141141
return sharedProps;
142142
})
143143
.children({
@@ -216,8 +216,8 @@ - (void)setUp
216216
yogaStyle.setPositionType(yoga::PositionType::Absolute);
217217
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
218218
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(30));
219-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
220-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(50));
219+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
220+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50));
221221
return sharedProps;
222222
})
223223
.children({
@@ -260,8 +260,8 @@ - (void)setUp
260260
yogaStyle.setPositionType(yoga::PositionType::Absolute);
261261
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
262262
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(90));
263-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
264-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(50));
263+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
264+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50));
265265
return sharedProps;
266266
})
267267
.children({
@@ -418,8 +418,8 @@ - (void)testEntireParagraphLink
418418
auto &props = *sharedProps;
419419
props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}};
420420
auto &yogaStyle = props.yogaStyle;
421-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
422-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
421+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
422+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
423423
return sharedProps;
424424
})
425425
.children({
@@ -434,8 +434,8 @@ - (void)testEntireParagraphLink
434434
yogaStyle.setPositionType(yoga::PositionType::Absolute);
435435
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
436436
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(90));
437-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
438-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(20));
437+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
438+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20));
439439
return sharedProps;
440440
})
441441
.children({

packages/react-native/React/Views/RCTLayout.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ CGFloat RCTCoreGraphicsFloatFromYogaValue(YGValue value, CGFloat baseFloatValue)
8787
return RCTCoreGraphicsFloatFromYogaFloat(value.value) * baseFloatValue;
8888
case YGUnitAuto:
8989
case YGUnitUndefined:
90-
case YGUnitMaxContent:
91-
case YGUnitFitContent:
92-
case YGUnitStretch:
9390
return baseFloatValue;
9491
}
9592
}

packages/react-native/React/Views/RCTShadowView.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ + (YGConfigRef)yogaConfig
6363
#define RCT_SET_YGVALUE(ygvalue, setter, ...) \
6464
switch (ygvalue.unit) { \
6565
case YGUnitAuto: \
66-
case YGUnitMaxContent: \
67-
case YGUnitFitContent: \
68-
case YGUnitStretch: \
6966
case YGUnitUndefined: \
7067
setter(__VA_ARGS__, YGUndefined); \
7168
break; \
@@ -91,10 +88,6 @@ + (YGConfigRef)yogaConfig
9188
case YGUnitPercent: \
9289
setter##Percent(__VA_ARGS__, ygvalue.value); \
9390
break; \
94-
case YGUnitMaxContent: \
95-
case YGUnitFitContent: \
96-
case YGUnitStretch: \
97-
break; \
9891
}
9992

10093
static void RCTProcessMetaPropsPadding(const YGValue metaProps[META_PROP_COUNT], YGNodeRef node)

packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ public enum YogaUnit {
1313
UNDEFINED(0),
1414
POINT(1),
1515
PERCENT(2),
16-
AUTO(3),
17-
MAX_CONTENT(4),
18-
FIT_CONTENT(5),
19-
STRETCH(6);
16+
AUTO(3);
2017

2118
private final int mIntValue;
2219

@@ -34,9 +31,6 @@ public static YogaUnit fromInt(int value) {
3431
case 1: return POINT;
3532
case 2: return PERCENT;
3633
case 3: return AUTO;
37-
case 4: return MAX_CONTENT;
38-
case 5: return FIT_CONTENT;
39-
case 6: return STRETCH;
4034
default: throw new IllegalArgumentException("Unknown enum value: " + value);
4135
}
4236
}

packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,9 @@ void YogaLayoutableShadowNode::setSize(Size size) const {
538538

539539
auto style = yogaNode_.style();
540540
style.setDimension(
541-
yoga::Dimension::Width, yoga::StyleSizeLength::points(size.width));
541+
yoga::Dimension::Width, yoga::StyleLength::points(size.width));
542542
style.setDimension(
543-
yoga::Dimension::Height, yoga::StyleSizeLength::points(size.height));
543+
yoga::Dimension::Height, yoga::StyleLength::points(size.height));
544544
yogaNode_.setStyle(style);
545545
yogaNode_.setDirty(true);
546546
}
@@ -631,18 +631,16 @@ void YogaLayoutableShadowNode::layoutTree(
631631
auto ownerHeight = yogaFloatFromFloat(maximumSize.height);
632632

633633
yogaStyle.setMaxDimension(
634-
yoga::Dimension::Width, yoga::StyleSizeLength::points(maximumSize.width));
634+
yoga::Dimension::Width, yoga::StyleLength::points(maximumSize.width));
635635

636636
yogaStyle.setMaxDimension(
637-
yoga::Dimension::Height,
638-
yoga::StyleSizeLength::points(maximumSize.height));
637+
yoga::Dimension::Height, yoga::StyleLength::points(maximumSize.height));
639638

640639
yogaStyle.setMinDimension(
641-
yoga::Dimension::Width, yoga::StyleSizeLength::points(minimumSize.width));
640+
yoga::Dimension::Width, yoga::StyleLength::points(minimumSize.width));
642641

643642
yogaStyle.setMinDimension(
644-
yoga::Dimension::Height,
645-
yoga::StyleSizeLength::points(minimumSize.height));
643+
yoga::Dimension::Height, yoga::StyleLength::points(minimumSize.height));
646644

647645
auto direction =
648646
yogaDirectionFromLayoutDirection(layoutConstraints.layoutDirection);

packages/react-native/ReactCommon/react/renderer/components/view/conversions.h

Lines changed: 21 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,18 @@ inline yoga::FloatOptional yogaOptionalFloatFromFloat(Float value) {
9393
inline std::optional<Float> optionalFloatFromYogaValue(
9494
const yoga::Style::Length& length,
9595
std::optional<Float> base = {}) {
96-
if (length.isPoints()) {
97-
return floatFromYogaOptionalFloat(length.value());
98-
} else if (length.isPercent()) {
99-
return base.has_value()
100-
? std::optional<Float>(
101-
base.value() * floatFromYogaOptionalFloat(length.value()))
102-
: std::optional<Float>();
103-
} else {
104-
return {};
96+
switch (length.unit()) {
97+
case yoga::Unit::Undefined:
98+
return {};
99+
case yoga::Unit::Point:
100+
return floatFromYogaOptionalFloat(length.value());
101+
case yoga::Unit::Percent:
102+
return base.has_value()
103+
? std::optional<Float>(
104+
base.value() * floatFromYogaOptionalFloat(length.value()))
105+
: std::optional<Float>();
106+
case yoga::Unit::Auto:
107+
return {};
105108
}
106109
}
107110

@@ -444,47 +447,6 @@ inline void fromRawValue(
444447
LOG(ERROR) << "Could not parse yoga::Display: " << stringValue;
445448
}
446449

447-
inline void fromRawValue(
448-
const PropsParserContext& /*context*/,
449-
const RawValue& value,
450-
yoga::Style::SizeLength& result) {
451-
if (value.hasType<Float>()) {
452-
result = yoga::StyleSizeLength::points((float)value);
453-
return;
454-
} else if (value.hasType<std::string>()) {
455-
const auto stringValue = (std::string)value;
456-
if (stringValue == "auto") {
457-
result = yoga::StyleSizeLength::ofAuto();
458-
return;
459-
} else if (stringValue == "max-content") {
460-
result = yoga::StyleSizeLength::ofMaxContent();
461-
return;
462-
} else if (stringValue == "stretch") {
463-
result = yoga::StyleSizeLength::ofStretch();
464-
return;
465-
} else if (stringValue == "fit-content") {
466-
result = yoga::StyleSizeLength::ofFitContent();
467-
return;
468-
} else {
469-
if (stringValue.back() == '%') {
470-
auto tryValue = folly::tryTo<float>(
471-
std::string_view(stringValue).substr(0, stringValue.length() - 1));
472-
if (tryValue.hasValue()) {
473-
result = yoga::StyleSizeLength::percent(tryValue.value());
474-
return;
475-
}
476-
} else {
477-
auto tryValue = folly::tryTo<float>(stringValue);
478-
if (tryValue.hasValue()) {
479-
result = yoga::StyleSizeLength::points(tryValue.value());
480-
return;
481-
}
482-
}
483-
}
484-
}
485-
result = yoga::StyleSizeLength::undefined();
486-
}
487-
488450
inline void fromRawValue(
489451
const PropsParserContext& context,
490452
const RawValue& value,
@@ -1414,36 +1376,15 @@ inline std::string toString(const yoga::Display& value) {
14141376
}
14151377

14161378
inline std::string toString(const yoga::Style::Length& length) {
1417-
if (length.isUndefined()) {
1418-
return "undefined";
1419-
} else if (length.isAuto()) {
1420-
return "auto";
1421-
} else if (length.isPoints()) {
1422-
return std::to_string(length.value().unwrap());
1423-
} else if (length.isPercent()) {
1424-
return std::to_string(length.value().unwrap()) + "%";
1425-
} else {
1426-
return "unknown";
1427-
}
1428-
}
1429-
1430-
inline std::string toString(const yoga::Style::SizeLength& length) {
1431-
if (length.isUndefined()) {
1432-
return "undefined";
1433-
} else if (length.isAuto()) {
1434-
return "auto";
1435-
} else if (length.isPoints()) {
1436-
return std::to_string(length.value().unwrap());
1437-
} else if (length.isPercent()) {
1438-
return std::to_string(length.value().unwrap()) + "%";
1439-
} else if (length.isMaxContent()) {
1440-
return "max-content";
1441-
} else if (length.isFitContent()) {
1442-
return "fit-content";
1443-
} else if (length.isStretch()) {
1444-
return "stretch";
1445-
} else {
1446-
return "unknown";
1379+
switch (length.unit()) {
1380+
case yoga::Unit::Undefined:
1381+
return "undefined";
1382+
case yoga::Unit::Point:
1383+
return std::to_string(length.value().unwrap());
1384+
case yoga::Unit::Percent:
1385+
return std::to_string(length.value().unwrap()) + "%";
1386+
case yoga::Unit::Auto:
1387+
return "auto";
14471388
}
14481389
}
14491390

packages/react-native/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class LayoutTest : public ::testing::Test {
7777
auto &props = *sharedProps;
7878
props.layoutConstraints = LayoutConstraints{{0,0}, {500, 500}};
7979
auto &yogaStyle = props.yogaStyle;
80-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
81-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
80+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
81+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
8282
return sharedProps;
8383
})
8484
.children({
@@ -90,8 +90,8 @@ class LayoutTest : public ::testing::Test {
9090
auto &props = *sharedProps;
9191
auto &yogaStyle = props.yogaStyle;
9292
yogaStyle.setPositionType(yoga::PositionType::Absolute);
93-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(50));
94-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(50));
93+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(50));
94+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50));
9595
return sharedProps;
9696
})
9797
.children({
@@ -105,8 +105,8 @@ class LayoutTest : public ::testing::Test {
105105
yogaStyle.setPositionType(yoga::PositionType::Absolute);
106106
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(10));
107107
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(10));
108-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(30));
109-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(90));
108+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(30));
109+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(90));
110110

111111
if (testCase == TRANSFORM_SCALE) {
112112
props.transform = props.transform * Transform::Scale(2, 2, 1);
@@ -138,8 +138,8 @@ class LayoutTest : public ::testing::Test {
138138
yogaStyle.setPositionType(yoga::PositionType::Absolute);
139139
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(10));
140140
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(10));
141-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(110));
142-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(20));
141+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(110));
142+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20));
143143
return sharedProps;
144144
})
145145
.children({
@@ -153,8 +153,8 @@ class LayoutTest : public ::testing::Test {
153153
yogaStyle.setPositionType(yoga::PositionType::Absolute);
154154
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(70));
155155
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(-50));
156-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(30));
157-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(60));
156+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(30));
157+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(60));
158158
return sharedProps;
159159
})
160160
}),
@@ -168,8 +168,8 @@ class LayoutTest : public ::testing::Test {
168168
yogaStyle.setPositionType(yoga::PositionType::Absolute);
169169
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(-60));
170170
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(50));
171-
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(70));
172-
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(20));
171+
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(70));
172+
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20));
173173
return sharedProps;
174174
})
175175
})

0 commit comments

Comments
 (0)