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:
committed by
Facebook Github Bot
parent
e167642672
commit
dee93017f7
246
tests/YGStyleAccessorsTest.cpp
Normal file
246
tests/YGStyleAccessorsTest.cpp
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <yoga/YGStyle.h>
|
||||||
|
#include <yoga/YGValue.h>
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
|
#define ACCESSOR_TESTS_1(NAME, X) \
|
||||||
|
style.NAME() = X; \
|
||||||
|
ASSERT_EQ(style.NAME(), X);
|
||||||
|
#define ACCESSOR_TESTS_2(NAME, X, ...) \
|
||||||
|
ACCESSOR_TESTS_1(NAME, X); \
|
||||||
|
ACCESSOR_TESTS_1(NAME, __VA_ARGS__);
|
||||||
|
#define ACCESSOR_TESTS_3(NAME, X, ...) \
|
||||||
|
ACCESSOR_TESTS_1(NAME, X); \
|
||||||
|
ACCESSOR_TESTS_2(NAME, __VA_ARGS__);
|
||||||
|
#define ACCESSOR_TESTS_4(NAME, X, ...) \
|
||||||
|
ACCESSOR_TESTS_1(NAME, X); \
|
||||||
|
ACCESSOR_TESTS_3(NAME, __VA_ARGS__);
|
||||||
|
#define ACCESSOR_TESTS_5(NAME, X, ...) \
|
||||||
|
ACCESSOR_TESTS_1(NAME, X); \
|
||||||
|
ACCESSOR_TESTS_4(NAME, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define ACCESSOR_TESTS_N(a, b, c, d, e, COUNT, ...) ACCESSOR_TESTS_##COUNT
|
||||||
|
#define ACCESSOR_TESTS(...) ACCESSOR_TESTS_N(__VA_ARGS__, 5, 4, 3, 2, 1)
|
||||||
|
|
||||||
|
#define INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \
|
||||||
|
style.NAME()[IDX] = X; \
|
||||||
|
ASSERT_EQ(style.NAME()[IDX], X);
|
||||||
|
|
||||||
|
#define INDEX_ACCESSOR_TESTS_2(NAME, IDX, X, Y) \
|
||||||
|
INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \
|
||||||
|
INDEX_ACCESSOR_TESTS_1(NAME, IDX, Y)
|
||||||
|
|
||||||
|
#define INDEX_ACCESSOR_TESTS_3(NAME, IDX, X, ...) \
|
||||||
|
INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \
|
||||||
|
INDEX_ACCESSOR_TESTS_2(NAME, IDX, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define INDEX_ACCESSOR_TESTS_4(NAME, IDX, X, ...) \
|
||||||
|
INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \
|
||||||
|
INDEX_ACCESSOR_TESTS_3(NAME, IDX, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define INDEX_ACCESSOR_TESTS_5(NAME, IDX, X, ...) \
|
||||||
|
INDEX_ACCESSOR_TESTS_1(NAME, IDX, X) \
|
||||||
|
INDEX_ACCESSOR_TESTS_4(NAME, IDX, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define INDEX_ACCESSOR_TESTS_N(a, b, c, d, e, COUNT, ...) \
|
||||||
|
INDEX_ACCESSOR_TESTS_##COUNT
|
||||||
|
#define INDEX_ACCESSOR_TESTS(...) \
|
||||||
|
INDEX_ACCESSOR_TESTS_N(__VA_ARGS__, 5, 4, 3, 2, 1)
|
||||||
|
|
||||||
|
// test macro for up to 5 values. If more are needed, extend the macros above.
|
||||||
|
#define ACCESSOR_TEST(NAME, DEFAULT_VAL, ...) \
|
||||||
|
TEST(YGStyle, style_##NAME##_access) { \
|
||||||
|
auto style = YGStyle{}; \
|
||||||
|
ASSERT_EQ(style.NAME(), DEFAULT_VAL); \
|
||||||
|
ACCESSOR_TESTS(__VA_ARGS__)(NAME, __VA_ARGS__) \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define INDEX_ACCESSOR_TEST(NAME, DEFAULT_VAL, IDX, ...) \
|
||||||
|
TEST(YGStyle, style_##NAME##_access) { \
|
||||||
|
auto style = YGStyle{}; \
|
||||||
|
ASSERT_EQ(style.NAME()[IDX], DEFAULT_VAL); \
|
||||||
|
INDEX_ACCESSOR_TESTS(__VA_ARGS__)(NAME, IDX, __VA_ARGS__) \
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace facebook {
|
||||||
|
namespace yoga {
|
||||||
|
|
||||||
|
using CompactValue = detail::CompactValue;
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
direction,
|
||||||
|
YGDirectionInherit,
|
||||||
|
YGDirectionLTR,
|
||||||
|
YGDirectionRTL,
|
||||||
|
YGDirectionInherit);
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
flexDirection,
|
||||||
|
YGFlexDirectionColumn,
|
||||||
|
YGFlexDirectionColumnReverse,
|
||||||
|
YGFlexDirectionRowReverse,
|
||||||
|
YGFlexDirectionRow)
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
justifyContent,
|
||||||
|
YGJustifyFlexStart,
|
||||||
|
YGJustifyFlexEnd,
|
||||||
|
YGJustifySpaceAround,
|
||||||
|
YGJustifyFlexStart,
|
||||||
|
YGJustifySpaceEvenly)
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
alignContent,
|
||||||
|
YGAlignFlexStart,
|
||||||
|
YGAlignAuto,
|
||||||
|
YGAlignFlexStart,
|
||||||
|
YGAlignCenter,
|
||||||
|
YGAlignFlexEnd,
|
||||||
|
YGAlignStretch)
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
alignItems,
|
||||||
|
YGAlignStretch,
|
||||||
|
YGAlignFlexStart,
|
||||||
|
YGAlignFlexEnd,
|
||||||
|
YGAlignBaseline,
|
||||||
|
YGAlignSpaceBetween,
|
||||||
|
YGAlignSpaceAround)
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
alignSelf,
|
||||||
|
YGAlignAuto,
|
||||||
|
YGAlignFlexStart,
|
||||||
|
YGAlignCenter,
|
||||||
|
YGAlignAuto,
|
||||||
|
YGAlignFlexEnd,
|
||||||
|
YGAlignStretch)
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
positionType,
|
||||||
|
YGPositionTypeRelative,
|
||||||
|
YGPositionTypeAbsolute,
|
||||||
|
YGPositionTypeRelative)
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
flexWrap,
|
||||||
|
YGWrapNoWrap,
|
||||||
|
YGWrapWrap,
|
||||||
|
YGWrapWrapReverse,
|
||||||
|
YGWrapNoWrap)
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
overflow,
|
||||||
|
YGOverflowVisible,
|
||||||
|
YGOverflowHidden,
|
||||||
|
YGOverflowScroll,
|
||||||
|
YGOverflowVisible)
|
||||||
|
|
||||||
|
ACCESSOR_TEST(display, YGDisplayFlex, YGDisplayNone, YGDisplayFlex)
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
flex,
|
||||||
|
YGFloatOptional{},
|
||||||
|
YGFloatOptional{123.45f},
|
||||||
|
YGFloatOptional{-9.87f},
|
||||||
|
YGFloatOptional{})
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
flexGrow,
|
||||||
|
YGFloatOptional{},
|
||||||
|
YGFloatOptional{123.45f},
|
||||||
|
YGFloatOptional{-9.87f},
|
||||||
|
YGFloatOptional{})
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
flexShrink,
|
||||||
|
YGFloatOptional{},
|
||||||
|
YGFloatOptional{123.45f},
|
||||||
|
YGFloatOptional{-9.87f},
|
||||||
|
YGFloatOptional{})
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
flexBasis,
|
||||||
|
CompactValue::ofAuto(),
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
CompactValue::ofAuto(),
|
||||||
|
CompactValue::of<YGUnitPoint>(7777.77f),
|
||||||
|
CompactValue::of<YGUnitPercent>(-100.0f))
|
||||||
|
|
||||||
|
INDEX_ACCESSOR_TEST(
|
||||||
|
position,
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
YGEdgeBottom,
|
||||||
|
CompactValue::ofAuto(),
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
CompactValue::of<YGUnitPoint>(7777.77f),
|
||||||
|
CompactValue::of<YGUnitPercent>(-100.0f))
|
||||||
|
|
||||||
|
INDEX_ACCESSOR_TEST(
|
||||||
|
margin,
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
YGEdgeTop,
|
||||||
|
CompactValue::ofAuto(),
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
CompactValue::of<YGUnitPoint>(7777.77f),
|
||||||
|
CompactValue::of<YGUnitPercent>(-100.0f))
|
||||||
|
|
||||||
|
INDEX_ACCESSOR_TEST(
|
||||||
|
padding,
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
YGEdgeAll,
|
||||||
|
CompactValue::of<YGUnitPoint>(7777.77f),
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
CompactValue::of<YGUnitPercent>(-100.0f))
|
||||||
|
|
||||||
|
INDEX_ACCESSOR_TEST(
|
||||||
|
border,
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
YGEdgeHorizontal,
|
||||||
|
CompactValue::of<YGUnitPoint>(-7777.77f),
|
||||||
|
CompactValue::ofUndefined())
|
||||||
|
|
||||||
|
INDEX_ACCESSOR_TEST(
|
||||||
|
dimensions,
|
||||||
|
CompactValue::ofAuto(),
|
||||||
|
YGDimensionWidth,
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
CompactValue::ofAuto(),
|
||||||
|
CompactValue::of<YGUnitPoint>(7777.77f),
|
||||||
|
CompactValue::of<YGUnitPercent>(-100.0f))
|
||||||
|
|
||||||
|
INDEX_ACCESSOR_TEST(
|
||||||
|
minDimensions,
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
YGDimensionHeight,
|
||||||
|
CompactValue::ofAuto(),
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
CompactValue::of<YGUnitPoint>(7777.77f),
|
||||||
|
CompactValue::of<YGUnitPercent>(-100.0f))
|
||||||
|
|
||||||
|
INDEX_ACCESSOR_TEST(
|
||||||
|
maxDimensions,
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
YGDimensionHeight,
|
||||||
|
CompactValue::ofAuto(),
|
||||||
|
CompactValue::ofUndefined(),
|
||||||
|
CompactValue::of<YGUnitPoint>(7777.77f),
|
||||||
|
CompactValue::of<YGUnitPercent>(-100.0f))
|
||||||
|
|
||||||
|
ACCESSOR_TEST(
|
||||||
|
aspectRatio,
|
||||||
|
YGFloatOptional{},
|
||||||
|
YGFloatOptional{-123.45f},
|
||||||
|
YGFloatOptional{9876.5f},
|
||||||
|
YGFloatOptional{0.0f},
|
||||||
|
YGFloatOptional{});
|
||||||
|
|
||||||
|
} // namespace yoga
|
||||||
|
} // namespace facebook
|
118
yoga/YGNode.cpp
118
yoga/YGNode.cpp
@@ -53,14 +53,14 @@ YGFloatOptional YGNode::getLeadingPosition(
|
|||||||
const float axisSize) const {
|
const float axisSize) const {
|
||||||
if (YGFlexDirectionIsRow(axis)) {
|
if (YGFlexDirectionIsRow(axis)) {
|
||||||
auto leadingPosition = YGComputedEdgeValue(
|
auto leadingPosition = YGComputedEdgeValue(
|
||||||
style_.position, YGEdgeStart, CompactValue::ofUndefined());
|
style_.position(), YGEdgeStart, CompactValue::ofUndefined());
|
||||||
if (!leadingPosition.isUndefined()) {
|
if (!leadingPosition.isUndefined()) {
|
||||||
return YGResolveValue(leadingPosition, axisSize);
|
return YGResolveValue(leadingPosition, axisSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto leadingPosition = YGComputedEdgeValue(
|
auto leadingPosition = YGComputedEdgeValue(
|
||||||
style_.position, leading[axis], CompactValue::ofUndefined());
|
style_.position(), leading[axis], CompactValue::ofUndefined());
|
||||||
|
|
||||||
return leadingPosition.isUndefined()
|
return leadingPosition.isUndefined()
|
||||||
? YGFloatOptional{0}
|
? YGFloatOptional{0}
|
||||||
@@ -72,14 +72,14 @@ YGFloatOptional YGNode::getTrailingPosition(
|
|||||||
const float axisSize) const {
|
const float axisSize) const {
|
||||||
if (YGFlexDirectionIsRow(axis)) {
|
if (YGFlexDirectionIsRow(axis)) {
|
||||||
auto trailingPosition = YGComputedEdgeValue(
|
auto trailingPosition = YGComputedEdgeValue(
|
||||||
style_.position, YGEdgeEnd, CompactValue::ofUndefined());
|
style_.position(), YGEdgeEnd, CompactValue::ofUndefined());
|
||||||
if (!trailingPosition.isUndefined()) {
|
if (!trailingPosition.isUndefined()) {
|
||||||
return YGResolveValue(trailingPosition, axisSize);
|
return YGResolveValue(trailingPosition, axisSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto trailingPosition = YGComputedEdgeValue(
|
auto trailingPosition = YGComputedEdgeValue(
|
||||||
style_.position, trailing[axis], CompactValue::ofUndefined());
|
style_.position(), trailing[axis], CompactValue::ofUndefined());
|
||||||
|
|
||||||
return trailingPosition.isUndefined()
|
return trailingPosition.isUndefined()
|
||||||
? YGFloatOptional{0}
|
? YGFloatOptional{0}
|
||||||
@@ -89,45 +89,47 @@ YGFloatOptional YGNode::getTrailingPosition(
|
|||||||
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) const {
|
bool YGNode::isLeadingPositionDefined(const YGFlexDirection axis) const {
|
||||||
return (YGFlexDirectionIsRow(axis) &&
|
return (YGFlexDirectionIsRow(axis) &&
|
||||||
!YGComputedEdgeValue(
|
!YGComputedEdgeValue(
|
||||||
style_.position, YGEdgeStart, CompactValue::ofUndefined())
|
style_.position(), YGEdgeStart, CompactValue::ofUndefined())
|
||||||
.isUndefined()) ||
|
.isUndefined()) ||
|
||||||
!YGComputedEdgeValue(
|
!YGComputedEdgeValue(
|
||||||
style_.position, leading[axis], CompactValue::ofUndefined())
|
style_.position(), leading[axis], CompactValue::ofUndefined())
|
||||||
.isUndefined();
|
.isUndefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) const {
|
bool YGNode::isTrailingPosDefined(const YGFlexDirection axis) const {
|
||||||
return (YGFlexDirectionIsRow(axis) &&
|
return (YGFlexDirectionIsRow(axis) &&
|
||||||
!YGComputedEdgeValue(
|
!YGComputedEdgeValue(
|
||||||
style_.position, YGEdgeEnd, CompactValue::ofUndefined())
|
style_.position(), YGEdgeEnd, CompactValue::ofUndefined())
|
||||||
.isUndefined()) ||
|
.isUndefined()) ||
|
||||||
!YGComputedEdgeValue(
|
!YGComputedEdgeValue(
|
||||||
style_.position, trailing[axis], CompactValue::ofUndefined())
|
style_.position(), trailing[axis], CompactValue::ofUndefined())
|
||||||
.isUndefined();
|
.isUndefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
YGFloatOptional YGNode::getLeadingMargin(
|
YGFloatOptional YGNode::getLeadingMargin(
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeStart].isUndefined()) {
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
return YGResolveValueMargin(style_.margin[YGEdgeStart], widthSize);
|
!style_.margin()[YGEdgeStart].isUndefined()) {
|
||||||
|
return YGResolveValueMargin(style_.margin()[YGEdgeStart], widthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return YGResolveValueMargin(
|
return YGResolveValueMargin(
|
||||||
YGComputedEdgeValue(style_.margin, leading[axis], CompactValue::ofZero()),
|
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) && !style_.margin[YGEdgeEnd].isUndefined()) {
|
if (YGFlexDirectionIsRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) {
|
||||||
return YGResolveValueMargin(style_.margin[YGEdgeEnd], widthSize);
|
return YGResolveValueMargin(style_.margin()[YGEdgeEnd], widthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return YGResolveValueMargin(
|
return YGResolveValueMargin(
|
||||||
YGComputedEdgeValue(
|
YGComputedEdgeValue(
|
||||||
style_.margin, trailing[axis], CompactValue::ofZero()),
|
style_.margin(), trailing[axis], CompactValue::ofZero()),
|
||||||
widthSize);
|
widthSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +301,7 @@ void YGNode::setPosition(
|
|||||||
const YGDirection directionRespectingRoot =
|
const YGDirection directionRespectingRoot =
|
||||||
owner_ != nullptr ? direction : YGDirectionLTR;
|
owner_ != nullptr ? direction : YGDirectionLTR;
|
||||||
const YGFlexDirection mainAxis =
|
const YGFlexDirection mainAxis =
|
||||||
YGResolveFlexDirection(style_.flexDirection, directionRespectingRoot);
|
YGResolveFlexDirection(style_.flexDirection(), directionRespectingRoot);
|
||||||
const YGFlexDirection crossAxis =
|
const YGFlexDirection crossAxis =
|
||||||
YGFlexDirectionCross(mainAxis, directionRespectingRoot);
|
YGFlexDirectionCross(mainAxis, directionRespectingRoot);
|
||||||
|
|
||||||
@@ -325,27 +327,28 @@ void YGNode::setPosition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNode::marginLeadingValue(const YGFlexDirection axis) const {
|
YGValue YGNode::marginLeadingValue(const YGFlexDirection axis) const {
|
||||||
if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeStart].isUndefined()) {
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
return style_.margin[YGEdgeStart];
|
!style_.margin()[YGEdgeStart].isUndefined()) {
|
||||||
|
return style_.margin()[YGEdgeStart];
|
||||||
} else {
|
} else {
|
||||||
return style_.margin[leading[axis]];
|
return style_.margin()[leading[axis]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNode::marginTrailingValue(const YGFlexDirection axis) const {
|
YGValue YGNode::marginTrailingValue(const YGFlexDirection axis) const {
|
||||||
if (YGFlexDirectionIsRow(axis) && !style_.margin[YGEdgeEnd].isUndefined()) {
|
if (YGFlexDirectionIsRow(axis) && !style_.margin()[YGEdgeEnd].isUndefined()) {
|
||||||
return style_.margin[YGEdgeEnd];
|
return style_.margin()[YGEdgeEnd];
|
||||||
} else {
|
} else {
|
||||||
return style_.margin[trailing[axis]];
|
return style_.margin()[trailing[axis]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNode::resolveFlexBasisPtr() const {
|
YGValue YGNode::resolveFlexBasisPtr() const {
|
||||||
YGValue flexBasis = style_.flexBasis;
|
YGValue flexBasis = style_.flexBasis();
|
||||||
if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) {
|
if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) {
|
||||||
return flexBasis;
|
return flexBasis;
|
||||||
}
|
}
|
||||||
if (!style_.flex.isUndefined() && style_.flex.unwrap() > 0.0f) {
|
if (!style_.flex().isUndefined() && style_.flex().unwrap() > 0.0f) {
|
||||||
return config_->useWebDefaults ? YGValueAuto : YGValueZero;
|
return config_->useWebDefaults ? YGValueAuto : YGValueZero;
|
||||||
}
|
}
|
||||||
return YGValueAuto;
|
return YGValueAuto;
|
||||||
@@ -353,23 +356,23 @@ YGValue YGNode::resolveFlexBasisPtr() const {
|
|||||||
|
|
||||||
void YGNode::resolveDimension() {
|
void YGNode::resolveDimension() {
|
||||||
using namespace yoga;
|
using namespace yoga;
|
||||||
for (int dim = YGDimensionWidth; dim < enums::count<YGDimension>(); dim++) {
|
const YGStyle& style = getStyle();
|
||||||
if (!getStyle().maxDimensions[dim].isUndefined() &&
|
for (auto dim : {YGDimensionWidth, YGDimensionHeight}) {
|
||||||
YGValueEqual(
|
if (!style.maxDimensions()[dim].isUndefined() &&
|
||||||
getStyle().maxDimensions[dim], style_.minDimensions[dim])) {
|
YGValueEqual(style.maxDimensions()[dim], style.minDimensions()[dim])) {
|
||||||
resolvedDimensions_[dim] = style_.maxDimensions[dim];
|
resolvedDimensions_[dim] = style.maxDimensions()[dim];
|
||||||
} else {
|
} else {
|
||||||
resolvedDimensions_[dim] = style_.dimensions[dim];
|
resolvedDimensions_[dim] = style.dimensions()[dim];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
YGDirection YGNode::resolveDirection(const YGDirection ownerDirection) {
|
YGDirection YGNode::resolveDirection(const YGDirection ownerDirection) {
|
||||||
if (style_.direction == YGDirectionInherit) {
|
if (style_.direction() == YGDirectionInherit) {
|
||||||
return ownerDirection > YGDirectionInherit ? ownerDirection
|
return ownerDirection > YGDirectionInherit ? ownerDirection
|
||||||
: YGDirectionLTR;
|
: YGDirectionLTR;
|
||||||
} else {
|
} 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
|
// Root nodes flexGrow should always be 0
|
||||||
if (owner_ == nullptr) {
|
if (owner_ == nullptr) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (!style_.flexGrow.isUndefined()) {
|
if (!style_.flexGrow().isUndefined()) {
|
||||||
return style_.flexGrow.unwrap();
|
return style_.flexGrow().unwrap();
|
||||||
}
|
}
|
||||||
if (!style_.flex.isUndefined() && style_.flex.unwrap() > 0.0f) {
|
if (!style_.flex().isUndefined() && style_.flex().unwrap() > 0.0f) {
|
||||||
return style_.flex.unwrap();
|
return style_.flex().unwrap();
|
||||||
}
|
}
|
||||||
return kDefaultFlexGrow;
|
return kDefaultFlexGrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::resolveFlexShrink() {
|
float YGNode::resolveFlexShrink() const {
|
||||||
if (owner_ == nullptr) {
|
if (owner_ == nullptr) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (!style_.flexShrink.isUndefined()) {
|
if (!style_.flexShrink().isUndefined()) {
|
||||||
return style_.flexShrink.unwrap();
|
return style_.flexShrink().unwrap();
|
||||||
}
|
}
|
||||||
if (!config_->useWebDefaults && !style_.flex.isUndefined() &&
|
if (!config_->useWebDefaults && !style_.flex().isUndefined() &&
|
||||||
style_.flex.unwrap() < 0.0f) {
|
style_.flex().unwrap() < 0.0f) {
|
||||||
return -style_.flex.unwrap();
|
return -style_.flex().unwrap();
|
||||||
}
|
}
|
||||||
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGNode::isNodeFlexible() {
|
bool YGNode::isNodeFlexible() {
|
||||||
return (
|
return (
|
||||||
(style_.positionType == YGPositionTypeRelative) &&
|
(style_.positionType() == YGPositionTypeRelative) &&
|
||||||
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getLeadingBorder(const YGFlexDirection axis) const {
|
float YGNode::getLeadingBorder(const YGFlexDirection axis) const {
|
||||||
YGValue leadingBorder;
|
YGValue leadingBorder;
|
||||||
if (YGFlexDirectionIsRow(axis) && !style_.border[YGEdgeStart].isUndefined()) {
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
leadingBorder = style_.border[YGEdgeStart];
|
!style_.border()[YGEdgeStart].isUndefined()) {
|
||||||
|
leadingBorder = style_.border()[YGEdgeStart];
|
||||||
if (leadingBorder.value >= 0) {
|
if (leadingBorder.value >= 0) {
|
||||||
return leadingBorder.value;
|
return leadingBorder.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
leadingBorder =
|
leadingBorder = YGComputedEdgeValue(
|
||||||
YGComputedEdgeValue(style_.border, leading[axis], CompactValue::ofZero());
|
style_.border(), leading[axis], CompactValue::ofZero());
|
||||||
return YGFloatMax(leadingBorder.value, 0.0f);
|
return YGFloatMax(leadingBorder.value, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const {
|
float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const {
|
||||||
YGValue trailingBorder;
|
YGValue trailingBorder;
|
||||||
if (YGFlexDirectionIsRow(flexDirection) &&
|
if (YGFlexDirectionIsRow(flexDirection) &&
|
||||||
!style_.border[YGEdgeEnd].isUndefined()) {
|
!style_.border()[YGEdgeEnd].isUndefined()) {
|
||||||
trailingBorder = style_.border[YGEdgeEnd];
|
trailingBorder = style_.border()[YGEdgeEnd];
|
||||||
if (trailingBorder.value >= 0.0f) {
|
if (trailingBorder.value >= 0.0f) {
|
||||||
return trailingBorder.value;
|
return trailingBorder.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trailingBorder = YGComputedEdgeValue(
|
trailingBorder = YGComputedEdgeValue(
|
||||||
style_.border, trailing[flexDirection], CompactValue::ofZero());
|
style_.border(), trailing[flexDirection], CompactValue::ofZero());
|
||||||
return YGFloatMax(trailingBorder.value, 0.0f);
|
return YGFloatMax(trailingBorder.value, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,16 +472,16 @@ YGFloatOptional YGNode::getLeadingPadding(
|
|||||||
const YGFlexDirection axis,
|
const YGFlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
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].isUndefined() &&
|
!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(
|
YGComputedEdgeValue(
|
||||||
style_.padding, leading[axis], CompactValue::ofZero()),
|
style_.padding(), leading[axis], CompactValue::ofZero()),
|
||||||
widthSize);
|
widthSize);
|
||||||
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
|
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
|
||||||
}
|
}
|
||||||
@@ -486,14 +490,14 @@ YGFloatOptional YGNode::getTrailingPadding(
|
|||||||
const YGFlexDirection axis,
|
const YGFlexDirection axis,
|
||||||
const float widthSize) const {
|
const float widthSize) const {
|
||||||
const YGFloatOptional paddingEdgeEnd =
|
const YGFloatOptional paddingEdgeEnd =
|
||||||
YGResolveValue(style_.padding[YGEdgeEnd], widthSize);
|
YGResolveValue(style_.padding()[YGEdgeEnd], widthSize);
|
||||||
if (YGFlexDirectionIsRow(axis) && paddingEdgeEnd >= YGFloatOptional{0.0f}) {
|
if (YGFlexDirectionIsRow(axis) && paddingEdgeEnd >= YGFloatOptional{0.0f}) {
|
||||||
return paddingEdgeEnd;
|
return paddingEdgeEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
YGFloatOptional resolvedValue = YGResolveValue(
|
YGFloatOptional resolvedValue = YGResolveValue(
|
||||||
YGComputedEdgeValue(
|
YGComputedEdgeValue(
|
||||||
style_.padding, trailing[axis], CompactValue::ofZero()),
|
style_.padding(), trailing[axis], CompactValue::ofZero()),
|
||||||
widthSize);
|
widthSize);
|
||||||
|
|
||||||
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
|
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
|
||||||
@@ -580,8 +584,8 @@ void YGNode::reset() {
|
|||||||
auto config = getConfig();
|
auto config = getConfig();
|
||||||
*this = YGNode{};
|
*this = YGNode{};
|
||||||
if (config->useWebDefaults) {
|
if (config->useWebDefaults) {
|
||||||
setStyleFlexDirection(YGFlexDirectionRow);
|
style_.flexDirection() = YGFlexDirectionRow;
|
||||||
setStyleAlignContent(YGAlignStretch);
|
style_.alignContent() = YGAlignStretch;
|
||||||
}
|
}
|
||||||
setConfig(config);
|
setConfig(config);
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "CompactValue.h"
|
||||||
#include "YGConfig.h"
|
#include "YGConfig.h"
|
||||||
#include "YGLayout.h"
|
#include "YGLayout.h"
|
||||||
#include "YGStyle.h"
|
#include "YGStyle.h"
|
||||||
@@ -62,6 +63,8 @@ private:
|
|||||||
// DO NOT CHANGE THE VISIBILITY OF THIS METHOD!
|
// DO NOT CHANGE THE VISIBILITY OF THIS METHOD!
|
||||||
YGNode& operator=(YGNode&&) = default;
|
YGNode& operator=(YGNode&&) = default;
|
||||||
|
|
||||||
|
using CompactValue = facebook::yoga::detail::CompactValue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
YGNode()
|
YGNode()
|
||||||
: hasNewLayout_{true},
|
: hasNewLayout_{true},
|
||||||
@@ -210,14 +213,6 @@ public:
|
|||||||
|
|
||||||
void setNodeType(YGNodeType nodeType) { nodeType_ = nodeType; }
|
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(YGMeasureFunc measureFunc);
|
||||||
void setMeasureFunc(MeasureWithContextFn);
|
void setMeasureFunc(MeasureWithContextFn);
|
||||||
void setMeasureFunc(std::nullptr_t) {
|
void setMeasureFunc(std::nullptr_t) {
|
||||||
@@ -296,8 +291,8 @@ public:
|
|||||||
|
|
||||||
void cloneChildrenIfNeeded(void*);
|
void cloneChildrenIfNeeded(void*);
|
||||||
void markDirtyAndPropogate();
|
void markDirtyAndPropogate();
|
||||||
float resolveFlexGrow();
|
float resolveFlexGrow() const;
|
||||||
float resolveFlexShrink();
|
float resolveFlexShrink() const;
|
||||||
bool isNodeFlexible();
|
bool isNodeFlexible();
|
||||||
bool didUseLegacyFlag();
|
bool didUseLegacyFlag();
|
||||||
bool isLayoutTreeEqualToNode(const YGNode& node) const;
|
bool isLayoutTreeEqualToNode(const YGNode& node) const;
|
||||||
|
@@ -132,85 +132,92 @@ void YGNodeToString(
|
|||||||
|
|
||||||
if (options & YGPrintOptionsStyle) {
|
if (options & YGPrintOptionsStyle) {
|
||||||
appendFormatedString(str, "style=\"");
|
appendFormatedString(str, "style=\"");
|
||||||
if (node->getStyle().flexDirection != YGNode().getStyle().flexDirection) {
|
if (node->getStyle().flexDirection() !=
|
||||||
|
YGNode().getStyle().flexDirection()) {
|
||||||
appendFormatedString(
|
appendFormatedString(
|
||||||
str,
|
str,
|
||||||
"flex-direction: %s; ",
|
"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(
|
appendFormatedString(
|
||||||
str,
|
str,
|
||||||
"justify-content: %s; ",
|
"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(
|
appendFormatedString(
|
||||||
str,
|
str,
|
||||||
"align-items: %s; ",
|
"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(
|
appendFormatedString(
|
||||||
str,
|
str,
|
||||||
"align-content: %s; ",
|
"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(
|
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(
|
appendFloatOptionalIfDefined(
|
||||||
str, "flex-shrink", node->getStyle().flexShrink);
|
str, "flex-shrink", node->getStyle().flexShrink());
|
||||||
appendNumberIfNotAuto(str, "flex-basis", node->getStyle().flexBasis);
|
appendNumberIfNotAuto(str, "flex-basis", node->getStyle().flexBasis());
|
||||||
appendFloatOptionalIfDefined(str, "flex", node->getStyle().flex);
|
appendFloatOptionalIfDefined(str, "flex", node->getStyle().flex());
|
||||||
|
|
||||||
if (node->getStyle().flexWrap != YGNode().getStyle().flexWrap) {
|
if (node->getStyle().flexWrap() != YGNode().getStyle().flexWrap()) {
|
||||||
appendFormatedString(
|
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(
|
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(
|
appendFormatedString(
|
||||||
str, "display: %s; ", YGDisplayToString(node->getStyle().display));
|
str, "display: %s; ", YGDisplayToString(node->getStyle().display()));
|
||||||
}
|
}
|
||||||
appendEdges(str, "margin", node->getStyle().margin);
|
appendEdges(str, "margin", node->getStyle().margin());
|
||||||
appendEdges(str, "padding", node->getStyle().padding);
|
appendEdges(str, "padding", node->getStyle().padding());
|
||||||
appendEdges(str, "border", node->getStyle().border);
|
appendEdges(str, "border", node->getStyle().border());
|
||||||
|
|
||||||
appendNumberIfNotAuto(
|
appendNumberIfNotAuto(
|
||||||
str, "width", node->getStyle().dimensions[YGDimensionWidth]);
|
str, "width", node->getStyle().dimensions()[YGDimensionWidth]);
|
||||||
appendNumberIfNotAuto(
|
appendNumberIfNotAuto(
|
||||||
str, "height", node->getStyle().dimensions[YGDimensionHeight]);
|
str, "height", node->getStyle().dimensions()[YGDimensionHeight]);
|
||||||
appendNumberIfNotAuto(
|
appendNumberIfNotAuto(
|
||||||
str, "max-width", node->getStyle().maxDimensions[YGDimensionWidth]);
|
str, "max-width", node->getStyle().maxDimensions()[YGDimensionWidth]);
|
||||||
appendNumberIfNotAuto(
|
appendNumberIfNotAuto(
|
||||||
str, "max-height", node->getStyle().maxDimensions[YGDimensionHeight]);
|
str, "max-height", node->getStyle().maxDimensions()[YGDimensionHeight]);
|
||||||
appendNumberIfNotAuto(
|
appendNumberIfNotAuto(
|
||||||
str, "min-width", node->getStyle().minDimensions[YGDimensionWidth]);
|
str, "min-width", node->getStyle().minDimensions()[YGDimensionWidth]);
|
||||||
appendNumberIfNotAuto(
|
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(
|
appendFormatedString(
|
||||||
str,
|
str,
|
||||||
"position: %s; ",
|
"position: %s; ",
|
||||||
YGPositionTypeToString(node->getStyle().positionType));
|
YGPositionTypeToString(node->getStyle().positionType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
appendEdgeIfNotUndefined(
|
appendEdgeIfNotUndefined(
|
||||||
str, "left", node->getStyle().position, YGEdgeLeft);
|
str, "left", node->getStyle().position(), YGEdgeLeft);
|
||||||
appendEdgeIfNotUndefined(
|
appendEdgeIfNotUndefined(
|
||||||
str, "right", node->getStyle().position, YGEdgeRight);
|
str, "right", node->getStyle().position(), YGEdgeRight);
|
||||||
appendEdgeIfNotUndefined(str, "top", node->getStyle().position, YGEdgeTop);
|
|
||||||
appendEdgeIfNotUndefined(
|
appendEdgeIfNotUndefined(
|
||||||
str, "bottom", node->getStyle().position, YGEdgeBottom);
|
str, "top", node->getStyle().position(), YGEdgeTop);
|
||||||
|
appendEdgeIfNotUndefined(
|
||||||
|
str, "bottom", node->getStyle().position(), YGEdgeBottom);
|
||||||
appendFormatedString(str, "\" ");
|
appendFormatedString(str, "\" ");
|
||||||
|
|
||||||
if (node->hasMeasureFunc()) {
|
if (node->hasMeasureFunc()) {
|
||||||
|
@@ -9,43 +9,46 @@
|
|||||||
|
|
||||||
// Yoga specific properties, not compatible with flexbox specification
|
// Yoga specific properties, not compatible with flexbox specification
|
||||||
bool operator==(const YGStyle& lhs, const YGStyle& rhs) {
|
bool operator==(const YGStyle& lhs, const YGStyle& rhs) {
|
||||||
bool areNonFloatValuesEqual = lhs.direction == rhs.direction &&
|
bool areNonFloatValuesEqual = lhs.direction() == rhs.direction() &&
|
||||||
lhs.flexDirection == rhs.flexDirection &&
|
lhs.flexDirection() == rhs.flexDirection() &&
|
||||||
lhs.justifyContent == rhs.justifyContent &&
|
lhs.justifyContent() == rhs.justifyContent() &&
|
||||||
lhs.alignContent == rhs.alignContent &&
|
lhs.alignContent() == rhs.alignContent() &&
|
||||||
lhs.alignItems == rhs.alignItems && lhs.alignSelf == rhs.alignSelf &&
|
lhs.alignItems() == rhs.alignItems() &&
|
||||||
lhs.positionType == rhs.positionType && lhs.flexWrap == rhs.flexWrap &&
|
lhs.alignSelf() == rhs.alignSelf() &&
|
||||||
lhs.overflow == rhs.overflow && lhs.display == rhs.display &&
|
lhs.positionType() == rhs.positionType() &&
|
||||||
YGValueEqual(lhs.flexBasis, rhs.flexBasis) && lhs.margin == rhs.margin &&
|
lhs.flexWrap() == rhs.flexWrap() && lhs.overflow() == rhs.overflow() &&
|
||||||
lhs.position == rhs.position && lhs.padding == rhs.padding &&
|
lhs.display() == rhs.display() &&
|
||||||
lhs.border == rhs.border && lhs.dimensions == rhs.dimensions &&
|
YGValueEqual(lhs.flexBasis(), rhs.flexBasis()) &&
|
||||||
lhs.minDimensions == rhs.minDimensions &&
|
lhs.margin() == rhs.margin() && lhs.position() == rhs.position() &&
|
||||||
lhs.maxDimensions == rhs.maxDimensions;
|
lhs.padding() == rhs.padding() && lhs.border() == rhs.border() &&
|
||||||
|
lhs.dimensions() == rhs.dimensions() &&
|
||||||
|
lhs.minDimensions() == rhs.minDimensions() &&
|
||||||
|
lhs.maxDimensions() == rhs.maxDimensions();
|
||||||
|
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
lhs.flex.isUndefined() == rhs.flex.isUndefined();
|
lhs.flex().isUndefined() == rhs.flex().isUndefined();
|
||||||
if (areNonFloatValuesEqual && !lhs.flex.isUndefined() &&
|
if (areNonFloatValuesEqual && !lhs.flex().isUndefined() &&
|
||||||
!rhs.flex.isUndefined()) {
|
!rhs.flex().isUndefined()) {
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual && lhs.flex == rhs.flex;
|
areNonFloatValuesEqual = areNonFloatValuesEqual && lhs.flex() == rhs.flex();
|
||||||
}
|
}
|
||||||
|
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
lhs.flexGrow.isUndefined() == rhs.flexGrow.isUndefined();
|
lhs.flexGrow().isUndefined() == rhs.flexGrow().isUndefined();
|
||||||
if (areNonFloatValuesEqual && !lhs.flexGrow.isUndefined()) {
|
if (areNonFloatValuesEqual && !lhs.flexGrow().isUndefined()) {
|
||||||
areNonFloatValuesEqual =
|
areNonFloatValuesEqual =
|
||||||
areNonFloatValuesEqual && lhs.flexGrow == rhs.flexGrow;
|
areNonFloatValuesEqual && lhs.flexGrow() == rhs.flexGrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
lhs.flexShrink.isUndefined() == rhs.flexShrink.isUndefined();
|
lhs.flexShrink().isUndefined() == rhs.flexShrink().isUndefined();
|
||||||
if (areNonFloatValuesEqual && !rhs.flexShrink.isUndefined()) {
|
if (areNonFloatValuesEqual && !rhs.flexShrink().isUndefined()) {
|
||||||
areNonFloatValuesEqual =
|
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 =
|
||||||
areNonFloatValuesEqual && lhs.aspectRatio == rhs.aspectRatio;
|
areNonFloatValuesEqual && lhs.aspectRatio() == rhs.aspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
return areNonFloatValuesEqual;
|
return areNonFloatValuesEqual;
|
||||||
|
182
yoga/YGStyle.h
182
yoga/YGStyle.h
@@ -20,8 +20,14 @@
|
|||||||
#define BITFIELD_ENUM_SIZED(num)
|
#define BITFIELD_ENUM_SIZED(num)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct YGStyle {
|
#define BITFIELD_ACCESSORS(FIELD) \
|
||||||
private:
|
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;
|
using CompactValue = facebook::yoga::detail::CompactValue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -29,47 +35,149 @@ public:
|
|||||||
using Edges =
|
using Edges =
|
||||||
facebook::yoga::detail::Values<facebook::yoga::enums::count<YGEdge>()>;
|
facebook::yoga::detail::Values<facebook::yoga::enums::count<YGEdge>()>;
|
||||||
|
|
||||||
/* Some platforms don't support enum bitfields,
|
template <typename T>
|
||||||
so please use BITFIELD_ENUM_SIZED(BITS_COUNT) */
|
struct BitfieldRef {
|
||||||
YGDirection direction BITFIELD_ENUM_SIZED(2);
|
YGStyle& style;
|
||||||
YGFlexDirection flexDirection BITFIELD_ENUM_SIZED(2);
|
T (YGStyle::*get)() const;
|
||||||
YGJustify justifyContent BITFIELD_ENUM_SIZED(3);
|
void (YGStyle::*set)(T);
|
||||||
YGAlign alignContent BITFIELD_ENUM_SIZED(3);
|
|
||||||
YGAlign alignItems BITFIELD_ENUM_SIZED(3);
|
operator T() const { return (style.*get)(); }
|
||||||
YGAlign alignSelf BITFIELD_ENUM_SIZED(3);
|
BitfieldRef<T>& operator=(T x) {
|
||||||
YGPositionType positionType BITFIELD_ENUM_SIZED(1);
|
(style.*set)(x);
|
||||||
YGWrap flexWrap BITFIELD_ENUM_SIZED(2);
|
return *this;
|
||||||
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 = {};
|
|
||||||
|
|
||||||
YGStyle()
|
YGStyle()
|
||||||
: direction(YGDirectionInherit),
|
: direction_(YGDirectionInherit),
|
||||||
flexDirection(YGFlexDirectionColumn),
|
flexDirection_(YGFlexDirectionColumn),
|
||||||
justifyContent(YGJustifyFlexStart),
|
justifyContent_(YGJustifyFlexStart),
|
||||||
alignContent(YGAlignFlexStart),
|
alignContent_(YGAlignFlexStart),
|
||||||
alignItems(YGAlignStretch),
|
alignItems_(YGAlignStretch),
|
||||||
alignSelf(YGAlignAuto),
|
alignSelf_(YGAlignAuto),
|
||||||
positionType(YGPositionTypeRelative),
|
positionType_(YGPositionTypeRelative),
|
||||||
flexWrap(YGWrapNoWrap),
|
flexWrap_(YGWrapNoWrap),
|
||||||
overflow(YGOverflowVisible),
|
overflow_(YGOverflowVisible),
|
||||||
display(YGDisplayFlex) {}
|
display_(YGDisplayFlex) {}
|
||||||
~YGStyle() = default;
|
~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);
|
bool operator==(const YGStyle& lhs, const YGStyle& rhs);
|
||||||
inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
|
inline bool operator!=(const YGStyle& lhs, const YGStyle& rhs) {
|
||||||
return !(lhs == rhs);
|
return !(lhs == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef BITFIELD_ENUM_SIZED
|
||||||
|
#undef BITFIELD_ACCESSORS
|
||||||
|
#undef BITFIELD_REF
|
||||||
|
377
yoga/Yoga.cpp
377
yoga/Yoga.cpp
@@ -224,8 +224,8 @@ WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
|
|||||||
gNodeInstanceCount++;
|
gNodeInstanceCount++;
|
||||||
|
|
||||||
if (config->useWebDefaults) {
|
if (config->useWebDefaults) {
|
||||||
node->setStyleFlexDirection(YGFlexDirectionRow);
|
node->getStyle().flexDirection() = YGFlexDirectionRow;
|
||||||
node->setStyleAlignContent(YGAlignStretch);
|
node->getStyle().alignContent() = YGAlignStretch;
|
||||||
}
|
}
|
||||||
node->setConfig(config);
|
node->setConfig(config);
|
||||||
return node;
|
return node;
|
||||||
@@ -522,61 +522,69 @@ void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetFlexGrow(const YGNodeRef node) {
|
float YGNodeStyleGetFlexGrow(const YGNodeRef n) {
|
||||||
return node->getStyle().flexGrow.isUndefined()
|
const YGNode* node = n;
|
||||||
|
return node->getStyle().flexGrow().isUndefined()
|
||||||
? kDefaultFlexGrow
|
? kDefaultFlexGrow
|
||||||
: node->getStyle().flexGrow.unwrap();
|
: node->getStyle().flexGrow().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
float YGNodeStyleGetFlexShrink(const YGNodeRef n) {
|
||||||
return node->getStyle().flexShrink.isUndefined()
|
const YGNode* node = n;
|
||||||
|
return node->getStyle().flexShrink().isUndefined()
|
||||||
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
|
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
|
||||||
: kDefaultFlexShrink)
|
: kDefaultFlexShrink)
|
||||||
: node->getStyle().flexShrink.unwrap();
|
: node->getStyle().flexShrink().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <typename T, typename NeedsUpdate, typename Update>
|
template <typename T, typename NeedsUpdate, typename Update>
|
||||||
void updateNodeProp(
|
void updateStyle(
|
||||||
YGNode* node,
|
YGNode* node,
|
||||||
T value,
|
T value,
|
||||||
NeedsUpdate&& needsUpdate,
|
NeedsUpdate&& needsUpdate,
|
||||||
Update&& update) {
|
Update&& update) {
|
||||||
if (needsUpdate(node, value)) {
|
if (needsUpdate(node->getStyle(), value)) {
|
||||||
update(node, value);
|
update(node->getStyle(), value);
|
||||||
node->markDirtyAndPropogate();
|
node->markDirtyAndPropogate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, T YGStyle::*Prop>
|
template <typename T, YGStyle::BitfieldRef<T> (YGStyle::*Prop)()>
|
||||||
void updateStyleProp(YGNode* node, T value) {
|
void updateStyle(YGNode* node, T value) {
|
||||||
updateNodeProp(
|
updateStyle(
|
||||||
node,
|
node,
|
||||||
value,
|
value,
|
||||||
[](YGNode* n, T x) { return (n->getStyle().*Prop) != x; },
|
[](YGStyle& s, T x) { return (s.*Prop)() != x; },
|
||||||
[](YGNode* n, T x) { (n->getStyle().*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) {
|
void updateIndexedStyleProp(YGNode* node, Idx idx, detail::CompactValue value) {
|
||||||
updateNodeProp(
|
using detail::CompactValue;
|
||||||
|
updateStyle(
|
||||||
node,
|
node,
|
||||||
value,
|
value,
|
||||||
[idx](YGNode* n, detail::CompactValue x) {
|
[idx](YGStyle& s, CompactValue x) { return (s.*Prop)()[idx] != x; },
|
||||||
return (n->getStyle().*Prop)[idx] != x;
|
[idx](YGStyle& s, CompactValue x) { (s.*Prop)()[idx] = x; });
|
||||||
},
|
|
||||||
[idx](YGNode* n, detail::CompactValue x) {
|
|
||||||
(n->getStyle().*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) {
|
void updateEdgeProp(YGNode* node, YGEdge edge, detail::CompactValue value) {
|
||||||
updateIndexedStyleProp<YGEdge, Prop>(node, edge, value);
|
updateIndexedStyleProp<YGEdge, Prop>(node, edge, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <detail::Values<enums::count<YGDimension>()> YGStyle::*Prop>
|
template <YGStyle::Dimensions& (YGStyle::*Prop)()>
|
||||||
void updateDimensionProp(
|
void updateDimensionProp(
|
||||||
YGNode* node,
|
YGNode* node,
|
||||||
YGDimension dimension,
|
YGDimension dimension,
|
||||||
@@ -584,141 +592,127 @@ void updateDimensionProp(
|
|||||||
updateIndexedStyleProp<YGDimension, Prop>(node, dimension, value);
|
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
|
} // namespace
|
||||||
|
|
||||||
void YGNodeStyleSetDirection(const YGNodeRef node, const YGDirection value) {
|
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) {
|
YGDirection YGNodeStyleGetDirection(const YGNodeRef node) {
|
||||||
return node->getStyle().direction;
|
return node->getStyle().direction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexDirection(
|
void YGNodeStyleSetFlexDirection(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGFlexDirection flexDirection) {
|
const YGFlexDirection flexDirection) {
|
||||||
YG_UPDATE_STYLE_PROP_BITFIELD(flexDirection, node, flexDirection);
|
updateStyle<YGFlexDirection, &YGStyle::flexDirection>(node, flexDirection);
|
||||||
}
|
}
|
||||||
YGFlexDirection YGNodeStyleGetFlexDirection(const YGNodeRef node) {
|
YGFlexDirection YGNodeStyleGetFlexDirection(const YGNodeRef node) {
|
||||||
return node->getStyle().flexDirection;
|
return node->getStyle().flexDirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetJustifyContent(
|
void YGNodeStyleSetJustifyContent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGJustify justifyContent) {
|
const YGJustify justifyContent) {
|
||||||
YG_UPDATE_STYLE_PROP_BITFIELD(justifyContent, node, justifyContent);
|
updateStyle<YGJustify, &YGStyle::justifyContent>(node, justifyContent);
|
||||||
}
|
}
|
||||||
YGJustify YGNodeStyleGetJustifyContent(const YGNodeRef node) {
|
YGJustify YGNodeStyleGetJustifyContent(const YGNodeRef node) {
|
||||||
return node->getStyle().justifyContent;
|
return node->getStyle().justifyContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetAlignContent(
|
void YGNodeStyleSetAlignContent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGAlign alignContent) {
|
const YGAlign alignContent) {
|
||||||
YG_UPDATE_STYLE_PROP_BITFIELD(alignContent, node, alignContent);
|
updateStyle<YGAlign, &YGStyle::alignContent>(node, alignContent);
|
||||||
}
|
}
|
||||||
YGAlign YGNodeStyleGetAlignContent(const YGNodeRef node) {
|
YGAlign YGNodeStyleGetAlignContent(const YGNodeRef node) {
|
||||||
return node->getStyle().alignContent;
|
return node->getStyle().alignContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetAlignItems(const YGNodeRef node, const YGAlign alignItems) {
|
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) {
|
YGAlign YGNodeStyleGetAlignItems(const YGNodeRef node) {
|
||||||
return node->getStyle().alignItems;
|
return node->getStyle().alignItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetAlignSelf(const YGNodeRef node, const YGAlign alignSelf) {
|
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) {
|
YGAlign YGNodeStyleGetAlignSelf(const YGNodeRef node) {
|
||||||
return node->getStyle().alignSelf;
|
return node->getStyle().alignSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetPositionType(
|
void YGNodeStyleSetPositionType(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGPositionType positionType) {
|
const YGPositionType positionType) {
|
||||||
YG_UPDATE_STYLE_PROP_BITFIELD(positionType, node, positionType);
|
updateStyle<YGPositionType, &YGStyle::positionType>(node, positionType);
|
||||||
}
|
}
|
||||||
YGPositionType YGNodeStyleGetPositionType(const YGNodeRef node) {
|
YGPositionType YGNodeStyleGetPositionType(const YGNodeRef node) {
|
||||||
return node->getStyle().positionType;
|
return node->getStyle().positionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) {
|
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) {
|
YGWrap YGNodeStyleGetFlexWrap(const YGNodeRef node) {
|
||||||
return node->getStyle().flexWrap;
|
return node->getStyle().flexWrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetOverflow(const YGNodeRef node, const YGOverflow overflow) {
|
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) {
|
YGOverflow YGNodeStyleGetOverflow(const YGNodeRef node) {
|
||||||
return node->getStyle().overflow;
|
return node->getStyle().overflow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetDisplay(const YGNodeRef node, const YGDisplay display) {
|
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) {
|
YGDisplay YGNodeStyleGetDisplay(const YGNodeRef node) {
|
||||||
return node->getStyle().display;
|
return node->getStyle().display();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
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.
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
float YGNodeStyleGetFlex(const YGNodeRef node) {
|
float YGNodeStyleGetFlex(const YGNodeRef node) {
|
||||||
return node->getStyle().flex.isUndefined() ? YGUndefined
|
const auto& style = node->getStyle();
|
||||||
: node->getStyle().flex.unwrap();
|
return style.flex().isUndefined() ? YGUndefined : style.flex().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) {
|
void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) {
|
||||||
updateStyleProp<YGFloatOptional, &YGStyle::flexGrow>(
|
updateStyle<YGFloatOptional, &YGStyle::flexGrow>(
|
||||||
node, YGFloatOptional{flexGrow});
|
node, YGFloatOptional{flexGrow});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) {
|
void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) {
|
||||||
updateStyleProp<YGFloatOptional, &YGStyle::flexShrink>(
|
updateStyle<YGFloatOptional, &YGStyle::flexShrink>(
|
||||||
node, YGFloatOptional{flexShrink});
|
node, YGFloatOptional{flexShrink});
|
||||||
}
|
}
|
||||||
|
|
||||||
YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) {
|
YGValue YGNodeStyleGetFlexBasis(const YGNodeRef node) {
|
||||||
YGValue flexBasis = node->getStyle().flexBasis;
|
return static_cast<const YGNode*>(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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
void YGNodeStyleSetFlexBasis(const YGNodeRef node, const float flexBasis) {
|
||||||
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
|
auto value = detail::CompactValue::ofMaybe<YGUnitPoint>(flexBasis);
|
||||||
updateStyleProp<detail::CompactValue, &YGStyle::flexBasis>(node, value);
|
updateStyle<detail::CompactValue, &YGStyle::flexBasis>(node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexBasisPercent(
|
void YGNodeStyleSetFlexBasisPercent(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float flexBasisPercent) {
|
const float flexBasisPercent) {
|
||||||
auto value = detail::CompactValue::ofMaybe<YGUnitPercent>(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) {
|
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
||||||
updateStyleProp<detail::CompactValue, &YGStyle::flexBasis>(
|
updateStyle<detail::CompactValue, &YGStyle::flexBasis>(
|
||||||
node, detail::CompactValue::ofAuto());
|
node, detail::CompactValue::ofAuto());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -731,7 +725,7 @@ void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
|
|||||||
updateEdgeProp<&YGStyle::position>(node, edge, value);
|
updateEdgeProp<&YGStyle::position>(node, edge, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetPosition(YGNodeRef node, YGEdge edge) {
|
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) {
|
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());
|
updateEdgeProp<&YGStyle::margin>(node, edge, detail::CompactValue::ofAuto());
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetMargin(YGNodeRef node, YGEdge edge) {
|
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) {
|
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);
|
updateEdgeProp<&YGStyle::padding>(node, edge, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetPadding(YGNodeRef node, YGEdge edge) {
|
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.
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
@@ -771,14 +765,14 @@ void YGNodeStyleSetBorder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
|
float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
|
||||||
if (node->getStyle().border[edge].isUndefined() ||
|
const auto& style = node->getStyle();
|
||||||
node->getStyle().border[edge].isAuto()) {
|
if (style.border()[edge].isUndefined() || style.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;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto border = (YGValue) node->getStyle().border[edge];
|
auto border = (YGValue) style.border()[edge];
|
||||||
return border.value;
|
return border.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -786,13 +780,13 @@ float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
|
|||||||
|
|
||||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
float YGNodeStyleGetAspectRatio(const YGNodeRef node) {
|
float YGNodeStyleGetAspectRatio(const YGNodeRef node) {
|
||||||
const YGFloatOptional op = node->getStyle().aspectRatio;
|
const YGFloatOptional op = node->getStyle().aspectRatio();
|
||||||
return op.isUndefined() ? YGUndefined : op.unwrap();
|
return op.isUndefined() ? YGUndefined : op.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
|
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
|
||||||
updateStyleProp<YGFloatOptional, &YGStyle::aspectRatio>(
|
updateStyle<YGFloatOptional, &YGStyle::aspectRatio>(
|
||||||
node, YGFloatOptional{aspectRatio});
|
node, YGFloatOptional{aspectRatio});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -809,7 +803,9 @@ void YGNodeStyleSetWidthAuto(YGNodeRef node) {
|
|||||||
node, YGDimensionWidth, detail::CompactValue::ofAuto());
|
node, YGDimensionWidth, detail::CompactValue::ofAuto());
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetWidth(YGNodeRef node) {
|
YGValue YGNodeStyleGetWidth(YGNodeRef node) {
|
||||||
return node->getStyle().dimensions[YGDimensionWidth];
|
return static_cast<const YGNode*>(node)
|
||||||
|
->getStyle()
|
||||||
|
.dimensions()[YGDimensionWidth];
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
void YGNodeStyleSetHeight(YGNodeRef node, float points) {
|
||||||
@@ -825,7 +821,9 @@ void YGNodeStyleSetHeightAuto(YGNodeRef node) {
|
|||||||
node, YGDimensionHeight, detail::CompactValue::ofAuto());
|
node, YGDimensionHeight, detail::CompactValue::ofAuto());
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetHeight(YGNodeRef node) {
|
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) {
|
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);
|
updateDimensionProp<&YGStyle::minDimensions>(node, YGDimensionWidth, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetMinWidth(const YGNodeRef node) {
|
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) {
|
void YGNodeStyleSetMinHeight(const YGNodeRef node, const float minHeight) {
|
||||||
@@ -851,7 +851,9 @@ void YGNodeStyleSetMinHeightPercent(
|
|||||||
updateDimensionProp<&YGStyle::minDimensions>(node, YGDimensionHeight, value);
|
updateDimensionProp<&YGStyle::minDimensions>(node, YGDimensionHeight, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetMinHeight(const YGNodeRef node) {
|
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) {
|
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);
|
updateDimensionProp<&YGStyle::maxDimensions>(node, YGDimensionWidth, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetMaxWidth(const YGNodeRef node) {
|
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) {
|
void YGNodeStyleSetMaxHeight(const YGNodeRef node, const float maxHeight) {
|
||||||
@@ -877,7 +881,9 @@ void YGNodeStyleSetMaxHeightPercent(
|
|||||||
updateDimensionProp<&YGStyle::maxDimensions>(node, YGDimensionHeight, value);
|
updateDimensionProp<&YGStyle::maxDimensions>(node, YGDimensionHeight, value);
|
||||||
}
|
}
|
||||||
YGValue YGNodeStyleGetMaxHeight(const YGNodeRef node) {
|
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) \
|
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
|
||||||
@@ -983,14 +989,12 @@ static inline float YGNodePaddingAndBorderForAxis(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline YGAlign YGNodeAlignItem(
|
static inline YGAlign YGNodeAlignItem(const YGNode* node, const YGNode* child) {
|
||||||
const YGNodeRef node,
|
const YGAlign align = child->getStyle().alignSelf() == YGAlignAuto
|
||||||
const YGNodeRef child) {
|
? node->getStyle().alignItems()
|
||||||
const YGAlign align = child->getStyle().alignSelf == YGAlignAuto
|
: child->getStyle().alignSelf();
|
||||||
? node->getStyle().alignItems
|
|
||||||
: child->getStyle().alignSelf;
|
|
||||||
if (align == YGAlignBaseline &&
|
if (align == YGAlignBaseline &&
|
||||||
YGFlexDirectionIsColumn(node->getStyle().flexDirection)) {
|
YGFlexDirectionIsColumn(node->getStyle().flexDirection())) {
|
||||||
return YGAlignFlexStart;
|
return YGAlignFlexStart;
|
||||||
}
|
}
|
||||||
return align;
|
return align;
|
||||||
@@ -1018,7 +1022,7 @@ static float YGBaseline(const YGNodeRef node, void* layoutContext) {
|
|||||||
if (child->getLineIndex() > 0) {
|
if (child->getLineIndex() > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (child->getStyle().positionType == YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (YGNodeAlignItem(node, child) == YGAlignBaseline ||
|
if (YGNodeAlignItem(node, child) == YGAlignBaseline ||
|
||||||
@@ -1041,17 +1045,17 @@ static float YGBaseline(const YGNodeRef node, void* layoutContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool YGIsBaselineLayout(const YGNodeRef node) {
|
static bool YGIsBaselineLayout(const YGNodeRef node) {
|
||||||
if (YGFlexDirectionIsColumn(node->getStyle().flexDirection)) {
|
if (YGFlexDirectionIsColumn(node->getStyle().flexDirection())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (node->getStyle().alignItems == YGAlignBaseline) {
|
if (node->getStyle().alignItems() == YGAlignBaseline) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const uint32_t childCount = YGNodeGetChildCount(node);
|
const uint32_t childCount = YGNodeGetChildCount(node);
|
||||||
for (uint32_t i = 0; i < childCount; i++) {
|
for (uint32_t i = 0; i < childCount; i++) {
|
||||||
const YGNodeRef child = YGNodeGetChild(node, i);
|
const YGNodeRef child = YGNodeGetChild(node, i);
|
||||||
if (child->getStyle().positionType == YGPositionTypeRelative &&
|
if (child->getStyle().positionType() == YGPositionTypeRelative &&
|
||||||
child->getStyle().alignSelf == YGAlignBaseline) {
|
child->getStyle().alignSelf() == YGAlignBaseline) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1103,14 +1107,14 @@ static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
|
|||||||
|
|
||||||
if (YGFlexDirectionIsColumn(axis)) {
|
if (YGFlexDirectionIsColumn(axis)) {
|
||||||
min = YGResolveValue(
|
min = YGResolveValue(
|
||||||
node->getStyle().minDimensions[YGDimensionHeight], axisSize);
|
node->getStyle().minDimensions()[YGDimensionHeight], axisSize);
|
||||||
max = YGResolveValue(
|
max = YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionHeight], axisSize);
|
node->getStyle().maxDimensions()[YGDimensionHeight], axisSize);
|
||||||
} else if (YGFlexDirectionIsRow(axis)) {
|
} else if (YGFlexDirectionIsRow(axis)) {
|
||||||
min = YGResolveValue(
|
min = YGResolveValue(
|
||||||
node->getStyle().minDimensions[YGDimensionWidth], axisSize);
|
node->getStyle().minDimensions()[YGDimensionWidth], axisSize);
|
||||||
max = YGResolveValue(
|
max = YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionWidth], axisSize);
|
node->getStyle().maxDimensions()[YGDimensionWidth], axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max >= YGFloatOptional{0} && value > max) {
|
if (max >= YGFloatOptional{0} && value > max) {
|
||||||
@@ -1158,7 +1162,8 @@ static void YGConstrainMaxSizeForMode(
|
|||||||
YGMeasureMode* mode,
|
YGMeasureMode* mode,
|
||||||
float* size) {
|
float* size) {
|
||||||
const YGFloatOptional maxSize =
|
const YGFloatOptional maxSize =
|
||||||
YGResolveValue(node->getStyle().maxDimensions[dim[axis]], ownerAxisSize) +
|
YGResolveValue(
|
||||||
|
node->getStyle().maxDimensions()[dim[axis]], ownerAxisSize) +
|
||||||
YGFloatOptional(node->getMarginForAxis(axis, ownerWidth));
|
YGFloatOptional(node->getMarginForAxis(axis, ownerWidth));
|
||||||
switch (*mode) {
|
switch (*mode) {
|
||||||
case YGMeasureModeExactly:
|
case YGMeasureModeExactly:
|
||||||
@@ -1190,7 +1195,7 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
YGMarkerLayoutData& layoutMarkerData,
|
YGMarkerLayoutData& layoutMarkerData,
|
||||||
void* const layoutContext) {
|
void* const layoutContext) {
|
||||||
const YGFlexDirection mainAxis =
|
const YGFlexDirection mainAxis =
|
||||||
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
|
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
|
||||||
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
||||||
const float mainAxisSize = isMainAxisRow ? width : height;
|
const float mainAxisSize = isMainAxisRow ? width : height;
|
||||||
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
|
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
|
||||||
@@ -1225,7 +1230,7 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
|
|
||||||
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(
|
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(
|
||||||
YGResolveValue(
|
YGResolveValue(
|
||||||
child->getResolvedDimension(YGDimensionWidth), ownerWidth),
|
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth),
|
||||||
paddingAndBorder));
|
paddingAndBorder));
|
||||||
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
|
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
|
||||||
// The height is definite, so use that as the flex basis.
|
// The height is definite, so use that as the flex basis.
|
||||||
@@ -1234,7 +1239,7 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
child, YGFlexDirectionColumn, ownerWidth));
|
child, YGFlexDirectionColumn, ownerWidth));
|
||||||
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(
|
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(
|
||||||
YGResolveValue(
|
YGResolveValue(
|
||||||
child->getResolvedDimension(YGDimensionHeight), ownerHeight),
|
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight),
|
||||||
paddingAndBorder));
|
paddingAndBorder));
|
||||||
} else {
|
} else {
|
||||||
// Compute the flex basis and hypothetical main size (i.e. the clamped flex
|
// Compute the flex basis and hypothetical main size (i.e. the clamped flex
|
||||||
@@ -1252,7 +1257,7 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
if (isRowStyleDimDefined) {
|
if (isRowStyleDimDefined) {
|
||||||
childWidth =
|
childWidth =
|
||||||
YGResolveValue(
|
YGResolveValue(
|
||||||
child->getResolvedDimension(YGDimensionWidth), ownerWidth)
|
child->getResolvedDimensions()[YGDimensionWidth], ownerWidth)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginRow;
|
marginRow;
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = YGMeasureModeExactly;
|
||||||
@@ -1260,7 +1265,7 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
if (isColumnStyleDimDefined) {
|
if (isColumnStyleDimDefined) {
|
||||||
childHeight =
|
childHeight =
|
||||||
YGResolveValue(
|
YGResolveValue(
|
||||||
child->getResolvedDimension(YGDimensionHeight), ownerHeight)
|
child->getResolvedDimensions()[YGDimensionHeight], ownerHeight)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginColumn;
|
marginColumn;
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = YGMeasureModeExactly;
|
||||||
@@ -1268,32 +1273,32 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
|
|
||||||
// The W3C spec doesn't say anything about the 'overflow' property, but all
|
// The W3C spec doesn't say anything about the 'overflow' property, but all
|
||||||
// major browsers appear to implement the following logic.
|
// major browsers appear to implement the following logic.
|
||||||
if ((!isMainAxisRow && node->getStyle().overflow == YGOverflowScroll) ||
|
if ((!isMainAxisRow && node->getStyle().overflow() == YGOverflowScroll) ||
|
||||||
node->getStyle().overflow != YGOverflowScroll) {
|
node->getStyle().overflow() != YGOverflowScroll) {
|
||||||
if (YGFloatIsUndefined(childWidth) && !YGFloatIsUndefined(width)) {
|
if (YGFloatIsUndefined(childWidth) && !YGFloatIsUndefined(width)) {
|
||||||
childWidth = width;
|
childWidth = width;
|
||||||
childWidthMeasureMode = YGMeasureModeAtMost;
|
childWidthMeasureMode = YGMeasureModeAtMost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((isMainAxisRow && node->getStyle().overflow == YGOverflowScroll) ||
|
if ((isMainAxisRow && node->getStyle().overflow() == YGOverflowScroll) ||
|
||||||
node->getStyle().overflow != YGOverflowScroll) {
|
node->getStyle().overflow() != YGOverflowScroll) {
|
||||||
if (YGFloatIsUndefined(childHeight) && !YGFloatIsUndefined(height)) {
|
if (YGFloatIsUndefined(childHeight) && !YGFloatIsUndefined(height)) {
|
||||||
childHeight = height;
|
childHeight = height;
|
||||||
childHeightMeasureMode = YGMeasureModeAtMost;
|
childHeightMeasureMode = YGMeasureModeAtMost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!child->getStyle().aspectRatio.isUndefined()) {
|
const auto& childStyle = child->getStyle();
|
||||||
|
if (!childStyle.aspectRatio().isUndefined()) {
|
||||||
if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) {
|
if (!isMainAxisRow && childWidthMeasureMode == YGMeasureModeExactly) {
|
||||||
childHeight = marginColumn +
|
childHeight = marginColumn +
|
||||||
(childWidth - marginRow) / child->getStyle().aspectRatio.unwrap();
|
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = YGMeasureModeExactly;
|
||||||
} else if (
|
} else if (
|
||||||
isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) {
|
isMainAxisRow && childHeightMeasureMode == YGMeasureModeExactly) {
|
||||||
childWidth = marginRow +
|
childWidth = marginRow +
|
||||||
(childHeight - marginColumn) *
|
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
|
||||||
child->getStyle().aspectRatio.unwrap();
|
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1310,9 +1315,9 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
childWidthStretch) {
|
childWidthStretch) {
|
||||||
childWidth = width;
|
childWidth = width;
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = YGMeasureModeExactly;
|
||||||
if (!child->getStyle().aspectRatio.isUndefined()) {
|
if (!childStyle.aspectRatio().isUndefined()) {
|
||||||
childHeight =
|
childHeight =
|
||||||
(childWidth - marginRow) / child->getStyle().aspectRatio.unwrap();
|
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1327,9 +1332,9 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
childHeight = height;
|
childHeight = height;
|
||||||
childHeightMeasureMode = YGMeasureModeExactly;
|
childHeightMeasureMode = YGMeasureModeExactly;
|
||||||
|
|
||||||
if (!child->getStyle().aspectRatio.isUndefined()) {
|
if (!childStyle.aspectRatio().isUndefined()) {
|
||||||
childWidth = (childHeight - marginColumn) *
|
childWidth =
|
||||||
child->getStyle().aspectRatio.unwrap();
|
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
|
||||||
childWidthMeasureMode = YGMeasureModeExactly;
|
childWidthMeasureMode = YGMeasureModeExactly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1383,7 +1388,7 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
YGMarkerLayoutData& layoutMarkerData,
|
YGMarkerLayoutData& layoutMarkerData,
|
||||||
void* const layoutContext) {
|
void* const layoutContext) {
|
||||||
const YGFlexDirection mainAxis =
|
const YGFlexDirection mainAxis =
|
||||||
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
|
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
|
||||||
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
||||||
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
||||||
|
|
||||||
@@ -1398,7 +1403,7 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
|
|
||||||
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow, width)) {
|
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionRow, width)) {
|
||||||
childWidth =
|
childWidth =
|
||||||
YGResolveValue(child->getResolvedDimension(YGDimensionWidth), width)
|
YGResolveValue(child->getResolvedDimensions()[YGDimensionWidth], width)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginRow;
|
marginRow;
|
||||||
} else {
|
} else {
|
||||||
@@ -1418,8 +1423,8 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn, height)) {
|
if (YGNodeIsStyleDimDefined(child, YGFlexDirectionColumn, height)) {
|
||||||
childHeight =
|
childHeight = YGResolveValue(
|
||||||
YGResolveValue(child->getResolvedDimension(YGDimensionHeight), height)
|
child->getResolvedDimensions()[YGDimensionHeight], height)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
marginColumn;
|
marginColumn;
|
||||||
} else {
|
} else {
|
||||||
@@ -1441,15 +1446,15 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
// Exactly one dimension needs to be defined for us to be able to do aspect
|
// 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
|
// ratio calculation. One dimension being the anchor and the other being
|
||||||
// flexible.
|
// flexible.
|
||||||
|
const auto& childStyle = child->getStyle();
|
||||||
if (YGFloatIsUndefined(childWidth) ^ YGFloatIsUndefined(childHeight)) {
|
if (YGFloatIsUndefined(childWidth) ^ YGFloatIsUndefined(childHeight)) {
|
||||||
if (!child->getStyle().aspectRatio.isUndefined()) {
|
if (!childStyle.aspectRatio().isUndefined()) {
|
||||||
if (YGFloatIsUndefined(childWidth)) {
|
if (YGFloatIsUndefined(childWidth)) {
|
||||||
childWidth = marginRow +
|
childWidth = marginRow +
|
||||||
(childHeight - marginColumn) *
|
(childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
|
||||||
child->getStyle().aspectRatio.unwrap();
|
|
||||||
} else if (YGFloatIsUndefined(childHeight)) {
|
} else if (YGFloatIsUndefined(childHeight)) {
|
||||||
childHeight = marginColumn +
|
childHeight = marginColumn +
|
||||||
(childWidth - marginRow) / child->getStyle().aspectRatio.unwrap();
|
(childWidth - marginRow) / childStyle.aspectRatio().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1521,7 +1526,7 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
leading[mainAxis]);
|
leading[mainAxis]);
|
||||||
} else if (
|
} else if (
|
||||||
!child->isLeadingPositionDefined(mainAxis) &&
|
!child->isLeadingPositionDefined(mainAxis) &&
|
||||||
node->getStyle().justifyContent == YGJustifyCenter) {
|
node->getStyle().justifyContent() == YGJustifyCenter) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dim[mainAxis]] -
|
(node->getLayout().measuredDimensions[dim[mainAxis]] -
|
||||||
child->getLayout().measuredDimensions[dim[mainAxis]]) /
|
child->getLayout().measuredDimensions[dim[mainAxis]]) /
|
||||||
@@ -1529,7 +1534,7 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
leading[mainAxis]);
|
leading[mainAxis]);
|
||||||
} else if (
|
} else if (
|
||||||
!child->isLeadingPositionDefined(mainAxis) &&
|
!child->isLeadingPositionDefined(mainAxis) &&
|
||||||
node->getStyle().justifyContent == YGJustifyFlexEnd) {
|
node->getStyle().justifyContent() == YGJustifyFlexEnd) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dim[mainAxis]] -
|
(node->getLayout().measuredDimensions[dim[mainAxis]] -
|
||||||
child->getLayout().measuredDimensions[dim[mainAxis]]),
|
child->getLayout().measuredDimensions[dim[mainAxis]]),
|
||||||
@@ -1559,7 +1564,7 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
} else if (
|
} else if (
|
||||||
!child->isLeadingPositionDefined(crossAxis) &&
|
!child->isLeadingPositionDefined(crossAxis) &&
|
||||||
((YGNodeAlignItem(node, child) == YGAlignFlexEnd) ^
|
((YGNodeAlignItem(node, child) == YGAlignFlexEnd) ^
|
||||||
(node->getStyle().flexWrap == YGWrapWrapReverse))) {
|
(node->getStyle().flexWrap() == YGWrapWrapReverse))) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dim[crossAxis]] -
|
(node->getLayout().measuredDimensions[dim[crossAxis]] -
|
||||||
child->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
|
// We want to make sure our available height does not violate min and max
|
||||||
// constraints
|
// constraints
|
||||||
const YGFloatOptional minDimensionOptional =
|
const YGFloatOptional minDimensionOptional =
|
||||||
YGResolveValue(node->getStyle().minDimensions[dimension], ownerDim);
|
YGResolveValue(node->getStyle().minDimensions()[dimension], ownerDim);
|
||||||
const float minInnerDim = minDimensionOptional.isUndefined()
|
const float minInnerDim = minDimensionOptional.isUndefined()
|
||||||
? 0.0f
|
? 0.0f
|
||||||
: minDimensionOptional.unwrap() - paddingAndBorder;
|
: minDimensionOptional.unwrap() - paddingAndBorder;
|
||||||
|
|
||||||
const YGFloatOptional maxDimensionOptional =
|
const YGFloatOptional maxDimensionOptional =
|
||||||
YGResolveValue(node->getStyle().maxDimensions[dimension], ownerDim);
|
YGResolveValue(node->getStyle().maxDimensions()[dimension], ownerDim);
|
||||||
|
|
||||||
const float maxInnerDim = maxDimensionOptional.isUndefined()
|
const float maxInnerDim = maxDimensionOptional.isUndefined()
|
||||||
? FLT_MAX
|
? FLT_MAX
|
||||||
@@ -1839,7 +1844,7 @@ static float YGNodeComputeFlexBasisForChildren(
|
|||||||
|
|
||||||
for (auto child : children) {
|
for (auto child : children) {
|
||||||
child->resolveDimension();
|
child->resolveDimension();
|
||||||
if (child->getStyle().display == YGDisplayNone) {
|
if (child->getStyle().display() == YGDisplayNone) {
|
||||||
YGZeroOutLayoutRecursivly(child, layoutContext);
|
YGZeroOutLayoutRecursivly(child, layoutContext);
|
||||||
child->setHasNewLayout(true);
|
child->setHasNewLayout(true);
|
||||||
child->setDirty(false);
|
child->setDirty(false);
|
||||||
@@ -1858,7 +1863,7 @@ static float YGNodeComputeFlexBasisForChildren(
|
|||||||
childDirection, mainDim, crossDim, availableInnerWidth);
|
childDirection, mainDim, crossDim, availableInnerWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (child->getStyle().positionType == YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child == singleFlexChild) {
|
if (child == singleFlexChild) {
|
||||||
@@ -1906,15 +1911,15 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
|
|||||||
|
|
||||||
float sizeConsumedOnCurrentLineIncludingMinConstraint = 0;
|
float sizeConsumedOnCurrentLineIncludingMinConstraint = 0;
|
||||||
const YGFlexDirection mainAxis = YGResolveFlexDirection(
|
const YGFlexDirection mainAxis = YGResolveFlexDirection(
|
||||||
node->getStyle().flexDirection, node->resolveDirection(ownerDirection));
|
node->getStyle().flexDirection(), node->resolveDirection(ownerDirection));
|
||||||
const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap;
|
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
|
||||||
|
|
||||||
// Add items to the current line until it's full or we run out of items.
|
// Add items to the current line until it's full or we run out of items.
|
||||||
uint32_t endOfLineIndex = startOfLineIndex;
|
uint32_t endOfLineIndex = startOfLineIndex;
|
||||||
for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) {
|
for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) {
|
||||||
const YGNodeRef child = node->getChild(endOfLineIndex);
|
const YGNodeRef child = node->getChild(endOfLineIndex);
|
||||||
if (child->getStyle().display == YGDisplayNone ||
|
if (child->getStyle().display() == YGDisplayNone ||
|
||||||
child->getStyle().positionType == YGPositionTypeAbsolute) {
|
child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
child->setLineIndex(lineCount);
|
child->setLineIndex(lineCount);
|
||||||
@@ -1997,7 +2002,7 @@ static float YGDistributeFreeSpaceSecondPass(
|
|||||||
float flexGrowFactor = 0;
|
float flexGrowFactor = 0;
|
||||||
float deltaFreeSpace = 0;
|
float deltaFreeSpace = 0;
|
||||||
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
||||||
const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap;
|
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
|
||||||
|
|
||||||
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
|
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
|
||||||
childFlexBasis = YGNodeBoundAxisWithinMinAndMax(
|
childFlexBasis = YGNodeBoundAxisWithinMinAndMax(
|
||||||
@@ -2067,11 +2072,11 @@ static float YGDistributeFreeSpaceSecondPass(
|
|||||||
YGMeasureMode childCrossMeasureMode;
|
YGMeasureMode childCrossMeasureMode;
|
||||||
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
|
YGMeasureMode childMainMeasureMode = YGMeasureModeExactly;
|
||||||
|
|
||||||
if (!currentRelativeChild->getStyle().aspectRatio.isUndefined()) {
|
const auto& childStyle = currentRelativeChild->getStyle();
|
||||||
childCrossSize = isMainAxisRow ? (childMainSize - marginMain) /
|
if (!childStyle.aspectRatio().isUndefined()) {
|
||||||
currentRelativeChild->getStyle().aspectRatio.unwrap()
|
childCrossSize = isMainAxisRow
|
||||||
: (childMainSize - marginMain) *
|
? (childMainSize - marginMain) / childStyle.aspectRatio().unwrap()
|
||||||
currentRelativeChild->getStyle().aspectRatio.unwrap();
|
: (childMainSize - marginMain) * childStyle.aspectRatio().unwrap();
|
||||||
childCrossMeasureMode = YGMeasureModeExactly;
|
childCrossMeasureMode = YGMeasureModeExactly;
|
||||||
|
|
||||||
childCrossSize += marginCross;
|
childCrossSize += marginCross;
|
||||||
@@ -2335,7 +2340,7 @@ static void YGJustifyMainAxis(
|
|||||||
const float availableInnerWidth,
|
const float availableInnerWidth,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
void* const layoutContext) {
|
void* const layoutContext) {
|
||||||
const YGStyle& style = node->getStyle();
|
const auto& style = node->getStyle();
|
||||||
const float leadingPaddingAndBorderMain =
|
const float leadingPaddingAndBorderMain =
|
||||||
node->getLeadingPaddingAndBorder(mainAxis, ownerWidth).unwrap();
|
node->getLeadingPaddingAndBorder(mainAxis, ownerWidth).unwrap();
|
||||||
const float trailingPaddingAndBorderMain =
|
const float trailingPaddingAndBorderMain =
|
||||||
@@ -2344,8 +2349,8 @@ 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]].isUndefined() &&
|
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
|
||||||
// considering child nodes main dim, leading and trailing padding etc)
|
// 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
|
// `minAvailableMainDim` denotes minimum available space in which child
|
||||||
// can be laid out, it will exclude space consumed by padding and border.
|
// can be laid out, it will exclude space consumed by padding and border.
|
||||||
const float minAvailableMainDim =
|
const float minAvailableMainDim =
|
||||||
YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisownerSize)
|
YGResolveValue(
|
||||||
|
style.minDimensions()[dim[mainAxis]], mainAxisownerSize)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
|
leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
|
||||||
const float occupiedSpaceByChildNodes =
|
const float occupiedSpaceByChildNodes =
|
||||||
@@ -2372,7 +2378,7 @@ static void YGJustifyMainAxis(
|
|||||||
i < collectedFlexItemsValues.endOfLineIndex;
|
i < collectedFlexItemsValues.endOfLineIndex;
|
||||||
i++) {
|
i++) {
|
||||||
const YGNodeRef child = node->getChild(i);
|
const YGNodeRef child = node->getChild(i);
|
||||||
if (child->getStyle().positionType == YGPositionTypeRelative) {
|
if (child->getStyle().positionType() == YGPositionTypeRelative) {
|
||||||
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
||||||
numberOfAutoMarginsOnCurrentLine++;
|
numberOfAutoMarginsOnCurrentLine++;
|
||||||
}
|
}
|
||||||
@@ -2387,7 +2393,7 @@ static void YGJustifyMainAxis(
|
|||||||
// each two elements.
|
// each two elements.
|
||||||
float leadingMainDim = 0;
|
float leadingMainDim = 0;
|
||||||
float betweenMainDim = 0;
|
float betweenMainDim = 0;
|
||||||
const YGJustify justifyContent = node->getStyle().justifyContent;
|
const YGJustify justifyContent = node->getStyle().justifyContent();
|
||||||
|
|
||||||
if (numberOfAutoMarginsOnCurrentLine == 0) {
|
if (numberOfAutoMarginsOnCurrentLine == 0) {
|
||||||
switch (justifyContent) {
|
switch (justifyContent) {
|
||||||
@@ -2436,10 +2442,10 @@ static void YGJustifyMainAxis(
|
|||||||
const YGNodeRef child = node->getChild(i);
|
const YGNodeRef child = node->getChild(i);
|
||||||
const YGStyle& childStyle = child->getStyle();
|
const YGStyle& childStyle = child->getStyle();
|
||||||
const YGLayout childLayout = child->getLayout();
|
const YGLayout childLayout = child->getLayout();
|
||||||
if (childStyle.display == YGDisplayNone) {
|
if (childStyle.display() == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (childStyle.positionType == YGPositionTypeAbsolute &&
|
if (childStyle.positionType() == YGPositionTypeAbsolute &&
|
||||||
child->isLeadingPositionDefined(mainAxis)) {
|
child->isLeadingPositionDefined(mainAxis)) {
|
||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
// In case the child is position absolute and has left/top being
|
// 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.
|
// 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
|
// We need to do that only for relative elements. Absolute elements do not
|
||||||
// take part in that phase.
|
// take part in that phase.
|
||||||
if (childStyle.positionType == YGPositionTypeRelative) {
|
if (childStyle.positionType() == YGPositionTypeRelative) {
|
||||||
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
||||||
collectedFlexItemsValues.mainDim +=
|
collectedFlexItemsValues.mainDim +=
|
||||||
collectedFlexItemsValues.remainingFreeSpace /
|
collectedFlexItemsValues.remainingFreeSpace /
|
||||||
@@ -2720,10 +2726,10 @@ static void YGNodelayoutImpl(
|
|||||||
|
|
||||||
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
|
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
|
||||||
const YGFlexDirection mainAxis =
|
const YGFlexDirection mainAxis =
|
||||||
YGResolveFlexDirection(node->getStyle().flexDirection, direction);
|
YGResolveFlexDirection(node->getStyle().flexDirection(), direction);
|
||||||
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
const YGFlexDirection crossAxis = YGFlexDirectionCross(mainAxis, direction);
|
||||||
const bool isMainAxisRow = YGFlexDirectionIsRow(mainAxis);
|
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 mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
|
||||||
const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
|
const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
|
||||||
@@ -2752,22 +2758,22 @@ static void YGNodelayoutImpl(
|
|||||||
|
|
||||||
const float minInnerWidth =
|
const float minInnerWidth =
|
||||||
YGResolveValue(
|
YGResolveValue(
|
||||||
node->getStyle().minDimensions[YGDimensionWidth], ownerWidth)
|
node->getStyle().minDimensions()[YGDimensionWidth], ownerWidth)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
paddingAndBorderAxisRow;
|
paddingAndBorderAxisRow;
|
||||||
const float maxInnerWidth =
|
const float maxInnerWidth =
|
||||||
YGResolveValue(
|
YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)
|
node->getStyle().maxDimensions()[YGDimensionWidth], ownerWidth)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
paddingAndBorderAxisRow;
|
paddingAndBorderAxisRow;
|
||||||
const float minInnerHeight =
|
const float minInnerHeight =
|
||||||
YGResolveValue(
|
YGResolveValue(
|
||||||
node->getStyle().minDimensions[YGDimensionHeight], ownerHeight)
|
node->getStyle().minDimensions()[YGDimensionHeight], ownerHeight)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
paddingAndBorderAxisColumn;
|
paddingAndBorderAxisColumn;
|
||||||
const float maxInnerHeight =
|
const float maxInnerHeight =
|
||||||
YGResolveValue(
|
YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight)
|
node->getStyle().maxDimensions()[YGDimensionHeight], ownerHeight)
|
||||||
.unwrap() -
|
.unwrap() -
|
||||||
paddingAndBorderAxisColumn;
|
paddingAndBorderAxisColumn;
|
||||||
|
|
||||||
@@ -2971,10 +2977,10 @@ static void YGNodelayoutImpl(
|
|||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
|
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) {
|
||||||
const YGNodeRef child = node->getChild(i);
|
const YGNodeRef child = node->getChild(i);
|
||||||
if (child->getStyle().display == YGDisplayNone) {
|
if (child->getStyle().display() == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child->getStyle().positionType == YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
||||||
// If the child is absolutely positioned and has a
|
// If the child is absolutely positioned and has a
|
||||||
// top/left/bottom/right set, override all the previously computed
|
// top/left/bottom/right set, override all the previously computed
|
||||||
// positions to set it correctly.
|
// positions to set it correctly.
|
||||||
@@ -3019,14 +3025,13 @@ static void YGNodelayoutImpl(
|
|||||||
child, crossAxis, availableInnerCrossDim)) {
|
child, crossAxis, availableInnerCrossDim)) {
|
||||||
float childMainSize =
|
float childMainSize =
|
||||||
child->getLayout().measuredDimensions[dim[mainAxis]];
|
child->getLayout().measuredDimensions[dim[mainAxis]];
|
||||||
float childCrossSize =
|
const auto& childStyle = child->getStyle();
|
||||||
!child->getStyle().aspectRatio.isUndefined()
|
float childCrossSize = !childStyle.aspectRatio().isUndefined()
|
||||||
? child->getMarginForAxis(crossAxis, availableInnerWidth)
|
? child->getMarginForAxis(crossAxis, availableInnerWidth)
|
||||||
.unwrap() +
|
.unwrap() +
|
||||||
(isMainAxisRow ? childMainSize /
|
(isMainAxisRow
|
||||||
child->getStyle().aspectRatio.unwrap()
|
? childMainSize / childStyle.aspectRatio().unwrap()
|
||||||
: childMainSize *
|
: childMainSize * childStyle.aspectRatio().unwrap())
|
||||||
child->getStyle().aspectRatio.unwrap())
|
|
||||||
: collectedFlexItemsValues.crossDim;
|
: collectedFlexItemsValues.crossDim;
|
||||||
|
|
||||||
childMainSize +=
|
childMainSize +=
|
||||||
@@ -3055,7 +3060,7 @@ static void YGNodelayoutImpl(
|
|||||||
const float childHeight =
|
const float childHeight =
|
||||||
!isMainAxisRow ? childMainSize : childCrossSize;
|
!isMainAxisRow ? childMainSize : childCrossSize;
|
||||||
|
|
||||||
auto alignContent = node->getStyle().alignContent;
|
auto alignContent = node->getStyle().alignContent();
|
||||||
auto crossAxisDoesNotGrow =
|
auto crossAxisDoesNotGrow =
|
||||||
alignContent != YGAlignStretch && isNodeFlexWrap;
|
alignContent != YGAlignStretch && isNodeFlexWrap;
|
||||||
const YGMeasureMode childWidthMeasureMode =
|
const YGMeasureMode childWidthMeasureMode =
|
||||||
@@ -3127,7 +3132,7 @@ static void YGNodelayoutImpl(
|
|||||||
if (!YGFloatIsUndefined(availableInnerCrossDim)) {
|
if (!YGFloatIsUndefined(availableInnerCrossDim)) {
|
||||||
const float remainingAlignContentDim =
|
const float remainingAlignContentDim =
|
||||||
availableInnerCrossDim - totalLineCrossDim;
|
availableInnerCrossDim - totalLineCrossDim;
|
||||||
switch (node->getStyle().alignContent) {
|
switch (node->getStyle().alignContent()) {
|
||||||
case YGAlignFlexEnd:
|
case YGAlignFlexEnd:
|
||||||
currentLead += remainingAlignContentDim;
|
currentLead += remainingAlignContentDim;
|
||||||
break;
|
break;
|
||||||
@@ -3171,10 +3176,10 @@ static void YGNodelayoutImpl(
|
|||||||
float maxDescentForCurrentLine = 0;
|
float maxDescentForCurrentLine = 0;
|
||||||
for (ii = startIndex; ii < childCount; ii++) {
|
for (ii = startIndex; ii < childCount; ii++) {
|
||||||
const YGNodeRef child = node->getChild(ii);
|
const YGNodeRef child = node->getChild(ii);
|
||||||
if (child->getStyle().display == YGDisplayNone) {
|
if (child->getStyle().display() == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child->getStyle().positionType == YGPositionTypeRelative) {
|
if (child->getStyle().positionType() == YGPositionTypeRelative) {
|
||||||
if (child->getLineIndex() != i) {
|
if (child->getLineIndex() != i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3213,10 +3218,10 @@ static void YGNodelayoutImpl(
|
|||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
for (ii = startIndex; ii < endIndex; ii++) {
|
for (ii = startIndex; ii < endIndex; ii++) {
|
||||||
const YGNodeRef child = node->getChild(ii);
|
const YGNodeRef child = node->getChild(ii);
|
||||||
if (child->getStyle().display == YGDisplayNone) {
|
if (child->getStyle().display() == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child->getStyle().positionType == YGPositionTypeRelative) {
|
if (child->getStyle().positionType() == YGPositionTypeRelative) {
|
||||||
switch (YGNodeAlignItem(node, child)) {
|
switch (YGNodeAlignItem(node, child)) {
|
||||||
case YGAlignFlexStart: {
|
case YGAlignFlexStart: {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
@@ -3342,7 +3347,7 @@ static void YGNodelayoutImpl(
|
|||||||
// If the user didn't specify a width or height for the node, set the
|
// If the user didn't specify a width or height for the node, set the
|
||||||
// dimensions based on the children.
|
// dimensions based on the children.
|
||||||
if (measureModeMainDim == YGMeasureModeUndefined ||
|
if (measureModeMainDim == YGMeasureModeUndefined ||
|
||||||
(node->getStyle().overflow != YGOverflowScroll &&
|
(node->getStyle().overflow() != YGOverflowScroll &&
|
||||||
measureModeMainDim == YGMeasureModeAtMost)) {
|
measureModeMainDim == YGMeasureModeAtMost)) {
|
||||||
// Clamp the size to the min/max size, if specified, and make sure it
|
// Clamp the size to the min/max size, if specified, and make sure it
|
||||||
// doesn't go below the padding and border amount.
|
// doesn't go below the padding and border amount.
|
||||||
@@ -3353,7 +3358,7 @@ static void YGNodelayoutImpl(
|
|||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
measureModeMainDim == YGMeasureModeAtMost &&
|
measureModeMainDim == YGMeasureModeAtMost &&
|
||||||
node->getStyle().overflow == YGOverflowScroll) {
|
node->getStyle().overflow() == YGOverflowScroll) {
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
YGFloatMax(
|
YGFloatMax(
|
||||||
YGFloatMin(
|
YGFloatMin(
|
||||||
@@ -3369,7 +3374,7 @@ static void YGNodelayoutImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (measureModeCrossDim == YGMeasureModeUndefined ||
|
if (measureModeCrossDim == YGMeasureModeUndefined ||
|
||||||
(node->getStyle().overflow != YGOverflowScroll &&
|
(node->getStyle().overflow() != YGOverflowScroll &&
|
||||||
measureModeCrossDim == YGMeasureModeAtMost)) {
|
measureModeCrossDim == YGMeasureModeAtMost)) {
|
||||||
// Clamp the size to the min/max size, if specified, and make sure it
|
// Clamp the size to the min/max size, if specified, and make sure it
|
||||||
// doesn't go below the padding and border amount.
|
// doesn't go below the padding and border amount.
|
||||||
@@ -3384,7 +3389,7 @@ static void YGNodelayoutImpl(
|
|||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
measureModeCrossDim == YGMeasureModeAtMost &&
|
measureModeCrossDim == YGMeasureModeAtMost &&
|
||||||
node->getStyle().overflow == YGOverflowScroll) {
|
node->getStyle().overflow() == YGOverflowScroll) {
|
||||||
node->setLayoutMeasuredDimension(
|
node->setLayoutMeasuredDimension(
|
||||||
YGFloatMax(
|
YGFloatMax(
|
||||||
YGFloatMin(
|
YGFloatMin(
|
||||||
@@ -3402,10 +3407,10 @@ static void YGNodelayoutImpl(
|
|||||||
|
|
||||||
// As we only wrapped in normal direction yet, we need to reverse the
|
// As we only wrapped in normal direction yet, we need to reverse the
|
||||||
// positions on wrap-reverse.
|
// positions on wrap-reverse.
|
||||||
if (performLayout && node->getStyle().flexWrap == YGWrapWrapReverse) {
|
if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) {
|
||||||
for (uint32_t i = 0; i < childCount; i++) {
|
for (uint32_t i = 0; i < childCount; i++) {
|
||||||
const YGNodeRef child = YGNodeGetChild(node, i);
|
const YGNodeRef child = YGNodeGetChild(node, i);
|
||||||
if (child->getStyle().positionType == YGPositionTypeRelative) {
|
if (child->getStyle().positionType() == YGPositionTypeRelative) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getLayout().measuredDimensions[dim[crossAxis]] -
|
node->getLayout().measuredDimensions[dim[crossAxis]] -
|
||||||
child->getLayout().position[pos[crossAxis]] -
|
child->getLayout().position[pos[crossAxis]] -
|
||||||
@@ -3418,7 +3423,7 @@ static void YGNodelayoutImpl(
|
|||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
|
// STEP 10: SIZING AND POSITIONING ABSOLUTE CHILDREN
|
||||||
for (auto child : node->getChildren()) {
|
for (auto child : node->getChildren()) {
|
||||||
if (child->getStyle().positionType != YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
YGNodeAbsoluteLayoutChild(
|
YGNodeAbsoluteLayoutChild(
|
||||||
@@ -3443,7 +3448,7 @@ static void YGNodelayoutImpl(
|
|||||||
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
if (needsMainTrailingPos || needsCrossTrailingPos) {
|
||||||
for (uint32_t i = 0; i < childCount; i++) {
|
for (uint32_t i = 0; i < childCount; i++) {
|
||||||
const YGNodeRef child = node->getChild(i);
|
const YGNodeRef child = node->getChild(i);
|
||||||
if (child->getStyle().display == YGDisplayNone) {
|
if (child->getStyle().display() == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (needsMainTrailingPos) {
|
if (needsMainTrailingPos) {
|
||||||
@@ -4014,10 +4019,11 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
widthMeasureMode = YGMeasureModeExactly;
|
widthMeasureMode = YGMeasureModeExactly;
|
||||||
} else if (!YGResolveValue(
|
} else if (!YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)
|
node->getStyle().maxDimensions()[YGDimensionWidth],
|
||||||
|
ownerWidth)
|
||||||
.isUndefined()) {
|
.isUndefined()) {
|
||||||
width = YGResolveValue(
|
width = YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionWidth], ownerWidth)
|
node->getStyle().maxDimensions()[YGDimensionWidth], ownerWidth)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
widthMeasureMode = YGMeasureModeAtMost;
|
widthMeasureMode = YGMeasureModeAtMost;
|
||||||
} else {
|
} else {
|
||||||
@@ -4036,11 +4042,12 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
heightMeasureMode = YGMeasureModeExactly;
|
heightMeasureMode = YGMeasureModeExactly;
|
||||||
} else if (!YGResolveValue(
|
} else if (!YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionHeight],
|
node->getStyle().maxDimensions()[YGDimensionHeight],
|
||||||
ownerHeight)
|
ownerHeight)
|
||||||
.isUndefined()) {
|
.isUndefined()) {
|
||||||
height = YGResolveValue(
|
height =
|
||||||
node->getStyle().maxDimensions[YGDimensionHeight], ownerHeight)
|
YGResolveValue(
|
||||||
|
node->getStyle().maxDimensions()[YGDimensionHeight], ownerHeight)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
heightMeasureMode = YGMeasureModeAtMost;
|
heightMeasureMode = YGMeasureModeAtMost;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user