Sunset the value
namespace (#1720)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1720 X-link: https://github.com/facebook/react-native/pull/46930 This is not really needed anymore, we can just use `StyleLength` statics instead Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D63922280 fbshipit-source-id: cd953bae8e9f68574463eafc49c33c2e85ac1856
This commit is contained in:
committed by
Facebook GitHub Bot
parent
820a4d5bf6
commit
2437d26ca5
@@ -12,7 +12,7 @@ namespace facebook::yoga {
|
|||||||
|
|
||||||
TEST(Style, computed_padding_is_floored) {
|
TEST(Style, computed_padding_is_floored) {
|
||||||
yoga::Style style;
|
yoga::Style style;
|
||||||
style.setPadding(Edge::All, value::points(-1.0f));
|
style.setPadding(Edge::All, StyleLength::points(-1.0f));
|
||||||
auto paddingStart = style.computeInlineStartPadding(
|
auto paddingStart = style.computeInlineStartPadding(
|
||||||
FlexDirection::Row, Direction::LTR, 0.0f /*widthSize*/);
|
FlexDirection::Row, Direction::LTR, 0.0f /*widthSize*/);
|
||||||
ASSERT_EQ(paddingStart, 0.0f);
|
ASSERT_EQ(paddingStart, 0.0f);
|
||||||
@@ -20,7 +20,7 @@ TEST(Style, computed_padding_is_floored) {
|
|||||||
|
|
||||||
TEST(Style, computed_border_is_floored) {
|
TEST(Style, computed_border_is_floored) {
|
||||||
yoga::Style style;
|
yoga::Style style;
|
||||||
style.setBorder(Edge::All, value::points(-1.0f));
|
style.setBorder(Edge::All, StyleLength::points(-1.0f));
|
||||||
auto borderStart =
|
auto borderStart =
|
||||||
style.computeInlineStartBorder(FlexDirection::Row, Direction::LTR);
|
style.computeInlineStartBorder(FlexDirection::Row, Direction::LTR);
|
||||||
ASSERT_EQ(borderStart, 0.0f);
|
ASSERT_EQ(borderStart, 0.0f);
|
||||||
@@ -28,14 +28,14 @@ TEST(Style, computed_border_is_floored) {
|
|||||||
|
|
||||||
TEST(Style, computed_gap_is_floored) {
|
TEST(Style, computed_gap_is_floored) {
|
||||||
yoga::Style style;
|
yoga::Style style;
|
||||||
style.setGap(Gutter::Column, value::points(-1.0f));
|
style.setGap(Gutter::Column, StyleLength::points(-1.0f));
|
||||||
auto gapBetweenColumns = style.computeGapForAxis(FlexDirection::Row, 0.0);
|
auto gapBetweenColumns = style.computeGapForAxis(FlexDirection::Row, 0.0);
|
||||||
ASSERT_EQ(gapBetweenColumns, 0.0f);
|
ASSERT_EQ(gapBetweenColumns, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Style, computed_margin_is_not_floored) {
|
TEST(Style, computed_margin_is_not_floored) {
|
||||||
yoga::Style style;
|
yoga::Style style;
|
||||||
style.setMargin(Edge::All, value::points(-1.0f));
|
style.setMargin(Edge::All, StyleLength::points(-1.0f));
|
||||||
auto marginStart = style.computeInlineStartMargin(
|
auto marginStart = style.computeInlineStartMargin(
|
||||||
FlexDirection::Row, Direction::LTR, 0.0f /*widthSize*/);
|
FlexDirection::Row, Direction::LTR, 0.0f /*widthSize*/);
|
||||||
ASSERT_EQ(marginStart, -1.0f);
|
ASSERT_EQ(marginStart, -1.0f);
|
||||||
|
@@ -16,7 +16,7 @@ TEST(StyleValuePool, undefined_at_init) {
|
|||||||
|
|
||||||
EXPECT_TRUE(handle.isUndefined());
|
EXPECT_TRUE(handle.isUndefined());
|
||||||
EXPECT_FALSE(handle.isDefined());
|
EXPECT_FALSE(handle.isDefined());
|
||||||
EXPECT_EQ(pool.getLength(handle), value::undefined());
|
EXPECT_EQ(pool.getLength(handle), StyleLength::undefined());
|
||||||
EXPECT_EQ(pool.getNumber(handle), FloatOptional{});
|
EXPECT_EQ(pool.getNumber(handle), FloatOptional{});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,63 +25,63 @@ TEST(StyleValuePool, auto_at_init) {
|
|||||||
auto handle = StyleValueHandle::ofAuto();
|
auto handle = StyleValueHandle::ofAuto();
|
||||||
|
|
||||||
EXPECT_TRUE(handle.isAuto());
|
EXPECT_TRUE(handle.isAuto());
|
||||||
EXPECT_EQ(pool.getLength(handle), value::ofAuto());
|
EXPECT_EQ(pool.getLength(handle), StyleLength::ofAuto());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StyleValuePool, store_small_int_points) {
|
TEST(StyleValuePool, store_small_int_points) {
|
||||||
StyleValuePool pool;
|
StyleValuePool pool;
|
||||||
StyleValueHandle handle;
|
StyleValueHandle handle;
|
||||||
|
|
||||||
pool.store(handle, value::points(10));
|
pool.store(handle, StyleLength::points(10));
|
||||||
|
|
||||||
EXPECT_EQ(pool.getLength(handle), value::points(10));
|
EXPECT_EQ(pool.getLength(handle), StyleLength::points(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StyleValuePool, store_small_negative_int_points) {
|
TEST(StyleValuePool, store_small_negative_int_points) {
|
||||||
StyleValuePool pool;
|
StyleValuePool pool;
|
||||||
StyleValueHandle handle;
|
StyleValueHandle handle;
|
||||||
|
|
||||||
pool.store(handle, value::points(-10));
|
pool.store(handle, StyleLength::points(-10));
|
||||||
|
|
||||||
EXPECT_EQ(pool.getLength(handle), value::points(-10));
|
EXPECT_EQ(pool.getLength(handle), StyleLength::points(-10));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StyleValuePool, store_small_int_percent) {
|
TEST(StyleValuePool, store_small_int_percent) {
|
||||||
StyleValuePool pool;
|
StyleValuePool pool;
|
||||||
StyleValueHandle handle;
|
StyleValueHandle handle;
|
||||||
|
|
||||||
pool.store(handle, value::percent(10));
|
pool.store(handle, StyleLength::percent(10));
|
||||||
|
|
||||||
EXPECT_EQ(pool.getLength(handle), value::percent(10));
|
EXPECT_EQ(pool.getLength(handle), StyleLength::percent(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StyleValuePool, store_large_int_percent) {
|
TEST(StyleValuePool, store_large_int_percent) {
|
||||||
StyleValuePool pool;
|
StyleValuePool pool;
|
||||||
StyleValueHandle handle;
|
StyleValueHandle handle;
|
||||||
|
|
||||||
pool.store(handle, value::percent(262144));
|
pool.store(handle, StyleLength::percent(262144));
|
||||||
|
|
||||||
EXPECT_EQ(pool.getLength(handle), value::percent(262144));
|
EXPECT_EQ(pool.getLength(handle), StyleLength::percent(262144));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StyleValuePool, store_large_int_after_small_int) {
|
TEST(StyleValuePool, store_large_int_after_small_int) {
|
||||||
StyleValuePool pool;
|
StyleValuePool pool;
|
||||||
StyleValueHandle handle;
|
StyleValueHandle handle;
|
||||||
|
|
||||||
pool.store(handle, value::percent(10));
|
pool.store(handle, StyleLength::percent(10));
|
||||||
pool.store(handle, value::percent(262144));
|
pool.store(handle, StyleLength::percent(262144));
|
||||||
|
|
||||||
EXPECT_EQ(pool.getLength(handle), value::percent(262144));
|
EXPECT_EQ(pool.getLength(handle), StyleLength::percent(262144));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StyleValuePool, store_small_int_after_large_int) {
|
TEST(StyleValuePool, store_small_int_after_large_int) {
|
||||||
StyleValuePool pool;
|
StyleValuePool pool;
|
||||||
StyleValueHandle handle;
|
StyleValueHandle handle;
|
||||||
|
|
||||||
pool.store(handle, value::percent(262144));
|
pool.store(handle, StyleLength::percent(262144));
|
||||||
pool.store(handle, value::percent(10));
|
pool.store(handle, StyleLength::percent(10));
|
||||||
|
|
||||||
EXPECT_EQ(pool.getLength(handle), value::percent(10));
|
EXPECT_EQ(pool.getLength(handle), StyleLength::percent(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StyleValuePool, store_small_int_number) {
|
TEST(StyleValuePool, store_small_int_number) {
|
||||||
@@ -97,35 +97,35 @@ TEST(StyleValuePool, store_undefined) {
|
|||||||
StyleValuePool pool;
|
StyleValuePool pool;
|
||||||
StyleValueHandle handle;
|
StyleValueHandle handle;
|
||||||
|
|
||||||
pool.store(handle, value::undefined());
|
pool.store(handle, StyleLength::undefined());
|
||||||
|
|
||||||
EXPECT_TRUE(handle.isUndefined());
|
EXPECT_TRUE(handle.isUndefined());
|
||||||
EXPECT_FALSE(handle.isDefined());
|
EXPECT_FALSE(handle.isDefined());
|
||||||
EXPECT_EQ(pool.getLength(handle), value::undefined());
|
EXPECT_EQ(pool.getLength(handle), StyleLength::undefined());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StyleValuePool, store_undefined_after_small_int) {
|
TEST(StyleValuePool, store_undefined_after_small_int) {
|
||||||
StyleValuePool pool;
|
StyleValuePool pool;
|
||||||
StyleValueHandle handle;
|
StyleValueHandle handle;
|
||||||
|
|
||||||
pool.store(handle, value::points(10));
|
pool.store(handle, StyleLength::points(10));
|
||||||
pool.store(handle, value::undefined());
|
pool.store(handle, StyleLength::undefined());
|
||||||
|
|
||||||
EXPECT_TRUE(handle.isUndefined());
|
EXPECT_TRUE(handle.isUndefined());
|
||||||
EXPECT_FALSE(handle.isDefined());
|
EXPECT_FALSE(handle.isDefined());
|
||||||
EXPECT_EQ(pool.getLength(handle), value::undefined());
|
EXPECT_EQ(pool.getLength(handle), StyleLength::undefined());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StyleValuePool, store_undefined_after_large_int) {
|
TEST(StyleValuePool, store_undefined_after_large_int) {
|
||||||
StyleValuePool pool;
|
StyleValuePool pool;
|
||||||
StyleValueHandle handle;
|
StyleValueHandle handle;
|
||||||
|
|
||||||
pool.store(handle, value::points(262144));
|
pool.store(handle, StyleLength::points(262144));
|
||||||
pool.store(handle, value::undefined());
|
pool.store(handle, StyleLength::undefined());
|
||||||
|
|
||||||
EXPECT_TRUE(handle.isUndefined());
|
EXPECT_TRUE(handle.isUndefined());
|
||||||
EXPECT_FALSE(handle.isDefined());
|
EXPECT_FALSE(handle.isDefined());
|
||||||
EXPECT_EQ(pool.getLength(handle), value::undefined());
|
EXPECT_EQ(pool.getLength(handle), StyleLength::undefined());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
@@ -177,18 +177,19 @@ float YGNodeStyleGetFlexShrink(const YGNodeConstRef nodeRef) {
|
|||||||
|
|
||||||
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
||||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||||
node, value::points(flexBasis));
|
node, StyleLength::points(flexBasis));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexBasisPercent(
|
void YGNodeStyleSetFlexBasisPercent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float flexBasisPercent) {
|
const float flexBasisPercent) {
|
||||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||||
node, value::percent(flexBasisPercent));
|
node, StyleLength::percent(flexBasisPercent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
||||||
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(node, value::ofAuto());
|
updateStyle<&Style::flexBasis, &Style::setFlexBasis>(
|
||||||
|
node, StyleLength::ofAuto());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
||||||
@@ -197,17 +198,17 @@ YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) {
|
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) {
|
||||||
updateStyle<&Style::position, &Style::setPosition>(
|
updateStyle<&Style::position, &Style::setPosition>(
|
||||||
node, scopedEnum(edge), value::points(points));
|
node, scopedEnum(edge), StyleLength::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
|
void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
|
||||||
updateStyle<&Style::position, &Style::setPosition>(
|
updateStyle<&Style::position, &Style::setPosition>(
|
||||||
node, scopedEnum(edge), value::percent(percent));
|
node, scopedEnum(edge), StyleLength::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetPositionAuto(YGNodeRef node, YGEdge edge) {
|
void YGNodeStyleSetPositionAuto(YGNodeRef node, YGEdge edge) {
|
||||||
updateStyle<&Style::position, &Style::setPosition>(
|
updateStyle<&Style::position, &Style::setPosition>(
|
||||||
node, scopedEnum(edge), value::ofAuto());
|
node, scopedEnum(edge), StyleLength::ofAuto());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
|
YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
|
||||||
@@ -216,17 +217,17 @@ YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
|
|||||||
|
|
||||||
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) {
|
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) {
|
||||||
updateStyle<&Style::margin, &Style::setMargin>(
|
updateStyle<&Style::margin, &Style::setMargin>(
|
||||||
node, scopedEnum(edge), value::points(points));
|
node, scopedEnum(edge), StyleLength::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) {
|
void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) {
|
||||||
updateStyle<&Style::margin, &Style::setMargin>(
|
updateStyle<&Style::margin, &Style::setMargin>(
|
||||||
node, scopedEnum(edge), value::percent(percent));
|
node, scopedEnum(edge), StyleLength::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
|
void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
|
||||||
updateStyle<&Style::margin, &Style::setMargin>(
|
updateStyle<&Style::margin, &Style::setMargin>(
|
||||||
node, scopedEnum(edge), value::ofAuto());
|
node, scopedEnum(edge), StyleLength::ofAuto());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
|
YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
|
||||||
@@ -235,12 +236,12 @@ YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
|
|||||||
|
|
||||||
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) {
|
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) {
|
||||||
updateStyle<&Style::padding, &Style::setPadding>(
|
updateStyle<&Style::padding, &Style::setPadding>(
|
||||||
node, scopedEnum(edge), value::points(points));
|
node, scopedEnum(edge), StyleLength::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) {
|
void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) {
|
||||||
updateStyle<&Style::padding, &Style::setPadding>(
|
updateStyle<&Style::padding, &Style::setPadding>(
|
||||||
node, scopedEnum(edge), value::percent(percent));
|
node, scopedEnum(edge), StyleLength::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
|
YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
|
||||||
@@ -252,7 +253,7 @@ void YGNodeStyleSetBorder(
|
|||||||
const YGEdge edge,
|
const YGEdge edge,
|
||||||
const float border) {
|
const float border) {
|
||||||
updateStyle<&Style::border, &Style::setBorder>(
|
updateStyle<&Style::border, &Style::setBorder>(
|
||||||
node, scopedEnum(edge), value::points(border));
|
node, scopedEnum(edge), StyleLength::points(border));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) {
|
float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) {
|
||||||
@@ -269,12 +270,12 @@ void YGNodeStyleSetGap(
|
|||||||
const YGGutter gutter,
|
const YGGutter gutter,
|
||||||
const float gapLength) {
|
const float gapLength) {
|
||||||
updateStyle<&Style::gap, &Style::setGap>(
|
updateStyle<&Style::gap, &Style::setGap>(
|
||||||
node, scopedEnum(gutter), value::points(gapLength));
|
node, scopedEnum(gutter), StyleLength::points(gapLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float percent) {
|
void YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float percent) {
|
||||||
updateStyle<&Style::gap, &Style::setGap>(
|
updateStyle<&Style::gap, &Style::setGap>(
|
||||||
node, scopedEnum(gutter), value::percent(percent));
|
node, scopedEnum(gutter), StyleLength::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) {
|
float YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) {
|
||||||
@@ -307,17 +308,17 @@ YGBoxSizing YGNodeStyleGetBoxSizing(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Width, value::points(points));
|
node, Dimension::Width, StyleLength::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Width, value::percent(percent));
|
node, Dimension::Width, StyleLength::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Width, value::ofAuto());
|
node, Dimension::Width, StyleLength::ofAuto());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
||||||
@@ -326,17 +327,17 @@ YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Height, value::points(points));
|
node, Dimension::Height, StyleLength::points(points));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Height, value::percent(percent));
|
node, Dimension::Height, StyleLength::percent(percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
||||||
updateStyle<&Style::dimension, &Style::setDimension>(
|
updateStyle<&Style::dimension, &Style::setDimension>(
|
||||||
node, Dimension::Height, value::ofAuto());
|
node, Dimension::Height, StyleLength::ofAuto());
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
||||||
@@ -345,12 +346,12 @@ YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
|
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
|
||||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, Dimension::Width, value::points(minWidth));
|
node, Dimension::Width, StyleLength::points(minWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
|
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
|
||||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, Dimension::Width, value::percent(minWidth));
|
node, Dimension::Width, StyleLength::percent(minWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
||||||
@@ -359,14 +360,14 @@ YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
|
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
|
||||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, Dimension::Height, value::points(minHeight));
|
node, Dimension::Height, StyleLength::points(minHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMinHeightPercent(
|
void YGNodeStyleSetMinHeightPercent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float minHeight) {
|
const float minHeight) {
|
||||||
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
updateStyle<&Style::minDimension, &Style::setMinDimension>(
|
||||||
node, Dimension::Height, value::percent(minHeight));
|
node, Dimension::Height, StyleLength::percent(minHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
||||||
@@ -375,12 +376,12 @@ YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
|
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
|
||||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, Dimension::Width, value::points(maxWidth));
|
node, Dimension::Width, StyleLength::points(maxWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
|
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
|
||||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, Dimension::Width, value::percent(maxWidth));
|
node, Dimension::Width, StyleLength::percent(maxWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
||||||
@@ -389,14 +390,14 @@ YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
|
|||||||
|
|
||||||
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
|
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
|
||||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, Dimension::Height, value::points(maxHeight));
|
node, Dimension::Height, StyleLength::points(maxHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetMaxHeightPercent(
|
void YGNodeStyleSetMaxHeightPercent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float maxHeight) {
|
const float maxHeight) {
|
||||||
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
updateStyle<&Style::maxDimension, &Style::setMaxDimension>(
|
||||||
node, Dimension::Height, value::percent(maxHeight));
|
node, Dimension::Height, StyleLength::percent(maxHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
|
||||||
|
@@ -288,9 +288,10 @@ Style::Length Node::processFlexBasis() const {
|
|||||||
return flexBasis;
|
return flexBasis;
|
||||||
}
|
}
|
||||||
if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) {
|
if (style_.flex().isDefined() && style_.flex().unwrap() > 0.0f) {
|
||||||
return config_->useWebDefaults() ? value::ofAuto() : value::points(0);
|
return config_->useWebDefaults() ? StyleLength::ofAuto()
|
||||||
|
: StyleLength::points(0);
|
||||||
}
|
}
|
||||||
return value::ofAuto();
|
return StyleLength::ofAuto();
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatOptional Node::resolveFlexBasis(
|
FloatOptional Node::resolveFlexBasis(
|
||||||
|
@@ -302,7 +302,7 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
std::vector<Node*> children_;
|
std::vector<Node*> children_;
|
||||||
const Config* config_;
|
const Config* config_;
|
||||||
std::array<Style::Length, 2> processedDimensions_{
|
std::array<Style::Length, 2> processedDimensions_{
|
||||||
{value::undefined(), value::undefined()}};
|
{StyleLength::undefined(), StyleLength::undefined()}};
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Node* resolveRef(const YGNodeRef ref) {
|
inline Node* resolveRef(const YGNodeRef ref) {
|
||||||
|
@@ -104,36 +104,4 @@ inline bool inexactEquals(const StyleLength& a, const StyleLength& b) {
|
|||||||
return a.unit() == b.unit() && inexactEquals(a.value(), b.value());
|
return a.unit() == b.unit() && inexactEquals(a.value(), b.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace value {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Canonical unit (one YGUnitPoint)
|
|
||||||
*/
|
|
||||||
constexpr StyleLength points(float value) {
|
|
||||||
return StyleLength::points(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Percent of reference
|
|
||||||
*/
|
|
||||||
constexpr StyleLength percent(float value) {
|
|
||||||
return StyleLength::percent(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* "auto" keyword
|
|
||||||
*/
|
|
||||||
constexpr StyleLength ofAuto() {
|
|
||||||
return StyleLength::ofAuto();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Undefined
|
|
||||||
*/
|
|
||||||
constexpr StyleLength undefined() {
|
|
||||||
return StyleLength::undefined();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace value
|
|
||||||
|
|
||||||
} // namespace facebook::yoga
|
} // namespace facebook::yoga
|
||||||
|
@@ -49,9 +49,9 @@ class StyleValuePool {
|
|||||||
|
|
||||||
StyleLength getLength(StyleValueHandle handle) const {
|
StyleLength getLength(StyleValueHandle handle) const {
|
||||||
if (handle.isUndefined()) {
|
if (handle.isUndefined()) {
|
||||||
return value::undefined();
|
return StyleLength::undefined();
|
||||||
} else if (handle.isAuto()) {
|
} else if (handle.isAuto()) {
|
||||||
return value::ofAuto();
|
return StyleLength::ofAuto();
|
||||||
} else {
|
} else {
|
||||||
assert(
|
assert(
|
||||||
handle.type() == StyleValueHandle::Type::Point ||
|
handle.type() == StyleValueHandle::Type::Point ||
|
||||||
@@ -61,8 +61,8 @@ class StyleValuePool {
|
|||||||
: unpackInlineInteger(handle.value());
|
: unpackInlineInteger(handle.value());
|
||||||
|
|
||||||
return handle.type() == StyleValueHandle::Type::Point
|
return handle.type() == StyleValueHandle::Type::Point
|
||||||
? value::points(value)
|
? StyleLength::points(value)
|
||||||
: value::percent(value);
|
: StyleLength::percent(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user