Switch storage in YGStyle to CompactValue

Summary:
@public

Switches the storage in `facebook::yoga::detail::Values` from `YGValue` to `facebook::yoga::detail::CompactValue`.
This cuts heap size for arrays of values in half.

Reviewed By: SidharthGuglani

Differential Revision: D13465586

fbshipit-source-id: 49a4d6d29a73bdd44843b1f3c57bf746050c94d6
This commit is contained in:
David Aurelio 2018-12-18 08:11:24 -08:00 committed by Facebook Github Bot
parent 375311091c
commit ac94e54f5a
8 changed files with 205 additions and 193 deletions

View File

@ -1084,6 +1084,10 @@
AC8360D121B025BC00FC46B9 /* YGConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CE2080020772F7C009A43B3 /* YGConfig.cpp */; }; AC8360D121B025BC00FC46B9 /* YGConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CE2080020772F7C009A43B3 /* YGConfig.cpp */; };
AC8360D221B025EF00FC46B9 /* YGConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CE2080120772F7C009A43B3 /* YGConfig.h */; }; AC8360D221B025EF00FC46B9 /* YGConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CE2080120772F7C009A43B3 /* YGConfig.h */; };
AC8360D321B0263000FC46B9 /* YGMarker.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = AC8360CC21B0256A00FC46B9 /* YGMarker.h */; }; AC8360D321B0263000FC46B9 /* YGMarker.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = AC8360CC21B0256A00FC46B9 /* YGMarker.h */; };
AC90463E21C91CC2005B24B3 /* CompactValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC90463D21C91CC2005B24B3 /* CompactValue.h */; };
AC90463F21C91D02005B24B3 /* CompactValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC90463D21C91CC2005B24B3 /* CompactValue.h */; };
AC90464021C91D14005B24B3 /* CompactValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC90463D21C91CC2005B24B3 /* CompactValue.h */; };
AC90464121C91DB8005B24B3 /* YGConfig.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 5CE2080120772F7C009A43B3 /* YGConfig.h */; };
B233E6EA1D2D845D00BC68BA /* RCTI18nManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B233E6E91D2D845D00BC68BA /* RCTI18nManager.m */; }; B233E6EA1D2D845D00BC68BA /* RCTI18nManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B233E6E91D2D845D00BC68BA /* RCTI18nManager.m */; };
B95154321D1B34B200FE7B80 /* RCTActivityIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = B95154311D1B34B200FE7B80 /* RCTActivityIndicatorView.m */; }; B95154321D1B34B200FE7B80 /* RCTActivityIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = B95154311D1B34B200FE7B80 /* RCTActivityIndicatorView.m */; };
BA0501AD2109DCF200A6BBC4 /* ReactMarker.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 13DA8A2F2097A90A00276ED4 /* ReactMarker.h */; }; BA0501AD2109DCF200A6BBC4 /* ReactMarker.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 13DA8A2F2097A90A00276ED4 /* ReactMarker.h */; };
@ -1700,6 +1704,7 @@
dstPath = include/yoga; dstPath = include/yoga;
dstSubfolderSpec = 16; dstSubfolderSpec = 16;
files = ( files = (
AC90464121C91DB8005B24B3 /* YGConfig.h in Copy Headers */,
AC6B69E621B146A500B2B68A /* YGValue.h in Copy Headers */, AC6B69E621B146A500B2B68A /* YGValue.h in Copy Headers */,
AC8360D321B0263000FC46B9 /* YGMarker.h in Copy Headers */, AC8360D321B0263000FC46B9 /* YGMarker.h in Copy Headers */,
3DE4F8681DF85D8E00B9E5A0 /* YGEnums.h in Copy Headers */, 3DE4F8681DF85D8E00B9E5A0 /* YGEnums.h in Copy Headers */,
@ -2102,7 +2107,6 @@
53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGEnums.cpp; sourceTree = "<group>"; }; 53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGEnums.cpp; sourceTree = "<group>"; };
53CBF1871FB4FE80002CBB31 /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Yoga.cpp; sourceTree = "<group>"; }; 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Yoga.cpp; sourceTree = "<group>"; };
53D123831FBF1D49001B8A10 /* libyoga.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libyoga.a; path = "../../../../../../../../../Library/Developer/Xcode/DerivedData/yoga-hdfifpwsinitsibujacpiefkjfdy/Build/Products/Debug/libyoga.a"; sourceTree = "<group>"; }; 53D123831FBF1D49001B8A10 /* libyoga.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libyoga.a; path = "../../../../../../../../../Library/Developer/Xcode/DerivedData/yoga-hdfifpwsinitsibujacpiefkjfdy/Build/Products/Debug/libyoga.a"; sourceTree = "<group>"; };
53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGFloatOptional.cpp; sourceTree = "<group>"; };
53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGFloatOptional.h; sourceTree = "<group>"; }; 53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGFloatOptional.h; sourceTree = "<group>"; };
53EC85DE1FDEC75A0051B2B5 /* YGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGNode.h; sourceTree = "<group>"; }; 53EC85DE1FDEC75A0051B2B5 /* YGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGNode.h; sourceTree = "<group>"; };
53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNode.cpp; sourceTree = "<group>"; }; 53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNode.cpp; sourceTree = "<group>"; };
@ -2227,6 +2231,7 @@
AC70D2E81DE489E4002E6351 /* RCTJavaScriptLoader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTJavaScriptLoader.mm; sourceTree = "<group>"; }; AC70D2E81DE489E4002E6351 /* RCTJavaScriptLoader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTJavaScriptLoader.mm; sourceTree = "<group>"; };
AC70D2EB1DE48A22002E6351 /* JSBundleType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBundleType.cpp; sourceTree = "<group>"; }; AC70D2EB1DE48A22002E6351 /* JSBundleType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBundleType.cpp; sourceTree = "<group>"; };
AC8360CC21B0256A00FC46B9 /* YGMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGMarker.h; sourceTree = "<group>"; }; AC8360CC21B0256A00FC46B9 /* YGMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGMarker.h; sourceTree = "<group>"; };
AC90463D21C91CC2005B24B3 /* CompactValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompactValue.h; sourceTree = "<group>"; };
ACDD3FDA1BC7430D00E7DE33 /* RCTBorderStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTBorderStyle.h; sourceTree = "<group>"; }; ACDD3FDA1BC7430D00E7DE33 /* RCTBorderStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTBorderStyle.h; sourceTree = "<group>"; };
B233E6E81D2D843200BC68BA /* RCTI18nManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RCTI18nManager.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; B233E6E81D2D843200BC68BA /* RCTI18nManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RCTI18nManager.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
B233E6E91D2D845D00BC68BA /* RCTI18nManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTI18nManager.m; sourceTree = "<group>"; }; B233E6E91D2D845D00BC68BA /* RCTI18nManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTI18nManager.m; sourceTree = "<group>"; };
@ -2349,12 +2354,12 @@
130A77021DF767AF001F9587 /* yoga */ = { 130A77021DF767AF001F9587 /* yoga */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
AC90463D21C91CC2005B24B3 /* CompactValue.h */,
AC6B69E121B1467C00B2B68A /* YGValue.cpp */, AC6B69E121B1467C00B2B68A /* YGValue.cpp */,
AC6B69E221B1467C00B2B68A /* YGValue.h */, AC6B69E221B1467C00B2B68A /* YGValue.h */,
AC8360CC21B0256A00FC46B9 /* YGMarker.h */, AC8360CC21B0256A00FC46B9 /* YGMarker.h */,
5CE2080020772F7C009A43B3 /* YGConfig.cpp */, 5CE2080020772F7C009A43B3 /* YGConfig.cpp */,
5CE2080120772F7C009A43B3 /* YGConfig.h */, 5CE2080120772F7C009A43B3 /* YGConfig.h */,
53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */,
53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */, 53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */,
5343895E203905B6008E0CB3 /* YGLayout.cpp */, 5343895E203905B6008E0CB3 /* YGLayout.cpp */,
5343895F203905B6008E0CB3 /* YGLayout.h */, 5343895F203905B6008E0CB3 /* YGLayout.h */,
@ -3278,6 +3283,7 @@
isa = PBXHeadersBuildPhase; isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
AC90463F21C91D02005B24B3 /* CompactValue.h in Headers */,
AC6B69E821B146C500B2B68A /* YGValue.h in Headers */, AC6B69E821B146C500B2B68A /* YGValue.h in Headers */,
AC8360D221B025EF00FC46B9 /* YGConfig.h in Headers */, AC8360D221B025EF00FC46B9 /* YGConfig.h in Headers */,
AC8360CE21B0256A00FC46B9 /* YGMarker.h in Headers */, AC8360CE21B0256A00FC46B9 /* YGMarker.h in Headers */,
@ -3342,6 +3348,7 @@
isa = PBXHeadersBuildPhase; isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
AC90464021C91D14005B24B3 /* CompactValue.h in Headers */,
AC6B69E521B1469A00B2B68A /* YGValue.h in Headers */, AC6B69E521B1469A00B2B68A /* YGValue.h in Headers */,
AC8360CF21B0258B00FC46B9 /* YGConfig.h in Headers */, AC8360CF21B0258B00FC46B9 /* YGConfig.h in Headers */,
AC8360CD21B0256A00FC46B9 /* YGMarker.h in Headers */, AC8360CD21B0256A00FC46B9 /* YGMarker.h in Headers */,
@ -3457,6 +3464,7 @@
3D80DA3E1DF820620028D040 /* RCTRootViewDelegate.h in Headers */, 3D80DA3E1DF820620028D040 /* RCTRootViewDelegate.h in Headers */,
3D80DA3F1DF820620028D040 /* RCTRootViewInternal.h in Headers */, 3D80DA3F1DF820620028D040 /* RCTRootViewInternal.h in Headers */,
3D80DA401DF820620028D040 /* RCTTouchEvent.h in Headers */, 3D80DA401DF820620028D040 /* RCTTouchEvent.h in Headers */,
AC90463E21C91CC2005B24B3 /* CompactValue.h in Headers */,
3D80DA411DF820620028D040 /* RCTTouchHandler.h in Headers */, 3D80DA411DF820620028D040 /* RCTTouchHandler.h in Headers */,
59E604A61FE9CCE300BD90C5 /* RCTScrollContentViewManager.h in Headers */, 59E604A61FE9CCE300BD90C5 /* RCTScrollContentViewManager.h in Headers */,
13134C8C1E296B2A00B9F3CB /* RCTMessageThread.h in Headers */, 13134C8C1E296B2A00B9F3CB /* RCTMessageThread.h in Headers */,

View File

@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include <yoga/YGValue.h> #include "YGValue.h"
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>
@ -73,6 +73,10 @@ class CompactValue {
return std::isnan(value) ? ofUndefined() : of<Unit>(value); return std::isnan(value) ? ofUndefined() : of<Unit>(value);
} }
static constexpr CompactValue ofZero() noexcept {
return CompactValue{Payload{ZERO_BITS_POINT}};
}
static constexpr CompactValue ofUndefined() noexcept { static constexpr CompactValue ofUndefined() noexcept {
return CompactValue{}; return CompactValue{};
} }

View File

@ -7,6 +7,7 @@
#pragma once #pragma once
#include "YGNode.h" #include "YGNode.h"
#include "Yoga-internal.h" #include "Yoga-internal.h"
#include "CompactValue.h"
// This struct is an helper model to hold the data for step 4 of flexbox // This struct is an helper model to hold the data for step 4 of flexbox
// algo, which is collecting the flex items in a line. // algo, which is collecting the flex items in a line.
@ -124,8 +125,7 @@ inline YGFlexDirection YGResolveFlexDirection(
} }
inline YGFloatOptional YGResolveValueMargin( inline YGFloatOptional YGResolveValueMargin(
const YGValue value, yoga::detail::CompactValue value,
const float ownerSize) { const float ownerSize) {
return value.unit == YGUnitAuto ? YGFloatOptional(0) return value.isAuto() ? YGFloatOptional{0} : YGResolveValue(value, ownerSize);
: YGResolveValue(value, ownerSize);
} }

View File

@ -6,87 +6,92 @@
*/ */
#include "YGNode.h" #include "YGNode.h"
#include <iostream> #include <iostream>
#include "CompactValue.h"
#include "Utils.h" #include "Utils.h"
using namespace facebook; using namespace facebook;
using facebook::yoga::detail::CompactValue;
YGFloatOptional YGNode::getLeadingPosition( YGFloatOptional YGNode::getLeadingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const float axisSize) const {
if (YGFlexDirectionIsRow(axis)) { if (YGFlexDirectionIsRow(axis)) {
const YGValue* leadingPosition = auto leadingPosition = YGComputedEdgeValue(
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined); style_.position, YGEdgeStart, CompactValue::ofUndefined());
if (leadingPosition->unit != YGUnitUndefined) { if (!leadingPosition.isUndefined()) {
return YGResolveValue(*leadingPosition, axisSize); return YGResolveValue(leadingPosition, axisSize);
} }
} }
const YGValue* leadingPosition = auto leadingPosition = YGComputedEdgeValue(
YGComputedEdgeValue(style_.position, leading[axis], &YGValueUndefined); style_.position, leading[axis], CompactValue::ofUndefined());
return leadingPosition->unit == YGUnitUndefined return leadingPosition.isUndefined()
? YGFloatOptional(0) ? YGFloatOptional{0}
: YGResolveValue(*leadingPosition, axisSize); : YGResolveValue(leadingPosition, axisSize);
} }
YGFloatOptional YGNode::getTrailingPosition( YGFloatOptional YGNode::getTrailingPosition(
const YGFlexDirection axis, const YGFlexDirection axis,
const float axisSize) const { const float axisSize) const {
if (YGFlexDirectionIsRow(axis)) { if (YGFlexDirectionIsRow(axis)) {
const YGValue* trailingPosition = auto trailingPosition = YGComputedEdgeValue(
YGComputedEdgeValue(style_.position, YGEdgeEnd, &YGValueUndefined); style_.position, YGEdgeEnd, CompactValue::ofUndefined());
if (trailingPosition->unit != YGUnitUndefined) { if (!trailingPosition.isUndefined()) {
return YGResolveValue(*trailingPosition, axisSize); return YGResolveValue(trailingPosition, axisSize);
} }
} }
const YGValue* trailingPosition = auto trailingPosition = YGComputedEdgeValue(
YGComputedEdgeValue(style_.position, trailing[axis], &YGValueUndefined); style_.position, trailing[axis], CompactValue::ofUndefined());
return trailingPosition->unit == YGUnitUndefined return trailingPosition.isUndefined()
? YGFloatOptional(0) ? YGFloatOptional{0}
: YGResolveValue(*trailingPosition, axisSize); : YGResolveValue(trailingPosition, axisSize);
} }
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) const { bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) const {
return (YGFlexDirectionIsRow(axis) && return (YGFlexDirectionIsRow(axis) &&
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined) !YGComputedEdgeValue(
->unit != YGUnitUndefined) || style_.position, YGEdgeStart, CompactValue::ofUndefined())
YGComputedEdgeValue(style_.position, leading[axis], &YGValueUndefined) .isUndefined()) ||
->unit != YGUnitUndefined; !YGComputedEdgeValue(
style_.position, leading[axis], CompactValue::ofUndefined())
.isUndefined();
} }
bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) const { bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) const {
return (YGFlexDirectionIsRow(axis) && return (YGFlexDirectionIsRow(axis) &&
YGComputedEdgeValue(style_.position, YGEdgeEnd, &YGValueUndefined) !YGComputedEdgeValue(
->unit != YGUnitUndefined) || style_.position, YGEdgeEnd, CompactValue::ofUndefined())
YGComputedEdgeValue(style_.position, trailing[axis], &YGValueUndefined) .isUndefined()) ||
->unit != YGUnitUndefined; !YGComputedEdgeValue(
style_.position, trailing[axis], CompactValue::ofUndefined())
.isUndefined();
} }
YGFloatOptional YGNode::getLeadingMargin( YGFloatOptional YGNode::getLeadingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const float widthSize) const {
if (YGFlexDirectionIsRow(axis) && if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeStart].isUndefined()) {
style_.margin[YGEdgeStart].unit != YGUnitUndefined) {
return YGResolveValueMargin(style_.margin[YGEdgeStart], widthSize); return YGResolveValueMargin(style_.margin[YGEdgeStart], widthSize);
} }
return YGResolveValueMargin( return YGResolveValueMargin(
*YGComputedEdgeValue(style_.margin, leading[axis], &YGValueZero), YGComputedEdgeValue(style_.margin, leading[axis], CompactValue::ofZero()),
widthSize); widthSize);
} }
YGFloatOptional YGNode::getTrailingMargin( YGFloatOptional YGNode::getTrailingMargin(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const float widthSize) const {
if (YGFlexDirectionIsRow(axis) && if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeEnd].isUndefined()) {
style_.margin[YGEdgeEnd].unit != YGUnitUndefined) {
return YGResolveValueMargin(style_.margin[YGEdgeEnd], widthSize); return YGResolveValueMargin(style_.margin[YGEdgeEnd], widthSize);
} }
return YGResolveValueMargin( return YGResolveValueMargin(
*YGComputedEdgeValue(style_.margin, trailing[axis], &YGValueZero), YGComputedEdgeValue(
style_.margin, trailing[axis], CompactValue::ofZero()),
widthSize); widthSize);
} }
@ -280,8 +285,7 @@ YGNode& YGNode::operator=(const YGNode& node) {
} }
YGValue YGNode::marginLeadingValue(const YGFlexDirection axis) const { YGValue YGNode::marginLeadingValue(const YGFlexDirection axis) const {
if (YGFlexDirectionIsRow(axis) && if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeStart].isUndefined()) {
style_.margin[YGEdgeStart].unit != YGUnitUndefined) {
return style_.margin[YGEdgeStart]; return style_.margin[YGEdgeStart];
} else { } else {
return style_.margin[leading[axis]]; return style_.margin[leading[axis]];
@ -289,8 +293,7 @@ YGValue YGNode::marginLeadingValue(const YGFlexDirection axis) const {
} }
YGValue YGNode::marginTrailingValue(const YGFlexDirection axis) const { YGValue YGNode::marginTrailingValue(const YGFlexDirection axis) const {
if (YGFlexDirectionIsRow(axis) && if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeEnd].isUndefined()) {
style_.margin[YGEdgeEnd].unit != YGUnitUndefined) {
return style_.margin[YGEdgeEnd]; return style_.margin[YGEdgeEnd];
} else { } else {
return style_.margin[trailing[axis]]; return style_.margin[trailing[axis]];
@ -310,7 +313,7 @@ YGValue YGNode::resolveFlexBasisPtr() const {
void YGNode::resolveDimension() { void YGNode::resolveDimension() {
for (uint32_t dim = YGDimensionWidth; dim < YGDimensionCount; dim++) { for (uint32_t dim = YGDimensionWidth; dim < YGDimensionCount; dim++) {
if (getStyle().maxDimensions[dim].unit != YGUnitUndefined && if (!getStyle().maxDimensions[dim].isUndefined() &&
YGValueEqual( YGValueEqual(
getStyle().maxDimensions[dim], style_.minDimensions[dim])) { getStyle().maxDimensions[dim], style_.minDimensions[dim])) {
resolvedDimensions_[dim] = style_.maxDimensions[dim]; resolvedDimensions_[dim] = style_.maxDimensions[dim];
@ -422,30 +425,32 @@ bool YGNode::isNodeFlexible() {
} }
float YGNode::getLeadingBorder(const YGFlexDirection axis) const { float YGNode::getLeadingBorder(const YGFlexDirection axis) const {
if (YGFlexDirectionIsRow(axis) && YGValue leadingBorder;
style_.border[YGEdgeStart].unit != YGUnitUndefined && if (YGFlexDirectionIsRow(axis) && !style_.border[YGEdgeStart].isUndefined()) {
!yoga::isUndefined(style_.border[YGEdgeStart].value) && leadingBorder = style_.border[YGEdgeStart];
style_.border[YGEdgeStart].value >= 0.0f) { if (leadingBorder.value >= 0) {
return style_.border[YGEdgeStart].value; return leadingBorder.value;
}
} }
float computedEdgeValue = leadingBorder =
YGComputedEdgeValue(style_.border, leading[axis], &YGValueZero)->value; YGComputedEdgeValue(style_.border, leading[axis], CompactValue::ofZero());
return YGFloatMax(computedEdgeValue, 0.0f); return YGFloatMax(leadingBorder.value, 0.0f);
} }
float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const { float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const {
YGValue trailingBorder;
if (YGFlexDirectionIsRow(flexDirection) && if (YGFlexDirectionIsRow(flexDirection) &&
style_.border[YGEdgeEnd].unit != YGUnitUndefined && !style_.border[YGEdgeEnd].isUndefined()) {
!yoga::isUndefined(style_.border[YGEdgeEnd].value) && trailingBorder = style_.border[YGEdgeEnd];
style_.border[YGEdgeEnd].value >= 0.0f) { if (trailingBorder.value >= 0.0f) {
return style_.border[YGEdgeEnd].value; return trailingBorder.value;
}
} }
float computedEdgeValue = trailingBorder = YGComputedEdgeValue(
YGComputedEdgeValue(style_.border, trailing[flexDirection], &YGValueZero) style_.border, trailing[flexDirection], CompactValue::ofZero());
->value; return YGFloatMax(trailingBorder.value, 0.0f);
return YGFloatMax(computedEdgeValue, 0.0f);
} }
YGFloatOptional YGNode::getLeadingPadding( YGFloatOptional YGNode::getLeadingPadding(
@ -454,13 +459,14 @@ YGFloatOptional YGNode::getLeadingPadding(
const YGFloatOptional paddingEdgeStart = const YGFloatOptional paddingEdgeStart =
YGResolveValue(style_.padding[YGEdgeStart], widthSize); YGResolveValue(style_.padding[YGEdgeStart], widthSize);
if (YGFlexDirectionIsRow(axis) && if (YGFlexDirectionIsRow(axis) &&
style_.padding[YGEdgeStart].unit != YGUnitUndefined && !style_.padding[YGEdgeStart].isUndefined() &&
!paddingEdgeStart.isUndefined() && paddingEdgeStart.unwrap() >= 0.0f) { !paddingEdgeStart.isUndefined() && paddingEdgeStart.unwrap() >= 0.0f) {
return paddingEdgeStart; return paddingEdgeStart;
} }
YGFloatOptional resolvedValue = YGResolveValue( YGFloatOptional resolvedValue = YGResolveValue(
*YGComputedEdgeValue(style_.padding, leading[axis], &YGValueZero), YGComputedEdgeValue(
style_.padding, leading[axis], CompactValue::ofZero()),
widthSize); widthSize);
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f)); return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
} }
@ -475,7 +481,8 @@ YGFloatOptional YGNode::getTrailingPadding(
} }
YGFloatOptional resolvedValue = YGResolveValue( YGFloatOptional resolvedValue = YGResolveValue(
*YGComputedEdgeValue(style_.padding, trailing[axis], &YGValueZero), YGComputedEdgeValue(
style_.padding, trailing[axis], CompactValue::ofZero()),
widthSize); widthSize);
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f)); return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));

View File

@ -99,7 +99,9 @@ static void appendEdgeIfNotUndefined(
const facebook::yoga::detail::Values<YGEdgeCount>& edges, const facebook::yoga::detail::Values<YGEdgeCount>& edges,
const YGEdge edge) { const YGEdge edge) {
appendNumberIfNotUndefined( appendNumberIfNotUndefined(
base, str, *YGComputedEdgeValue(edges, edge, &YGValueUndefined)); base,
str,
YGComputedEdgeValue(edges, edge, detail::CompactValue::ofUndefined()));
} }
void YGNodeToString( void YGNodeToString(

View File

@ -8,6 +8,7 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <initializer_list> #include <initializer_list>
#include "CompactValue.h"
#include "YGFloatOptional.h" #include "YGFloatOptional.h"
#include "Yoga-internal.h" #include "Yoga-internal.h"
#include "Yoga.h" #include "Yoga.h"
@ -17,6 +18,10 @@ constexpr YGValue kYGValueUndefined = {0, YGUnitUndefined};
constexpr YGValue kYGValueAuto = {0, YGUnitAuto}; constexpr YGValue kYGValueAuto = {0, YGUnitAuto};
struct YGStyle { struct YGStyle {
private:
using CompactValue = facebook::yoga::detail::CompactValue;
public:
using Dimensions = facebook::yoga::detail::Values<2>; using Dimensions = facebook::yoga::detail::Values<2>;
using Edges = facebook::yoga::detail::Values<YGEdgeCount>; using Edges = facebook::yoga::detail::Values<YGEdgeCount>;
@ -33,14 +38,14 @@ struct YGStyle {
YGFloatOptional flex = {}; YGFloatOptional flex = {};
YGFloatOptional flexGrow = {}; YGFloatOptional flexGrow = {};
YGFloatOptional flexShrink = {}; YGFloatOptional flexShrink = {};
YGValue flexBasis = kYGValueAuto; CompactValue flexBasis = CompactValue::ofAuto();
Edges margin{kYGValueUndefined}; Edges margin = {};
Edges position{kYGValueUndefined}; Edges position = {};
Edges padding{kYGValueUndefined}; Edges padding = {};
Edges border{kYGValueUndefined}; Edges border = {};
Dimensions dimensions{kYGValueAuto}; Dimensions dimensions{CompactValue::ofAuto()};
Dimensions minDimensions{kYGValueUndefined}; Dimensions minDimensions = {};
Dimensions maxDimensions{kYGValueUndefined}; Dimensions maxDimensions = {};
// Yoga specific properties, not compatible with flexbox specification // Yoga specific properties, not compatible with flexbox specification
YGFloatOptional aspectRatio = {}; YGFloatOptional aspectRatio = {};

View File

@ -9,6 +9,7 @@
#include <array> #include <array>
#include <cmath> #include <cmath>
#include <vector> #include <vector>
#include "CompactValue.h"
#include "Yoga.h" #include "Yoga.h"
using YGVector = std::vector<YGNodeRef>; using YGVector = std::vector<YGNodeRef>;
@ -95,7 +96,7 @@ namespace detail {
template <size_t Size> template <size_t Size>
class Values { class Values {
private: private:
std::array<YGValue, Size> values_; std::array<CompactValue, Size> values_;
public: public:
Values() = default; Values() = default;
@ -103,10 +104,10 @@ class Values {
values_.fill(defaultValue); values_.fill(defaultValue);
} }
const YGValue& operator[](size_t i) const noexcept { const CompactValue& operator[](size_t i) const noexcept {
return values_[i]; return values_[i];
} }
YGValue& operator[](size_t i) noexcept { CompactValue& operator[](size_t i) noexcept {
return values_[i]; return values_[i];
} }
@ -120,6 +121,11 @@ class Values {
std::get<I>(values_) = value; std::get<I>(values_) = value;
} }
template <size_t I>
void set(YGValue&& value) noexcept {
set<I>(value);
}
bool operator==(const Values& other) const noexcept { bool operator==(const Values& other) const noexcept {
for (size_t i = 0; i < Size; ++i) { for (size_t i = 0; i < Size; ++i) {
if (values_[i] != other.values_[i]) { if (values_[i] != other.values_[i]) {
@ -142,7 +148,7 @@ static const float kWebDefaultFlexShrink = 1.0f;
extern bool YGFloatsEqual(const float a, const float b); extern bool YGFloatsEqual(const float a, const float b);
extern bool YGValueEqual(const YGValue a, const YGValue b); extern bool YGValueEqual(const YGValue a, const YGValue b);
extern const YGValue* YGComputedEdgeValue( extern facebook::yoga::detail::CompactValue YGComputedEdgeValue(
const facebook::yoga::detail::Values<YGEdgeCount>& edges, const facebook::yoga::detail::Values<YGEdgeCount>& edges,
const YGEdge edge, YGEdge edge,
const YGValue* const defaultValue); facebook::yoga::detail::CompactValue defaultValue);

View File

@ -23,6 +23,8 @@ __forceinline const float fmaxf(const float a, const float b) {
#endif #endif
#endif #endif
using namespace facebook::yoga;
#ifdef ANDROID #ifdef ANDROID
static int YGAndroidLog( static int YGAndroidLog(
const YGConfigRef config, const YGConfigRef config,
@ -102,31 +104,31 @@ bool YGFloatIsUndefined(const float value) {
return facebook::yoga::isUndefined(value); return facebook::yoga::isUndefined(value);
} }
const YGValue* YGComputedEdgeValue( detail::CompactValue YGComputedEdgeValue(
const facebook::yoga::detail::Values<YGEdgeCount>& edges, const facebook::yoga::detail::Values<YGEdgeCount>& edges,
const YGEdge edge, YGEdge edge,
const YGValue* const defaultValue) { detail::CompactValue defaultValue) {
if (edges[edge].unit != YGUnitUndefined) { if (!edges[edge].isUndefined()) {
return &edges[edge]; return edges[edge];
} }
if ((edge == YGEdgeTop || edge == YGEdgeBottom) && if ((edge == YGEdgeTop || edge == YGEdgeBottom) &&
edges[YGEdgeVertical].unit != YGUnitUndefined) { !edges[YGEdgeVertical].isUndefined()) {
return &edges[YGEdgeVertical]; return edges[YGEdgeVertical];
} }
if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart || if ((edge == YGEdgeLeft || edge == YGEdgeRight || edge == YGEdgeStart ||
edge == YGEdgeEnd) && edge == YGEdgeEnd) &&
edges[YGEdgeHorizontal].unit != YGUnitUndefined) { !edges[YGEdgeHorizontal].isUndefined()) {
return &edges[YGEdgeHorizontal]; return edges[YGEdgeHorizontal];
} }
if (edges[YGEdgeAll].unit != YGUnitUndefined) { if (!edges[YGEdgeAll].isUndefined()) {
return &edges[YGEdgeAll]; return edges[YGEdgeAll];
} }
if (edge == YGEdgeStart || edge == YGEdgeEnd) { if (edge == YGEdgeStart || edge == YGEdgeEnd) {
return &YGValueUndefined; return detail::CompactValue::ofUndefined();
} }
return defaultValue; return defaultValue;
@ -595,14 +597,21 @@ namespace {
struct Value { struct Value {
template <YGUnit U> template <YGUnit U>
static YGValue create(float value) { static detail::CompactValue create(float value) {
return { return detail::CompactValue::ofMaybe<U>(value);
YGFloatSanitize(value),
YGFloatIsUndefined(value) ? YGUnitUndefined : U,
};
} }
}; };
template <>
inline detail::CompactValue Value::create<YGUnitUndefined>(float) {
return detail::CompactValue::ofUndefined();
}
template <>
inline detail::CompactValue Value::create<YGUnitAuto>(float) {
return detail::CompactValue::ofAuto();
}
template <YGStyle::Dimensions YGStyle::*P> template <YGStyle::Dimensions YGStyle::*P>
struct DimensionProp { struct DimensionProp {
template <YGDimension idx> template <YGDimension idx>
@ -616,10 +625,8 @@ struct DimensionProp {
template <YGDimension idx, YGUnit U> template <YGDimension idx, YGUnit U>
static void set(YGNodeRef node, float newValue) { static void set(YGNodeRef node, float newValue) {
YGValue value = Value::create<U>(newValue); auto value = Value::create<U>(newValue);
if (((node->getStyle().*P)[idx].value != value.value && if ((node->getStyle().*P)[idx] != value) {
value.unit != YGUnitUndefined) ||
(node->getStyle().*P)[idx].unit != value.unit) {
(node->getStyle().*P)[idx] = value; (node->getStyle().*P)[idx] = value;
node->markDirtyAndPropogate(); node->markDirtyAndPropogate();
} }
@ -628,37 +635,30 @@ struct DimensionProp {
} // namespace } // namespace
#define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_AUTO_IMPL( \ #define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_AUTO_IMPL( \
type, name, paramName, instanceName) \ type, name, paramName, instanceName) \
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \ void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
YGValue value = { \ auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(paramName); \
YGFloatSanitize(paramName), \ if (node->getStyle().instanceName != value) { \
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \ node->getStyle().instanceName = value; \
}; \ node->markDirtyAndPropogate(); \
if ((node->getStyle().instanceName.value != value.value && \ } \
value.unit != YGUnitUndefined) || \ } \
node->getStyle().instanceName.unit != value.unit) { \ \
node->getStyle().instanceName = value; \ void YGNodeStyleSet##name##Percent( \
node->markDirtyAndPropogate(); \ const YGNodeRef node, const type paramName) { \
} \ auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(paramName); \
} \ if (node->getStyle().instanceName != value) { \
\ node->getStyle().instanceName = value; \
void YGNodeStyleSet##name##Percent( \ node->markDirtyAndPropogate(); \
const YGNodeRef node, const type paramName) { \ } \
if (node->getStyle().instanceName.value != YGFloatSanitize(paramName) || \ } \
node->getStyle().instanceName.unit != YGUnitPercent) { \ \
node->getStyle().instanceName = YGFloatIsUndefined(paramName) \ void YGNodeStyleSet##name##Auto(const YGNodeRef node) { \
? YGValue{0, YGUnitAuto} \ if (node->getStyle().instanceName != detail::CompactValue::ofAuto()) { \
: YGValue{paramName, YGUnitPercent}; \ node->getStyle().instanceName = detail::CompactValue::ofAuto(); \
node->markDirtyAndPropogate(); \ node->markDirtyAndPropogate(); \
} \ } \
} \
\
void YGNodeStyleSet##name##Auto(const YGNodeRef node) { \
if (node->getStyle().instanceName.unit != YGUnitAuto) { \
node->getStyle().instanceName = {0, YGUnitAuto}; \
node->markDirtyAndPropogate(); \
} \
} }
#define YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL( \ #define YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL( \
@ -676,49 +676,40 @@ struct DimensionProp {
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO_IMPL(type, name, instanceName) \ #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO_IMPL(type, name, instanceName) \
void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge) { \ void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge) { \
if (node->getStyle().instanceName[edge].unit != YGUnitAuto) { \ if (node->getStyle().instanceName[edge] != \
node->getStyle().instanceName[edge] = {0, YGUnitAuto}; \ detail::CompactValue::ofAuto()) { \
node->getStyle().instanceName[edge] = detail::CompactValue::ofAuto(); \
node->markDirtyAndPropogate(); \ node->markDirtyAndPropogate(); \
} \ } \
} }
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL( \ #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL( \
type, name, paramName, instanceName) \ type, name, paramName, instanceName) \
void YGNodeStyleSet##name( \ void YGNodeStyleSet##name( \
const YGNodeRef node, const YGEdge edge, const float paramName) { \ const YGNodeRef node, const YGEdge edge, const float paramName) { \
YGValue value = { \ auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(paramName); \
YGFloatSanitize(paramName), \ if (node->getStyle().instanceName[edge] != value) { \
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \ node->getStyle().instanceName[edge] = value; \
}; \ node->markDirtyAndPropogate(); \
if ((node->getStyle().instanceName[edge].value != value.value && \ } \
value.unit != YGUnitUndefined) || \ } \
node->getStyle().instanceName[edge].unit != value.unit) { \ \
node->getStyle().instanceName[edge] = value; \ void YGNodeStyleSet##name##Percent( \
node->markDirtyAndPropogate(); \ const YGNodeRef node, const YGEdge edge, const float paramName) { \
} \ auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(paramName); \
} \ if (node->getStyle().instanceName[edge] != value) { \
\ node->getStyle().instanceName[edge] = value; \
void YGNodeStyleSet##name##Percent( \ node->markDirtyAndPropogate(); \
const YGNodeRef node, const YGEdge edge, const float paramName) { \ } \
YGValue value = { \ } \
YGFloatSanitize(paramName), \ \
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent, \ WIN_STRUCT(type) \
}; \ YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \
if ((node->getStyle().instanceName[edge].value != value.value && \ YGValue value = node->getStyle().instanceName[edge]; \
value.unit != YGUnitUndefined) || \ if (value.unit == YGUnitUndefined || value.unit == YGUnitAuto) { \
node->getStyle().instanceName[edge].unit != value.unit) { \ value.value = YGUndefined; \
node->getStyle().instanceName[edge] = value; \ } \
node->markDirtyAndPropogate(); \ return WIN_STRUCT_REF(value); \
} \
} \
\
WIN_STRUCT(type) \
YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \
YGValue value = node->getStyle().instanceName[edge]; \
if (value.unit == YGUnitUndefined || value.unit == YGUnitAuto) { \
value.value = YGUndefined; \
} \
return WIN_STRUCT_REF(value); \
} }
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \ #define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
@ -881,13 +872,8 @@ YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) {
} }
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) { void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
YGValue value = { auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
YGFloatSanitize(flexBasis), if (node->getStyle().flexBasis != value) {
YGFloatIsUndefined(flexBasis) ? YGUnitUndefined : YGUnitPoint,
};
if ((node->getStyle().flexBasis.value != value.value &&
value.unit != YGUnitUndefined) ||
node->getStyle().flexBasis.unit != value.unit) {
node->getStyle().flexBasis = value; node->getStyle().flexBasis = value;
node->markDirtyAndPropogate(); node->markDirtyAndPropogate();
} }
@ -896,18 +882,16 @@ void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
void YGNodeStyleSetFlexBasisPercent( void YGNodeStyleSetFlexBasisPercent(
const YGNodeRef node, const YGNodeRef node,
const float flexBasisPercent) { const float flexBasisPercent) {
if (node->getStyle().flexBasis.value != flexBasisPercent || auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(flexBasisPercent);
node->getStyle().flexBasis.unit != YGUnitPercent) { if (node->getStyle().flexBasis != value) {
node->getStyle().flexBasis = YGFloatIsUndefined(flexBasisPercent) node->getStyle().flexBasis = value;
? YGValue{0, YGUnitAuto}
: YGValue{flexBasisPercent, YGUnitPercent};
node->markDirtyAndPropogate(); node->markDirtyAndPropogate();
} }
} }
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) { void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
if (node->getStyle().flexBasis.unit != YGUnitAuto) { if (node->getStyle().flexBasis != detail::CompactValue::ofAuto()) {
node->getStyle().flexBasis = {0, YGUnitAuto}; node->getStyle().flexBasis = detail::CompactValue::ofAuto();
node->markDirtyAndPropogate(); node->markDirtyAndPropogate();
} }
} }
@ -922,27 +906,23 @@ void YGNodeStyleSetBorder(
const YGNodeRef node, const YGNodeRef node,
const YGEdge edge, const YGEdge edge,
const float border) { const float border) {
YGValue value = { auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(border);
YGFloatSanitize(border), if (node->getStyle().border[edge] != value) {
YGFloatIsUndefined(border) ? YGUnitUndefined : YGUnitPoint,
};
if ((node->getStyle().border[edge].value != value.value &&
value.unit != YGUnitUndefined) ||
node->getStyle().border[edge].unit != value.unit) {
node->getStyle().border[edge] = value; node->getStyle().border[edge] = value;
node->markDirtyAndPropogate(); node->markDirtyAndPropogate();
} }
} }
float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) { float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
if (node->getStyle().border[edge].unit == YGUnitUndefined || if (node->getStyle().border[edge].isUndefined() ||
node->getStyle().border[edge].unit == YGUnitAuto) { node->getStyle().border[edge].isAuto()) {
// TODO(T26792433): Rather than returning YGUndefined, change the api to // TODO(T26792433): Rather than returning YGUndefined, change the api to
// return YGFloatOptional. // return YGFloatOptional.
return YGUndefined; return YGUndefined;
} }
return node->getStyle().border[edge].value; auto border = (YGValue)node->getStyle().border[edge];
return border.value;
} }
// Yoga specific properties, not compatible with flexbox specification // Yoga specific properties, not compatible with flexbox specification
@ -2433,7 +2413,7 @@ static void YGJustifyMainAxis(
// remainingFreeSpace is 0 when min main dimension is not given // remainingFreeSpace is 0 when min main dimension is not given
if (measureModeMainDim == YGMeasureModeAtMost && if (measureModeMainDim == YGMeasureModeAtMost &&
collectedFlexItemsValues.remainingFreeSpace > 0) { collectedFlexItemsValues.remainingFreeSpace > 0) {
if (style.minDimensions[dim[mainAxis]].unit != YGUnitUndefined && if (!style.minDimensions[dim[mainAxis]].isUndefined() &&
!YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize) !YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize)
.isUndefined()) { .isUndefined()) {
// This condition makes sure that if the size of main dimension(after // This condition makes sure that if the size of main dimension(after