[yoga] Replace float with double #1095

Closed
cntrump wants to merge 1 commits from pr_replace_float_with_double into main
36 changed files with 694 additions and 686 deletions
Showing only changes of commit 860bb8b660 - Show all commits

View File

@@ -13,14 +13,14 @@
using facebook::yoga::detail::CompactValue; using facebook::yoga::detail::CompactValue;
const auto tooSmall = nextafterf(CompactValue::LOWER_BOUND, -INFINITY); const auto tooSmall = nextafter(CompactValue::LOWER_BOUND, -INFINITY);
const auto tooLargePoints = const auto tooLargePoints =
nextafterf(CompactValue::UPPER_BOUND_POINT, INFINITY); nextafter(CompactValue::UPPER_BOUND_POINT, INFINITY);
const auto tooLargePercent = const auto tooLargePercent =
nextafterf(CompactValue::UPPER_BOUND_PERCENT, INFINITY); nextafter(CompactValue::UPPER_BOUND_PERCENT, INFINITY);
TEST(YogaTest, compact_value_can_represent_undefined) { TEST(YogaTest, compact_value_can_represent_undefined) {
auto c = CompactValue{YGValue{12.5f, YGUnitUndefined}}; auto c = CompactValue{YGValue{12.5, YGUnitUndefined}};
YGValue v = c; YGValue v = c;
ASSERT_EQ(v, YGValueUndefined); ASSERT_EQ(v, YGValueUndefined);
ASSERT_NE(v, YGValueAuto); ASSERT_NE(v, YGValueAuto);
@@ -32,7 +32,7 @@ TEST(YogaTest, compact_value_can_represent_undefined) {
TEST(YogaTest, compact_value_manages_infinity_as_undefined) { TEST(YogaTest, compact_value_manages_infinity_as_undefined) {
auto c = CompactValue{ auto c = CompactValue{
YGValue{std::numeric_limits<float>::infinity(), YGUnitUndefined}}; YGValue{std::numeric_limits<double>::infinity(), YGUnitUndefined}};
YGValue v = c; YGValue v = c;
ASSERT_EQ(v, YGValueUndefined); ASSERT_EQ(v, YGValueUndefined);
ASSERT_NE(v, YGValueAuto); ASSERT_NE(v, YGValueAuto);
@@ -299,23 +299,23 @@ TEST(YogaTest, dedicated_unit_factories) {
ASSERT_EQ(CompactValue::ofUndefined(), CompactValue(YGValueUndefined)); ASSERT_EQ(CompactValue::ofUndefined(), CompactValue(YGValueUndefined));
ASSERT_EQ(CompactValue::ofAuto(), CompactValue(YGValueAuto)); ASSERT_EQ(CompactValue::ofAuto(), CompactValue(YGValueAuto));
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPoint>(-9876.5f), CompactValue::of<YGUnitPoint>(-9876.5),
CompactValue(YGValue{-9876.5f, YGUnitPoint})); CompactValue(YGValue{-9876.5, YGUnitPoint}));
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPercent>(123.456f), CompactValue::of<YGUnitPercent>(123.456),
CompactValue(YGValue{123.456f, YGUnitPercent})); CompactValue(YGValue{123.456, YGUnitPercent}));
} }
TEST(YogaTest, dedicated_unit_maybe_factories) { TEST(YogaTest, dedicated_unit_maybe_factories) {
ASSERT_EQ( ASSERT_EQ(
CompactValue::ofMaybe<YGUnitPoint>(-9876.5f), CompactValue::ofMaybe<YGUnitPoint>(-9876.5),
CompactValue(YGValue{-9876.5f, YGUnitPoint})); CompactValue(YGValue{-9876.5, YGUnitPoint}));
ASSERT_EQ( ASSERT_EQ(
CompactValue::ofMaybe<YGUnitPoint>(YGUndefined), CompactValue::ofMaybe<YGUnitPoint>(YGUndefined),
CompactValue(YGValueUndefined)); CompactValue(YGValueUndefined));
ASSERT_EQ( ASSERT_EQ(
CompactValue::ofMaybe<YGUnitPercent>(123.456f), CompactValue::ofMaybe<YGUnitPercent>(123.456),
CompactValue(YGValue{123.456f, YGUnitPercent})); CompactValue(YGValue{123.456, YGUnitPercent}));
ASSERT_EQ( ASSERT_EQ(
CompactValue::ofMaybe<YGUnitPercent>(YGUndefined), CompactValue::ofMaybe<YGUnitPercent>(YGUndefined),
CompactValue(YGValueUndefined)); CompactValue(YGValueUndefined));
@@ -324,7 +324,7 @@ TEST(YogaTest, dedicated_unit_maybe_factories) {
TEST(YogaTest, can_be_assigned_from_YGValue) { TEST(YogaTest, can_be_assigned_from_YGValue) {
CompactValue c{}; CompactValue c{};
YGValue v{2.0f, YGUnitPercent}; YGValue v{2.0, YGUnitPercent};
c = v; c = v;
ASSERT_EQ((YGValue) c, v); ASSERT_EQ((YGValue) c, v);
@@ -335,28 +335,28 @@ TEST(YogaTest, can_be_assigned_from_YGValue) {
TEST(YogaTest, compact_value_bound_representations) { TEST(YogaTest, compact_value_bound_representations) {
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPoint>(CompactValue::LOWER_BOUND).repr(), CompactValue::of<YGUnitPoint>(CompactValue::LOWER_BOUND).repr(),
uint32_t{0}); uint64_t{0});
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPoint>(CompactValue::UPPER_BOUND_POINT).repr(), CompactValue::of<YGUnitPoint>(CompactValue::UPPER_BOUND_POINT).repr(),
uint32_t{0x3fffffff}); uint64_t{0x3fffffffffffffff});
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPercent>(CompactValue::LOWER_BOUND).repr(), CompactValue::of<YGUnitPercent>(CompactValue::LOWER_BOUND).repr(),
uint32_t{0x40000000}); uint64_t{0x4000000000000000});
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPercent>(CompactValue::UPPER_BOUND_PERCENT).repr(), CompactValue::of<YGUnitPercent>(CompactValue::UPPER_BOUND_PERCENT).repr(),
uint32_t{0x7f7fffff}); uint64_t{0x7f7fffffffffffff});
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPoint>(-CompactValue::LOWER_BOUND).repr(), CompactValue::of<YGUnitPoint>(-CompactValue::LOWER_BOUND).repr(),
uint32_t{0x80000000}); uint64_t{0x8000000000000000});
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPoint>(-CompactValue::UPPER_BOUND_POINT).repr(), CompactValue::of<YGUnitPoint>(-CompactValue::UPPER_BOUND_POINT).repr(),
uint32_t{0xbfffffff}); uint64_t{0xbfffffffffffffff});
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPercent>(-CompactValue::LOWER_BOUND).repr(), CompactValue::of<YGUnitPercent>(-CompactValue::LOWER_BOUND).repr(),
uint32_t{0xc0000000}); uint64_t{0xc000000000000000});
ASSERT_EQ( ASSERT_EQ(
CompactValue::of<YGUnitPercent>(-CompactValue::UPPER_BOUND_PERCENT) CompactValue::of<YGUnitPercent>(-CompactValue::UPPER_BOUND_PERCENT)
.repr(), .repr(),
uint32_t{0xff7fffff}); uint64_t{0xff7fffffffffffff});
} }

View File

@@ -231,7 +231,7 @@ TEST_F(EventTest, layout_events_has_max_measure_cache) {
YGNodeInsertChild(root, a, 0); YGNodeInsertChild(root, a, 0);
auto b = YGNodeNew(); auto b = YGNodeNew();
YGNodeInsertChild(root, b, 1); YGNodeInsertChild(root, b, 1);
YGNodeStyleSetFlexBasis(a, 10.0f); YGNodeStyleSetFlexBasis(a, 10.0);
for (auto s : {20, 30, 40}) { for (auto s : {20, 30, 40}) {
YGNodeCalculateLayout(root, s, s, YGDirectionLTR); YGNodeCalculateLayout(root, s, s, YGDirectionLTR);
@@ -251,7 +251,7 @@ TEST_F(EventTest, layout_events_has_max_measure_cache) {
TEST_F(EventTest, measure_functions_get_wrapped) { TEST_F(EventTest, measure_functions_get_wrapped) {
auto root = YGNodeNew(); auto root = YGNodeNew();
YGNodeSetMeasureFunc( YGNodeSetMeasureFunc(
root, [](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode) { root, [](YGNodeRef, double, YGMeasureMode, double, YGMeasureMode) {
return YGSize{}; return YGSize{};
}); });
@@ -269,7 +269,7 @@ TEST_F(EventTest, baseline_functions_get_wrapped) {
auto child = YGNodeNew(); auto child = YGNodeNew();
YGNodeInsertChild(root, child, 0); YGNodeInsertChild(root, child, 0);
YGNodeSetBaselineFunc(child, [](YGNodeRef, float, float) { return 0.0f; }); YGNodeSetBaselineFunc(child, [](YGNodeRef, double, double) { return 0.0; });
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline); YGNodeStyleSetAlignItems(root, YGAlignBaseline);

View File

@@ -9,18 +9,18 @@
#include <yoga/YGNode.h> #include <yoga/YGNode.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static float _baselineFunc( static double _baselineFunc(
YGNodeRef node, YGNodeRef node,
const float width, const double width,
const float height) { const double height) {
return height / 2; return height / 2;
} }
static YGSize _measure1( static YGSize _measure1(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
.width = 42, .width = 42,
@@ -30,9 +30,9 @@ static YGSize _measure1(
static YGSize _measure2( static YGSize _measure2(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
.width = 279, .width = 279,

View File

@@ -11,9 +11,9 @@
static YGSize _measure( static YGSize _measure(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
.width = widthMode == YGMeasureModeExactly ? width : 50, .width = widthMode == YGMeasureModeExactly ? width : 50,

View File

@@ -9,8 +9,8 @@
#include <yoga/YGNode.h> #include <yoga/YGNode.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static float _baseline(YGNodeRef node, const float width, const float height) { static double _baseline(YGNodeRef node, const double width, const double height) {
float* baseline = (float*) node->getContext(); double* baseline = (double*) node->getContext();
return *baseline; return *baseline;
} }
@@ -31,7 +31,7 @@ TEST(YogaTest, align_baseline_customer_func) {
YGNodeStyleSetHeight(root_child1, 20); YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1); YGNodeInsertChild(root, root_child1, 1);
float baselineValue = 10; double baselineValue = 10;
const YGNodeRef root_child1_child0 = YGNodeNew(); const YGNodeRef root_child1_child0 = YGNodeNew();
root_child1_child0->setContext(&baselineValue); root_child1_child0->setContext(&baselineValue);
YGNodeStyleSetWidth(root_child1_child0, 50); YGNodeStyleSetWidth(root_child1_child0, 50);

View File

@@ -37,7 +37,7 @@ TEST(YogaTest, margin_side_overrides_horizontal_and_vertical) {
YGEdgeLeft, YGEdgeLeft,
YGEdgeRight}}; YGEdgeRight}};
for (float edgeValue = 0; edgeValue < 2; ++edgeValue) { for (double edgeValue = 0; edgeValue < 2; ++edgeValue) {
for (const auto& edge : edges) { for (const auto& edge : edges) {
YGEdge horizontalOrVertical = edge == YGEdgeTop || edge == YGEdgeBottom YGEdge horizontalOrVertical = edge == YGEdgeTop || edge == YGEdgeBottom
? YGEdgeVertical ? YGEdgeVertical
@@ -67,7 +67,7 @@ TEST(YogaTest, margin_side_overrides_all) {
YGEdgeLeft, YGEdgeLeft,
YGEdgeRight}}; YGEdgeRight}};
for (float edgeValue = 0; edgeValue < 2; ++edgeValue) { for (double edgeValue = 0; edgeValue < 2; ++edgeValue) {
for (const auto& edge : edges) { for (const auto& edge : edges) {
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);
@@ -87,7 +87,7 @@ TEST(YogaTest, margin_side_overrides_all) {
TEST(YogaTest, margin_horizontal_and_vertical_overrides_all) { TEST(YogaTest, margin_horizontal_and_vertical_overrides_all) {
const std::array<YGEdge, 2> directions = {{YGEdgeHorizontal, YGEdgeVertical}}; const std::array<YGEdge, 2> directions = {{YGEdgeHorizontal, YGEdgeVertical}};
for (float directionValue = 0; directionValue < 2; ++directionValue) { for (double directionValue = 0; directionValue < 2; ++directionValue) {
for (const auto& direction : directions) { for (const auto& direction : directions) {
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);

View File

@@ -37,7 +37,7 @@ TEST(YogaTest, padding_side_overrides_horizontal_and_vertical) {
YGEdgeLeft, YGEdgeLeft,
YGEdgeRight}}; YGEdgeRight}};
for (float edgeValue = 0; edgeValue < 2; ++edgeValue) { for (double edgeValue = 0; edgeValue < 2; ++edgeValue) {
for (const auto& edge : edges) { for (const auto& edge : edges) {
YGEdge horizontalOrVertical = edge == YGEdgeTop || edge == YGEdgeBottom YGEdge horizontalOrVertical = edge == YGEdgeTop || edge == YGEdgeBottom
? YGEdgeVertical ? YGEdgeVertical
@@ -67,7 +67,7 @@ TEST(YogaTest, padding_side_overrides_all) {
YGEdgeLeft, YGEdgeLeft,
YGEdgeRight}}; YGEdgeRight}};
for (float edgeValue = 0; edgeValue < 2; ++edgeValue) { for (double edgeValue = 0; edgeValue < 2; ++edgeValue) {
for (const auto& edge : edges) { for (const auto& edge : edges) {
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);
@@ -87,7 +87,7 @@ TEST(YogaTest, padding_side_overrides_all) {
TEST(YogaTest, padding_horizontal_and_vertical_overrides_all) { TEST(YogaTest, padding_horizontal_and_vertical_overrides_all) {
const std::array<YGEdge, 2> directions = {{YGEdgeHorizontal, YGEdgeVertical}}; const std::array<YGEdge, 2> directions = {{YGEdgeHorizontal, YGEdgeVertical}};
for (float directionValue = 0; directionValue < 2; ++directionValue) { for (double directionValue = 0; directionValue < 2; ++directionValue) {
for (const auto& direction : directions) { for (const auto& direction : directions) {
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);

View File

@@ -96,7 +96,7 @@ TEST(YogaTest, assert_webdefault_values) {
ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(root)); ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(root));
ASSERT_EQ(YGAlignStretch, YGNodeStyleGetAlignContent(root)); ASSERT_EQ(YGAlignStretch, YGNodeStyleGetAlignContent(root));
ASSERT_FLOAT_EQ(1.0f, YGNodeStyleGetFlexShrink(root)); ASSERT_FLOAT_EQ(1.0, YGNodeStyleGetFlexShrink(root));
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);
YGConfigFree(config); YGConfigFree(config);
@@ -110,7 +110,7 @@ TEST(YogaTest, assert_webdefault_values_reset) {
ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(root)); ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(root));
ASSERT_EQ(YGAlignStretch, YGNodeStyleGetAlignContent(root)); ASSERT_EQ(YGAlignStretch, YGNodeStyleGetAlignContent(root));
ASSERT_FLOAT_EQ(1.0f, YGNodeStyleGetFlexShrink(root)); ASSERT_FLOAT_EQ(1.0, YGNodeStyleGetFlexShrink(root));
YGNodeFreeRecursive(root); YGNodeFreeRecursive(root);
YGConfigFree(config); YGConfigFree(config);

View File

@@ -546,16 +546,16 @@ TEST(YogaTest, flex_grow_less_than_factor_one) {
YGNodeStyleSetHeight(root, 500); YGNodeStyleSetHeight(root, 500);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config); const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 0.2f); YGNodeStyleSetFlexGrow(root_child0, 0.2);
YGNodeStyleSetFlexBasis(root_child0, 40); YGNodeStyleSetFlexBasis(root_child0, 40);
YGNodeInsertChild(root, root_child0, 0); YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config); const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 0.2f); YGNodeStyleSetFlexGrow(root_child1, 0.2);
YGNodeInsertChild(root, root_child1, 1); YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config); const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 0.4f); YGNodeStyleSetFlexGrow(root_child2, 0.4);
YGNodeInsertChild(root, root_child2, 2); YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);

View File

@@ -12,17 +12,17 @@
#include <yoga/YGValue.h> #include <yoga/YGValue.h>
constexpr auto empty = YGFloatOptional{}; constexpr auto empty = YGFloatOptional{};
constexpr auto zero = YGFloatOptional{0.0f}; constexpr auto zero = YGFloatOptional{0.0};
constexpr auto one = YGFloatOptional{1.0f}; constexpr auto one = YGFloatOptional{1.0};
constexpr auto positive = YGFloatOptional{1234.5f}; constexpr auto positive = YGFloatOptional{1234.5};
constexpr auto negative = YGFloatOptional{-9876.5f}; constexpr auto negative = YGFloatOptional{-9876.5};
TEST(YGFloatOptional, value) { TEST(YGFloatOptional, value) {
ASSERT_TRUE(YGFloatIsUndefined(empty.unwrap())); ASSERT_TRUE(YGFloatIsUndefined(empty.unwrap()));
ASSERT_EQ(zero.unwrap(), 0.0f); ASSERT_EQ(zero.unwrap(), 0.0);
ASSERT_EQ(one.unwrap(), 1.0f); ASSERT_EQ(one.unwrap(), 1.0);
ASSERT_EQ(positive.unwrap(), 1234.5f); ASSERT_EQ(positive.unwrap(), 1234.5);
ASSERT_EQ(negative.unwrap(), -9876.5f); ASSERT_EQ(negative.unwrap(), -9876.5);
ASSERT_TRUE(empty.isUndefined()); ASSERT_TRUE(empty.isUndefined());
ASSERT_FALSE(zero.isUndefined()); ASSERT_FALSE(zero.isUndefined());
@@ -36,15 +36,15 @@ TEST(YGFloatOptional, equality) {
ASSERT_TRUE(empty == YGUndefined); ASSERT_TRUE(empty == YGUndefined);
ASSERT_FALSE(empty == zero); ASSERT_FALSE(empty == zero);
ASSERT_FALSE(empty == negative); ASSERT_FALSE(empty == negative);
ASSERT_FALSE(empty == 12.3f); ASSERT_FALSE(empty == 12.3);
ASSERT_TRUE(zero == zero); ASSERT_TRUE(zero == zero);
ASSERT_TRUE(zero == 0.0f); ASSERT_TRUE(zero == 0.0);
ASSERT_FALSE(zero == positive); ASSERT_FALSE(zero == positive);
ASSERT_FALSE(zero == -5555.5f); ASSERT_FALSE(zero == -5555.5);
ASSERT_TRUE(one == one); ASSERT_TRUE(one == one);
ASSERT_TRUE(one == 1.0f); ASSERT_TRUE(one == 1.0);
ASSERT_FALSE(one == positive); ASSERT_FALSE(one == positive);
ASSERT_TRUE(positive == positive); ASSERT_TRUE(positive == positive);
@@ -61,15 +61,15 @@ TEST(YGFloatOptional, inequality) {
ASSERT_FALSE(empty != YGUndefined); ASSERT_FALSE(empty != YGUndefined);
ASSERT_TRUE(empty != zero); ASSERT_TRUE(empty != zero);
ASSERT_TRUE(empty != negative); ASSERT_TRUE(empty != negative);
ASSERT_TRUE(empty != 12.3f); ASSERT_TRUE(empty != 12.3);
ASSERT_FALSE(zero != zero); ASSERT_FALSE(zero != zero);
ASSERT_FALSE(zero != 0.0f); ASSERT_FALSE(zero != 0.0);
ASSERT_TRUE(zero != positive); ASSERT_TRUE(zero != positive);
ASSERT_TRUE(zero != -5555.5f); ASSERT_TRUE(zero != -5555.5);
ASSERT_FALSE(one != one); ASSERT_FALSE(one != one);
ASSERT_FALSE(one != 1.0f); ASSERT_FALSE(one != 1.0);
ASSERT_TRUE(one != positive); ASSERT_TRUE(one != positive);
ASSERT_FALSE(positive != positive); ASSERT_FALSE(positive != positive);
@@ -198,12 +198,12 @@ TEST(YGFloatOptionalTest, YGFloatOptionalMax) {
ASSERT_EQ(YGFloatOptionalMax(negative, empty), negative); ASSERT_EQ(YGFloatOptionalMax(negative, empty), negative);
ASSERT_EQ(YGFloatOptionalMax(negative, YGFloatOptional{-INFINITY}), negative); ASSERT_EQ(YGFloatOptionalMax(negative, YGFloatOptional{-INFINITY}), negative);
ASSERT_EQ( ASSERT_EQ(
YGFloatOptionalMax(YGFloatOptional{1.0f}, YGFloatOptional{1.125f}), YGFloatOptionalMax(YGFloatOptional{1.0}, YGFloatOptional{1.125}),
YGFloatOptional{1.125f}); YGFloatOptional{1.125});
} }
TEST(YGFloatOptionalTest, unwrap) { TEST(YGFloatOptionalTest, unwrap) {
ASSERT_TRUE(YGFloatIsUndefined(empty.unwrap())); ASSERT_TRUE(YGFloatIsUndefined(empty.unwrap()));
ASSERT_EQ(zero.unwrap(), 0.0f); ASSERT_EQ(zero.unwrap(), 0.0);
ASSERT_EQ(YGFloatOptional{123456.78f}.unwrap(), 123456.78f); ASSERT_EQ(YGFloatOptional{123456.78}.unwrap(), 123456.78);
} }

View File

@@ -11,9 +11,9 @@
static YGSize _measureMax( static YGSize _measureMax(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
int* measureCount = (int*) node->getContext(); int* measureCount = (int*) node->getContext();
(*measureCount)++; (*measureCount)++;
@@ -26,9 +26,9 @@ static YGSize _measureMax(
static YGSize _measureMin( static YGSize _measureMin(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
int* measureCount = (int*) node->getContext(); int* measureCount = (int*) node->getContext();
*measureCount = *measureCount + 1; *measureCount = *measureCount + 1;
@@ -46,9 +46,9 @@ static YGSize _measureMin(
static YGSize _measure_84_49( static YGSize _measure_84_49(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
int* measureCount = (int*) node->getContext(); int* measureCount = (int*) node->getContext();
if (measureCount) { if (measureCount) {
@@ -56,8 +56,8 @@ static YGSize _measure_84_49(
} }
return YGSize{ return YGSize{
.width = 84.f, .width = 84,
.height = 49.f, .height = 49,
}; };
} }
@@ -160,12 +160,12 @@ TEST(
int measureCount = 0; int measureCount = 0;
const YGNodeRef root = YGNodeNew(); const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 288.f); YGNodeStyleSetWidth(root, 288);
YGNodeStyleSetHeight(root, 288.f); YGNodeStyleSetHeight(root, 288);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
const YGNodeRef root_child0 = YGNodeNew(); const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPadding(root_child0, YGEdgeAll, 2.88f); YGNodeStyleSetPadding(root_child0, YGEdgeAll, 2.88);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeInsertChild(root, root_child0, 0); YGNodeInsertChild(root, root_child0, 0);

View File

@@ -10,9 +10,9 @@
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
struct _MeasureConstraint { struct _MeasureConstraint {
float width; double width;
YGMeasureMode widthMode; YGMeasureMode widthMode;
float height; double height;
YGMeasureMode heightMode; YGMeasureMode heightMode;
}; };
@@ -23,9 +23,9 @@ struct _MeasureConstraintList {
static YGSize _measure( static YGSize _measure(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
struct _MeasureConstraintList* constraintList = struct _MeasureConstraintList* constraintList =
(struct _MeasureConstraintList*) node->getContext(); (struct _MeasureConstraintList*) node->getContext();

View File

@@ -11,9 +11,9 @@
static YGSize _measure( static YGSize _measure(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
int* measureCount = (int*) node->getContext(); int* measureCount = (int*) node->getContext();
if (measureCount) { if (measureCount) {
@@ -28,9 +28,9 @@ static YGSize _measure(
static YGSize _simulate_wrapping_text( static YGSize _simulate_wrapping_text(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
if (widthMode == YGMeasureModeUndefined || width >= 68) { if (widthMode == YGMeasureModeUndefined || width >= 68) {
return YGSize{.width = 68, .height = 16}; return YGSize{.width = 68, .height = 16};
@@ -44,9 +44,9 @@ static YGSize _simulate_wrapping_text(
static YGSize _measure_assert_negative( static YGSize _measure_assert_negative(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
EXPECT_GE(width, 0); EXPECT_GE(width, 0);
EXPECT_GE(height, 0); EXPECT_GE(height, 0);
@@ -643,9 +643,9 @@ TEST(YogaTest, cant_call_negative_measure_horizontal) {
static YGSize _measure_90_10( static YGSize _measure_90_10(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
@@ -656,9 +656,9 @@ static YGSize _measure_90_10(
static YGSize _measure_100_100( static YGSize _measure_100_100(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{

View File

@@ -1298,9 +1298,9 @@ TEST(YogaTest, min_max_percent_no_width_height) {
static YGSize _measureCk_test_label_shrink_based_on_height( static YGSize _measureCk_test_label_shrink_based_on_height(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
if (heightMode == YGMeasureModeAtMost) { if (heightMode == YGMeasureModeAtMost) {

View File

@@ -22,7 +22,7 @@ TEST(YGNode, hasMeasureFunc_initial) {
TEST(YGNode, hasMeasureFunc_with_measure_fn) { TEST(YGNode, hasMeasureFunc_with_measure_fn) {
auto n = YGNode{}; auto n = YGNode{};
n.setMeasureFunc([](YGNode*, float, YGMeasureMode, float, YGMeasureMode) { n.setMeasureFunc([](YGNode*, double, YGMeasureMode, double, YGMeasureMode) {
return YGSize{}; return YGSize{};
}); });
ASSERT_TRUE(n.hasMeasureFunc()); ASSERT_TRUE(n.hasMeasureFunc());
@@ -32,7 +32,7 @@ TEST(YGNode, measure_with_measure_fn) {
auto n = YGNode{}; auto n = YGNode{};
n.setMeasureFunc( n.setMeasureFunc(
[](YGNode*, float w, YGMeasureMode wm, float h, YGMeasureMode hm) { [](YGNode*, double w, YGMeasureMode wm, double h, YGMeasureMode hm) {
return YGSize{w * wm, h / hm}; return YGSize{w * wm, h / hm};
}); });
@@ -44,7 +44,7 @@ TEST(YGNode, measure_with_measure_fn) {
TEST(YGNode, measure_with_context_measure_fn) { TEST(YGNode, measure_with_context_measure_fn) {
auto n = YGNode{}; auto n = YGNode{};
n.setMeasureFunc( n.setMeasureFunc(
[](YGNode*, float, YGMeasureMode, float, YGMeasureMode, void* ctx) { [](YGNode*, double, YGMeasureMode, double, YGMeasureMode, void* ctx) {
return *(YGSize*) ctx; return *(YGSize*) ctx;
}); });
@@ -57,11 +57,11 @@ TEST(YGNode, measure_with_context_measure_fn) {
TEST(YGNode, switching_measure_fn_types) { TEST(YGNode, switching_measure_fn_types) {
auto n = YGNode{}; auto n = YGNode{};
n.setMeasureFunc( n.setMeasureFunc(
[](YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*) { [](YGNode*, double, YGMeasureMode, double, YGMeasureMode, void*) {
return YGSize{}; return YGSize{};
}); });
n.setMeasureFunc( n.setMeasureFunc(
[](YGNode*, float w, YGMeasureMode wm, float h, YGMeasureMode hm) { [](YGNode*, double w, YGMeasureMode wm, double h, YGMeasureMode hm) {
return YGSize{w * wm, h / hm}; return YGSize{w * wm, h / hm};
}); });
@@ -72,7 +72,7 @@ TEST(YGNode, switching_measure_fn_types) {
TEST(YGNode, hasMeasureFunc_after_unset) { TEST(YGNode, hasMeasureFunc_after_unset) {
auto n = YGNode{}; auto n = YGNode{};
n.setMeasureFunc([](YGNode*, float, YGMeasureMode, float, YGMeasureMode) { n.setMeasureFunc([](YGNode*, double, YGMeasureMode, double, YGMeasureMode) {
return YGSize{}; return YGSize{};
}); });
@@ -83,7 +83,7 @@ TEST(YGNode, hasMeasureFunc_after_unset) {
TEST(YGNode, hasMeasureFunc_after_unset_context) { TEST(YGNode, hasMeasureFunc_after_unset_context) {
auto n = YGNode{}; auto n = YGNode{};
n.setMeasureFunc( n.setMeasureFunc(
[](YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*) { [](YGNode*, double, YGMeasureMode, double, YGMeasureMode, void*) {
return YGSize{}; return YGSize{};
}); });
@@ -98,30 +98,30 @@ TEST(YGNode, hasBaselineFunc_initial) {
TEST(YGNode, hasBaselineFunc_with_baseline_fn) { TEST(YGNode, hasBaselineFunc_with_baseline_fn) {
auto n = YGNode{}; auto n = YGNode{};
n.setBaselineFunc([](YGNode*, float, float) { return 0.0f; }); n.setBaselineFunc([](YGNode*, double, double) { return 0.0; });
ASSERT_TRUE(n.hasBaselineFunc()); ASSERT_TRUE(n.hasBaselineFunc());
} }
TEST(YGNode, baseline_with_baseline_fn) { TEST(YGNode, baseline_with_baseline_fn) {
auto n = YGNode{}; auto n = YGNode{};
n.setBaselineFunc([](YGNode*, float w, float h) { return w + h; }); n.setBaselineFunc([](YGNode*, double w, double h) { return w + h; });
ASSERT_EQ(n.baseline(1.25f, 2.5f, nullptr), 3.75f); ASSERT_EQ(n.baseline(1.25, 2.5, nullptr), 3.75);
} }
TEST(YGNode, baseline_with_context_baseline_fn) { TEST(YGNode, baseline_with_context_baseline_fn) {
auto n = YGNode{}; auto n = YGNode{};
n.setBaselineFunc([](YGNode*, float w, float h, void* ctx) { n.setBaselineFunc([](YGNode*, double w, double h, void* ctx) {
return w + h + *(float*) ctx; return w + h + *(double*) ctx;
}); });
auto ctx = -10.0f; auto ctx = -10.0;
ASSERT_EQ(n.baseline(1.25f, 2.5f, &ctx), -6.25f); ASSERT_EQ(n.baseline(1.25, 2.5, &ctx), -6.25);
} }
TEST(YGNode, hasBaselineFunc_after_unset) { TEST(YGNode, hasBaselineFunc_after_unset) {
auto n = YGNode{}; auto n = YGNode{};
n.setBaselineFunc([](YGNode*, float, float) { return 0.0f; }); n.setBaselineFunc([](YGNode*, double, double) { return 0.0; });
n.setBaselineFunc(nullptr); n.setBaselineFunc(nullptr);
ASSERT_FALSE(n.hasBaselineFunc()); ASSERT_FALSE(n.hasBaselineFunc());
@@ -129,7 +129,7 @@ TEST(YGNode, hasBaselineFunc_after_unset) {
TEST(YGNode, hasBaselineFunc_after_unset_context) { TEST(YGNode, hasBaselineFunc_after_unset_context) {
auto n = YGNode{}; auto n = YGNode{};
n.setBaselineFunc([](YGNode*, float, float, void*) { return 0.0f; }); n.setBaselineFunc([](YGNode*, double, double, void*) { return 0.0; });
n.setMeasureFunc(nullptr); n.setMeasureFunc(nullptr);
ASSERT_FALSE(n.hasMeasureFunc()); ASSERT_FALSE(n.hasMeasureFunc());
@@ -137,9 +137,9 @@ TEST(YGNode, hasBaselineFunc_after_unset_context) {
TEST(YGNode, switching_baseline_fn_types) { TEST(YGNode, switching_baseline_fn_types) {
auto n = YGNode{}; auto n = YGNode{};
n.setBaselineFunc([](YGNode*, float, float, void*) { return 0.0f; }); n.setBaselineFunc([](YGNode*, double, double, void*) { return 0.0; });
n.setBaselineFunc([](YGNode*, float, float) { return 1.0f; }); n.setBaselineFunc([](YGNode*, double, double) { return 1.0; });
ASSERT_EQ(n.baseline(1, 2, nullptr), 1.0f); ASSERT_EQ(n.baseline(1, 2, nullptr), 1.0);
} }
void PrintTo(const YGSize& size, std::ostream* os) { void PrintTo(const YGSize& size, std::ostream* os) {

View File

@@ -1196,9 +1196,9 @@ TEST(YogaTest, percent_absolute_position) {
static YGSize _measureCk_test_label_shrink_based_on_height( static YGSize _measureCk_test_label_shrink_based_on_height(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
if (heightMode == YGMeasureModeAtMost) { if (heightMode == YGMeasureModeAtMost) {

View File

@@ -44,9 +44,9 @@ TEST(YogaTest, rounding_value) {
static YGSize measureText( static YGSize measureText(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return (YGSize){.width = 10, .height = 10}; return (YGSize){.width = 10, .height = 10};
} }

View File

@@ -11,37 +11,37 @@
static YGSize _measureFloor( static YGSize _measureFloor(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
width = 10.2f, width = 10.2,
height = 10.2f, height = 10.2,
}; };
} }
static YGSize _measureCeil( static YGSize _measureCeil(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
width = 10.5f, width = 10.5,
height = 10.5f, height = 10.5,
}; };
} }
static YGSize _measureFractial( static YGSize _measureFractial(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode) { YGMeasureMode heightMode) {
return YGSize{ return YGSize{
width = 0.5f, width = 0.5,
height = 0.5f, height = 0.5,
}; };
} }
@@ -53,35 +53,35 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_floor) {
root_child0->setMeasureFunc(_measureFloor); root_child0->setMeasureFunc(_measureFloor);
YGNodeInsertChild(root, root_child0, 0); YGNodeInsertChild(root, root_child0, 0);
YGConfigSetPointScaleFactor(config, 0.0f); YGConfigSetPointScaleFactor(config, 0.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetHeight(root_child0));
YGConfigSetPointScaleFactor(config, 1.0f); YGConfigSetPointScaleFactor(config, 1.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(11, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(11, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(11, YGNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(11, YGNodeLayoutGetHeight(root_child0));
YGConfigSetPointScaleFactor(config, 2.0f); YGConfigSetPointScaleFactor(config, 2.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(10.5, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10.5, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10.5, YGNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10.5, YGNodeLayoutGetHeight(root_child0));
YGConfigSetPointScaleFactor(config, 4.0f); YGConfigSetPointScaleFactor(config, 4.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetHeight(root_child0));
YGConfigSetPointScaleFactor(config, 1.0f / 3.0f); YGConfigSetPointScaleFactor(config, 1.0 / 3.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
@@ -101,7 +101,7 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) {
root_child0->setMeasureFunc(_measureCeil); root_child0->setMeasureFunc(_measureCeil);
YGNodeInsertChild(root, root_child0, 0); YGNodeInsertChild(root, root_child0, 0);
YGConfigSetPointScaleFactor(config, 1.0f); YGConfigSetPointScaleFactor(config, 1.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -124,7 +124,7 @@ TEST(
root_child0->setMeasureFunc(_measureFractial); root_child0->setMeasureFunc(_measureFractial);
YGNodeInsertChild(root, root_child0, 0); YGNodeInsertChild(root, root_child0, 0);
YGConfigSetPointScaleFactor(config, 2.0f); YGConfigSetPointScaleFactor(config, 2.0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);

View File

@@ -317,23 +317,23 @@ TEST(YogaTest, rounding_total_fractial) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 87.4f); YGNodeStyleSetWidth(root, 87.4);
YGNodeStyleSetHeight(root, 113.4f); YGNodeStyleSetHeight(root, 113.4);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config); const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 0.7f); YGNodeStyleSetFlexGrow(root_child0, 0.7);
YGNodeStyleSetFlexBasis(root_child0, 50.3f); YGNodeStyleSetFlexBasis(root_child0, 50.3);
YGNodeStyleSetHeight(root_child0, 20.3f); YGNodeStyleSetHeight(root_child0, 20.3);
YGNodeInsertChild(root, root_child0, 0); YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config); const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1.6f); YGNodeStyleSetFlexGrow(root_child1, 1.6);
YGNodeStyleSetHeight(root_child1, 10); YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1); YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config); const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1.1f); YGNodeStyleSetFlexGrow(root_child2, 1.1);
YGNodeStyleSetHeight(root_child2, 10.7f); YGNodeStyleSetHeight(root_child2, 10.7);
YGNodeInsertChild(root, root_child2, 2); YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -388,37 +388,37 @@ TEST(YogaTest, rounding_total_fractial_nested) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 87.4f); YGNodeStyleSetWidth(root, 87.4);
YGNodeStyleSetHeight(root, 113.4f); YGNodeStyleSetHeight(root, 113.4);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config); const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 0.7f); YGNodeStyleSetFlexGrow(root_child0, 0.7);
YGNodeStyleSetFlexBasis(root_child0, 50.3f); YGNodeStyleSetFlexBasis(root_child0, 50.3);
YGNodeStyleSetHeight(root_child0, 20.3f); YGNodeStyleSetHeight(root_child0, 20.3);
YGNodeInsertChild(root, root_child0, 0); YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1); YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexBasis(root_child0_child0, 0.3f); YGNodeStyleSetFlexBasis(root_child0_child0, 0.3);
YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3f); YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 13.3);
YGNodeStyleSetHeight(root_child0_child0, 9.9f); YGNodeStyleSetHeight(root_child0_child0, 9.9);
YGNodeInsertChild(root_child0, root_child0_child0, 0); YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child1, 4); YGNodeStyleSetFlexGrow(root_child0_child1, 4);
YGNodeStyleSetFlexBasis(root_child0_child1, 0.3f); YGNodeStyleSetFlexBasis(root_child0_child1, 0.3);
YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3f); YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 13.3);
YGNodeStyleSetHeight(root_child0_child1, 1.1f); YGNodeStyleSetHeight(root_child0_child1, 1.1);
YGNodeInsertChild(root_child0, root_child0_child1, 1); YGNodeInsertChild(root_child0, root_child0_child1, 1);
const YGNodeRef root_child1 = YGNodeNewWithConfig(config); const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child1, 1.6f); YGNodeStyleSetFlexGrow(root_child1, 1.6);
YGNodeStyleSetHeight(root_child1, 10); YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1); YGNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child2 = YGNodeNewWithConfig(config); const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child2, 1.1f); YGNodeStyleSetFlexGrow(root_child2, 1.1);
YGNodeStyleSetHeight(root_child2, 10.7f); YGNodeStyleSetHeight(root_child2, 10.7);
YGNodeInsertChild(root, root_child2, 2); YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -494,7 +494,7 @@ TEST(YogaTest, rounding_fractial_input_1) {
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.4f); YGNodeStyleSetHeight(root, 113.4);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config); const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexGrow(root_child0, 1);
@@ -565,7 +565,7 @@ TEST(YogaTest, rounding_fractial_input_2) {
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.6f); YGNodeStyleSetHeight(root, 113.6);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config); const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexGrow(root_child0, 1);
@@ -635,9 +635,9 @@ TEST(YogaTest, rounding_fractial_input_3) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPosition(root, YGEdgeTop, 0.3f); YGNodeStyleSetPosition(root, YGEdgeTop, 0.3);
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.4f); YGNodeStyleSetHeight(root, 113.4);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config); const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexGrow(root_child0, 1);
@@ -707,9 +707,9 @@ TEST(YogaTest, rounding_fractial_input_4) {
const YGConfigRef config = YGConfigNew(); const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config); const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPosition(root, YGEdgeTop, 0.7f); YGNodeStyleSetPosition(root, YGEdgeTop, 0.7);
YGNodeStyleSetWidth(root, 100); YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 113.4f); YGNodeStyleSetHeight(root, 113.4);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config); const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0, 1); YGNodeStyleSetFlexGrow(root_child0, 1);

View File

@@ -156,22 +156,22 @@ ACCESSOR_TEST(display, YGDisplayFlex, YGDisplayNone, YGDisplayFlex)
ACCESSOR_TEST( ACCESSOR_TEST(
flex, flex,
YGFloatOptional{}, YGFloatOptional{},
YGFloatOptional{123.45f}, YGFloatOptional{123.45},
YGFloatOptional{-9.87f}, YGFloatOptional{-9.87},
YGFloatOptional{}) YGFloatOptional{})
ACCESSOR_TEST( ACCESSOR_TEST(
flexGrow, flexGrow,
YGFloatOptional{}, YGFloatOptional{},
YGFloatOptional{123.45f}, YGFloatOptional{123.45},
YGFloatOptional{-9.87f}, YGFloatOptional{-9.87},
YGFloatOptional{}) YGFloatOptional{})
ACCESSOR_TEST( ACCESSOR_TEST(
flexShrink, flexShrink,
YGFloatOptional{}, YGFloatOptional{},
YGFloatOptional{123.45f}, YGFloatOptional{123.45},
YGFloatOptional{-9.87f}, YGFloatOptional{-9.87},
YGFloatOptional{}) YGFloatOptional{})
ACCESSOR_TEST( ACCESSOR_TEST(
@@ -179,8 +179,8 @@ ACCESSOR_TEST(
CompactValue::ofAuto(), CompactValue::ofAuto(),
CompactValue::ofUndefined(), CompactValue::ofUndefined(),
CompactValue::ofAuto(), CompactValue::ofAuto(),
CompactValue::of<YGUnitPoint>(7777.77f), CompactValue::of<YGUnitPoint>(7777.77),
CompactValue::of<YGUnitPercent>(-100.0f)) CompactValue::of<YGUnitPercent>(-100.0))
INDEX_ACCESSOR_TEST( INDEX_ACCESSOR_TEST(
position, position,
@@ -188,8 +188,8 @@ INDEX_ACCESSOR_TEST(
YGEdgeBottom, YGEdgeBottom,
CompactValue::ofAuto(), CompactValue::ofAuto(),
CompactValue::ofUndefined(), CompactValue::ofUndefined(),
CompactValue::of<YGUnitPoint>(7777.77f), CompactValue::of<YGUnitPoint>(7777.77),
CompactValue::of<YGUnitPercent>(-100.0f)) CompactValue::of<YGUnitPercent>(-100.0))
INDEX_ACCESSOR_TEST( INDEX_ACCESSOR_TEST(
margin, margin,
@@ -197,22 +197,22 @@ INDEX_ACCESSOR_TEST(
YGEdgeTop, YGEdgeTop,
CompactValue::ofAuto(), CompactValue::ofAuto(),
CompactValue::ofUndefined(), CompactValue::ofUndefined(),
CompactValue::of<YGUnitPoint>(7777.77f), CompactValue::of<YGUnitPoint>(7777.77),
CompactValue::of<YGUnitPercent>(-100.0f)) CompactValue::of<YGUnitPercent>(-100.0))
INDEX_ACCESSOR_TEST( INDEX_ACCESSOR_TEST(
padding, padding,
CompactValue::ofUndefined(), CompactValue::ofUndefined(),
YGEdgeAll, YGEdgeAll,
CompactValue::of<YGUnitPoint>(7777.77f), CompactValue::of<YGUnitPoint>(7777.77),
CompactValue::ofUndefined(), CompactValue::ofUndefined(),
CompactValue::of<YGUnitPercent>(-100.0f)) CompactValue::of<YGUnitPercent>(-100.0))
INDEX_ACCESSOR_TEST( INDEX_ACCESSOR_TEST(
border, border,
CompactValue::ofUndefined(), CompactValue::ofUndefined(),
YGEdgeHorizontal, YGEdgeHorizontal,
CompactValue::of<YGUnitPoint>(-7777.77f), CompactValue::of<YGUnitPoint>(-7777.77),
CompactValue::ofUndefined()) CompactValue::ofUndefined())
INDEX_ACCESSOR_TEST( INDEX_ACCESSOR_TEST(
@@ -221,8 +221,8 @@ INDEX_ACCESSOR_TEST(
YGDimensionWidth, YGDimensionWidth,
CompactValue::ofUndefined(), CompactValue::ofUndefined(),
CompactValue::ofAuto(), CompactValue::ofAuto(),
CompactValue::of<YGUnitPoint>(7777.77f), CompactValue::of<YGUnitPoint>(7777.77),
CompactValue::of<YGUnitPercent>(-100.0f)) CompactValue::of<YGUnitPercent>(-100.0))
INDEX_ACCESSOR_TEST( INDEX_ACCESSOR_TEST(
minDimensions, minDimensions,
@@ -230,8 +230,8 @@ INDEX_ACCESSOR_TEST(
YGDimensionHeight, YGDimensionHeight,
CompactValue::ofAuto(), CompactValue::ofAuto(),
CompactValue::ofUndefined(), CompactValue::ofUndefined(),
CompactValue::of<YGUnitPoint>(7777.77f), CompactValue::of<YGUnitPoint>(7777.77),
CompactValue::of<YGUnitPercent>(-100.0f)) CompactValue::of<YGUnitPercent>(-100.0))
INDEX_ACCESSOR_TEST( INDEX_ACCESSOR_TEST(
maxDimensions, maxDimensions,
@@ -239,15 +239,15 @@ INDEX_ACCESSOR_TEST(
YGDimensionHeight, YGDimensionHeight,
CompactValue::ofAuto(), CompactValue::ofAuto(),
CompactValue::ofUndefined(), CompactValue::ofUndefined(),
CompactValue::of<YGUnitPoint>(7777.77f), CompactValue::of<YGUnitPoint>(7777.77),
CompactValue::of<YGUnitPercent>(-100.0f)) CompactValue::of<YGUnitPercent>(-100.0))
ACCESSOR_TEST( ACCESSOR_TEST(
aspectRatio, aspectRatio,
YGFloatOptional{}, YGFloatOptional{},
YGFloatOptional{-123.45f}, YGFloatOptional{-123.45},
YGFloatOptional{9876.5f}, YGFloatOptional{9876.5},
YGFloatOptional{0.0f}, YGFloatOptional{0.0},
YGFloatOptional{}); YGFloatOptional{});
} // namespace yoga } // namespace yoga

View File

@@ -10,14 +10,14 @@
#include <yoga/YGValue.h> #include <yoga/YGValue.h>
TEST(YGValue, supports_equality) { TEST(YGValue, supports_equality) {
ASSERT_EQ((YGValue{12.5f, YGUnitPercent}), (YGValue{12.5f, YGUnitPercent})); ASSERT_EQ((YGValue{12.5, YGUnitPercent}), (YGValue{12.5, YGUnitPercent}));
ASSERT_NE((YGValue{12.5f, YGUnitPercent}), (YGValue{56.7f, YGUnitPercent})); ASSERT_NE((YGValue{12.5, YGUnitPercent}), (YGValue{56.7, YGUnitPercent}));
ASSERT_NE((YGValue{12.5f, YGUnitPercent}), (YGValue{12.5f, YGUnitPoint})); ASSERT_NE((YGValue{12.5, YGUnitPercent}), (YGValue{12.5, YGUnitPoint}));
ASSERT_NE((YGValue{12.5f, YGUnitPercent}), (YGValue{12.5f, YGUnitAuto})); ASSERT_NE((YGValue{12.5, YGUnitPercent}), (YGValue{12.5, YGUnitAuto}));
ASSERT_NE((YGValue{12.5f, YGUnitPercent}), (YGValue{12.5f, YGUnitUndefined})); ASSERT_NE((YGValue{12.5, YGUnitPercent}), (YGValue{12.5, YGUnitUndefined}));
ASSERT_EQ( ASSERT_EQ(
(YGValue{12.5f, YGUnitUndefined}), (YGValue{12.5, YGUnitUndefined}),
(YGValue{YGUndefined, YGUnitUndefined})); (YGValue{YGUndefined, YGUnitUndefined}));
ASSERT_EQ((YGValue{0, YGUnitAuto}), (YGValue{-1, YGUnitAuto})); ASSERT_EQ((YGValue{0, YGUnitAuto}), (YGValue{-1, YGUnitAuto}));
} }

View File

@@ -14,7 +14,7 @@
#include <limits> #include <limits>
static_assert( static_assert(
std::numeric_limits<float>::is_iec559, std::numeric_limits<double>::is_iec559,
"facebook::yoga::detail::CompactValue only works with IEEE754 floats"); "facebook::yoga::detail::CompactValue only works with IEEE754 floats");
#ifdef YOGA_COMPACT_VALUE_TEST #ifdef YOGA_COMPACT_VALUE_TEST
@@ -27,7 +27,7 @@ namespace facebook {
namespace yoga { namespace yoga {
namespace detail { namespace detail {
// This class stores YGValue in 32 bits. // This class stores YGValue in 64 bits.
// - The value does not matter for Undefined and Auto. NaNs are used for their // - The value does not matter for Undefined and Auto. NaNs are used for their
// representation. // representation.
// - To differentiate between Point and Percent, one exponent bit is used. // - To differentiate between Point and Percent, one exponent bit is used.
@@ -44,13 +44,13 @@ class YOGA_EXPORT CompactValue {
friend constexpr bool operator==(CompactValue, CompactValue) noexcept; friend constexpr bool operator==(CompactValue, CompactValue) noexcept;
public: public:
static constexpr auto LOWER_BOUND = 1.08420217e-19f; static constexpr auto LOWER_BOUND = 1.4916681462400413e-154;
static constexpr auto UPPER_BOUND_POINT = 36893485948395847680.0f; static constexpr auto UPPER_BOUND_POINT = 2.6815615859885191e+154;
static constexpr auto UPPER_BOUND_PERCENT = 18446742974197923840.0f; static constexpr auto UPPER_BOUND_PERCENT = 1.0474849945267653e+152;
template <YGUnit Unit> template <YGUnit Unit>
static CompactValue of(float value) noexcept { static CompactValue of(double value) noexcept {
if (value == 0.0f || (value < LOWER_BOUND && value > -LOWER_BOUND)) { if (value == 0.0 || (value < LOWER_BOUND && value > -LOWER_BOUND)) {
constexpr auto zero = constexpr auto zero =
Unit == YGUnitPercent ? ZERO_BITS_PERCENT : ZERO_BITS_POINT; Unit == YGUnitPercent ? ZERO_BITS_PERCENT : ZERO_BITS_POINT;
return {Payload{zero}}; return {Payload{zero}};
@@ -59,10 +59,10 @@ public:
constexpr auto upperBound = constexpr auto upperBound =
Unit == YGUnitPercent ? UPPER_BOUND_PERCENT : UPPER_BOUND_POINT; Unit == YGUnitPercent ? UPPER_BOUND_PERCENT : UPPER_BOUND_POINT;
if (value > upperBound || value < -upperBound) { if (value > upperBound || value < -upperBound) {
value = copysignf(upperBound, value); value = copysign(upperBound, value);
} }
uint32_t unitBit = Unit == YGUnitPercent ? PERCENT_BIT : 0; uint64_t unitBit = Unit == YGUnitPercent ? PERCENT_BIT : 0;
auto data = Payload{value}; auto data = Payload{value};
data.repr -= BIAS; data.repr -= BIAS;
data.repr |= unitBit; data.repr |= unitBit;
@@ -70,7 +70,7 @@ public:
} }
template <YGUnit Unit> template <YGUnit Unit>
static CompactValue ofMaybe(float value) noexcept { static CompactValue ofMaybe(double value) noexcept {
return std::isnan(value) || std::isinf(value) ? ofUndefined() return std::isnan(value) || std::isinf(value) ? ofUndefined()
: of<Unit>(value); : of<Unit>(value);
} }
@@ -88,9 +88,9 @@ public:
} }
constexpr CompactValue() noexcept constexpr CompactValue() noexcept
: payload_(std::numeric_limits<float>::quiet_NaN()) {} : payload_(std::numeric_limits<double>::quiet_NaN()) {}
CompactValue(const YGValue& x) noexcept : payload_(uint32_t{0}) { CompactValue(const YGValue& x) noexcept : payload_(uint64_t{0}) {
switch (x.unit) { switch (x.unit) {
case YGUnitUndefined: case YGUnitUndefined:
*this = ofUndefined(); *this = ofUndefined();
@@ -112,9 +112,9 @@ public:
case AUTO_BITS: case AUTO_BITS:
return YGValueAuto; return YGValueAuto;
case ZERO_BITS_POINT: case ZERO_BITS_POINT:
return YGValue{0.0f, YGUnitPoint}; return YGValue{0.0, YGUnitPoint};
case ZERO_BITS_PERCENT: case ZERO_BITS_PERCENT:
return YGValue{0.0f, YGUnitPercent}; return YGValue{0.0, YGUnitPercent};
} }
if (std::isnan(payload_.value)) { if (std::isnan(payload_.value)) {
@@ -125,8 +125,8 @@ public:
data.repr &= ~PERCENT_BIT; data.repr &= ~PERCENT_BIT;
data.repr += BIAS; data.repr += BIAS;
return YGValue{ return YGValue{data.value,
data.value, payload_.repr & 0x40000000 ? YGUnitPercent : YGUnitPoint}; payload_.repr & 0x4000000000000000 ? YGUnitPercent : YGUnitPoint};
} }
bool isUndefined() const noexcept { bool isUndefined() const noexcept {
@@ -139,37 +139,37 @@ public:
private: private:
union Payload { union Payload {
float value; double value;
uint32_t repr; uint64_t repr;
Payload() = delete; Payload() = delete;
constexpr Payload(uint32_t r) : repr(r) {} constexpr Payload(uint64_t r) : repr(r) {}
constexpr Payload(float v) : value(v) {} constexpr Payload(double v) : value(v) {}
}; };
static constexpr uint32_t BIAS = 0x20000000; static constexpr uint64_t BIAS = 0x2000000000000000;
static constexpr uint32_t PERCENT_BIT = 0x40000000; static constexpr uint64_t PERCENT_BIT = 0x4000000000000000;
// these are signaling NaNs with specific bit pattern as payload they will be // these are signaling NaNs with specific bit pattern as payload they will be
// silenced whenever going through an FPU operation on ARM + x86 // silenced whenever going through an FPU operation on ARM + x86
static constexpr uint32_t AUTO_BITS = 0x7faaaaaa; static constexpr uint64_t AUTO_BITS = 0x7faaaaaaaaaaaaaa;
static constexpr uint32_t ZERO_BITS_POINT = 0x7f8f0f0f; static constexpr uint64_t ZERO_BITS_POINT = 0x7f8f0f0f0f0f0f0f;
static constexpr uint32_t ZERO_BITS_PERCENT = 0x7f80f0f0; static constexpr uint64_t ZERO_BITS_PERCENT = 0x7f80f0f0f0f0f0f0;
constexpr CompactValue(Payload data) noexcept : payload_(data) {} constexpr CompactValue(Payload data) noexcept : payload_(data) {}
Payload payload_; Payload payload_;
VISIBLE_FOR_TESTING uint32_t repr() { return payload_.repr; } VISIBLE_FOR_TESTING uint64_t repr() { return payload_.repr; }
}; };
template <> template <>
CompactValue CompactValue::of<YGUnitUndefined>(float) noexcept = delete; CompactValue CompactValue::of<YGUnitUndefined>(double) noexcept = delete;
template <> template <>
CompactValue CompactValue::of<YGUnitAuto>(float) noexcept = delete; CompactValue CompactValue::of<YGUnitAuto>(double) noexcept = delete;
template <> template <>
CompactValue CompactValue::ofMaybe<YGUnitUndefined>(float) noexcept = delete; CompactValue CompactValue::ofMaybe<YGUnitUndefined>(double) noexcept = delete;
template <> template <>
CompactValue CompactValue::ofMaybe<YGUnitAuto>(float) noexcept = delete; CompactValue CompactValue::ofMaybe<YGUnitAuto>(double) noexcept = delete;
constexpr bool operator==(CompactValue a, CompactValue b) noexcept { constexpr bool operator==(CompactValue a, CompactValue b) noexcept {
return a.payload_.repr == b.payload_.repr; return a.payload_.repr == b.payload_.repr;

View File

@@ -18,16 +18,16 @@ YGFlexDirection YGFlexDirectionCross(
: YGFlexDirectionColumn; : YGFlexDirectionColumn;
} }
float YGFloatMax(const float a, const float b) { double YGFloatMax(const double a, const double b) {
if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) { if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) {
return fmaxf(a, b); return fmax(a, b);
} }
return yoga::isUndefined(a) ? b : a; return yoga::isUndefined(a) ? b : a;
} }
float YGFloatMin(const float a, const float b) { double YGFloatMin(const double a, const double b) {
if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) { if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) {
return fminf(a, b); return fmin(a, b);
} }
return yoga::isUndefined(a) ? b : a; return yoga::isUndefined(a) ? b : a;
@@ -43,12 +43,12 @@ bool YGValueEqual(const YGValue& a, const YGValue& b) {
return true; return true;
} }
return fabs(a.value - b.value) < 0.0001f; return fabs(a.value - b.value) < 0.0001;
} }
bool YGFloatsEqual(const float a, const float b) { bool YGFloatsEqual(const double a, const double b) {
if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) { if (!yoga::isUndefined(a) && !yoga::isUndefined(b)) {
return fabs(a - b) < 0.0001f; return fabs(a - b) < 0.0001;
} }
return yoga::isUndefined(a) && yoga::isUndefined(b); return yoga::isUndefined(a) && yoga::isUndefined(b);
} }
@@ -60,7 +60,7 @@ bool YGDoubleEqual(const double a, const double b) {
return yoga::isUndefined(a) && yoga::isUndefined(b); return yoga::isUndefined(a) && yoga::isUndefined(b);
} }
float YGFloatSanitize(const float val) { double YGFloatSanitize(const double val) {
return yoga::isUndefined(val) ? 0 : val; return yoga::isUndefined(val) ? 0 : val;
} }

View File

@@ -38,19 +38,19 @@
struct YGCollectFlexItemsRowValues { struct YGCollectFlexItemsRowValues {
uint32_t itemsOnLine; uint32_t itemsOnLine;
float sizeConsumedOnCurrentLine; double sizeConsumedOnCurrentLine;
float totalFlexGrowFactors; double totalFlexGrowFactors;
float totalFlexShrinkScaledFactors; double totalFlexShrinkScaledFactors;
uint32_t endOfLineIndex; uint32_t endOfLineIndex;
std::vector<YGNodeRef> relativeChildren; std::vector<YGNodeRef> relativeChildren;
float remainingFreeSpace; double remainingFreeSpace;
// The size of the mainDim for the row after considering size, padding, margin // The size of the mainDim for the row after considering size, padding, margin
// and border of flex items. This is used to calculate maxLineDim after going // and border of flex items. This is used to calculate maxLineDim after going
// through all the rows to decide on the main axis size of owner. // through all the rows to decide on the main axis size of owner.
float mainDim; double mainDim;
// The size of the crossDim for the row after considering size, padding, // The size of the crossDim for the row after considering size, padding,
// margin and border of flex items. Used for calculating containers crossSize. // margin and border of flex items. Used for calculating containers crossSize.
float crossDim; double crossDim;
}; };
bool YGValueEqual(const YGValue& a, const YGValue& b); bool YGValueEqual(const YGValue& a, const YGValue& b);
@@ -60,27 +60,27 @@ inline bool YGValueEqual(
return YGValueEqual((YGValue) a, (YGValue) b); return YGValueEqual((YGValue) a, (YGValue) b);
} }
// This custom float equality function returns true if either absolute // This custom double equality function returns true if either absolute
// difference between two floats is less than 0.0001f or both are undefined. // difference between two floats is less than 0.0001f or both are undefined.
bool YGFloatsEqual(const float a, const float b); bool YGFloatsEqual(const double a, const double b);
bool YGDoubleEqual(const double a, const double b); bool YGDoubleEqual(const double a, const double b);
float YGFloatMax(const float a, const float b); double YGFloatMax(const double a, const double b);
YGFloatOptional YGFloatOptionalMax( YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional op1, const YGFloatOptional op1,
const YGFloatOptional op2); const YGFloatOptional op2);
float YGFloatMin(const float a, const float b); double YGFloatMin(const double a, const double b);
// This custom float comparison function compares the array of float with // This custom double comparison function compares the array of double with
// YGFloatsEqual, as the default float comparison operator will not work(Look // YGFloatsEqual, as the default double comparison operator will not work(Look
// at the comments of YGFloatsEqual function). // at the comments of YGFloatsEqual function).
template <std::size_t size> template <std::size_t size>
bool YGFloatArrayEqual( bool YGFloatArrayEqual(
const std::array<float, size>& val1, const std::array<double, size>& val1,
const std::array<float, size>& val2) { const std::array<double, size>& val2) {
bool areEqual = true; bool areEqual = true;
for (std::size_t i = 0; i < size && areEqual; ++i) { for (std::size_t i = 0; i < size && areEqual; ++i) {
areEqual = YGFloatsEqual(val1[i], val2[i]); areEqual = YGFloatsEqual(val1[i], val2[i]);
@@ -89,7 +89,7 @@ bool YGFloatArrayEqual(
} }
// This function returns 0 if YGFloatIsUndefined(val) is true and val otherwise // This function returns 0 if YGFloatIsUndefined(val) is true and val otherwise
float YGFloatSanitize(const float val); double YGFloatSanitize(const double val);
YGFlexDirection YGFlexDirectionCross( YGFlexDirection YGFlexDirectionCross(
const YGFlexDirection flexDirection, const YGFlexDirection flexDirection,
@@ -102,12 +102,12 @@ inline bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) {
inline YGFloatOptional YGResolveValue( inline YGFloatOptional YGResolveValue(
const YGValue value, const YGValue value,
const float ownerSize) { const double ownerSize) {
switch (value.unit) { switch (value.unit) {
case YGUnitPoint: case YGUnitPoint:
return YGFloatOptional{value.value}; return YGFloatOptional{value.value};
case YGUnitPercent: case YGUnitPercent:
return YGFloatOptional{value.value * ownerSize * 0.01f}; return YGFloatOptional{value.value * ownerSize * 0.01};
default: default:
return YGFloatOptional{}; return YGFloatOptional{};
} }
@@ -115,7 +115,7 @@ inline YGFloatOptional YGResolveValue(
inline YGFloatOptional YGResolveValue( inline YGFloatOptional YGResolveValue(
yoga::detail::CompactValue value, yoga::detail::CompactValue value,
float ownerSize) { double ownerSize) {
return YGResolveValue((YGValue) value, ownerSize); return YGResolveValue((YGValue) value, ownerSize);
} }
@@ -140,7 +140,7 @@ inline YGFlexDirection YGResolveFlexDirection(
inline YGFloatOptional YGResolveValueMargin( inline YGFloatOptional YGResolveValueMargin(
yoga::detail::CompactValue value, yoga::detail::CompactValue value,
const float ownerSize) { const double ownerSize) {
return value.isAuto() ? YGFloatOptional{0} : YGResolveValue(value, ownerSize); return value.isAuto() ? YGFloatOptional{0} : YGResolveValue(value, ownerSize);
} }

View File

@@ -40,7 +40,7 @@ public:
bool useLegacyStretchBehaviour = false; bool useLegacyStretchBehaviour = false;
bool shouldDiffLayoutWithoutLegacyStretchBehaviour = false; bool shouldDiffLayoutWithoutLegacyStretchBehaviour = false;
bool printTree = false; bool printTree = false;
float pointScaleFactor = 1.0f; double pointScaleFactor = 1.0;
std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()> std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()>
experimentalFeatures = {}; experimentalFeatures = {};
void* context = nullptr; void* context = nullptr;

View File

@@ -10,6 +10,7 @@
#include "YGMacros.h" #include "YGMacros.h"
#ifdef __cplusplus #ifdef __cplusplus
YG_EXTERN_CXX_BEGIN
namespace facebook { namespace facebook {
namespace yoga { namespace yoga {
namespace enums { namespace enums {
@@ -27,6 +28,7 @@ constexpr int n() {
} // namespace enums } // namespace enums
} // namespace yoga } // namespace yoga
} // namespace facebook } // namespace facebook
YG_EXTERN_CXX_END
#endif #endif
#define YG_ENUM_DECL(NAME, ...) \ #define YG_ENUM_DECL(NAME, ...) \
@@ -37,6 +39,7 @@ constexpr int n() {
#define YG_ENUM_SEQ_DECL(NAME, ...) \ #define YG_ENUM_SEQ_DECL(NAME, ...) \
YG_ENUM_DECL(NAME, __VA_ARGS__) \ YG_ENUM_DECL(NAME, __VA_ARGS__) \
YG_EXTERN_C_END \ YG_EXTERN_C_END \
YG_EXTERN_CXX_BEGIN \
namespace facebook { \ namespace facebook { \
namespace yoga { \ namespace yoga { \
namespace enums { \ namespace enums { \
@@ -47,6 +50,7 @@ constexpr int n() {
} \ } \
} \ } \
} \ } \
YG_EXTERN_CXX_END \
YG_EXTERN_C_BEGIN YG_EXTERN_C_BEGIN
#else #else
#define YG_ENUM_SEQ_DECL YG_ENUM_DECL #define YG_ENUM_SEQ_DECL YG_ENUM_DECL

View File

@@ -13,14 +13,14 @@
struct YGFloatOptional { struct YGFloatOptional {
private: private:
float value_ = std::numeric_limits<float>::quiet_NaN(); double value_ = std::numeric_limits<double>::quiet_NaN();
public: public:
explicit constexpr YGFloatOptional(float value) : value_(value) {} explicit constexpr YGFloatOptional(double value) : value_(value) {}
constexpr YGFloatOptional() = default; constexpr YGFloatOptional() = default;
// returns the wrapped value, or a value x with YGIsUndefined(x) == true // returns the wrapped value, or a value x with YGIsUndefined(x) == true
constexpr float unwrap() const { return value_; } constexpr double unwrap() const { return value_; }
bool isUndefined() const { return std::isnan(value_); } bool isUndefined() const { return std::isnan(value_); }
}; };
@@ -35,17 +35,17 @@ inline bool operator!=(YGFloatOptional lhs, YGFloatOptional rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
inline bool operator==(YGFloatOptional lhs, float rhs) { inline bool operator==(YGFloatOptional lhs, double rhs) {
return lhs == YGFloatOptional{rhs}; return lhs == YGFloatOptional{rhs};
} }
inline bool operator!=(YGFloatOptional lhs, float rhs) { inline bool operator!=(YGFloatOptional lhs, double rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
inline bool operator==(float lhs, YGFloatOptional rhs) { inline bool operator==(double lhs, YGFloatOptional rhs) {
return rhs == lhs; return rhs == lhs;
} }
inline bool operator!=(float lhs, YGFloatOptional rhs) { inline bool operator!=(double lhs, YGFloatOptional rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }

View File

@@ -13,11 +13,11 @@
using namespace facebook::yoga; using namespace facebook::yoga;
struct YGLayout { struct YGLayout {
std::array<float, 4> position = {}; std::array<double, 4> position = {};
std::array<float, 2> dimensions = {{YGUndefined, YGUndefined}}; std::array<double, 2> dimensions = {{YGUndefined, YGUndefined}};
std::array<float, 4> margin = {}; std::array<double, 4> margin = {};
std::array<float, 4> border = {}; std::array<double, 4> border = {};
std::array<float, 4> padding = {}; std::array<double, 4> padding = {};
private: private:
static constexpr size_t directionOffset = 0; static constexpr size_t directionOffset = 0;
@@ -41,7 +41,7 @@ public:
uint32_t nextCachedMeasurementsIndex = 0; uint32_t nextCachedMeasurementsIndex = 0;
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT> std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
cachedMeasurements = {}; cachedMeasurements = {};
std::array<float, 2> measuredDimensions = {{YGUndefined, YGUndefined}}; std::array<double, 2> measuredDimensions = {{YGUndefined, YGUndefined}};
YGCachedMeasurement cachedLayout = YGCachedMeasurement(); YGCachedMeasurement cachedLayout = YGCachedMeasurement();

View File

@@ -8,9 +8,13 @@
#pragma once #pragma once
#ifdef __cplusplus #ifdef __cplusplus
#define YG_EXTERN_CXX_BEGIN extern "C++" {
#define YG_EXTERN_CXX_END }
#define YG_EXTERN_C_BEGIN extern "C" { #define YG_EXTERN_C_BEGIN extern "C" {
#define YG_EXTERN_C_END } #define YG_EXTERN_C_END }
#else #else
#define YG_EXTERN_CXX_BEGIN
#define YG_EXTERN_CXX_END
#define YG_EXTERN_C_BEGIN #define YG_EXTERN_C_BEGIN
#define YG_EXTERN_C_END #define YG_EXTERN_C_END
#endif #endif

View File

@@ -85,7 +85,7 @@ CompactValue YGNode::computeEdgeValueForColumn(
YGFloatOptional YGNode::getLeadingPosition( YGFloatOptional YGNode::getLeadingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const double axisSize) const {
auto leadingPosition = YGFlexDirectionIsRow(axis) auto leadingPosition = YGFlexDirectionIsRow(axis)
? computeEdgeValueForRow( ? computeEdgeValueForRow(
style_.position(), style_.position(),
@@ -99,7 +99,7 @@ YGFloatOptional YGNode::getLeadingPosition(
YGFloatOptional YGNode::getTrailingPosition( YGFloatOptional YGNode::getTrailingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const double axisSize) const {
auto trailingPosition = YGFlexDirectionIsRow(axis) auto trailingPosition = YGFlexDirectionIsRow(axis)
? computeEdgeValueForRow( ? computeEdgeValueForRow(
style_.position(), style_.position(),
@@ -137,7 +137,7 @@ bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) const {
YGFloatOptional YGNode::getLeadingMargin( YGFloatOptional YGNode::getLeadingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const double widthSize) const {
auto leadingMargin = YGFlexDirectionIsRow(axis) auto leadingMargin = YGFlexDirectionIsRow(axis)
? computeEdgeValueForRow( ? computeEdgeValueForRow(
style_.margin(), YGEdgeStart, leading[axis], CompactValue::ofZero()) style_.margin(), YGEdgeStart, leading[axis], CompactValue::ofZero())
@@ -148,7 +148,7 @@ YGFloatOptional YGNode::getLeadingMargin(
YGFloatOptional YGNode::getTrailingMargin( YGFloatOptional YGNode::getTrailingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const double widthSize) const {
auto trailingMargin = YGFlexDirectionIsRow(axis) auto trailingMargin = YGFlexDirectionIsRow(axis)
? computeEdgeValueForRow( ? computeEdgeValueForRow(
style_.margin(), YGEdgeEnd, trailing[axis], CompactValue::ofZero()) style_.margin(), YGEdgeEnd, trailing[axis], CompactValue::ofZero())
@@ -159,14 +159,14 @@ YGFloatOptional YGNode::getTrailingMargin(
YGFloatOptional YGNode::getMarginForAxis( YGFloatOptional YGNode::getMarginForAxis(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const double widthSize) const {
return getLeadingMargin(axis, widthSize) + getTrailingMargin(axis, widthSize); return getLeadingMargin(axis, widthSize) + getTrailingMargin(axis, widthSize);
} }
YGSize YGNode::measure( YGSize YGNode::measure(
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode, YGMeasureMode heightMode,
void* layoutContext) { void* layoutContext) {
return facebook::yoga::detail::getBooleanData(flags, measureUsesContext_) return facebook::yoga::detail::getBooleanData(flags, measureUsesContext_)
@@ -175,7 +175,7 @@ YGSize YGNode::measure(
: measure_.noContext(this, width, widthMode, height, heightMode); : measure_.noContext(this, width, widthMode, height, heightMode);
} }
float YGNode::baseline(float width, float height, void* layoutContext) { double YGNode::baseline(double width, double height, void* layoutContext) {
return facebook::yoga::detail::getBooleanData(flags, baselineUsesContext_) return facebook::yoga::detail::getBooleanData(flags, baselineUsesContext_)
? baseline_.withContext(this, width, height, layoutContext) ? baseline_.withContext(this, width, height, layoutContext)
: baseline_.noContext(this, width, height); : baseline_.noContext(this, width, height);
@@ -256,15 +256,15 @@ void YGNode::setLayoutDirection(YGDirection direction) {
layout_.setDirection(direction); layout_.setDirection(direction);
} }
void YGNode::setLayoutMargin(float margin, int index) { void YGNode::setLayoutMargin(double margin, int index) {
layout_.margin[index] = margin; layout_.margin[index] = margin;
} }
void YGNode::setLayoutBorder(float border, int index) { void YGNode::setLayoutBorder(double border, int index) {
layout_.border[index] = border; layout_.border[index] = border;
} }
void YGNode::setLayoutPadding(float padding, int index) { void YGNode::setLayoutPadding(double padding, int index) {
layout_.padding[index] = padding; layout_.padding[index] = padding;
} }
@@ -277,7 +277,7 @@ void YGNode::setLayoutComputedFlexBasis(
layout_.computedFlexBasis = computedFlexBasis; layout_.computedFlexBasis = computedFlexBasis;
} }
void YGNode::setLayoutPosition(float position, int index) { void YGNode::setLayoutPosition(double position, int index) {
layout_.position[index] = position; layout_.position[index] = position;
} }
@@ -286,7 +286,7 @@ void YGNode::setLayoutComputedFlexBasisGeneration(
layout_.computedFlexBasisGeneration = computedFlexBasisGeneration; layout_.computedFlexBasisGeneration = computedFlexBasisGeneration;
} }
void YGNode::setLayoutMeasuredDimension(float measuredDimension, int index) { void YGNode::setLayoutMeasuredDimension(double measuredDimension, int index) {
layout_.measuredDimensions[index] = measuredDimension; layout_.measuredDimensions[index] = measuredDimension;
} }
@@ -294,7 +294,7 @@ void YGNode::setLayoutHadOverflow(bool hadOverflow) {
layout_.setHadOverflow(hadOverflow); layout_.setHadOverflow(hadOverflow);
} }
void YGNode::setLayoutDimension(float dimension, int index) { void YGNode::setLayoutDimension(double dimension, int index) {
layout_.dimensions[index] = dimension; layout_.dimensions[index] = dimension;
} }
@@ -302,7 +302,7 @@ void YGNode::setLayoutDimension(float dimension, int index) {
// -right depending on which is defined. // -right depending on which is defined.
YGFloatOptional YGNode::relativePosition( YGFloatOptional YGNode::relativePosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const double axisSize) const {
if (isLeadingPositionDefined(axis)) { if (isLeadingPositionDefined(axis)) {
return getLeadingPosition(axis, axisSize); return getLeadingPosition(axis, axisSize);
} }
@@ -316,9 +316,9 @@ YGFloatOptional YGNode::relativePosition(
void YGNode::setPosition( void YGNode::setPosition(
const YGDirection direction, const YGDirection direction,
const float mainSize, const double mainSize,
const float crossSize, const double crossSize,
const float ownerWidth) { const double ownerWidth) {
/* Root nodes should be always layouted as LTR, so we don't return negative /* Root nodes should be always layouted as LTR, so we don't return negative
* values. */ * values. */
const YGDirection directionRespectingRoot = const YGDirection directionRespectingRoot =
@@ -374,7 +374,7 @@ YGValue YGNode::resolveFlexBasisPtr() const {
if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) { if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) {
return flexBasis; return flexBasis;
} }
if (!style_.flex().isUndefined() && style_.flex().unwrap() > 0.0f) { if (!style_.flex().isUndefined() && style_.flex().unwrap() > 0.0) {
return facebook::yoga::detail::getBooleanData(flags, useWebDefaults_) return facebook::yoga::detail::getBooleanData(flags, useWebDefaults_)
? YGValueAuto ? YGValueAuto
: YGValueZero; : YGValueZero;
@@ -432,7 +432,7 @@ void YGNode::markDirtyAndPropogateDownwards() {
}); });
} }
float YGNode::resolveFlexGrow() const { double YGNode::resolveFlexGrow() const {
// Root nodes flexGrow should always be 0 // Root nodes flexGrow should always be 0
if (owner_ == nullptr) { if (owner_ == nullptr) {
return 0.0; return 0.0;
@@ -440,13 +440,13 @@ float YGNode::resolveFlexGrow() const {
if (!style_.flexGrow().isUndefined()) { if (!style_.flexGrow().isUndefined()) {
return style_.flexGrow().unwrap(); return style_.flexGrow().unwrap();
} }
if (!style_.flex().isUndefined() && style_.flex().unwrap() > 0.0f) { if (!style_.flex().isUndefined() && style_.flex().unwrap() > 0.0) {
return style_.flex().unwrap(); return style_.flex().unwrap();
} }
return kDefaultFlexGrow; return kDefaultFlexGrow;
} }
float YGNode::resolveFlexShrink() const { double YGNode::resolveFlexShrink() const {
if (owner_ == nullptr) { if (owner_ == nullptr) {
return 0.0; return 0.0;
} }
@@ -454,7 +454,7 @@ float YGNode::resolveFlexShrink() const {
return style_.flexShrink().unwrap(); return style_.flexShrink().unwrap();
} }
if (!facebook::yoga::detail::getBooleanData(flags, useWebDefaults_) && if (!facebook::yoga::detail::getBooleanData(flags, useWebDefaults_) &&
!style_.flex().isUndefined() && style_.flex().unwrap() < 0.0f) { !style_.flex().isUndefined() && style_.flex().unwrap() < 0.0) {
return -style_.flex().unwrap(); return -style_.flex().unwrap();
} }
return facebook::yoga::detail::getBooleanData(flags, useWebDefaults_) return facebook::yoga::detail::getBooleanData(flags, useWebDefaults_)
@@ -468,27 +468,27 @@ bool YGNode::isNodeFlexible() {
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0)); (resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
} }
float YGNode::getLeadingBorder(const YGFlexDirection axis) const { double YGNode::getLeadingBorder(const YGFlexDirection axis) const {
YGValue leadingBorder = YGFlexDirectionIsRow(axis) YGValue leadingBorder = YGFlexDirectionIsRow(axis)
? computeEdgeValueForRow( ? computeEdgeValueForRow(
style_.border(), YGEdgeStart, leading[axis], CompactValue::ofZero()) style_.border(), YGEdgeStart, leading[axis], CompactValue::ofZero())
: computeEdgeValueForColumn( : computeEdgeValueForColumn(
style_.border(), leading[axis], CompactValue::ofZero()); style_.border(), leading[axis], CompactValue::ofZero());
return fmaxf(leadingBorder.value, 0.0f); return fmax(leadingBorder.value, 0.0);
} }
float YGNode::getTrailingBorder(const YGFlexDirection axis) const { double YGNode::getTrailingBorder(const YGFlexDirection axis) const {
YGValue trailingBorder = YGFlexDirectionIsRow(axis) YGValue trailingBorder = YGFlexDirectionIsRow(axis)
? computeEdgeValueForRow( ? computeEdgeValueForRow(
style_.border(), YGEdgeEnd, trailing[axis], CompactValue::ofZero()) style_.border(), YGEdgeEnd, trailing[axis], CompactValue::ofZero())
: computeEdgeValueForColumn( : computeEdgeValueForColumn(
style_.border(), trailing[axis], CompactValue::ofZero()); style_.border(), trailing[axis], CompactValue::ofZero());
return fmaxf(trailingBorder.value, 0.0f); return fmax(trailingBorder.value, 0.0);
} }
YGFloatOptional YGNode::getLeadingPadding( YGFloatOptional YGNode::getLeadingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const double widthSize) const {
auto leadingPadding = YGFlexDirectionIsRow(axis) auto leadingPadding = YGFlexDirectionIsRow(axis)
? computeEdgeValueForRow( ? computeEdgeValueForRow(
style_.padding(), style_.padding(),
@@ -498,31 +498,31 @@ YGFloatOptional YGNode::getLeadingPadding(
: computeEdgeValueForColumn( : computeEdgeValueForColumn(
style_.padding(), leading[axis], CompactValue::ofZero()); style_.padding(), leading[axis], CompactValue::ofZero());
return YGFloatOptionalMax( return YGFloatOptionalMax(
YGResolveValue(leadingPadding, widthSize), YGFloatOptional(0.0f)); YGResolveValue(leadingPadding, widthSize), YGFloatOptional(0.0));
} }
YGFloatOptional YGNode::getTrailingPadding( YGFloatOptional YGNode::getTrailingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const double widthSize) const {
auto trailingPadding = YGFlexDirectionIsRow(axis) auto trailingPadding = YGFlexDirectionIsRow(axis)
? computeEdgeValueForRow( ? computeEdgeValueForRow(
style_.padding(), YGEdgeEnd, trailing[axis], CompactValue::ofZero()) style_.padding(), YGEdgeEnd, trailing[axis], CompactValue::ofZero())
: computeEdgeValueForColumn( : computeEdgeValueForColumn(
style_.padding(), trailing[axis], CompactValue::ofZero()); style_.padding(), trailing[axis], CompactValue::ofZero());
return YGFloatOptionalMax( return YGFloatOptionalMax(
YGResolveValue(trailingPadding, widthSize), YGFloatOptional(0.0f)); YGResolveValue(trailingPadding, widthSize), YGFloatOptional(0.0));
} }
YGFloatOptional YGNode::getLeadingPaddingAndBorder( YGFloatOptional YGNode::getLeadingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const double widthSize) const {
return getLeadingPadding(axis, widthSize) + return getLeadingPadding(axis, widthSize) +
YGFloatOptional(getLeadingBorder(axis)); YGFloatOptional(getLeadingBorder(axis));
} }
YGFloatOptional YGNode::getTrailingPaddingAndBorder( YGFloatOptional YGNode::getTrailingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const double widthSize) const {
return getTrailingPadding(axis, widthSize) + return getTrailingPadding(axis, widthSize) +
YGFloatOptional(getTrailingBorder(axis)); YGFloatOptional(getTrailingBorder(axis));
} }

View File

@@ -23,8 +23,8 @@ YGConfigRef YGConfigGetDefault();
struct YOGA_EXPORT YGNode { struct YOGA_EXPORT YGNode {
using MeasureWithContextFn = using MeasureWithContextFn =
YGSize (*)(YGNode*, float, YGMeasureMode, float, YGMeasureMode, void*); YGSize (*)(YGNode*, double, YGMeasureMode, double, YGMeasureMode, void*);
using BaselineWithContextFn = float (*)(YGNode*, float, float, void*); using BaselineWithContextFn = double (*)(YGNode*, double, double, void*);
using PrintWithContextFn = void (*)(YGNode*, void*); using PrintWithContextFn = void (*)(YGNode*, void*);
private: private:
@@ -37,7 +37,7 @@ private:
static constexpr size_t printUsesContext_ = 6; static constexpr size_t printUsesContext_ = 6;
static constexpr size_t useWebDefaults_ = 7; static constexpr size_t useWebDefaults_ = 7;
void* context_ = nullptr; const void* context_ = nullptr;
uint8_t flags = 1; uint8_t flags = 1;
uint8_t reserved_ = 0; uint8_t reserved_ = 0;
union { union {
@@ -64,7 +64,7 @@ private:
YGFloatOptional relativePosition( YGFloatOptional relativePosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const; const double axisSize) const;
void setMeasureFunc(decltype(measure_)); void setMeasureFunc(decltype(measure_));
void setBaselineFunc(decltype(baseline_)); void setBaselineFunc(decltype(baseline_));
@@ -107,7 +107,7 @@ public:
YGNode& operator=(const YGNode&) = delete; YGNode& operator=(const YGNode&) = delete;
// Getters // Getters
void* getContext() const { return context_; } const void* getContext() const { return context_; }
uint8_t& reserved() { return reserved_; } uint8_t& reserved() { return reserved_; }
uint8_t reserved() const { return reserved_; } uint8_t reserved() const { return reserved_; }
@@ -124,13 +124,13 @@ public:
bool hasMeasureFunc() const noexcept { return measure_.noContext != nullptr; } bool hasMeasureFunc() const noexcept { return measure_.noContext != nullptr; }
YGSize measure(float, YGMeasureMode, float, YGMeasureMode, void*); YGSize measure(double, YGMeasureMode, double, YGMeasureMode, void*);
bool hasBaselineFunc() const noexcept { bool hasBaselineFunc() const noexcept {
return baseline_.noContext != nullptr; return baseline_.noContext != nullptr;
} }
float baseline(float width, float height, void* layoutContext); double baseline(double width, double height, void* layoutContext);
YGDirtiedFunc getDirtied() const { return dirtied_; } YGDirtiedFunc getDirtied() const { return dirtied_; }
@@ -207,38 +207,38 @@ public:
// Methods related to positions, margin, padding and border // Methods related to positions, margin, padding and border
YGFloatOptional getLeadingPosition( YGFloatOptional getLeadingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const; const double axisSize) const;
bool isLeadingPositionDefined(const YGFlexDirection axis) const; bool isLeadingPositionDefined(const YGFlexDirection axis) const;
bool isTrailingPosDefined(const YGFlexDirection axis) const; bool isTrailingPosDefined(const YGFlexDirection axis) const;
YGFloatOptional getTrailingPosition( YGFloatOptional getTrailingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const; const double axisSize) const;
YGFloatOptional getLeadingMargin( YGFloatOptional getLeadingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const double widthSize) const;
YGFloatOptional getTrailingMargin( YGFloatOptional getTrailingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const double widthSize) const;
float getLeadingBorder(const YGFlexDirection flexDirection) const; double getLeadingBorder(const YGFlexDirection flexDirection) const;
float getTrailingBorder(const YGFlexDirection flexDirection) const; double getTrailingBorder(const YGFlexDirection flexDirection) const;
YGFloatOptional getLeadingPadding( YGFloatOptional getLeadingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const double widthSize) const;
YGFloatOptional getTrailingPadding( YGFloatOptional getTrailingPadding(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const double widthSize) const;
YGFloatOptional getLeadingPaddingAndBorder( YGFloatOptional getLeadingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const double widthSize) const;
YGFloatOptional getTrailingPaddingAndBorder( YGFloatOptional getTrailingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const double widthSize) const;
YGFloatOptional getMarginForAxis( YGFloatOptional getMarginForAxis(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const double widthSize) const;
// Setters // Setters
void setContext(void* context) { context_ = context; } void setContext(const void* context) { context_ = context; }
void setPrintFunc(YGPrintFunc printFunc) { void setPrintFunc(YGPrintFunc printFunc) {
print_.noContext = printFunc; print_.noContext = printFunc;
@@ -303,19 +303,19 @@ public:
void setLayoutComputedFlexBasis(const YGFloatOptional computedFlexBasis); void setLayoutComputedFlexBasis(const YGFloatOptional computedFlexBasis);
void setLayoutComputedFlexBasisGeneration( void setLayoutComputedFlexBasisGeneration(
uint32_t computedFlexBasisGeneration); uint32_t computedFlexBasisGeneration);
void setLayoutMeasuredDimension(float measuredDimension, int index); void setLayoutMeasuredDimension(double measuredDimension, int index);
void setLayoutHadOverflow(bool hadOverflow); void setLayoutHadOverflow(bool hadOverflow);
void setLayoutDimension(float dimension, int index); void setLayoutDimension(double dimension, int index);
void setLayoutDirection(YGDirection direction); void setLayoutDirection(YGDirection direction);
void setLayoutMargin(float margin, int index); void setLayoutMargin(double margin, int index);
void setLayoutBorder(float border, int index); void setLayoutBorder(double border, int index);
void setLayoutPadding(float padding, int index); void setLayoutPadding(double padding, int index);
void setLayoutPosition(float position, int index); void setLayoutPosition(double position, int index);
void setPosition( void setPosition(
const YGDirection direction, const YGDirection direction,
const float mainSize, const double mainSize,
const float crossSize, const double crossSize,
const float ownerWidth); const double ownerWidth);
void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout); void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout);
void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag); void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag);
void markDirtyAndPropogateDownwards(); void markDirtyAndPropogateDownwards();
@@ -337,8 +337,8 @@ public:
void cloneChildrenIfNeeded(void*); void cloneChildrenIfNeeded(void*);
void markDirtyAndPropogate(); void markDirtyAndPropogate();
float resolveFlexGrow() const; double resolveFlexGrow() const;
float resolveFlexShrink() const; double resolveFlexShrink() const;
bool isNodeFlexible(); bool isNodeFlexible();
bool didUseLegacyFlag(); bool didUseLegacyFlag();
bool isLayoutTreeEqualToNode(const YGNode& node) const; bool isLayoutTreeEqualToNode(const YGNode& node) const;

View File

@@ -16,21 +16,21 @@
#endif #endif
#if defined(COMPILING_WITH_CLANG_ON_WINDOWS) #if defined(COMPILING_WITH_CLANG_ON_WINDOWS)
#include <limits> #include <limits>
constexpr float YGUndefined = std::numeric_limits<float>::quiet_NaN(); constexpr double YGUndefined = std::numeric_limits<double>::quiet_NaN();
#else #else
YG_EXTERN_C_BEGIN YG_EXTERN_C_BEGIN
// Not defined in MSVC++ // Not defined in MSVC++
#ifndef NAN #ifndef NAN
static const uint32_t __nan = 0x7fc00000; static const uint64_t __nan = 0x7ff8000000000000;
#define NAN (*(const float*) __nan) #define NAN (*(const double*) __nan)
#endif #endif
#define YGUndefined NAN #define YGUndefined NAN
#endif #endif
typedef struct YGValue { typedef struct YGValue {
float value; double value;
YGUnit unit; YGUnit unit;
} YGValue; } YGValue;
@@ -44,6 +44,7 @@ YG_EXTERN_C_END
#undef COMPILING_WITH_CLANG_ON_WINDOWS #undef COMPILING_WITH_CLANG_ON_WINDOWS
#ifdef __cplusplus #ifdef __cplusplus
YG_EXTERN_CXX_BEGIN
inline bool operator==(const YGValue& lhs, const YGValue& rhs) { inline bool operator==(const YGValue& lhs, const YGValue& rhs) {
if (lhs.unit != rhs.unit) { if (lhs.unit != rhs.unit) {
@@ -75,14 +76,14 @@ namespace yoga {
namespace literals { namespace literals {
inline YGValue operator"" _pt(long double value) { inline YGValue operator"" _pt(long double value) {
return YGValue{static_cast<float>(value), YGUnitPoint}; return YGValue{static_cast<double>(value), YGUnitPoint};
} }
inline YGValue operator"" _pt(unsigned long long value) { inline YGValue operator"" _pt(unsigned long long value) {
return operator"" _pt(static_cast<long double>(value)); return operator"" _pt(static_cast<long double>(value));
} }
inline YGValue operator"" _percent(long double value) { inline YGValue operator"" _percent(long double value) {
return YGValue{static_cast<float>(value), YGUnitPercent}; return YGValue{static_cast<double>(value), YGUnitPercent};
} }
inline YGValue operator"" _percent(unsigned long long value) { inline YGValue operator"" _percent(unsigned long long value) {
return operator"" _percent(static_cast<long double>(value)); return operator"" _percent(static_cast<long double>(value));
@@ -92,4 +93,5 @@ inline YGValue operator"" _percent(unsigned long long value) {
} // namespace yoga } // namespace yoga
} // namespace facebook } // namespace facebook
YG_EXTERN_CXX_END
#endif #endif

View File

@@ -19,8 +19,8 @@ YG_EXTERN_C_BEGIN
void YGNodeCalculateLayoutWithContext( void YGNodeCalculateLayoutWithContext(
YGNodeRef node, YGNodeRef node,
float availableWidth, double availableWidth,
float availableHeight, double availableHeight,
YGDirection ownerDirection, YGDirection ownerDirection,
void* layoutContext); void* layoutContext);
@@ -29,10 +29,6 @@ YG_EXTERN_C_END
namespace facebook { namespace facebook {
namespace yoga { namespace yoga {
inline bool isUndefined(float value) {
return std::isnan(value);
}
inline bool isUndefined(double value) { inline bool isUndefined(double value) {
return std::isnan(value); return std::isnan(value);
} }
@@ -49,13 +45,13 @@ extern const YGValue YGValueAuto;
extern const YGValue YGValueZero; extern const YGValue YGValueZero;
struct YGCachedMeasurement { struct YGCachedMeasurement {
float availableWidth; double availableWidth;
float availableHeight; double availableHeight;
YGMeasureMode widthMeasureMode; YGMeasureMode widthMeasureMode;
YGMeasureMode heightMeasureMode; YGMeasureMode heightMeasureMode;
float computedWidth; double computedWidth;
float computedHeight; double computedHeight;
YGCachedMeasurement() YGCachedMeasurement()
: availableWidth(-1), : availableWidth(-1),
@@ -143,8 +139,8 @@ public:
} // namespace yoga } // namespace yoga
} // namespace facebook } // namespace facebook
static const float kDefaultFlexGrow = 0.0f; static const double kDefaultFlexGrow = 0.0;
static const float kDefaultFlexShrink = 0.0f; static const double kDefaultFlexShrink = 0.0;
static const float kWebDefaultFlexShrink = 1.0f; static const double kWebDefaultFlexShrink = 1.0;
extern bool YGFloatsEqual(const float a, const float b); extern bool YGFloatsEqual(const double a, const double b);

File diff suppressed because it is too large Load Diff

View File

@@ -25,8 +25,8 @@
YG_EXTERN_C_BEGIN YG_EXTERN_C_BEGIN
typedef struct YGSize { typedef struct YGSize {
float width; double width;
float height; double height;
} YGSize; } YGSize;
typedef struct YGConfig* YGConfigRef; typedef struct YGConfig* YGConfigRef;
@@ -36,11 +36,11 @@ typedef const struct YGNode* YGNodeConstRef;
typedef YGSize (*YGMeasureFunc)( typedef YGSize (*YGMeasureFunc)(
YGNodeRef node, YGNodeRef node,
float width, double width,
YGMeasureMode widthMode, YGMeasureMode widthMode,
float height, double height,
YGMeasureMode heightMode); YGMeasureMode heightMode);
typedef float (*YGBaselineFunc)(YGNodeRef node, float width, float height); typedef double (*YGBaselineFunc)(YGNodeRef node, double width, double height);
typedef void (*YGDirtiedFunc)(YGNodeRef node); typedef void (*YGDirtiedFunc)(YGNodeRef node);
typedef void (*YGPrintFunc)(YGNodeRef node); typedef void (*YGPrintFunc)(YGNodeRef node);
typedef void (*YGNodeCleanupFunc)(YGNodeRef node); typedef void (*YGNodeCleanupFunc)(YGNodeRef node);
@@ -93,8 +93,8 @@ WIN_EXPORT bool YGNodeIsReferenceBaseline(YGNodeRef node);
WIN_EXPORT void YGNodeCalculateLayout( WIN_EXPORT void YGNodeCalculateLayout(
YGNodeRef node, YGNodeRef node,
float availableWidth, double availableWidth,
float availableHeight, double availableHeight,
YGDirection ownerDirection); YGDirection ownerDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function // Mark a node as dirty. Only valid for nodes with a custom measure function
@@ -113,27 +113,27 @@ WIN_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants(YGNodeRef node);
WIN_EXPORT void YGNodePrint(YGNodeRef node, YGPrintOptions options); WIN_EXPORT void YGNodePrint(YGNodeRef node, YGPrintOptions options);
WIN_EXPORT bool YGFloatIsUndefined(float value); WIN_EXPORT bool YGFloatIsUndefined(double value);
WIN_EXPORT bool YGNodeCanUseCachedMeasurement( WIN_EXPORT bool YGNodeCanUseCachedMeasurement(
YGMeasureMode widthMode, YGMeasureMode widthMode,
float width, double width,
YGMeasureMode heightMode, YGMeasureMode heightMode,
float height, double height,
YGMeasureMode lastWidthMode, YGMeasureMode lastWidthMode,
float lastWidth, double lastWidth,
YGMeasureMode lastHeightMode, YGMeasureMode lastHeightMode,
float lastHeight, double lastHeight,
float lastComputedWidth, double lastComputedWidth,
float lastComputedHeight, double lastComputedHeight,
float marginRow, double marginRow,
float marginColumn, double marginColumn,
YGConfigRef config); YGConfigRef config);
WIN_EXPORT void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeRef srcNode); WIN_EXPORT void YGNodeCopyStyle(YGNodeRef dstNode, YGNodeRef srcNode);
WIN_EXPORT void* YGNodeGetContext(YGNodeRef node); WIN_EXPORT const void* YGNodeGetContext(YGNodeRef node);
WIN_EXPORT void YGNodeSetContext(YGNodeRef node, void* context); WIN_EXPORT void YGNodeSetContext(YGNodeRef node, const void* context);
void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled); void YGConfigSetPrintTreeFlag(YGConfigRef config, bool enabled);
bool YGNodeHasMeasureFunc(YGNodeRef node); bool YGNodeHasMeasureFunc(YGNodeRef node);
WIN_EXPORT void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc); WIN_EXPORT void YGNodeSetMeasureFunc(YGNodeRef node, YGMeasureFunc measureFunc);
@@ -187,75 +187,75 @@ WIN_EXPORT YGOverflow YGNodeStyleGetOverflow(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetDisplay(YGNodeRef node, YGDisplay display); WIN_EXPORT void YGNodeStyleSetDisplay(YGNodeRef node, YGDisplay display);
WIN_EXPORT YGDisplay YGNodeStyleGetDisplay(YGNodeConstRef node); WIN_EXPORT YGDisplay YGNodeStyleGetDisplay(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlex(YGNodeRef node, float flex); WIN_EXPORT void YGNodeStyleSetFlex(YGNodeRef node, double flex);
WIN_EXPORT float YGNodeStyleGetFlex(YGNodeConstRef node); WIN_EXPORT double YGNodeStyleGetFlex(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexGrow(YGNodeRef node, float flexGrow); WIN_EXPORT void YGNodeStyleSetFlexGrow(YGNodeRef node, double flexGrow);
WIN_EXPORT float YGNodeStyleGetFlexGrow(YGNodeConstRef node); WIN_EXPORT double YGNodeStyleGetFlexGrow(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexShrink(YGNodeRef node, float flexShrink); WIN_EXPORT void YGNodeStyleSetFlexShrink(YGNodeRef node, double flexShrink);
WIN_EXPORT float YGNodeStyleGetFlexShrink(YGNodeConstRef node); WIN_EXPORT double YGNodeStyleGetFlexShrink(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, float flexBasis); WIN_EXPORT void YGNodeStyleSetFlexBasis(YGNodeRef node, double flexBasis);
WIN_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, float flexBasis); WIN_EXPORT void YGNodeStyleSetFlexBasisPercent(YGNodeRef node, double flexBasis);
WIN_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node); WIN_EXPORT void YGNodeStyleSetFlexBasisAuto(YGNodeRef node);
WIN_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetFlexBasis(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetPosition( WIN_EXPORT void YGNodeStyleSetPosition(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float position); double position);
WIN_EXPORT void YGNodeStyleSetPositionPercent( WIN_EXPORT void YGNodeStyleSetPositionPercent(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float position); double position);
WIN_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge); WIN_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin); WIN_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, double margin);
WIN_EXPORT void YGNodeStyleSetMarginPercent( WIN_EXPORT void YGNodeStyleSetMarginPercent(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float margin); double margin);
WIN_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge); WIN_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge);
WIN_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge); WIN_EXPORT YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetPadding( WIN_EXPORT void YGNodeStyleSetPadding(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float padding); double padding);
WIN_EXPORT void YGNodeStyleSetPaddingPercent( WIN_EXPORT void YGNodeStyleSetPaddingPercent(
YGNodeRef node, YGNodeRef node,
YGEdge edge, YGEdge edge,
float padding); double padding);
WIN_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge); WIN_EXPORT YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, float border); WIN_EXPORT void YGNodeStyleSetBorder(YGNodeRef node, YGEdge edge, double border);
WIN_EXPORT float YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge); WIN_EXPORT double YGNodeStyleGetBorder(YGNodeConstRef node, YGEdge edge);
WIN_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, float width); WIN_EXPORT void YGNodeStyleSetWidth(YGNodeRef node, double width);
WIN_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, float width); WIN_EXPORT void YGNodeStyleSetWidthPercent(YGNodeRef node, double width);
WIN_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node); WIN_EXPORT void YGNodeStyleSetWidthAuto(YGNodeRef node);
WIN_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetWidth(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, float height); WIN_EXPORT void YGNodeStyleSetHeight(YGNodeRef node, double height);
WIN_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, float height); WIN_EXPORT void YGNodeStyleSetHeightPercent(YGNodeRef node, double height);
WIN_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node); WIN_EXPORT void YGNodeStyleSetHeightAuto(YGNodeRef node);
WIN_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetHeight(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, float minWidth); WIN_EXPORT void YGNodeStyleSetMinWidth(YGNodeRef node, double minWidth);
WIN_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, float minWidth); WIN_EXPORT void YGNodeStyleSetMinWidthPercent(YGNodeRef node, double minWidth);
WIN_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetMinWidth(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, float minHeight); WIN_EXPORT void YGNodeStyleSetMinHeight(YGNodeRef node, double minHeight);
WIN_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, float minHeight); WIN_EXPORT void YGNodeStyleSetMinHeightPercent(YGNodeRef node, double minHeight);
WIN_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetMinHeight(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, float maxWidth); WIN_EXPORT void YGNodeStyleSetMaxWidth(YGNodeRef node, double maxWidth);
WIN_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, float maxWidth); WIN_EXPORT void YGNodeStyleSetMaxWidthPercent(YGNodeRef node, double maxWidth);
WIN_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetMaxWidth(YGNodeConstRef node);
WIN_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, float maxHeight); WIN_EXPORT void YGNodeStyleSetMaxHeight(YGNodeRef node, double maxHeight);
WIN_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, float maxHeight); WIN_EXPORT void YGNodeStyleSetMaxHeightPercent(YGNodeRef node, double maxHeight);
WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node); WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node);
// Yoga specific properties, not compatible with flexbox specification Aspect // Yoga specific properties, not compatible with flexbox specification Aspect
@@ -273,15 +273,15 @@ WIN_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node);
// - On a node with flex grow/shrink aspect ratio controls the size of the node // - On a node with flex grow/shrink aspect ratio controls the size of the node
// in the cross axis if unset // in the cross axis if unset
// - Aspect ratio takes min/max dimensions into account // - Aspect ratio takes min/max dimensions into account
WIN_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio); WIN_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, double aspectRatio);
WIN_EXPORT float YGNodeStyleGetAspectRatio(YGNodeConstRef node); WIN_EXPORT double YGNodeStyleGetAspectRatio(YGNodeConstRef node);
WIN_EXPORT float YGNodeLayoutGetLeft(YGNodeRef node); WIN_EXPORT double YGNodeLayoutGetLeft(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetTop(YGNodeRef node); WIN_EXPORT double YGNodeLayoutGetTop(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetRight(YGNodeRef node); WIN_EXPORT double YGNodeLayoutGetRight(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetBottom(YGNodeRef node); WIN_EXPORT double YGNodeLayoutGetBottom(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetWidth(YGNodeRef node); WIN_EXPORT double YGNodeLayoutGetWidth(YGNodeRef node);
WIN_EXPORT float YGNodeLayoutGetHeight(YGNodeRef node); WIN_EXPORT double YGNodeLayoutGetHeight(YGNodeRef node);
WIN_EXPORT YGDirection YGNodeLayoutGetDirection(YGNodeRef node); WIN_EXPORT YGDirection YGNodeLayoutGetDirection(YGNodeRef node);
WIN_EXPORT bool YGNodeLayoutGetHadOverflow(YGNodeRef node); WIN_EXPORT bool YGNodeLayoutGetHadOverflow(YGNodeRef node);
bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(YGNodeRef node); bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(YGNodeRef node);
@@ -290,9 +290,9 @@ bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(YGNodeRef node);
// set using point values then the returned value will be the same as // set using point values then the returned value will be the same as
// YGNodeStyleGetXXX. However if they were set using a percentage value then the // YGNodeStyleGetXXX. However if they were set using a percentage value then the
// returned value is the computed value used during layout. // returned value is the computed value used during layout.
WIN_EXPORT float YGNodeLayoutGetMargin(YGNodeRef node, YGEdge edge); WIN_EXPORT double YGNodeLayoutGetMargin(YGNodeRef node, YGEdge edge);
WIN_EXPORT float YGNodeLayoutGetBorder(YGNodeRef node, YGEdge edge); WIN_EXPORT double YGNodeLayoutGetBorder(YGNodeRef node, YGEdge edge);
WIN_EXPORT float YGNodeLayoutGetPadding(YGNodeRef node, YGEdge edge); WIN_EXPORT double YGNodeLayoutGetPadding(YGNodeRef node, YGEdge edge);
WIN_EXPORT void YGConfigSetLogger(YGConfigRef config, YGLogger logger); WIN_EXPORT void YGConfigSetLogger(YGConfigRef config, YGLogger logger);
WIN_EXPORT void YGAssert(bool condition, const char* message); WIN_EXPORT void YGAssert(bool condition, const char* message);
@@ -308,7 +308,7 @@ WIN_EXPORT void YGAssertWithConfig(
// want to avoid rounding - set PointScaleFactor to 0 // want to avoid rounding - set PointScaleFactor to 0
WIN_EXPORT void YGConfigSetPointScaleFactor( WIN_EXPORT void YGConfigSetPointScaleFactor(
YGConfigRef config, YGConfigRef config,
float pixelsInPoint); double pixelsInPoint);
void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour( void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
YGConfigRef config, YGConfigRef config,
bool shouldDiffLayout); bool shouldDiffLayout);
@@ -351,7 +351,7 @@ WIN_EXPORT YGConfigRef YGConfigGetDefault(void);
WIN_EXPORT void YGConfigSetContext(YGConfigRef config, void* context); WIN_EXPORT void YGConfigSetContext(YGConfigRef config, void* context);
WIN_EXPORT void* YGConfigGetContext(YGConfigRef config); WIN_EXPORT void* YGConfigGetContext(YGConfigRef config);
WIN_EXPORT float YGRoundValueToPixelGrid( WIN_EXPORT double YGRoundValueToPixelGrid(
double value, double value,
double pointScaleFactor, double pointScaleFactor,
bool forceCeil, bool forceCeil,
@@ -360,6 +360,7 @@ WIN_EXPORT float YGRoundValueToPixelGrid(
YG_EXTERN_C_END YG_EXTERN_C_END
#ifdef __cplusplus #ifdef __cplusplus
YG_EXTERN_CXX_BEGIN
#include <functional> #include <functional>
#include <vector> #include <vector>
@@ -371,4 +372,5 @@ void YGTraversePreOrder(
void YGNodeSetChildren(YGNodeRef owner, const std::vector<YGNodeRef>& children); void YGNodeSetChildren(YGNodeRef owner, const std::vector<YGNodeRef>& children);
YG_EXTERN_CXX_END
#endif #endif

View File

@@ -127,12 +127,12 @@ struct Event::TypedData<Event::LayoutPassEnd> {
template <> template <>
struct Event::TypedData<Event::MeasureCallbackEnd> { struct Event::TypedData<Event::MeasureCallbackEnd> {
void* layoutContext; void* layoutContext;
float width; double width;
YGMeasureMode widthMeasureMode; YGMeasureMode widthMeasureMode;
float height; double height;
YGMeasureMode heightMeasureMode; YGMeasureMode heightMeasureMode;
float measuredWidth; double measuredWidth;
float measuredHeight; double measuredHeight;
const LayoutPassReason reason; const LayoutPassReason reason;
}; };