YGStyle: mutable accessors return Ref instances

Summary:
@public

Change style property accessors to return `Ref` instances instead of references to `CompactValue`.

This will allow to track assignments to properties later on, e.g. for instrumentation or dynamic property storage.

Reviewed By: SidharthGuglani

Differential Revision: D15078961

fbshipit-source-id: 259f05f7d30f093c04bf333c5bd4fb3601b8e933
This commit is contained in:
David Aurelio
2019-05-01 06:47:30 -07:00
committed by Facebook Github Bot
parent cea862a6bf
commit 0a4f7bd558
3 changed files with 174 additions and 105 deletions

View File

@@ -8,7 +8,7 @@
#include <yoga/YGStyle.h>
#include <yoga/YGValue.h>
#include <initializer_list>
#include <utility>
#define ACCESSOR_TESTS_1(NAME, X) \
style.NAME() = X; \
@@ -30,8 +30,13 @@
#define ACCESSOR_TESTS(...) ACCESSOR_TESTS_N(__VA_ARGS__, 5, 4, 3, 2, 1)
#define INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \
{ \
style.NAME()[IDX] = X; \
ASSERT_EQ(style.NAME()[IDX], X);
ASSERT_EQ(style.NAME()[IDX], X); \
auto asArray = decltype(std::declval<const YGStyle&>().NAME()){X}; \
style.NAME() = asArray; \
ASSERT_EQ(static_cast<decltype(asArray)>(style.NAME()), asArray); \
}
#define INDEX_ACCESSOR_TESTS_2(NAME, IDX, X, Y) \
INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \

View File

@@ -28,12 +28,47 @@
{ *this, &YGStyle::get_##FIELD, &YGStyle::set_##FIELD }
class YGStyle {
template <typename Enum>
using Values =
facebook::yoga::detail::Values<facebook::yoga::enums::count<Enum>()>;
using CompactValue = facebook::yoga::detail::CompactValue;
public:
using Dimensions = facebook::yoga::detail::Values<2>;
using Edges =
facebook::yoga::detail::Values<facebook::yoga::enums::count<YGEdge>()>;
using Dimensions = Values<YGDimension>;
using Edges = Values<YGEdge>;
template <typename T, T YGStyle::*Prop>
struct Ref {
YGStyle& style;
operator T() const { return style.*Prop; }
Ref<T, Prop>& operator=(T value) {
style.*Prop = value;
return *this;
}
};
template <typename Idx, Values<Idx> YGStyle::*Prop>
struct IdxRef {
struct Ref {
YGStyle& style;
Idx idx;
operator CompactValue() const { return (style.*Prop)[idx]; }
operator YGValue() const { return (style.*Prop)[idx]; }
Ref& operator=(CompactValue value) {
(style.*Prop)[idx] = value;
return *this;
}
};
YGStyle& style;
IdxRef<Idx, Prop>& operator=(const Values<Idx>& values) {
style.*Prop = values;
return *this;
}
operator const Values<Idx>&() const { return style.*Prop; }
Ref operator[](Idx idx) { return {style, idx}; }
CompactValue operator[](Idx idx) const { return (style.*Prop)[idx]; }
};
template <typename T>
struct BitfieldRef {
@@ -61,6 +96,37 @@ public:
display_(YGDisplayFlex) {}
~YGStyle() = default;
private:
/* Some platforms don't support enum bitfields,
so please use BITFIELD_ENUM_SIZED(BITS_COUNT) */
YGDirection direction_ BITFIELD_ENUM_SIZED(2);
YGFlexDirection flexDirection_ BITFIELD_ENUM_SIZED(2);
YGJustify justifyContent_ BITFIELD_ENUM_SIZED(3);
YGAlign alignContent_ BITFIELD_ENUM_SIZED(3);
YGAlign alignItems_ BITFIELD_ENUM_SIZED(3);
YGAlign alignSelf_ BITFIELD_ENUM_SIZED(3);
YGPositionType positionType_ BITFIELD_ENUM_SIZED(1);
YGWrap flexWrap_ BITFIELD_ENUM_SIZED(2);
YGOverflow overflow_ BITFIELD_ENUM_SIZED(2);
YGDisplay display_ BITFIELD_ENUM_SIZED(1);
YGFloatOptional flex_ = {};
YGFloatOptional flexGrow_ = {};
YGFloatOptional flexShrink_ = {};
CompactValue flexBasis_ = CompactValue::ofAuto();
Edges margin_ = {};
Edges position_ = {};
Edges padding_ = {};
Edges border_ = {};
Dimensions dimensions_{CompactValue::ofAuto()};
Dimensions minDimensions_ = {};
Dimensions maxDimensions_ = {};
// Yoga specific properties, not compatible with flexbox specification
YGFloatOptional aspectRatio_ = {};
public:
// for library users needing a type
using ValueRepr = std::remove_reference<decltype(margin_[0])>::type;
YGDirection direction() const { return direction_; }
BitfieldRef<YGDirection> direction() { return BITFIELD_REF(direction); }
@@ -98,69 +164,47 @@ public:
BitfieldRef<YGDisplay> display() { return BITFIELD_REF(display); }
YGFloatOptional flex() const { return flex_; }
YGFloatOptional& flex() { return flex_; }
Ref<YGFloatOptional, &YGStyle::flex_> flex() { return {*this}; }
YGFloatOptional flexGrow() const { return flexGrow_; }
YGFloatOptional& flexGrow() { return flexGrow_; }
Ref<YGFloatOptional, &YGStyle::flexGrow_> flexGrow() { return {*this}; }
YGFloatOptional flexShrink() const { return flexShrink_; }
YGFloatOptional& flexShrink() { return flexShrink_; }
Ref<YGFloatOptional, &YGStyle::flexShrink_> flexShrink() { return {*this}; }
CompactValue flexBasis() const { return flexBasis_; }
CompactValue& flexBasis() { return flexBasis_; }
Ref<CompactValue, &YGStyle::flexBasis_> flexBasis() { return {*this}; }
const Edges& margin() const { return margin_; }
Edges& margin() { return margin_; }
IdxRef<YGEdge, &YGStyle::margin_> margin() { return {*this}; }
const Edges& position() const { return position_; }
Edges& position() { return position_; }
IdxRef<YGEdge, &YGStyle::position_> position() { return {*this}; }
const Edges& padding() const { return padding_; }
Edges& padding() { return padding_; }
IdxRef<YGEdge, &YGStyle::padding_> padding() { return {*this}; }
const Edges& border() const { return border_; }
Edges& border() { return border_; }
IdxRef<YGEdge, &YGStyle::border_> border() { return {*this}; }
const Dimensions& dimensions() const { return dimensions_; }
Dimensions& dimensions() { return dimensions_; }
IdxRef<YGDimension, &YGStyle::dimensions_> dimensions() { return {*this}; }
const Dimensions& minDimensions() const { return minDimensions_; }
Dimensions& minDimensions() { return minDimensions_; }
IdxRef<YGDimension, &YGStyle::minDimensions_> minDimensions() {
return {*this};
}
const Dimensions& maxDimensions() const { return maxDimensions_; }
Dimensions& maxDimensions() { return maxDimensions_; }
IdxRef<YGDimension, &YGStyle::maxDimensions_> maxDimensions() {
return {*this};
}
// Yoga specific properties, not compatible with flexbox specification
YGFloatOptional aspectRatio() const { return aspectRatio_; }
YGFloatOptional& aspectRatio() { return aspectRatio_; }
Ref<YGFloatOptional, &YGStyle::aspectRatio_> aspectRatio() { return {*this}; }
private:
/* Some platforms don't support enum bitfields,
so please use BITFIELD_ENUM_SIZED(BITS_COUNT) */
YGDirection direction_ BITFIELD_ENUM_SIZED(2);
YGFlexDirection flexDirection_ BITFIELD_ENUM_SIZED(2);
YGJustify justifyContent_ BITFIELD_ENUM_SIZED(3);
YGAlign alignContent_ BITFIELD_ENUM_SIZED(3);
YGAlign alignItems_ BITFIELD_ENUM_SIZED(3);
YGAlign alignSelf_ BITFIELD_ENUM_SIZED(3);
YGPositionType positionType_ BITFIELD_ENUM_SIZED(1);
YGWrap flexWrap_ BITFIELD_ENUM_SIZED(2);
YGOverflow overflow_ BITFIELD_ENUM_SIZED(2);
YGDisplay display_ BITFIELD_ENUM_SIZED(1);
YGFloatOptional flex_ = {};
YGFloatOptional flexGrow_ = {};
YGFloatOptional flexShrink_ = {};
CompactValue flexBasis_ = CompactValue::ofAuto();
Edges margin_ = {};
Edges position_ = {};
Edges padding_ = {};
Edges border_ = {};
Dimensions dimensions_{CompactValue::ofAuto()};
Dimensions minDimensions_ = {};
Dimensions maxDimensions_ = {};
// Yoga specific properties, not compatible with flexbox specification
YGFloatOptional aspectRatio_ = {};
BITFIELD_ACCESSORS(direction)
BITFIELD_ACCESSORS(flexDirection)
BITFIELD_ACCESSORS(justifyContent)
@@ -171,10 +215,6 @@ private:
BITFIELD_ACCESSORS(flexWrap);
BITFIELD_ACCESSORS(overflow);
BITFIELD_ACCESSORS(display);
public:
// for library users needing a type
using ValueRepr = std::remove_reference<decltype(margin_[0])>::type;
};
bool operator==(const YGStyle& lhs, const YGStyle& rhs);

View File

@@ -558,36 +558,27 @@ void updateStyle(YGNode* node, T value) {
[](YGStyle& s, T x) { (s.*Prop)() = x; });
}
template <typename T, T& (YGStyle::*Prop)()>
void updateStyle(YGNode* node, T value) {
template <typename Ref, typename T>
void updateStyle(YGNode* node, Ref (YGStyle::*prop)(), T value) {
updateStyle(
node,
value,
[](YGStyle& s, T x) { return (s.*Prop)() != x; },
[](YGStyle& s, T x) { (s.*Prop)() = x; });
[prop](YGStyle& s, T x) { return (s.*prop)() != x; },
[prop](YGStyle& s, T x) { (s.*prop)() = x; });
}
template <typename Idx, detail::Values<enums::count<Idx>()>& (YGStyle::*Prop)()>
void updateIndexedStyleProp(YGNode* node, Idx idx, detail::CompactValue value) {
template <typename Ref, typename Idx>
void updateIndexedStyleProp(
YGNode* node,
Ref (YGStyle::*prop)(),
Idx idx,
detail::CompactValue value) {
using detail::CompactValue;
updateStyle(
node,
value,
[idx](YGStyle& s, CompactValue x) { return (s.*Prop)()[idx] != x; },
[idx](YGStyle& s, CompactValue x) { (s.*Prop)()[idx] = x; });
}
template <YGStyle::Edges& (YGStyle::*Prop)()>
void updateEdgeProp(YGNode* node, YGEdge edge, detail::CompactValue value) {
updateIndexedStyleProp<YGEdge, Prop>(node, edge, value);
}
template <YGStyle::Dimensions& (YGStyle::*Prop)()>
void updateDimensionProp(
YGNode* node,
YGDimension dimension,
detail::CompactValue value) {
updateIndexedStyleProp<YGDimension, Prop>(node, dimension, value);
[idx, prop](YGStyle& s, CompactValue x) { return (s.*prop)()[idx] != x; },
[idx, prop](YGStyle& s, CompactValue x) { (s.*prop)()[idx] = x; });
}
} // namespace
@@ -670,9 +661,16 @@ YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
return node->getStyle().display();
}
// MSVC has trouble inferring the return type of pointer to member functions
// with const and non-const overloads, instead of preferring the non-const
// overload like clang and GCC. For the purposes of updateStyle(), we can help
// MSVC by specifying that return type explicitely. In combination with
// decltype, MSVC will prefer the non-const version.
#define MSVC_HINT(PROP) decltype(YGStyle{}.PROP())
// TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
updateStyle<YGFloatOptional, &YGStyle::flex>(node, YGFloatOptional{flex});
updateStyle<MSVC_HINT(flex)>(node, &YGStyle::flex, YGFloatOptional{flex});
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
@@ -684,14 +682,14 @@ float YGNodeStyleGetFlex(const YGNodeConstRef node) {
// TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) {
updateStyle<YGFloatOptional, &YGStyle::flexGrow>(
node, YGFloatOptional{flexGrow});
updateStyle<MSVC_HINT(flexGrow)>(
node, &YGStyle::flexGrow, YGFloatOptional{flexGrow});
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) {
updateStyle<YGFloatOptional, &YGStyle::flexShrink>(
node, YGFloatOptional{flexShrink});
updateStyle<MSVC_HINT(flexShrink)>(
node, &YGStyle::flexShrink, YGFloatOptional{flexShrink});
}
YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
@@ -705,28 +703,30 @@ YGValue YGNodeStyleGetFlexBasis(const YGNodeConstRef node) {
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
updateStyle<detail::CompactValue, &YGStyle::flexBasis>(node, value);
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
}
void YGNodeStyleSetFlexBasisPercent(
const YGNodeRef node,
const float flexBasisPercent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent);
updateStyle<detail::CompactValue, &YGStyle::flexBasis>(node, value);
updateStyle<MSVC_HINT(flexBasis)>(node, &YGStyle::flexBasis, value);
}
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
updateStyle<detail::CompactValue, &YGStyle::flexBasis>(
node, detail::CompactValue::ofAuto());
updateStyle<MSVC_HINT(flexBasis)>(
node, &YGStyle::flexBasis, detail::CompactValue::ofAuto());
}
void YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateEdgeProp<&YGStyle::position>(node, edge, value);
updateIndexedStyleProp<MSVC_HINT(position)>(
node, &YGStyle::position, edge, value);
}
void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateEdgeProp<&YGStyle::position>(node, edge, value);
updateIndexedStyleProp<MSVC_HINT(position)>(
node, &YGStyle::position, edge, value);
}
YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
return node->getStyle().position()[edge];
@@ -734,14 +734,17 @@ YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateEdgeProp<&YGStyle::margin>(node, edge, value);
updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &YGStyle::margin, edge, value);
}
void YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateEdgeProp<&YGStyle::margin>(node, edge, value);
updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &YGStyle::margin, edge, value);
}
void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
updateEdgeProp<&YGStyle::margin>(node, edge, detail::CompactValue::ofAuto());
updateIndexedStyleProp<MSVC_HINT(margin)>(
node, &YGStyle::margin, edge, detail::CompactValue::ofAuto());
}
YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
return node->getStyle().margin()[edge];
@@ -749,11 +752,13 @@ YGValue YGNodeStyleGetMargin(YGNodeConstRef node, YGEdge edge) {
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateEdgeProp<&YGStyle::padding>(node, edge, value);
updateIndexedStyleProp<MSVC_HINT(padding)>(
node, &YGStyle::padding, edge, value);
}
void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateEdgeProp<&YGStyle::padding>(node, edge, value);
updateIndexedStyleProp<MSVC_HINT(padding)>(
node, &YGStyle::padding, edge, value);
}
YGValue YGNodeStyleGetPadding(YGNodeConstRef node, YGEdge edge) {
return node->getStyle().padding()[edge];
@@ -765,7 +770,8 @@ void YGNodeStyleSetBorder(
const YGEdge edge,
const float border) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(border);
updateEdgeProp<&YGStyle::border>(node, edge, value);
updateIndexedStyleProp<MSVC_HINT(border)>(
node, &YGStyle::border, edge, value);
}
float YGNodeStyleGetBorder(const YGNodeConstRef node, const YGEdge edge) {
@@ -789,21 +795,26 @@ float YGNodeStyleGetAspectRatio(const YGNodeConstRef node) {
// TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
updateStyle<YGFloatOptional, &YGStyle::aspectRatio>(
node, YGFloatOptional{aspectRatio});
updateStyle<MSVC_HINT(aspectRatio)>(
node, &YGStyle::aspectRatio, YGFloatOptional{aspectRatio});
}
void YGNodeStyleSetWidth(YGNodeRef node, float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateDimensionProp<&YGStyle::dimensions>(node, YGDimensionWidth, value);
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionWidth, value);
}
void YGNodeStyleSetWidthPercent(YGNodeRef node, float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateDimensionProp<&YGStyle::dimensions>(node, YGDimensionWidth, value);
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionWidth, value);
}
void YGNodeStyleSetWidthAuto(YGNodeRef node) {
updateDimensionProp<&YGStyle::dimensions>(
node, YGDimensionWidth, detail::CompactValue::ofAuto());
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node,
&YGStyle::dimensions,
YGDimensionWidth,
detail::CompactValue::ofAuto());
}
YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
return node->getStyle().dimensions()[YGDimensionWidth];
@@ -811,15 +822,20 @@ YGValue YGNodeStyleGetWidth(YGNodeConstRef node) {
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(points);
updateDimensionProp<&YGStyle::dimensions>(node, YGDimensionHeight, value);
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionHeight, value);
}
void YGNodeStyleSetHeightPercent(YGNodeRef node, float percent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(percent);
updateDimensionProp<&YGStyle::dimensions>(node, YGDimensionHeight, value);
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node, &YGStyle::dimensions, YGDimensionHeight, value);
}
void YGNodeStyleSetHeightAuto(YGNodeRef node) {
updateDimensionProp<&YGStyle::dimensions>(
node, YGDimensionHeight, detail::CompactValue::ofAuto());
updateIndexedStyleProp<MSVC_HINT(dimensions)>(
node,
&YGStyle::dimensions,
YGDimensionHeight,
detail::CompactValue::ofAuto());
}
YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
return node->getStyle().dimensions()[YGDimensionHeight];
@@ -827,11 +843,13 @@ YGValue YGNodeStyleGetHeight(YGNodeConstRef node) {
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minWidth);
updateDimensionProp<&YGStyle::minDimensions>(node, YGDimensionWidth, value);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionWidth, value);
}
void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minWidth);
updateDimensionProp<&YGStyle::minDimensions>(node, YGDimensionWidth, value);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionWidth, value);
}
YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
return node->getStyle().minDimensions()[YGDimensionWidth];
@@ -839,13 +857,15 @@ YGValue YGNodeStyleGetMinWidth(const YGNodeConstRef node) {
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(minHeight);
updateDimensionProp<&YGStyle::minDimensions>(node, YGDimensionHeight, value);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionHeight, value);
}
void YGNodeStyleSetMinHeightPercent(
const YGNodeRef node,
const float minHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(minHeight);
updateDimensionProp<&YGStyle::minDimensions>(node, YGDimensionHeight, value);
updateIndexedStyleProp<MSVC_HINT(minDimensions)>(
node, &YGStyle::minDimensions, YGDimensionHeight, value);
}
YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
return node->getStyle().minDimensions()[YGDimensionHeight];
@@ -853,11 +873,13 @@ YGValue YGNodeStyleGetMinHeight(const YGNodeConstRef node) {
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxWidth);
updateDimensionProp<&YGStyle::maxDimensions>(node, YGDimensionWidth, value);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionWidth, value);
}
void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxWidth);
updateDimensionProp<&YGStyle::maxDimensions>(node, YGDimensionWidth, value);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionWidth, value);
}
YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
return node->getStyle().maxDimensions()[YGDimensionWidth];
@@ -865,13 +887,15 @@ YGValue YGNodeStyleGetMaxWidth(const YGNodeConstRef node) {
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(maxHeight);
updateDimensionProp<&YGStyle::maxDimensions>(node, YGDimensionHeight, value);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionHeight, value);
}
void YGNodeStyleSetMaxHeightPercent(
const YGNodeRef node,
const float maxHeight) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(maxHeight);
updateDimensionProp<&YGStyle::maxDimensions>(node, YGDimensionHeight, value);
updateIndexedStyleProp<MSVC_HINT(maxDimensions)>(
node, &YGStyle::maxDimensions, YGDimensionHeight, value);
}
YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) {
return node->getStyle().maxDimensions()[YGDimensionHeight];