`YGStyle`: wrap all fields into accessors

Summary:
@public

In order to encapsulate property access on `YGStyle`, as a first measure we wrap all fields with accessors.

This will e.g. enable dynamic property storage and instrumentation in the future.

All accessors have a `const` version that allows direct access via `const&`. For mutation, bit fields are wrapped with a custom reference object.

This style allows for the least amount of changes in client code. Property access simply needs appended parens, eg `style.direction` becomes `style.direction`.

Reviewed By: shergin

Differential Revision: D14999096

fbshipit-source-id: fbf29f7ddab520513d4618f5e70094c4f6330b30
This commit is contained in:
David Aurelio 2019-04-23 08:08:51 -07:00 коммит произвёл Facebook Github Bot
Родитель af84193df4
Коммит 54af7fc645
16 изменённых файлов: 589 добавлений и 454 удалений

Просмотреть файл

@ -185,8 +185,8 @@ using namespace facebook::react;
}
// `overflow`
if (oldViewProps.yogaStyle.overflow != newViewProps.yogaStyle.overflow) {
self.clipsToBounds = newViewProps.yogaStyle.overflow != YGOverflowVisible;
if (oldViewProps.yogaStyle.overflow() != newViewProps.yogaStyle.overflow()) {
self.clipsToBounds = newViewProps.yogaStyle.overflow() != YGOverflowVisible;
needsInvalidateLayer = YES;
}

Просмотреть файл

@ -161,7 +161,7 @@ local_ref<JString> getPlatformComponentName(const ShadowView& shadowView) {
std::dynamic_pointer_cast<const ScrollViewProps>(shadowView.props);
if (newViewProps &&
newViewProps->yogaStyle.flexDirection == YGFlexDirectionRow) {
newViewProps->yogaStyle.flexDirection() == YGFlexDirectionRow) {
componentName = make_jstring("AndroidHorizontalScrollView");
} else {
componentName = make_jstring(shadowView.componentName);

Просмотреть файл

@ -16,17 +16,17 @@ namespace react {
static YGStyle yogaStyleFromLayoutConstraints(
const LayoutConstraints &layoutConstraints) {
auto yogaStyle = YGStyle{};
yogaStyle.minDimensions[YGDimensionWidth] =
yogaStyle.minDimensions()[YGDimensionWidth] =
yogaStyleValueFromFloat(layoutConstraints.minimumSize.width);
yogaStyle.minDimensions[YGDimensionHeight] =
yogaStyle.minDimensions()[YGDimensionHeight] =
yogaStyleValueFromFloat(layoutConstraints.minimumSize.height);
yogaStyle.maxDimensions[YGDimensionWidth] =
yogaStyle.maxDimensions()[YGDimensionWidth] =
yogaStyleValueFromFloat(layoutConstraints.maximumSize.width);
yogaStyle.maxDimensions[YGDimensionHeight] =
yogaStyle.maxDimensions()[YGDimensionHeight] =
yogaStyleValueFromFloat(layoutConstraints.maximumSize.height);
yogaStyle.direction =
yogaStyle.direction() =
yogaDirectionFromLayoutDirection(layoutConstraints.layoutDirection);
return yogaStyle;

Просмотреть файл

@ -121,18 +121,20 @@ BorderMetrics ViewProps::resolveBorderMetrics(
bool{layoutMetrics.layoutDirection == LayoutDirection::RightToLeft};
auto borderWidths = CascadedBorderWidths{
/* .left = */ optionalFloatFromYogaValue(yogaStyle.border[YGEdgeLeft]),
/* .top = */ optionalFloatFromYogaValue(yogaStyle.border[YGEdgeTop]),
/* .right = */ optionalFloatFromYogaValue(yogaStyle.border[YGEdgeRight]),
/* .left = */ optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeLeft]),
/* .top = */ optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeTop]),
/* .right = */
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeRight]),
/* .bottom = */
optionalFloatFromYogaValue(yogaStyle.border[YGEdgeBottom]),
/* .start = */ optionalFloatFromYogaValue(yogaStyle.border[YGEdgeStart]),
/* .end = */ optionalFloatFromYogaValue(yogaStyle.border[YGEdgeEnd]),
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeBottom]),
/* .start = */
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeStart]),
/* .end = */ optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeEnd]),
/* .horizontal = */
optionalFloatFromYogaValue(yogaStyle.border[YGEdgeHorizontal]),
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeHorizontal]),
/* .vertical = */
optionalFloatFromYogaValue(yogaStyle.border[YGEdgeVertical]),
/* .all = */ optionalFloatFromYogaValue(yogaStyle.border[YGEdgeAll]),
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeVertical]),
/* .all = */ optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeAll]),
};
return {

Просмотреть файл

@ -23,7 +23,7 @@ bool ViewShadowNode::isLayoutOnly() const {
// Accessibility Props
!viewProps.accessible &&
// Style Props
viewProps.yogaStyle.overflow == YGOverflowVisible &&
viewProps.yogaStyle.overflow() == YGOverflowVisible &&
viewProps.opacity == 1.0 && !viewProps.backgroundColor &&
!viewProps.foregroundColor && !viewProps.shadowColor &&
viewProps.transform == Transform{} && viewProps.zIndex == 0 &&

Просмотреть файл

@ -107,7 +107,7 @@ inline LayoutMetrics layoutMetricsFromYogaNode(YGNode &yogaNode) {
layoutMetrics.borderWidth.bottom +
floatFromYogaFloat(YGNodeLayoutGetPadding(&yogaNode, YGEdgeBottom))};
layoutMetrics.displayType = yogaNode.getStyle().display == YGDisplayNone
layoutMetrics.displayType = yogaNode.getStyle().display() == YGDisplayNone
? DisplayType::None
: DisplayType::Flex;
@ -304,7 +304,7 @@ inline void fromRawValue(const RawValue &value, YGDisplay &result) {
inline void fromRawValue(
const RawValue &value,
decltype(YGStyle{}.margin[0]) /* type is subject to change */ &result) {
decltype(YGStyle{}.margin()[0]) /* type is subject to change */ &result) {
if (value.hasType<Float>()) {
result = yogaStyleValueFromFloat((Float)value);
return;

Просмотреть файл

@ -115,71 +115,77 @@ static inline YGStyle convertRawProp(
const RawProps &rawProps,
const YGStyle &sourceValue) {
auto yogaStyle = YGStyle{};
yogaStyle.direction = convertRawProp(
rawProps, "direction", sourceValue.direction, yogaStyle.direction);
yogaStyle.flexDirection = convertRawProp(
yogaStyle.direction() = convertRawProp(
rawProps, "direction", sourceValue.direction(), yogaStyle.direction());
yogaStyle.flexDirection() = convertRawProp(
rawProps,
"flexDirection",
sourceValue.flexDirection,
yogaStyle.flexDirection);
yogaStyle.justifyContent = convertRawProp(
sourceValue.flexDirection(),
yogaStyle.flexDirection());
yogaStyle.justifyContent() = convertRawProp(
rawProps,
"justifyContent",
sourceValue.justifyContent,
yogaStyle.justifyContent);
yogaStyle.alignContent = convertRawProp(
sourceValue.justifyContent(),
yogaStyle.justifyContent());
yogaStyle.alignContent() = convertRawProp(
rawProps,
"alignContent",
sourceValue.alignContent,
yogaStyle.alignContent);
yogaStyle.alignItems = convertRawProp(
rawProps, "alignItems", sourceValue.alignItems, yogaStyle.alignItems);
yogaStyle.alignSelf = convertRawProp(
rawProps, "alignSelf", sourceValue.alignSelf, yogaStyle.alignSelf);
yogaStyle.positionType = convertRawProp(
rawProps, "position", sourceValue.positionType, yogaStyle.positionType);
yogaStyle.flexWrap = convertRawProp(
rawProps, "flexWrap", sourceValue.flexWrap, yogaStyle.flexWrap);
yogaStyle.overflow = convertRawProp(
rawProps, "overflow", sourceValue.overflow, yogaStyle.overflow);
yogaStyle.display = convertRawProp(
rawProps, "display", sourceValue.display, yogaStyle.display);
yogaStyle.flex =
convertRawProp(rawProps, "flex", sourceValue.flex, yogaStyle.flex);
yogaStyle.flexGrow = convertRawProp(
rawProps, "flexGrow", sourceValue.flexGrow, yogaStyle.flexGrow);
yogaStyle.flexShrink = convertRawProp(
rawProps, "flexShrink", sourceValue.flexShrink, yogaStyle.flexShrink);
yogaStyle.flexBasis = convertRawProp(
rawProps, "flexBasis", sourceValue.flexBasis, yogaStyle.flexBasis);
yogaStyle.margin = convertRawProp(
rawProps, "margin", "", sourceValue.margin, yogaStyle.margin);
yogaStyle.position =
convertRawProp(rawProps, sourceValue.position, yogaStyle.position);
yogaStyle.padding = convertRawProp(
rawProps, "padding", "", sourceValue.padding, yogaStyle.padding);
yogaStyle.border = convertRawProp(
rawProps, "border", "Width", sourceValue.border, yogaStyle.border);
yogaStyle.dimensions = convertRawProp(
sourceValue.alignContent(),
yogaStyle.alignContent());
yogaStyle.alignItems() = convertRawProp(
rawProps, "alignItems", sourceValue.alignItems(), yogaStyle.alignItems());
yogaStyle.alignSelf() = convertRawProp(
rawProps, "alignSelf", sourceValue.alignSelf(), yogaStyle.alignSelf());
yogaStyle.positionType() = convertRawProp(
rawProps,
"position",
sourceValue.positionType(),
yogaStyle.positionType());
yogaStyle.flexWrap() = convertRawProp(
rawProps, "flexWrap", sourceValue.flexWrap(), yogaStyle.flexWrap());
yogaStyle.overflow() = convertRawProp(
rawProps, "overflow", sourceValue.overflow(), yogaStyle.overflow());
yogaStyle.display() = convertRawProp(
rawProps, "display", sourceValue.display(), yogaStyle.display());
yogaStyle.flex() =
convertRawProp(rawProps, "flex", sourceValue.flex(), yogaStyle.flex());
yogaStyle.flexGrow() = convertRawProp(
rawProps, "flexGrow", sourceValue.flexGrow(), yogaStyle.flexGrow());
yogaStyle.flexShrink() = convertRawProp(
rawProps, "flexShrink", sourceValue.flexShrink(), yogaStyle.flexShrink());
yogaStyle.flexBasis() = convertRawProp(
rawProps, "flexBasis", sourceValue.flexBasis(), yogaStyle.flexBasis());
yogaStyle.margin() = convertRawProp(
rawProps, "margin", "", sourceValue.margin(), yogaStyle.margin());
yogaStyle.position() =
convertRawProp(rawProps, sourceValue.position(), yogaStyle.position());
yogaStyle.padding() = convertRawProp(
rawProps, "padding", "", sourceValue.padding(), yogaStyle.padding());
yogaStyle.border() = convertRawProp(
rawProps, "border", "Width", sourceValue.border(), yogaStyle.border());
yogaStyle.dimensions() = convertRawProp(
rawProps,
"width",
"height",
sourceValue.dimensions,
yogaStyle.dimensions);
yogaStyle.minDimensions = convertRawProp(
sourceValue.dimensions(),
yogaStyle.dimensions());
yogaStyle.minDimensions() = convertRawProp(
rawProps,
"minWidth",
"minHeight",
sourceValue.minDimensions,
yogaStyle.minDimensions);
yogaStyle.maxDimensions = convertRawProp(
sourceValue.minDimensions(),
yogaStyle.minDimensions());
yogaStyle.maxDimensions() = convertRawProp(
rawProps,
"maxWidth",
"maxHeight",
sourceValue.maxDimensions,
yogaStyle.maxDimensions);
yogaStyle.aspectRatio = convertRawProp(
rawProps, "aspectRatio", sourceValue.aspectRatio, yogaStyle.aspectRatio);
sourceValue.maxDimensions(),
yogaStyle.maxDimensions());
yogaStyle.aspectRatio() = convertRawProp(
rawProps,
"aspectRatio",
sourceValue.aspectRatio(),
yogaStyle.aspectRatio());
return yogaStyle;
}

Просмотреть файл

@ -135,8 +135,8 @@ void YogaLayoutableShadowNode::setSize(Size size) const {
ensureUnsealed();
auto style = yogaNode_.getStyle();
style.dimensions[YGDimensionWidth] = yogaStyleValueFromFloat(size.width);
style.dimensions[YGDimensionHeight] = yogaStyleValueFromFloat(size.height);
style.dimensions()[YGDimensionWidth] = yogaStyleValueFromFloat(size.width);
style.dimensions()[YGDimensionHeight] = yogaStyleValueFromFloat(size.height);
yogaNode_.setStyle(style);
yogaNode_.setDirty(true);
}
@ -146,7 +146,7 @@ void YogaLayoutableShadowNode::setPositionType(
ensureUnsealed();
auto style = yogaNode_.getStyle();
style.positionType = positionType;
style.positionType() = positionType;
yogaNode_.setStyle(style);
yogaNode_.setDirty(true);
}

Просмотреть файл

@ -31,63 +31,66 @@ YogaStylableProps::YogaStylableProps(
#if RN_DEBUG_STRING_CONVERTIBLE
SharedDebugStringConvertibleList YogaStylableProps::getDebugProps() const {
auto defaultYogaStyle = YGStyle{};
const auto defaultYogaStyle = YGStyle{};
return {
debugStringConvertibleItem(
"direction", yogaStyle.direction, defaultYogaStyle.direction),
"direction", yogaStyle.direction(), defaultYogaStyle.direction()),
debugStringConvertibleItem(
"flexDirection",
yogaStyle.flexDirection,
defaultYogaStyle.flexDirection),
yogaStyle.flexDirection(),
defaultYogaStyle.flexDirection()),
debugStringConvertibleItem(
"justifyContent",
yogaStyle.justifyContent,
defaultYogaStyle.justifyContent),
yogaStyle.justifyContent(),
defaultYogaStyle.justifyContent()),
debugStringConvertibleItem(
"alignContent",
yogaStyle.alignContent,
defaultYogaStyle.alignContent),
yogaStyle.alignContent(),
defaultYogaStyle.alignContent()),
debugStringConvertibleItem(
"alignItems", yogaStyle.alignItems, defaultYogaStyle.alignItems),
"alignItems", yogaStyle.alignItems(), defaultYogaStyle.alignItems()),
debugStringConvertibleItem(
"alignSelf", yogaStyle.alignSelf, defaultYogaStyle.alignSelf),
"alignSelf", yogaStyle.alignSelf(), defaultYogaStyle.alignSelf()),
debugStringConvertibleItem(
"positionType",
yogaStyle.positionType,
defaultYogaStyle.positionType),
yogaStyle.positionType(),
defaultYogaStyle.positionType()),
debugStringConvertibleItem(
"flexWrap", yogaStyle.flexWrap, defaultYogaStyle.flexWrap),
"flexWrap", yogaStyle.flexWrap(), defaultYogaStyle.flexWrap()),
debugStringConvertibleItem(
"overflow", yogaStyle.overflow, defaultYogaStyle.overflow),
"overflow", yogaStyle.overflow(), defaultYogaStyle.overflow()),
debugStringConvertibleItem(
"display", yogaStyle.display, defaultYogaStyle.display),
debugStringConvertibleItem("flex", yogaStyle.flex, defaultYogaStyle.flex),
"display", yogaStyle.display(), defaultYogaStyle.display()),
debugStringConvertibleItem(
"flexGrow", yogaStyle.flexGrow, defaultYogaStyle.flexGrow),
"flex", yogaStyle.flex(), defaultYogaStyle.flex()),
debugStringConvertibleItem(
"flexShrink", yogaStyle.flexShrink, defaultYogaStyle.flexShrink),
"flexGrow", yogaStyle.flexGrow(), defaultYogaStyle.flexGrow()),
debugStringConvertibleItem(
"flexBasis", yogaStyle.flexBasis, defaultYogaStyle.flexBasis),
"flexShrink", yogaStyle.flexShrink(), defaultYogaStyle.flexShrink()),
debugStringConvertibleItem(
"margin", yogaStyle.margin, defaultYogaStyle.margin),
"flexBasis", yogaStyle.flexBasis(), defaultYogaStyle.flexBasis()),
debugStringConvertibleItem(
"position", yogaStyle.position, defaultYogaStyle.position),
"margin", yogaStyle.margin(), defaultYogaStyle.margin()),
debugStringConvertibleItem(
"padding", yogaStyle.padding, defaultYogaStyle.padding),
"position", yogaStyle.position(), defaultYogaStyle.position()),
debugStringConvertibleItem(
"border", yogaStyle.border, defaultYogaStyle.border),
"padding", yogaStyle.padding(), defaultYogaStyle.padding()),
debugStringConvertibleItem(
"dimensions", yogaStyle.dimensions, defaultYogaStyle.dimensions),
"border", yogaStyle.border(), defaultYogaStyle.border()),
debugStringConvertibleItem(
"dimensions", yogaStyle.dimensions(), defaultYogaStyle.dimensions()),
debugStringConvertibleItem(
"minDimensions",
yogaStyle.minDimensions,
defaultYogaStyle.minDimensions),
yogaStyle.minDimensions(),
defaultYogaStyle.minDimensions()),
debugStringConvertibleItem(
"maxDimensions",
yogaStyle.maxDimensions,
defaultYogaStyle.maxDimensions),
yogaStyle.maxDimensions(),
defaultYogaStyle.maxDimensions()),
debugStringConvertibleItem(
"aspectRatio", yogaStyle.aspectRatio, defaultYogaStyle.aspectRatio),
"aspectRatio",
yogaStyle.aspectRatio(),
defaultYogaStyle.aspectRatio()),
};
}
#endif

Просмотреть файл

@ -45,12 +45,12 @@ void fromRawValue(const RawValue &rawValue, std::vector<T> &result) {
result.push_back(itemResult);
}
template <typename T>
template <typename T, typename U = T>
T convertRawProp(
const RawProps &rawProps,
const std::string &name,
const T &sourceValue,
const T &defaultValue = T()) {
const U &defaultValue = U()) {
const auto rawValue = rawProps.at(name);
if (!rawValue) {

Просмотреть файл

@ -53,14 +53,14 @@ YGFloatOptional YGNode::getLeadingPosition(
const float axisSize) const {
if (YGFlexDirectionIsRow(axis)) {
auto leadingPosition = YGComputedEdgeValue(
style_.position, YGEdgeStart, CompactValue::ofUndefined());
style_.position(), YGEdgeStart, CompactValue::ofUndefined());
if (!leadingPosition.isUndefined()) {
return YGResolveValue(leadingPosition, axisSize);
}
}
auto leadingPosition = YGComputedEdgeValue(
style_.position, leading[axis], CompactValue::ofUndefined());
style_.position(), leading[axis], CompactValue::ofUndefined());
return leadingPosition.isUndefined()
? YGFloatOptional{0}
@ -72,14 +72,14 @@ YGFloatOptional YGNode::getTrailingPosition(
const float axisSize) const {
if (YGFlexDirectionIsRow(axis)) {
auto trailingPosition = YGComputedEdgeValue(
style_.position, YGEdgeEnd, CompactValue::ofUndefined());
style_.position(), YGEdgeEnd, CompactValue::ofUndefined());
if (!trailingPosition.isUndefined()) {
return YGResolveValue(trailingPosition, axisSize);
}
}
auto trailingPosition = YGComputedEdgeValue(
style_.position, trailing[axis], CompactValue::ofUndefined());
style_.position(), trailing[axis], CompactValue::ofUndefined());
return trailingPosition.isUndefined()
? YGFloatOptional{0}
@ -89,45 +89,47 @@ YGFloatOptional YGNode::getTrailingPosition(
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) const {
return (YGFlexDirectionIsRow(axis) &&
!YGComputedEdgeValue(
style_.position, YGEdgeStart, CompactValue::ofUndefined())
style_.position(), YGEdgeStart, CompactValue::ofUndefined())
.isUndefined()) ||
!YGComputedEdgeValue(
style_.position, leading[axis], CompactValue::ofUndefined())
style_.position(), leading[axis], CompactValue::ofUndefined())
.isUndefined();
}
bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) const {
return (YGFlexDirectionIsRow(axis) &&
!YGComputedEdgeValue(
style_.position, YGEdgeEnd, CompactValue::ofUndefined())
style_.position(), YGEdgeEnd, CompactValue::ofUndefined())
.isUndefined()) ||
!YGComputedEdgeValue(
style_.position, trailing[axis], CompactValue::ofUndefined())
style_.position(), trailing[axis], CompactValue::ofUndefined())
.isUndefined();
}
YGFloatOptional YGNode::getLeadingMargin(
const YGFlexDirection axis,
const float widthSize) const {
if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeStart].isUndefined()) {
return YGResolveValueMargin(style_.margin[YGEdgeStart], widthSize);
if (YGFlexDirectionIsRow(axis) &&
!style_.margin()[YGEdgeStart].isUndefined()) {
return YGResolveValueMargin(style_.margin()[YGEdgeStart], widthSize);
}
return YGResolveValueMargin(
YGComputedEdgeValue(style_.margin, leading[axis], CompactValue::ofZero()),
YGComputedEdgeValue(
style_.margin(), leading[axis], CompactValue::ofZero()),
widthSize);
}
YGFloatOptional YGNode::getTrailingMargin(
const YGFlexDirection axis,
const float widthSize) const {
if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeEnd].isUndefined()) {
return YGResolveValueMargin(style_.margin[YGEdgeEnd], widthSize);
if (YGFlexDirectionIsRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) {
return YGResolveValueMargin(style_.margin()[YGEdgeEnd], widthSize);
}
return YGResolveValueMargin(
YGComputedEdgeValue(
style_.margin, trailing[axis], CompactValue::ofZero()),
style_.margin(), trailing[axis], CompactValue::ofZero()),
widthSize);
}
@ -299,7 +301,7 @@ void YGNode::setPosition(
const YGDirection directionRespectingRoot =
owner_ != nullptr ? direction : YGDirectionLTR;
const YGFlexDirection mainAxis =
YGResolveFlexDirection(style_.flexDirection, directionRespectingRoot);
YGResolveFlexDirection(style_.flexDirection(), directionRespectingRoot);
const YGFlexDirection crossAxis =
YGFlexDirectionCross(mainAxis, directionRespectingRoot);
@ -325,27 +327,28 @@ void YGNode::setPosition(
}
YGValue YGNode::marginLeadingValue(const YGFlexDirection axis) const {
if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeStart].isUndefined()) {
return style_.margin[YGEdgeStart];
if (YGFlexDirectionIsRow(axis) &&
!style_.margin()[YGEdgeStart].isUndefined()) {
return style_.margin()[YGEdgeStart];
} else {
return style_.margin[leading[axis]];
return style_.margin()[leading[axis]];
}
}
YGValue YGNode::marginTrailingValue(const YGFlexDirection axis) const {
if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeEnd].isUndefined()) {
return style_.margin[YGEdgeEnd];
if (YGFlexDirectionIsRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) {
return style_.margin()[YGEdgeEnd];
} else {
return style_.margin[trailing[axis]];
return style_.margin()[trailing[axis]];
}
}
YGValue YGNode::resolveFlexBasisPtr() const {
YGValue flexBasis = style_.flexBasis;
YGValue flexBasis = style_.flexBasis();
if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) {
return flexBasis;
}
if (!style_.flex.isUndefined() && style_.flex.unwrap() > 0.0f) {
if (!style_.flex().isUndefined() && style_.flex().unwrap() > 0.0f) {
return config_->useWebDefaults ? YGValueAuto : YGValueZero;
}
return YGValueAuto;
@ -353,23 +356,23 @@ YGValue YGNode::resolveFlexBasisPtr() const {
void YGNode::resolveDimension() {
using namespace yoga;
for (int dim = YGDimensionWidth; dim < enums::count<YGDimension>(); dim++) {
if (!getStyle().maxDimensions[dim].isUndefined() &&
YGValueEqual(
getStyle().maxDimensions[dim], style_.minDimensions[dim])) {
resolvedDimensions_[dim] = style_.maxDimensions[dim];
const YGStyle& style = getStyle();
for (auto dim : {YGDimensionWidth, YGDimensionHeight}) {
if (!style.maxDimensions()[dim].isUndefined() &&
YGValueEqual(style.maxDimensions()[dim], style.minDimensions()[dim])) {
resolvedDimensions_[dim] = style.maxDimensions()[dim];
} else {
resolvedDimensions_[dim] = style_.dimensions[dim];
resolvedDimensions_[dim] = style.dimensions()[dim];
}
}
}
YGDirection YGNode::resolveDirection(const YGDirection ownerDirection) {
if (style_.direction == YGDirectionInherit) {
if (style_.direction() == YGDirectionInherit) {
return ownerDirection > YGDirectionInherit ? ownerDirection
: YGDirectionLTR;
} else {
return style_.direction;
return style_.direction();
}
}
@ -401,66 +404,67 @@ void YGNode::markDirtyAndPropogateDownwards() {
});
}
float YGNode::resolveFlexGrow() {
float YGNode::resolveFlexGrow() const {
// Root nodes flexGrow should always be 0
if (owner_ == nullptr) {
return 0.0;
}
if (!style_.flexGrow.isUndefined()) {
return style_.flexGrow.unwrap();
if (!style_.flexGrow().isUndefined()) {
return style_.flexGrow().unwrap();
}
if (!style_.flex.isUndefined() && style_.flex.unwrap() > 0.0f) {
return style_.flex.unwrap();
if (!style_.flex().isUndefined() && style_.flex().unwrap() > 0.0f) {
return style_.flex().unwrap();
}
return kDefaultFlexGrow;
}
float YGNode::resolveFlexShrink() {
float YGNode::resolveFlexShrink() const {
if (owner_ == nullptr) {
return 0.0;
}
if (!style_.flexShrink.isUndefined()) {
return style_.flexShrink.unwrap();
if (!style_.flexShrink().isUndefined()) {
return style_.flexShrink().unwrap();
}
if (!config_->useWebDefaults && !style_.flex.isUndefined() &&
style_.flex.unwrap() < 0.0f) {
return -style_.flex.unwrap();
if (!config_->useWebDefaults && !style_.flex().isUndefined() &&
style_.flex().unwrap() < 0.0f) {
return -style_.flex().unwrap();
}
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
}
bool YGNode::isNodeFlexible() {
return (
(style_.positionType == YGPositionTypeRelative) &&
(style_.positionType() == YGPositionTypeRelative) &&
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
}
float YGNode::getLeadingBorder(const YGFlexDirection axis) const {
YGValue leadingBorder;
if (YGFlexDirectionIsRow(axis) && !style_.border[YGEdgeStart].isUndefined()) {
leadingBorder = style_.border[YGEdgeStart];
if (YGFlexDirectionIsRow(axis) &&
!style_.border()[YGEdgeStart].isUndefined()) {
leadingBorder = style_.border()[YGEdgeStart];
if (leadingBorder.value >= 0) {
return leadingBorder.value;
}
}
leadingBorder =
YGComputedEdgeValue(style_.border, leading[axis], CompactValue::ofZero());
leadingBorder = YGComputedEdgeValue(
style_.border(), leading[axis], CompactValue::ofZero());
return YGFloatMax(leadingBorder.value, 0.0f);
}
float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const {
YGValue trailingBorder;
if (YGFlexDirectionIsRow(flexDirection) &&
!style_.border[YGEdgeEnd].isUndefined()) {
trailingBorder = style_.border[YGEdgeEnd];
!style_.border()[YGEdgeEnd].isUndefined()) {
trailingBorder = style_.border()[YGEdgeEnd];
if (trailingBorder.value >= 0.0f) {
return trailingBorder.value;
}
}
trailingBorder = YGComputedEdgeValue(
style_.border, trailing[flexDirection], CompactValue::ofZero());
style_.border(), trailing[flexDirection], CompactValue::ofZero());
return YGFloatMax(trailingBorder.value, 0.0f);
}
@ -468,16 +472,16 @@ YGFloatOptional YGNode::getLeadingPadding(
const YGFlexDirection axis,
const float widthSize) const {
const YGFloatOptional paddingEdgeStart =
YGResolveValue(style_.padding[YGEdgeStart], widthSize);
YGResolveValue(style_.padding()[YGEdgeStart], widthSize);
if (YGFlexDirectionIsRow(axis) &&
!style_.padding[YGEdgeStart].isUndefined() &&
!style_.padding()[YGEdgeStart].isUndefined() &&
!paddingEdgeStart.isUndefined() && paddingEdgeStart.unwrap() >= 0.0f) {
return paddingEdgeStart;
}
YGFloatOptional resolvedValue = YGResolveValue(
YGComputedEdgeValue(
style_.padding, leading[axis], CompactValue::ofZero()),
style_.padding(), leading[axis], CompactValue::ofZero()),
widthSize);
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
}
@ -486,14 +490,14 @@ YGFloatOptional YGNode::getTrailingPadding(
const YGFlexDirection axis,
const float widthSize) const {
const YGFloatOptional paddingEdgeEnd =
YGResolveValue(style_.padding[YGEdgeEnd], widthSize);
YGResolveValue(style_.padding()[YGEdgeEnd], widthSize);
if (YGFlexDirectionIsRow(axis) && paddingEdgeEnd >= YGFloatOptional{0.0f}) {
return paddingEdgeEnd;
}
YGFloatOptional resolvedValue = YGResolveValue(
YGComputedEdgeValue(
style_.padding, trailing[axis], CompactValue::ofZero()),
style_.padding(), trailing[axis], CompactValue::ofZero()),
widthSize);
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
@ -580,8 +584,8 @@ void YGNode::reset() {
auto config = getConfig();
*this = YGNode{};
if (config->useWebDefaults) {
setStyleFlexDirection(YGFlexDirectionRow);
setStyleAlignContent(YGAlignStretch);
style_.flexDirection() = YGFlexDirectionRow;
style_.alignContent() = YGAlignStretch;
}
setConfig(config);
}

Просмотреть файл

@ -6,6 +6,7 @@
*/
#pragma once
#include <stdio.h>
#include "CompactValue.h"
#include "YGConfig.h"
#include "YGLayout.h"
#include "YGStyle.h"
@ -62,6 +63,8 @@ private:
// DO NOT CHANGE THE VISIBILITY OF THIS METHOD!
YGNode& operator=(YGNode&&) = default;
using CompactValue = facebook::yoga::detail::CompactValue;
public:
YGNode()
: hasNewLayout_{true},
@ -210,14 +213,6 @@ public:
void setNodeType(YGNodeType nodeType) { nodeType_ = nodeType; }
void setStyleFlexDirection(YGFlexDirection direction) {
style_.flexDirection = direction;
}
void setStyleAlignContent(YGAlign alignContent) {
style_.alignContent = alignContent;
}
void setMeasureFunc(YGMeasureFunc measureFunc);
void setMeasureFunc(MeasureWithContextFn);
void setMeasureFunc(std::nullptr_t) {
@ -296,8 +291,8 @@ public:
void cloneChildrenIfNeeded(void*);
void markDirtyAndPropogate();
float resolveFlexGrow();
float resolveFlexShrink();
float resolveFlexGrow() const;
float resolveFlexShrink() const;
bool isNodeFlexible();
bool didUseLegacyFlag();
bool isLayoutTreeEqualToNode(const YGNode& node) const;

Просмотреть файл

@ -132,85 +132,92 @@ void YGNodeToString(
if (options & YGPrintOptionsStyle) {
appendFormatedString(str, "style=\"");
if (node->getStyle().flexDirection != YGNode().getStyle().flexDirection) {
if (node->getStyle().flexDirection() !=
YGNode().getStyle().flexDirection()) {
appendFormatedString(
str,
"flex-direction: %s; ",
YGFlexDirectionToString(node->getStyle().flexDirection));
YGFlexDirectionToString(node->getStyle().flexDirection()));
}
if (node->getStyle().justifyContent != YGNode().getStyle().justifyContent) {
if (node->getStyle().justifyContent() !=
YGNode().getStyle().justifyContent()) {
appendFormatedString(
str,
"justify-content: %s; ",
YGJustifyToString(node->getStyle().justifyContent));
YGJustifyToString(node->getStyle().justifyContent()));
}
if (node->getStyle().alignItems != YGNode().getStyle().alignItems) {
if (node->getStyle().alignItems() != YGNode().getStyle().alignItems()) {
appendFormatedString(
str,
"align-items: %s; ",
YGAlignToString(node->getStyle().alignItems));
YGAlignToString(node->getStyle().alignItems()));
}
if (node->getStyle().alignContent != YGNode().getStyle().alignContent) {
if (node->getStyle().alignContent() != YGNode().getStyle().alignContent()) {
appendFormatedString(
str,
"align-content: %s; ",
YGAlignToString(node->getStyle().alignContent));
YGAlignToString(node->getStyle().alignContent()));
}
if (node->getStyle().alignSelf != YGNode().getStyle().alignSelf) {
if (node->getStyle().alignSelf() != YGNode().getStyle().alignSelf()) {
appendFormatedString(
str, "align-self: %s; ", YGAlignToString(node->getStyle().alignSelf));
str,
"align-self: %s; ",
YGAlignToString(node->getStyle().alignSelf()));
}
appendFloatOptionalIfDefined(str, "flex-grow", node->getStyle().flexGrow);
appendFloatOptionalIfDefined(str, "flex-grow", node->getStyle().flexGrow());
appendFloatOptionalIfDefined(
str, "flex-shrink", node->getStyle().flexShrink);
appendNumberIfNotAuto(str, "flex-basis", node->getStyle().flexBasis);
appendFloatOptionalIfDefined(str, "flex", node->getStyle().flex);
str, "flex-shrink", node->getStyle().flexShrink());
appendNumberIfNotAuto(str, "flex-basis", node->getStyle().flexBasis());
appendFloatOptionalIfDefined(str, "flex", node->getStyle().flex());
if (node->getStyle().flexWrap != YGNode().getStyle().flexWrap) {
if (node->getStyle().flexWrap() != YGNode().getStyle().flexWrap()) {
appendFormatedString(
str, "flex-wrap: %s; ", YGWrapToString(node->getStyle().flexWrap));
str, "flex-wrap: %s; ", YGWrapToString(node->getStyle().flexWrap()));
}
if (node->getStyle().overflow != YGNode().getStyle().overflow) {
if (node->getStyle().overflow() != YGNode().getStyle().overflow()) {
appendFormatedString(
str, "overflow: %s; ", YGOverflowToString(node->getStyle().overflow));
str,
"overflow: %s; ",
YGOverflowToString(node->getStyle().overflow()));
}
if (node->getStyle().display != YGNode().getStyle().display) {
if (node->getStyle().display() != YGNode().getStyle().display()) {
appendFormatedString(
str, "display: %s; ", YGDisplayToString(node->getStyle().display));
str, "display: %s; ", YGDisplayToString(node->getStyle().display()));
}
appendEdges(str, "margin", node->getStyle().margin);
appendEdges(str, "padding", node->getStyle().padding);
appendEdges(str, "border", node->getStyle().border);
appendEdges(str, "margin", node->getStyle().margin());
appendEdges(str, "padding", node->getStyle().padding());
appendEdges(str, "border", node->getStyle().border());
appendNumberIfNotAuto(
str, "width", node->getStyle().dimensions[YGDimensionWidth]);
str, "width", node->getStyle().dimensions()[YGDimensionWidth]);
appendNumberIfNotAuto(
str, "height", node->getStyle().dimensions[YGDimensionHeight]);
str, "height", node->getStyle().dimensions()[YGDimensionHeight]);
appendNumberIfNotAuto(
str, "max-width", node->getStyle().maxDimensions[YGDimensionWidth]);
str, "max-width", node->getStyle().maxDimensions()[YGDimensionWidth]);
appendNumberIfNotAuto(
str, "max-height", node->getStyle().maxDimensions[YGDimensionHeight]);
str, "max-height", node->getStyle().maxDimensions()[YGDimensionHeight]);
appendNumberIfNotAuto(
str, "min-width", node->getStyle().minDimensions[YGDimensionWidth]);
str, "min-width", node->getStyle().minDimensions()[YGDimensionWidth]);
appendNumberIfNotAuto(
str, "min-height", node->getStyle().minDimensions[YGDimensionHeight]);
str, "min-height", node->getStyle().minDimensions()[YGDimensionHeight]);
if (node->getStyle().positionType != YGNode().getStyle().positionType) {
if (node->getStyle().positionType() != YGNode().getStyle().positionType()) {
appendFormatedString(
str,
"position: %s; ",
YGPositionTypeToString(node->getStyle().positionType));
YGPositionTypeToString(node->getStyle().positionType()));
}
appendEdgeIfNotUndefined(
str, "left", node->getStyle().position, YGEdgeLeft);
str, "left", node->getStyle().position(), YGEdgeLeft);
appendEdgeIfNotUndefined(
str, "right", node->getStyle().position, YGEdgeRight);
appendEdgeIfNotUndefined(str, "top", node->getStyle().position, YGEdgeTop);
str, "right", node->getStyle().position(), YGEdgeRight);
appendEdgeIfNotUndefined(
str, "bottom", node->getStyle().position, YGEdgeBottom);
str, "top", node->getStyle().position(), YGEdgeTop);
appendEdgeIfNotUndefined(
str, "bottom", node->getStyle().position(), YGEdgeBottom);
appendFormatedString(str, "\" ");
if (node->hasMeasureFunc()) {

Просмотреть файл

@ -9,43 +9,46 @@
// Yoga specific properties, not compatible with flexbox specification
bool operator==(const YGStyle& lhs, const YGStyle& rhs) {
bool areNonFloatValuesEqual = lhs.direction == rhs.direction &&
lhs.flexDirection == rhs.flexDirection &&
lhs.justifyContent == rhs.justifyContent &&
lhs.alignContent == rhs.alignContent &&
lhs.alignItems == rhs.alignItems && lhs.alignSelf == rhs.alignSelf &&
lhs.positionType == rhs.positionType && lhs.flexWrap == rhs.flexWrap &&
lhs.overflow == rhs.overflow && lhs.display == rhs.display &&
YGValueEqual(lhs.flexBasis, rhs.flexBasis) && lhs.margin == rhs.margin &&
lhs.position == rhs.position && lhs.padding == rhs.padding &&
lhs.border == rhs.border && lhs.dimensions == rhs.dimensions &&
lhs.minDimensions == rhs.minDimensions &&
lhs.maxDimensions == rhs.maxDimensions;
bool areNonFloatValuesEqual = lhs.direction() == rhs.direction() &&
lhs.flexDirection() == rhs.flexDirection() &&
lhs.justifyContent() == rhs.justifyContent() &&
lhs.alignContent() == rhs.alignContent() &&
lhs.alignItems() == rhs.alignItems() &&
lhs.alignSelf() == rhs.alignSelf() &&
lhs.positionType() == rhs.positionType() &&
lhs.flexWrap() == rhs.flexWrap() && lhs.overflow() == rhs.overflow() &&
lhs.display() == rhs.display() &&
YGValueEqual(lhs.flexBasis(), rhs.flexBasis()) &&
lhs.margin() == rhs.margin() && lhs.position() == rhs.position() &&
lhs.padding() == rhs.padding() && lhs.border() == rhs.border() &&
lhs.dimensions() == rhs.dimensions() &&
lhs.minDimensions() == rhs.minDimensions() &&
lhs.maxDimensions() == rhs.maxDimensions();
areNonFloatValuesEqual = areNonFloatValuesEqual &&
lhs.flex.isUndefined() == rhs.flex.isUndefined();
if (areNonFloatValuesEqual && !lhs.flex.isUndefined() &&
!rhs.flex.isUndefined()) {
areNonFloatValuesEqual = areNonFloatValuesEqual && lhs.flex == rhs.flex;
lhs.flex().isUndefined() == rhs.flex().isUndefined();
if (areNonFloatValuesEqual && !lhs.flex().isUndefined() &&
!rhs.flex().isUndefined()) {
areNonFloatValuesEqual = areNonFloatValuesEqual && lhs.flex() == rhs.flex();
}
areNonFloatValuesEqual = areNonFloatValuesEqual &&
lhs.flexGrow.isUndefined() == rhs.flexGrow.isUndefined();
if (areNonFloatValuesEqual && !lhs.flexGrow.isUndefined()) {
lhs.flexGrow().isUndefined() == rhs.flexGrow().isUndefined();
if (areNonFloatValuesEqual && !lhs.flexGrow().isUndefined()) {
areNonFloatValuesEqual =
areNonFloatValuesEqual && lhs.flexGrow == rhs.flexGrow;
areNonFloatValuesEqual && lhs.flexGrow() == rhs.flexGrow();
}
areNonFloatValuesEqual = areNonFloatValuesEqual &&
lhs.flexShrink.isUndefined() == rhs.flexShrink.isUndefined();
if (areNonFloatValuesEqual && !rhs.flexShrink.isUndefined()) {
lhs.flexShrink().isUndefined() == rhs.flexShrink().isUndefined();
if (areNonFloatValuesEqual && !rhs.flexShrink().isUndefined()) {
areNonFloatValuesEqual =
areNonFloatValuesEqual && lhs.flexShrink == rhs.flexShrink;
areNonFloatValuesEqual && lhs.flexShrink() == rhs.flexShrink();
}
if (!(lhs.aspectRatio.isUndefined() && rhs.aspectRatio.isUndefined())) {
if (!(lhs.aspectRatio().isUndefined() && rhs.aspectRatio().isUndefined())) {
areNonFloatValuesEqual =
areNonFloatValuesEqual && lhs.aspectRatio == rhs.aspectRatio;
areNonFloatValuesEqual && lhs.aspectRatio() == rhs.aspectRatio();
}
return areNonFloatValuesEqual;

Просмотреть файл

@ -20,8 +20,14 @@
#define BITFIELD_ENUM_SIZED(num)
#endif
struct YGStyle {
private:
#define BITFIELD_ACCESSORS(FIELD) \
decltype(FIELD##_) get_##FIELD() const { return FIELD##_; } \
void set_##FIELD(decltype(FIELD##_) x) { FIELD##_ = x; }
#define BITFIELD_REF(FIELD) \
{ *this, &YGStyle::get_##FIELD, &YGStyle::set_##FIELD }
class YGStyle {
using CompactValue = facebook::yoga::detail::CompactValue;
public:
@ -29,47 +35,149 @@ public:
using Edges =
facebook::yoga::detail::Values<facebook::yoga::enums::count<YGEdge>()>;
/* 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 = {};
template <typename T>
struct BitfieldRef {
YGStyle& style;
T (YGStyle::*get)() const;
void (YGStyle::*set)(T);
operator T() const { return (style.*get)(); }
BitfieldRef<T>& operator=(T x) {
(style.*set)(x);
return *this;
}
};
YGStyle()
: direction(YGDirectionInherit),
flexDirection(YGFlexDirectionColumn),
justifyContent(YGJustifyFlexStart),
alignContent(YGAlignFlexStart),
alignItems(YGAlignStretch),
alignSelf(YGAlignAuto),
positionType(YGPositionTypeRelative),
flexWrap(YGWrapNoWrap),
overflow(YGOverflowVisible),
display(YGDisplayFlex) {}
: direction_(YGDirectionInherit),
flexDirection_(YGFlexDirectionColumn),
justifyContent_(YGJustifyFlexStart),
alignContent_(YGAlignFlexStart),
alignItems_(YGAlignStretch),
alignSelf_(YGAlignAuto),
positionType_(YGPositionTypeRelative),
flexWrap_(YGWrapNoWrap),
overflow_(YGOverflowVisible),
display_(YGDisplayFlex) {}
~YGStyle() = default;
YGDirection direction() const { return direction_; }
BitfieldRef<YGDirection> direction() { return BITFIELD_REF(direction); }
YGFlexDirection flexDirection() const { return flexDirection_; }
BitfieldRef<YGFlexDirection> flexDirection() {
return BITFIELD_REF(flexDirection);
}
YGJustify justifyContent() const { return justifyContent_; }
BitfieldRef<YGJustify> justifyContent() {
return BITFIELD_REF(justifyContent);
}
YGAlign alignContent() const { return alignContent_; }
BitfieldRef<YGAlign> alignContent() { return BITFIELD_REF(alignContent); }
YGAlign alignItems() const { return alignItems_; }
BitfieldRef<YGAlign> alignItems() { return BITFIELD_REF(alignItems); }
YGAlign alignSelf() const { return alignSelf_; }
BitfieldRef<YGAlign> alignSelf() { return BITFIELD_REF(alignSelf); }
YGPositionType positionType() const { return positionType_; }
BitfieldRef<YGPositionType> positionType() {
return BITFIELD_REF(positionType);
}
YGWrap flexWrap() const { return flexWrap_; }
BitfieldRef<YGWrap> flexWrap() { return BITFIELD_REF(flexWrap); }
YGOverflow overflow() const { return overflow_; }
BitfieldRef<YGOverflow> overflow() { return BITFIELD_REF(overflow); }
YGDisplay display() const { return display_; }
BitfieldRef<YGDisplay> display() { return BITFIELD_REF(display); }
YGFloatOptional flex() const { return flex_; }
YGFloatOptional& flex() { return flex_; }
YGFloatOptional flexGrow() const { return flexGrow_; }
YGFloatOptional& flexGrow() { return flexGrow_; }
YGFloatOptional flexShrink() const { return flexShrink_; }
YGFloatOptional& flexShrink() { return flexShrink_; }
CompactValue flexBasis() const { return flexBasis_; }
CompactValue& flexBasis() { return flexBasis_; }
const Edges& margin() const { return margin_; }
Edges& margin() { return margin_; }
const Edges& position() const { return position_; }
Edges& position() { return position_; }
const Edges& padding() const { return padding_; }
Edges& padding() { return padding_; }
const Edges& border() const { return border_; }
Edges& border() { return border_; }
const Dimensions& dimensions() const { return dimensions_; }
Dimensions& dimensions() { return dimensions_; }
const Dimensions& minDimensions() const { return minDimensions_; }
Dimensions& minDimensions() { return minDimensions_; }
const Dimensions& maxDimensions() const { return maxDimensions_; }
Dimensions& maxDimensions() { return maxDimensions_; }
// Yoga specific properties, not compatible with flexbox specification
YGFloatOptional aspectRatio() const { return aspectRatio_; }
YGFloatOptional& aspectRatio() { return aspectRatio_; }
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)
BITFIELD_ACCESSORS(alignContent);
BITFIELD_ACCESSORS(alignItems);
BITFIELD_ACCESSORS(alignSelf);
BITFIELD_ACCESSORS(positionType);
BITFIELD_ACCESSORS(flexWrap);
BITFIELD_ACCESSORS(overflow);
BITFIELD_ACCESSORS(display);
};
bool operator==(const YGStyle& lhs, const YGStyle& rhs);
inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
return !(lhs == rhs);
}
#undef BITFIELD_ENUM_SIZED
#undef BITFIELD_ACCESSORS
#undef BITFIELD_REF

Просмотреть файл

@ -224,8 +224,8 @@ WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
gNodeInstanceCount++;
if (config->useWebDefaults) {
node->setStyleFlexDirection(YGFlexDirectionRow);
node->setStyleAlignContent(YGAlignStretch);
node->getStyle().flexDirection() = YGFlexDirectionRow;
node->getStyle().alignContent() = YGAlignStretch;
}
node->setConfig(config);
return node;
@ -522,61 +522,69 @@ void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) {
}
}
float YGNodeStyleGetFlexGrow(const YGNodeRef node) {
return node->getStyle().flexGrow.isUndefined()
float YGNodeStyleGetFlexGrow(const YGNodeRef n) {
const YGNode* node = n;
return node->getStyle().flexGrow().isUndefined()
? kDefaultFlexGrow
: node->getStyle().flexGrow.unwrap();
: node->getStyle().flexGrow().unwrap();
}
float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
return node->getStyle().flexShrink.isUndefined()
float YGNodeStyleGetFlexShrink(const YGNodeRef n) {
const YGNode* node = n;
return node->getStyle().flexShrink().isUndefined()
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
: kDefaultFlexShrink)
: node->getStyle().flexShrink.unwrap();
: node->getStyle().flexShrink().unwrap();
}
namespace {
template <typename T, typename NeedsUpdate, typename Update>
void updateNodeProp(
void updateStyle(
YGNode* node,
T value,
NeedsUpdate&& needsUpdate,
Update&& update) {
if (needsUpdate(node, value)) {
update(node, value);
if (needsUpdate(node->getStyle(), value)) {
update(node->getStyle(), value);
node->markDirtyAndPropogate();
}
}
template <typename T, T YGStyle::*Prop>
void updateStyleProp(YGNode* node, T value) {
updateNodeProp(
template <typename T, YGStyle::BitfieldRef<T> (YGStyle::*Prop)()>
void updateStyle(YGNode* node, T value) {
updateStyle(
node,
value,
[](YGNode* n, T x) { return (n->getStyle().*Prop) != x; },
[](YGNode* n, T x) { (n->getStyle().*Prop) = x; });
[](YGStyle& s, T x) { return (s.*Prop)() != x; },
[](YGStyle& s, T x) { (s.*Prop)() = x; });
}
template <typename Idx, detail::Values<enums::count<Idx>()> YGStyle::*Prop>
template <typename T, T& (YGStyle::*Prop)()>
void updateStyle(YGNode* node, T value) {
updateStyle(
node,
value,
[](YGStyle& s, T x) { return (s.*Prop)() != x; },
[](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) {
updateNodeProp(
using detail::CompactValue;
updateStyle(
node,
value,
[idx](YGNode* n, detail::CompactValue x) {
return (n->getStyle().*Prop)[idx] != x;
},
[idx](YGNode* n, detail::CompactValue x) {
(n->getStyle().*Prop)[idx] = x;
});
[idx](YGStyle& s, CompactValue x) { return (s.*Prop)()[idx] != x; },
[idx](YGStyle& s, CompactValue x) { (s.*Prop)()[idx] = x; });
}
template <detail::Values<enums::count<YGEdge>()> YGStyle::*Prop>
template <YGStyle::Edges& (YGStyle::*Prop)()>
void updateEdgeProp(YGNode* node, YGEdge edge, detail::CompactValue value) {
updateIndexedStyleProp<YGEdge, Prop>(node, edge, value);
}
template <detail::Values<enums::count<YGDimension>()> YGStyle::*Prop>
template <YGStyle::Dimensions& (YGStyle::*Prop)()>
void updateDimensionProp(
YGNode* node,
YGDimension dimension,
@ -584,141 +592,127 @@ void updateDimensionProp(
updateIndexedStyleProp<YGDimension, Prop>(node, dimension, value);
}
#define YG_UPDATE_STYLE_PROP_BITFIELD(PROP_NAME, node, value) \
updateNodeProp( \
node, \
value, \
[](YGNode* n, decltype(value) x) { \
return n->getStyle().PROP_NAME != x; \
}, \
[](YGNode* n, decltype(value) x) { n->getStyle().PROP_NAME = x; })
} // namespace
void YGNodeStyleSetDirection(const YGNodeRef node, const YGDirection value) {
YG_UPDATE_STYLE_PROP_BITFIELD(direction, node, value);
updateStyle<YGDirection, &YGStyle::direction>(node, value);
}
YGDirection YGNodeStyleGetDirection(const YGNodeRef node) {
return node->getStyle().direction;
return node->getStyle().direction();
}
void YGNodeStyleSetFlexDirection(
const YGNodeRef node,
const YGFlexDirection flexDirection) {
YG_UPDATE_STYLE_PROP_BITFIELD(flexDirection, node, flexDirection);
updateStyle<YGFlexDirection, &YGStyle::flexDirection>(node, flexDirection);
}
YGFlexDirection YGNodeStyleGetFlexDirection(const YGNodeRef node) {
return node->getStyle().flexDirection;
return node->getStyle().flexDirection();
}
void YGNodeStyleSetJustifyContent(
const YGNodeRef node,
const YGJustify justifyContent) {
YG_UPDATE_STYLE_PROP_BITFIELD(justifyContent, node, justifyContent);
updateStyle<YGJustify, &YGStyle::justifyContent>(node, justifyContent);
}
YGJustify YGNodeStyleGetJustifyContent(const YGNodeRef node) {
return node->getStyle().justifyContent;
return node->getStyle().justifyContent();
}
void YGNodeStyleSetAlignContent(
const YGNodeRef node,
const YGAlign alignContent) {
YG_UPDATE_STYLE_PROP_BITFIELD(alignContent, node, alignContent);
updateStyle<YGAlign, &YGStyle::alignContent>(node, alignContent);
}
YGAlign YGNodeStyleGetAlignContent(const YGNodeRef node) {
return node->getStyle().alignContent;
return node->getStyle().alignContent();
}
void YGNodeStyleSetAlignItems(const YGNodeRef node, const YGAlign alignItems) {
YG_UPDATE_STYLE_PROP_BITFIELD(alignItems, node, alignItems);
updateStyle<YGAlign, &YGStyle::alignItems>(node, alignItems);
}
YGAlign YGNodeStyleGetAlignItems(const YGNodeRef node) {
return node->getStyle().alignItems;
return node->getStyle().alignItems();
}
void YGNodeStyleSetAlignSelf(const YGNodeRef node, const YGAlign alignSelf) {
YG_UPDATE_STYLE_PROP_BITFIELD(alignSelf, node, alignSelf);
updateStyle<YGAlign, &YGStyle::alignSelf>(node, alignSelf);
}
YGAlign YGNodeStyleGetAlignSelf(const YGNodeRef node) {
return node->getStyle().alignSelf;
return node->getStyle().alignSelf();
}
void YGNodeStyleSetPositionType(
const YGNodeRef node,
const YGPositionType positionType) {
YG_UPDATE_STYLE_PROP_BITFIELD(positionType, node, positionType);
updateStyle<YGPositionType, &YGStyle::positionType>(node, positionType);
}
YGPositionType YGNodeStyleGetPositionType(const YGNodeRef node) {
return node->getStyle().positionType;
return node->getStyle().positionType();
}
void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) {
YG_UPDATE_STYLE_PROP_BITFIELD(flexWrap, node, flexWrap);
updateStyle<YGWrap, &YGStyle::flexWrap>(node, flexWrap);
}
YGWrap YGNodeStyleGetFlexWrap(const YGNodeRef node) {
return node->getStyle().flexWrap;
return node->getStyle().flexWrap();
}
void YGNodeStyleSetOverflow(const YGNodeRef node, const YGOverflow overflow) {
YG_UPDATE_STYLE_PROP_BITFIELD(overflow, node, overflow);
updateStyle<YGOverflow, &YGStyle::overflow>(node, overflow);
}
YGOverflow YGNodeStyleGetOverflow(const YGNodeRef node) {
return node->getStyle().overflow;
return node->getStyle().overflow();
}
void YGNodeStyleSetDisplay(const YGNodeRef node, const YGDisplay display) {
YG_UPDATE_STYLE_PROP_BITFIELD(display, node, display);
updateStyle<YGDisplay, &YGStyle::display>(node, display);
}
YGDisplay YGNodeStyleGetDisplay(const YGNodeRef node) {
return node->getStyle().display;
return node->getStyle().display();
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
updateStyleProp<YGFloatOptional, &YGStyle::flex>(node, YGFloatOptional{flex});
updateStyle<YGFloatOptional, &YGStyle::flex>(node, YGFloatOptional{flex});
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
float YGNodeStyleGetFlex(const YGNodeRef node) {
return node->getStyle().flex.isUndefined() ? YGUndefined
: node->getStyle().flex.unwrap();
const auto& style = node->getStyle();
return style.flex().isUndefined() ? YGUndefined : style.flex().unwrap();
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) {
updateStyleProp<YGFloatOptional, &YGStyle::flexGrow>(
updateStyle<YGFloatOptional, &YGStyle::flexGrow>(
node, YGFloatOptional{flexGrow});
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) {
updateStyleProp<YGFloatOptional, &YGStyle::flexShrink>(
updateStyle<YGFloatOptional, &YGStyle::flexShrink>(
node, YGFloatOptional{flexShrink});
}
YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) {
YGValue flexBasis = node->getStyle().flexBasis;
if (flexBasis.unit == YGUnitUndefined || flexBasis.unit == YGUnitAuto) {
// TODO(T26792433): Get rid off the use of YGUndefined at client side
flexBasis.value = YGUndefined;
}
return flexBasis;
return static_cast<const YGNode*>(node)->getStyle().flexBasis();
}
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
updateStyleProp<detail::CompactValue, &YGStyle::flexBasis>(node, value);
updateStyle<detail::CompactValue, &YGStyle::flexBasis>(node, value);
}
void YGNodeStyleSetFlexBasisPercent(
const YGNodeRef node,
const float flexBasisPercent) {
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent);
updateStyleProp<detail::CompactValue, &YGStyle::flexBasis>(node, value);
updateStyle<detail::CompactValue, &YGStyle::flexBasis>(node, value);
}
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
updateStyleProp<detail::CompactValue, &YGStyle::flexBasis>(
updateStyle<detail::CompactValue, &YGStyle::flexBasis>(
node, detail::CompactValue::ofAuto());
}
@ -731,7 +725,7 @@ void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
updateEdgeProp<&YGStyle::position>(node, edge, value);
}
YGValue YGNodeStyleGetPosition(YGNodeRef node, YGEdge edge) {
return node->getStyle().position[edge];
return static_cast<const YGNode*>(node)->getStyle().position()[edge];
}
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float points) {
@ -746,7 +740,7 @@ void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge) {
updateEdgeProp<&YGStyle::margin>(node, edge, detail::CompactValue::ofAuto());
}
YGValue YGNodeStyleGetMargin(YGNodeRef node, YGEdge edge) {
return node->getStyle().margin[edge];
return static_cast<const YGNode*>(node)->getStyle().margin()[edge];
}
void YGNodeStyleSetPadding(YGNodeRef node, YGEdge edge, float points) {
@ -758,7 +752,7 @@ void YGNodeStyleSetPaddingPercent(YGNodeRef node, YGEdge edge, float percent) {
updateEdgeProp<&YGStyle::padding>(node, edge, value);
}
YGValue YGNodeStyleGetPadding(YGNodeRef node, YGEdge edge) {
return node->getStyle().padding[edge];
return static_cast<const YGNode*>(node)->getStyle().padding()[edge];
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
@ -771,14 +765,14 @@ void YGNodeStyleSetBorder(
}
float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
if (node->getStyle().border[edge].isUndefined() ||
node->getStyle().border[edge].isAuto()) {
const auto& style = node->getStyle();
if (style.border()[edge].isUndefined() || style.border()[edge].isAuto()) {
// TODO(T26792433): Rather than returning YGUndefined, change the api to
// return YGFloatOptional.
return YGUndefined;
}
auto border = (YGValue) node->getStyle().border[edge];
auto border = (YGValue) style.border()[edge];
return border.value;
}
@ -786,13 +780,13 @@ float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
// TODO(T26792433): Change the API to accept YGFloatOptional.
float YGNodeStyleGetAspectRatio(const YGNodeRef node) {
const YGFloatOptional op = node->getStyle().aspectRatio;
const YGFloatOptional op = node->getStyle().aspectRatio();
return op.isUndefined() ? YGUndefined : op.unwrap();
}
// TODO(T26792433): Change the API to accept YGFloatOptional.
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
updateStyleProp<YGFloatOptional, &YGStyle::aspectRatio>(
updateStyle<YGFloatOptional, &YGStyle::aspectRatio>(
node, YGFloatOptional{aspectRatio});
}
@ -809,7 +803,9 @@ void YGNodeStyleSetWidthAuto(YGNodeRef node) {
node, YGDimensionWidth, detail::CompactValue::ofAuto());
}
YGValue YGNodeStyleGetWidth(YGNodeRef node) {
return node->getStyle().dimensions[YGDimensionWidth];
return static_cast<const YGNode*>(node)
->getStyle()
.dimensions()[YGDimensionWidth];
}
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
@ -825,7 +821,9 @@ void YGNodeStyleSetHeightAuto(YGNodeRef node) {
node, YGDimensionHeight, detail::CompactValue::ofAuto());
}
YGValue YGNodeStyleGetHeight(YGNodeRef node) {
return node->getStyle().dimensions[YGDimensionHeight];
return static_cast<const YGNode*>(node)
->getStyle()
.dimensions()[YGDimensionHeight];
}
void YGNodeStyleSetMinWidth(const YGNodeRef node, const float minWidth) {
@ -837,7 +835,9 @@ void YGNodeStyleSetMinWidthPercent(const YGNodeRef node, const float minWidth) {
updateDimensionProp<&YGStyle::minDimensions>(node, YGDimensionWidth, value);
}
YGValue YGNodeStyleGetMinWidth(const YGNodeRef node) {
return node->getStyle().minDimensions[YGDimensionWidth];
return static_cast<const YGNode*>(node)
->getStyle()
.minDimensions()[YGDimensionWidth];
};
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
@ -851,7 +851,9 @@ void YGNodeStyleSetMinHeightPercent(
updateDimensionProp<&YGStyle::minDimensions>(node, YGDimensionHeight, value);
}
YGValue YGNodeStyleGetMinHeight(const YGNodeRef node) {
return node->getStyle().minDimensions[YGDimensionHeight];
return static_cast<const YGNode*>(node)
->getStyle()
.minDimensions()[YGDimensionHeight];
};
void YGNodeStyleSetMaxWidth(const YGNodeRef node, const float maxWidth) {
@ -863,7 +865,9 @@ void YGNodeStyleSetMaxWidthPercent(const YGNodeRef node, const float maxWidth) {
updateDimensionProp<&YGStyle::maxDimensions>(node, YGDimensionWidth, value);
}
YGValue YGNodeStyleGetMaxWidth(const YGNodeRef node) {
return node->getStyle().maxDimensions[YGDimensionWidth];
return static_cast<const YGNode*>(node)
->getStyle()
.maxDimensions()[YGDimensionWidth];
};
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
@ -877,7 +881,9 @@ void YGNodeStyleSetMaxHeightPercent(
updateDimensionProp<&YGStyle::maxDimensions>(node, YGDimensionHeight, value);
}
YGValue YGNodeStyleGetMaxHeight(const YGNodeRef node) {
return node->getStyle().maxDimensions[YGDimensionHeight];
return static_cast<const YGNode*>(node)
->getStyle()
.maxDimensions()[YGDimensionHeight];
};
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
@ -983,14 +989,12 @@ static inline float YGNodePaddingAndBorderForAxis(
.unwrap();
}
static inline YGAlign YGNodeAlignItem(
const YGNodeRef node,
const YGNodeRef child) {
const YGAlign align = child->getStyle().alignSelf == YGAlignAuto
? node->getStyle().alignItems
: child->getStyle().alignSelf;
static inline YGAlign YGNodeAlignItem(const YGNode* node, const YGNode* child) {
const YGAlign align = child->getStyle().alignSelf() == YGAlignAuto
? node->getStyle().alignItems()
: child->getStyle().alignSelf();
if (align == YGAlignBaseline &&
YGFlexDirectionIsColumn(node->getStyle().flexDirection)) {
YGFlexDirectionIsColumn(node->getStyle().flexDirection())) {
return YGAlignFlexStart;
}
return align;
@ -1018,7 +1022,7 @@ static float YGBaseline(const YGNodeRef node, void* layoutContext) {
if (child->getLineIndex() > 0) {
break;
}
if (child->getStyle().positionType == YGPositionTypeAbsolute) {
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
continue;
}
if (YGNodeAlignItem(node, child) == YGAlignBaseline ||
@ -1041,17 +1045,17 @@ static float YGBaseline(const YGNodeRef node, void* layoutContext) {
}
static bool YGIsBaselineLayout(const YGNodeRef node) {
if (YGFlexDirectionIsColumn(node->getStyle().flexDirection)) {
if (YGFlexDirectionIsColumn(node->getStyle().flexDirection())) {
return false;
}
if (node->getStyle().alignItems == YGAlignBaseline) {
if (node->getStyle().alignItems() == YGAlignBaseline) {
return true;
}
const uint32_t childCount = YGNodeGetChildCount(node);
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeGetChild(node, i);
if (child->getStyle().positionType == YGPositionTypeRelative &&
child->getStyle().alignSelf == YGAlignBaseline) {
if (child->getStyle().positionType() == YGPositionTypeRelative &&
child->getStyle().alignSelf() == YGAlignBaseline) {
return true;
}
}
@ -1103,14 +1107,14 @@ static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
if (YGFlexDirectionIsColumn(axis)) {
min = YGResolveValue(
node->getStyle().minDimensions[YGDimensionHeight], axisSize);
node->getStyle().minDimensions()[YGDimensionHeight], axisSize);
max = YGResolveValue(
node->getStyle().maxDimensions[YGDimensionHeight], axisSize);
node->getStyle().maxDimensions()[YGDimensionHeight], axisSize);
} else if (YGFlexDirectionIsRow(axis)) {
min = YGResolveValue(
node->getStyle().minDimensions[YGDimensionWidth], axisSize);
node->getStyle().minDimensions()[YGDimensionWidth], axisSize);
max = YGResolveValue(
node->getStyle().maxDimensions[YGDimensionWidth], axisSize);
node->getStyle().maxDimensions()[YGDimensionWidth], axisSize);
}
if (max >= YGFloatOptional{0} && value > max) {
@ -1158,7 +1162,8 @@ static void YGConstrainMaxSizeForMode(
YGMeasureMode* mode,
float* size) {
const YGFloatOptional maxSize =
YGResolveValue(node->getStyle().maxDimensions[dim[axis]], ownerAxisSize) +
YGResolveValue(
node->getStyle().maxDimensions()[dim[axis]], ownerAxisSize) +
YGFloatOptional(node->getMarginForAxis(axis, ownerWidth));
switch (*mode) {
case YGMeasureModeExactly:
@ -1190,7 +1195,7 @@ static void YGNodeComputeFlexBasisForChild(
YGMarkerLayoutData& layoutMarkerData,
void* const layoutContext) {
const YGFlexDirection mainAxis =
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
const float mainAxisSize = isMainAxisRow ? width : height;
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
@ -1225,7 +1230,7 @@ static void YGNodeComputeFlexBasisForChild(
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(
YGResolveValue(
child->getResolvedDimension(YGDimensionWidth), ownerWidth),
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth),
paddingAndBorder));
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
// The height is definite, so use that as the flex basis.
@ -1234,7 +1239,7 @@ static void YGNodeComputeFlexBasisForChild(
child, YGFlexDirectionColumn, ownerWidth));
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(
YGResolveValue(
child->getResolvedDimension(YGDimensionHeight), ownerHeight),
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight),
paddingAndBorder));
} else {
// Compute the flex basis and hypothetical main size (i.e. the clamped flex
@ -1252,7 +1257,7 @@ static void YGNodeComputeFlexBasisForChild(
if (isRowStyleDimDefined) {
childWidth =
YGResolveValue(
child->getResolvedDimension(YGDimensionWidth), ownerWidth)
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth)
.unwrap() +
marginRow;
childWidthMeasureMode = YGMeasureModeExactly;
@ -1260,7 +1265,7 @@ static void YGNodeComputeFlexBasisForChild(
if (isColumnStyleDimDefined) {
childHeight =
YGResolveValue(
child->getResolvedDimension(YGDimensionHeight), ownerHeight)
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight)
.unwrap() +
marginColumn;
childHeightMeasureMode = YGMeasureModeExactly;
@ -1268,32 +1273,32 @@ static void YGNodeComputeFlexBasisForChild(
// The W3C spec doesn't say anything about the 'overflow' property, but all
// major browsers appear to implement the following logic.
if ((!isMainAxisRow && node->getStyle().overflow == YGOverflowScroll) ||
node->getStyle().overflow != YGOverflowScroll) {
if ((!isMainAxisRow && node->getStyle().overflow() == YGOverflowScroll) ||
node->getStyle().overflow() != YGOverflowScroll) {
if (YGFloatIsUndefined(childWidth) && !YGFloatIsUndefined(width)) {
childWidth = width;
childWidthMeasureMode = YGMeasureModeAtMost;
}
}
if ((isMainAxisRow && node->getStyle().overflow == YGOverflowScroll) ||
node->getStyle().overflow != YGOverflowScroll) {
if ((isMainAxisRow && node->getStyle().overflow() == YGOverflowScroll) ||
node->getStyle().overflow() != YGOverflowScroll) {
if (YGFloatIsUndefined(childHeight) && !YGFloatIsUndefined(height)) {
childHeight = height;
childHeightMeasureMode = YGMeasureModeAtMost;
}
}
if (!child->getStyle().aspectRatio.isUndefined()) {
const auto& childStyle = child->getStyle();
if (!childStyle.aspectRatio().isUndefined()) {
if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) {
childHeight = marginColumn +
(childWidth - marginRow) / child->getStyle().aspectRatio.unwrap();
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
childHeightMeasureMode = YGMeasureModeExactly;
} else if (
isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) {
childWidth = marginRow +
(childHeight - marginColumn) *
child->getStyle().aspectRatio.unwrap();
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
childWidthMeasureMode = YGMeasureModeExactly;
}
}
@ -1310,9 +1315,9 @@ static void YGNodeComputeFlexBasisForChild(
childWidthStretch) {
childWidth = width;
childWidthMeasureMode = YGMeasureModeExactly;
if (!child->getStyle().aspectRatio.isUndefined()) {
if (!childStyle.aspectRatio().isUndefined()) {
childHeight =
(childWidth - marginRow) / child->getStyle().aspectRatio.unwrap();
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
childHeightMeasureMode = YGMeasureModeExactly;
}
}
@ -1327,9 +1332,9 @@ static void YGNodeComputeFlexBasisForChild(
childHeight = height;
childHeightMeasureMode = YGMeasureModeExactly;
if (!child->getStyle().aspectRatio.isUndefined()) {
childWidth = (childHeight - marginColumn) *
child->getStyle().aspectRatio.unwrap();
if (!childStyle.aspectRatio().isUndefined()) {
childWidth =
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
childWidthMeasureMode = YGMeasureModeExactly;
}
}
@ -1383,7 +1388,7 @@ static void YGNodeAbsoluteLayoutChild(
YGMarkerLayoutData& layoutMarkerData,
void* const layoutContext) {
const YGFlexDirection mainAxis =
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
@ -1398,7 +1403,7 @@ static void YGNodeAbsoluteLayoutChild(
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow, width)) {
childWidth =
YGResolveValue(child->getResolvedDimension(YGDimensionWidth), width)
YGResolveValue(child->getResolvedDimensions()[YGDimensionWidth], width)
.unwrap() +
marginRow;
} else {
@ -1418,9 +1423,9 @@ static void YGNodeAbsoluteLayoutChild(
}
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn, height)) {
childHeight =
YGResolveValue(child->getResolvedDimension(YGDimensionHeight), height)
.unwrap() +
childHeight = YGResolveValue(
child->getResolvedDimensions()[YGDimensionHeight], height)
.unwrap() +
marginColumn;
} else {
// If the child doesn't have a specified height, compute the height based on
@ -1441,15 +1446,15 @@ static void YGNodeAbsoluteLayoutChild(
// Exactly one dimension needs to be defined for us to be able to do aspect
// ratio calculation. One dimension being the anchor and the other being
// flexible.
const auto& childStyle = child->getStyle();
if (YGFloatIsUndefined(childWidth) ^ YGFloatIsUndefined(childHeight)) {
if (!child->getStyle().aspectRatio.isUndefined()) {
if (!childStyle.aspectRatio().isUndefined()) {
if (YGFloatIsUndefined(childWidth)) {
childWidth = marginRow +
(childHeight - marginColumn) *
child->getStyle().aspectRatio.unwrap();
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
} else if (YGFloatIsUndefined(childHeight)) {
childHeight = marginColumn +
(childWidth - marginRow) / child->getStyle().aspectRatio.unwrap();
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
}
}
}
@ -1521,7 +1526,7 @@ static void YGNodeAbsoluteLayoutChild(
leading[mainAxis]);
} else if (
!child->isLeadingPositionDefined(mainAxis) &&
node->getStyle().justifyContent == YGJustifyCenter) {
node->getStyle().justifyContent() == YGJustifyCenter) {
child->setLayoutPosition(
(node->getLayout().measuredDimensions[dim[mainAxis]] -
child->getLayout().measuredDimensions[dim[mainAxis]]) /
@ -1529,7 +1534,7 @@ static void YGNodeAbsoluteLayoutChild(
leading[mainAxis]);
} else if (
!child->isLeadingPositionDefined(mainAxis) &&
node->getStyle().justifyContent == YGJustifyFlexEnd) {
node->getStyle().justifyContent() == YGJustifyFlexEnd) {
child->setLayoutPosition(
(node->getLayout().measuredDimensions[dim[mainAxis]] -
child->getLayout().measuredDimensions[dim[mainAxis]]),
@ -1559,7 +1564,7 @@ static void YGNodeAbsoluteLayoutChild(
} else if (
!child->isLeadingPositionDefined(crossAxis) &&
((YGNodeAlignItem(node, child) == YGAlignFlexEnd) ^
(node->getStyle().flexWrap == YGWrapWrapReverse))) {
(node->getStyle().flexWrap() == YGWrapWrapReverse))) {
child->setLayoutPosition(
(node->getLayout().measuredDimensions[dim[crossAxis]] -
child->getLayout().measuredDimensions[dim[crossAxis]]),
@ -1782,13 +1787,13 @@ static float YGNodeCalculateAvailableInnerDim(
// We want to make sure our available height does not violate min and max
// constraints
const YGFloatOptional minDimensionOptional =
YGResolveValue(node->getStyle().minDimensions[dimension], ownerDim);
YGResolveValue(node->getStyle().minDimensions()[dimension], ownerDim);
const float minInnerDim = minDimensionOptional.isUndefined()
? 0.0f
: minDimensionOptional.unwrap() - paddingAndBorder;
const YGFloatOptional maxDimensionOptional =
YGResolveValue(node->getStyle().maxDimensions[dimension], ownerDim);
YGResolveValue(node->getStyle().maxDimensions()[dimension], ownerDim);
const float maxInnerDim = maxDimensionOptional.isUndefined()
? FLT_MAX
@ -1839,7 +1844,7 @@ static float YGNodeComputeFlexBasisForChildren(
for (auto child : children) {
child->resolveDimension();
if (child->getStyle().display == YGDisplayNone) {
if (child->getStyle().display() == YGDisplayNone) {
YGZeroOutLayoutRecursivly(child, layoutContext);
child->setHasNewLayout(true);
child->setDirty(false);
@ -1858,7 +1863,7 @@ static float YGNodeComputeFlexBasisForChildren(
childDirection, mainDim, crossDim, availableInnerWidth);
}
if (child->getStyle().positionType == YGPositionTypeAbsolute) {
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
continue;
}
if (child == singleFlexChild) {
@ -1906,15 +1911,15 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
float sizeConsumedOnCurrentLineIncludingMinConstraint = 0;
const YGFlexDirection mainAxis = YGResolveFlexDirection(
node->getStyle().flexDirection, node->resolveDirection(ownerDirection));
const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap;
node->getStyle().flexDirection(), node->resolveDirection(ownerDirection));
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
// Add items to the current line until it's full or we run out of items.
uint32_t endOfLineIndex = startOfLineIndex;
for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) {
const YGNodeRef child = node->getChild(endOfLineIndex);
if (child->getStyle().display == YGDisplayNone ||
child->getStyle().positionType == YGPositionTypeAbsolute) {
if (child->getStyle().display() == YGDisplayNone ||
child->getStyle().positionType() == YGPositionTypeAbsolute) {
continue;
}
child->setLineIndex(lineCount);
@ -1997,7 +2002,7 @@ static float YGDistributeFreeSpaceSecondPass(
float flexGrowFactor = 0;
float deltaFreeSpace = 0;
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap;
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
childFlexBasis = YGNodeBoundAxisWithinMinAndMax(
@ -2067,11 +2072,11 @@ static float YGDistributeFreeSpaceSecondPass(
YGMeasureMode childCrossMeasureMode;
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
if (!currentRelativeChild->getStyle().aspectRatio.isUndefined()) {
childCrossSize = isMainAxisRow ? (childMainSize - marginMain) /
currentRelativeChild->getStyle().aspectRatio.unwrap()
: (childMainSize - marginMain) *
currentRelativeChild->getStyle().aspectRatio.unwrap();
const auto& childStyle = currentRelativeChild->getStyle();
if (!childStyle.aspectRatio().isUndefined()) {
childCrossSize = isMainAxisRow
? (childMainSize - marginMain) / childStyle.aspectRatio().unwrap()
: (childMainSize - marginMain) * childStyle.aspectRatio().unwrap();
childCrossMeasureMode = YGMeasureModeExactly;
childCrossSize += marginCross;
@ -2335,7 +2340,7 @@ static void YGJustifyMainAxis(
const float availableInnerWidth,
const bool performLayout,
void* const layoutContext) {
const YGStyle& style = node->getStyle();
const auto& style = node->getStyle();
const float leadingPaddingAndBorderMain =
node->getLeadingPaddingAndBorder(mainAxis, ownerWidth).unwrap();
const float trailingPaddingAndBorderMain =
@ -2344,8 +2349,8 @@ static void YGJustifyMainAxis(
// remainingFreeSpace is 0 when min main dimension is not given
if (measureModeMainDim == YGMeasureModeAtMost &&
collectedFlexItemsValues.remainingFreeSpace > 0) {
if (!style.minDimensions[dim[mainAxis]].isUndefined() &&
!YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize)
if (!style.minDimensions()[dim[mainAxis]].isUndefined() &&
!YGResolveValue(style.minDimensions()[dim[mainAxis]], mainAxisownerSize)
.isUndefined()) {
// This condition makes sure that if the size of main dimension(after
// considering child nodes main dim, leading and trailing padding etc)
@ -2355,7 +2360,8 @@ static void YGJustifyMainAxis(
// `minAvailableMainDim` denotes minimum available space in which child
// can be laid out, it will exclude space consumed by padding and border.
const float minAvailableMainDim =
YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize)
YGResolveValue(
style.minDimensions()[dim[mainAxis]], mainAxisownerSize)
.unwrap() -
leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
const float occupiedSpaceByChildNodes =
@ -2372,7 +2378,7 @@ static void YGJustifyMainAxis(
i < collectedFlexItemsValues.endOfLineIndex;
i++) {
const YGNodeRef child = node->getChild(i);
if (child->getStyle().positionType == YGPositionTypeRelative) {
if (child->getStyle().positionType() == YGPositionTypeRelative) {
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
numberOfAutoMarginsOnCurrentLine++;
}
@ -2387,7 +2393,7 @@ static void YGJustifyMainAxis(
// each two elements.
float leadingMainDim = 0;
float betweenMainDim = 0;
const YGJustify justifyContent = node->getStyle().justifyContent;
const YGJustify justifyContent = node->getStyle().justifyContent();
if (numberOfAutoMarginsOnCurrentLine == 0) {
switch (justifyContent) {
@ -2436,10 +2442,10 @@ static void YGJustifyMainAxis(
const YGNodeRef child = node->getChild(i);
const YGStyle& childStyle = child->getStyle();
const YGLayout childLayout = child->getLayout();
if (childStyle.display == YGDisplayNone) {
if (childStyle.display() == YGDisplayNone) {
continue;
}
if (childStyle.positionType == YGPositionTypeAbsolute &&
if (childStyle.positionType() == YGPositionTypeAbsolute &&
child->isLeadingPositionDefined(mainAxis)) {
if (performLayout) {
// In case the child is position absolute and has left/top being
@ -2456,7 +2462,7 @@ static void YGJustifyMainAxis(
// Now that we placed the element, we need to update the variables.
// We need to do that only for relative elements. Absolute elements do not
// take part in that phase.
if (childStyle.positionType == YGPositionTypeRelative) {
if (childStyle.positionType() == YGPositionTypeRelative) {
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
collectedFlexItemsValues.mainDim +=
collectedFlexItemsValues.remainingFreeSpace /
@ -2720,10 +2726,10 @@ static void YGNodelayoutImpl(
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
const YGFlexDirection mainAxis =
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap;
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
@ -2752,22 +2758,22 @@ static void YGNodelayoutImpl(
const float minInnerWidth =
YGResolveValue(
node->getStyle().minDimensions[YGDimensionWidth], ownerWidth)
node->getStyle().minDimensions()[YGDimensionWidth], ownerWidth)
.unwrap() -
paddingAndBorderAxisRow;
const float maxInnerWidth =
YGResolveValue(
node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)
node->getStyle().maxDimensions()[YGDimensionWidth], ownerWidth)
.unwrap() -
paddingAndBorderAxisRow;
const float minInnerHeight =
YGResolveValue(
node->getStyle().minDimensions[YGDimensionHeight], ownerHeight)
node->getStyle().minDimensions()[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn;
const float maxInnerHeight =
YGResolveValue(
node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight)
node->getStyle().maxDimensions()[YGDimensionHeight], ownerHeight)
.unwrap() -
paddingAndBorderAxisColumn;
@ -2971,10 +2977,10 @@ static void YGNodelayoutImpl(
if (performLayout) {
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
const YGNodeRef child = node->getChild(i);
if (child->getStyle().display == YGDisplayNone) {
if (child->getStyle().display() == YGDisplayNone) {
continue;
}
if (child->getStyle().positionType == YGPositionTypeAbsolute) {
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
// If the child is absolutely positioned and has a
// top/left/bottom/right set, override all the previously computed
// positions to set it correctly.
@ -3019,14 +3025,13 @@ static void YGNodelayoutImpl(
child, crossAxis, availableInnerCrossDim)) {
float childMainSize =
child->getLayout().measuredDimensions[dim[mainAxis]];
float childCrossSize =
!child->getStyle().aspectRatio.isUndefined()
const auto& childStyle = child->getStyle();
float childCrossSize = !childStyle.aspectRatio().isUndefined()
? child->getMarginForAxis(crossAxis, availableInnerWidth)
.unwrap() +
(isMainAxisRow ? childMainSize /
child->getStyle().aspectRatio.unwrap()
: childMainSize *
child->getStyle().aspectRatio.unwrap())
(isMainAxisRow
? childMainSize / childStyle.aspectRatio().unwrap()
: childMainSize * childStyle.aspectRatio().unwrap())
: collectedFlexItemsValues.crossDim;
childMainSize +=
@ -3055,7 +3060,7 @@ static void YGNodelayoutImpl(
const float childHeight =
!isMainAxisRow ? childMainSize : childCrossSize;
auto alignContent = node->getStyle().alignContent;
auto alignContent = node->getStyle().alignContent();
auto crossAxisDoesNotGrow =
alignContent != YGAlignStretch && isNodeFlexWrap;
const YGMeasureMode childWidthMeasureMode =
@ -3127,7 +3132,7 @@ static void YGNodelayoutImpl(
if (!YGFloatIsUndefined(availableInnerCrossDim)) {
const float remainingAlignContentDim =
availableInnerCrossDim - totalLineCrossDim;
switch (node->getStyle().alignContent) {
switch (node->getStyle().alignContent()) {
case YGAlignFlexEnd:
currentLead += remainingAlignContentDim;
break;
@ -3171,10 +3176,10 @@ static void YGNodelayoutImpl(
float maxDescentForCurrentLine = 0;
for (ii = startIndex; ii < childCount; ii++) {
const YGNodeRef child = node->getChild(ii);
if (child->getStyle().display == YGDisplayNone) {
if (child->getStyle().display() == YGDisplayNone) {
continue;
}
if (child->getStyle().positionType == YGPositionTypeRelative) {
if (child->getStyle().positionType() == YGPositionTypeRelative) {
if (child->getLineIndex() != i) {
break;
}
@ -3213,10 +3218,10 @@ static void YGNodelayoutImpl(
if (performLayout) {
for (ii = startIndex; ii < endIndex; ii++) {
const YGNodeRef child = node->getChild(ii);
if (child->getStyle().display == YGDisplayNone) {
if (child->getStyle().display() == YGDisplayNone) {
continue;
}
if (child->getStyle().positionType == YGPositionTypeRelative) {
if (child->getStyle().positionType() == YGPositionTypeRelative) {
switch (YGNodeAlignItem(node, child)) {
case YGAlignFlexStart: {
child->setLayoutPosition(
@ -3342,7 +3347,7 @@ static void YGNodelayoutImpl(
// If the user didn't specify a width or height for the node, set the
// dimensions based on the children.
if (measureModeMainDim == YGMeasureModeUndefined ||
(node->getStyle().overflow != YGOverflowScroll &&
(node->getStyle().overflow() != YGOverflowScroll &&
measureModeMainDim == YGMeasureModeAtMost)) {
// Clamp the size to the min/max size, if specified, and make sure it
// doesn't go below the padding and border amount.
@ -3353,7 +3358,7 @@ static void YGNodelayoutImpl(
} else if (
measureModeMainDim == YGMeasureModeAtMost &&
node->getStyle().overflow == YGOverflowScroll) {
node->getStyle().overflow() == YGOverflowScroll) {
node->setLayoutMeasuredDimension(
YGFloatMax(
YGFloatMin(
@ -3369,7 +3374,7 @@ static void YGNodelayoutImpl(
}
if (measureModeCrossDim == YGMeasureModeUndefined ||
(node->getStyle().overflow != YGOverflowScroll &&
(node->getStyle().overflow() != YGOverflowScroll &&
measureModeCrossDim == YGMeasureModeAtMost)) {
// Clamp the size to the min/max size, if specified, and make sure it
// doesn't go below the padding and border amount.
@ -3384,7 +3389,7 @@ static void YGNodelayoutImpl(
} else if (
measureModeCrossDim == YGMeasureModeAtMost &&
node->getStyle().overflow == YGOverflowScroll) {
node->getStyle().overflow() == YGOverflowScroll) {
node->setLayoutMeasuredDimension(
YGFloatMax(
YGFloatMin(
@ -3402,10 +3407,10 @@ static void YGNodelayoutImpl(
// As we only wrapped in normal direction yet, we need to reverse the
// positions on wrap-reverse.
if (performLayout && node->getStyle().flexWrap == YGWrapWrapReverse) {
if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) {
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = YGNodeGetChild(node, i);
if (child->getStyle().positionType == YGPositionTypeRelative) {
if (child->getStyle().positionType() == YGPositionTypeRelative) {
child->setLayoutPosition(
node->getLayout().measuredDimensions[dim[crossAxis]] -
child->getLayout().position[pos[crossAxis]] -
@ -3418,7 +3423,7 @@ static void YGNodelayoutImpl(
if (performLayout) {
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
for (auto child : node->getChildren()) {
if (child->getStyle().positionType != YGPositionTypeAbsolute) {
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
continue;
}
YGNodeAbsoluteLayoutChild(
@ -3443,7 +3448,7 @@ static void YGNodelayoutImpl(
if (needsMainTrailingPos || needsCrossTrailingPos) {
for (uint32_t i = 0; i < childCount; i++) {
const YGNodeRef child = node->getChild(i);
if (child->getStyle().display == YGDisplayNone) {
if (child->getStyle().display() == YGDisplayNone) {
continue;
}
if (needsMainTrailingPos) {
@ -4014,10 +4019,11 @@ void YGNodeCalculateLayoutWithContext(
.unwrap();
widthMeasureMode = YGMeasureModeExactly;
} else if (!YGResolveValue(
node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)
node->getStyle().maxDimensions()[YGDimensionWidth],
ownerWidth)
.isUndefined()) {
width = YGResolveValue(
node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)
node->getStyle().maxDimensions()[YGDimensionWidth], ownerWidth)
.unwrap();
widthMeasureMode = YGMeasureModeAtMost;
} else {
@ -4036,12 +4042,13 @@ void YGNodeCalculateLayoutWithContext(
.unwrap();
heightMeasureMode = YGMeasureModeExactly;
} else if (!YGResolveValue(
node->getStyle().maxDimensions[YGDimensionHeight],
node->getStyle().maxDimensions()[YGDimensionHeight],
ownerHeight)
.isUndefined()) {
height = YGResolveValue(
node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight)
.unwrap();
height =
YGResolveValue(
node->getStyle().maxDimensions()[YGDimensionHeight], ownerHeight)
.unwrap();
heightMeasureMode = YGMeasureModeAtMost;
} else {
height = ownerHeight;