C++ style enums 13/N: Wrap (#1400)
Summary: X-link: https://github.com/facebook/react-native/pull/39539 Pull Request resolved: https://github.com/facebook/yoga/pull/1400 Moves internal usages of YGPositionType to PositionType bypass-github-export-checks Changelog: [Internal] Reviewed By: rshest Differential Revision: D49361746 fbshipit-source-id: ccc77b4c77753b5f41e11f1849d4c02153c190b7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4ea6b4c4f9
commit
03d0523996
@@ -135,12 +135,7 @@ ACCESSOR_TEST(
|
|||||||
PositionType::Absolute,
|
PositionType::Absolute,
|
||||||
PositionType::Relative)
|
PositionType::Relative)
|
||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(flexWrap, Wrap::NoWrap, Wrap::Wrap, Wrap::WrapReverse)
|
||||||
flexWrap,
|
|
||||||
YGWrapNoWrap,
|
|
||||||
YGWrapWrap,
|
|
||||||
YGWrapWrapReverse,
|
|
||||||
YGWrapNoWrap)
|
|
||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
overflow,
|
overflow,
|
||||||
|
@@ -492,10 +492,11 @@ YGPositionType YGNodeStyleGetPositionType(const YGNodeConstRef node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) {
|
void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) {
|
||||||
updateStyle<MSVC_HINT(flexWrap)>(node, &Style::flexWrap, flexWrap);
|
updateStyle<MSVC_HINT(flexWrap)>(
|
||||||
|
node, &Style::flexWrap, scopedEnum(flexWrap));
|
||||||
}
|
}
|
||||||
YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
|
YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().flexWrap();
|
return unscopedEnum(resolveRef(node)->getStyle().flexWrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetOverflow(const YGNodeRef node, const YGOverflow overflow) {
|
void YGNodeStyleSetOverflow(const YGNodeRef node, const YGOverflow overflow) {
|
||||||
|
@@ -520,7 +520,7 @@ static void layoutAbsoluteChild(
|
|||||||
} else if (
|
} else if (
|
||||||
!child->isLeadingPositionDefined(crossAxis) &&
|
!child->isLeadingPositionDefined(crossAxis) &&
|
||||||
((resolveChildAlignment(node, child) == Align::FlexEnd) ^
|
((resolveChildAlignment(node, child) == Align::FlexEnd) ^
|
||||||
(node->getStyle().flexWrap() == YGWrapWrapReverse))) {
|
(node->getStyle().flexWrap() == Wrap::WrapReverse))) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
(node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
||||||
child->getLayout().measuredDimensions[dimension(crossAxis)]),
|
child->getLayout().measuredDimensions[dimension(crossAxis)]),
|
||||||
@@ -877,7 +877,7 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
float flexGrowFactor = 0;
|
float flexGrowFactor = 0;
|
||||||
float deltaFreeSpace = 0;
|
float deltaFreeSpace = 0;
|
||||||
const bool isMainAxisRow = isRow(mainAxis);
|
const bool isMainAxisRow = isRow(mainAxis);
|
||||||
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
|
const bool isNodeFlexWrap = node->getStyle().flexWrap() != Wrap::NoWrap;
|
||||||
|
|
||||||
for (auto currentLineChild : flexLine.itemsInFlow) {
|
for (auto currentLineChild : flexLine.itemsInFlow) {
|
||||||
childFlexBasis = boundAxisWithinMinAndMax(
|
childFlexBasis = boundAxisWithinMinAndMax(
|
||||||
@@ -1604,7 +1604,7 @@ static void calculateLayoutImpl(
|
|||||||
resolveDirection(node->getStyle().flexDirection(), direction);
|
resolveDirection(node->getStyle().flexDirection(), direction);
|
||||||
const FlexDirection crossAxis = resolveCrossDirection(mainAxis, direction);
|
const FlexDirection crossAxis = resolveCrossDirection(mainAxis, direction);
|
||||||
const bool isMainAxisRow = isRow(mainAxis);
|
const bool isMainAxisRow = isRow(mainAxis);
|
||||||
const bool isNodeFlexWrap = node->getStyle().flexWrap() != YGWrapNoWrap;
|
const bool isNodeFlexWrap = node->getStyle().flexWrap() != Wrap::NoWrap;
|
||||||
|
|
||||||
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
|
const float mainAxisownerSize = isMainAxisRow ? ownerWidth : ownerHeight;
|
||||||
const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
|
const float crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
|
||||||
@@ -2302,7 +2302,7 @@ static void calculateLayoutImpl(
|
|||||||
|
|
||||||
// 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() == Wrap::WrapReverse) {
|
||||||
for (size_t i = 0; i < childCount; i++) {
|
for (size_t i = 0; i < childCount; i++) {
|
||||||
const auto child = node->getChild(i);
|
const auto child = node->getChild(i);
|
||||||
if (child->getStyle().positionType() != PositionType::Absolute) {
|
if (child->getStyle().positionType() != PositionType::Absolute) {
|
||||||
|
@@ -32,7 +32,7 @@ FlexLine calculateFlexLine(
|
|||||||
float sizeConsumedIncludingMinConstraint = 0;
|
float sizeConsumedIncludingMinConstraint = 0;
|
||||||
const FlexDirection mainAxis = resolveDirection(
|
const FlexDirection mainAxis = resolveDirection(
|
||||||
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() != Wrap::NoWrap;
|
||||||
const float gap = node->getGapForAxis(mainAxis, availableInnerWidth).unwrap();
|
const float gap = node->getGapForAxis(mainAxis, availableInnerWidth).unwrap();
|
||||||
|
|
||||||
// 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.
|
||||||
|
@@ -166,8 +166,7 @@ void nodeToString(
|
|||||||
appendFloatOptionalIfDefined(str, "flex", style.flex());
|
appendFloatOptionalIfDefined(str, "flex", style.flex());
|
||||||
|
|
||||||
if (style.flexWrap() != yoga::Node{}.getStyle().flexWrap()) {
|
if (style.flexWrap() != yoga::Node{}.getStyle().flexWrap()) {
|
||||||
appendFormattedString(
|
appendFormattedString(str, "flex-wrap: %s; ", toString(style.flexWrap()));
|
||||||
str, "flex-wrap: %s; ", YGWrapToString(style.flexWrap()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style.overflow() != yoga::Node{}.getStyle().overflow()) {
|
if (style.overflow() != yoga::Node{}.getStyle().overflow()) {
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include <yoga/enums/FlexDirection.h>
|
#include <yoga/enums/FlexDirection.h>
|
||||||
#include <yoga/enums/Justify.h>
|
#include <yoga/enums/Justify.h>
|
||||||
#include <yoga/enums/PositionType.h>
|
#include <yoga/enums/PositionType.h>
|
||||||
|
#include <yoga/enums/Wrap.h>
|
||||||
#include <yoga/numeric/FloatOptional.h>
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
#include <yoga/style/CompactValue.h>
|
#include <yoga/style/CompactValue.h>
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ class YG_EXPORT Style {
|
|||||||
static constexpr uint8_t flexWrapOffset =
|
static constexpr uint8_t flexWrapOffset =
|
||||||
positionTypeOffset + minimumBitCount<PositionType>();
|
positionTypeOffset + minimumBitCount<PositionType>();
|
||||||
static constexpr uint8_t overflowOffset =
|
static constexpr uint8_t overflowOffset =
|
||||||
flexWrapOffset + minimumBitCount<YGWrap>();
|
flexWrapOffset + minimumBitCount<Wrap>();
|
||||||
static constexpr uint8_t displayOffset =
|
static constexpr uint8_t displayOffset =
|
||||||
overflowOffset + minimumBitCount<YGOverflow>();
|
overflowOffset + minimumBitCount<YGOverflow>();
|
||||||
|
|
||||||
@@ -193,10 +194,10 @@ class YG_EXPORT Style {
|
|||||||
return {*this, positionTypeOffset};
|
return {*this, positionTypeOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
YGWrap flexWrap() const {
|
Wrap flexWrap() const {
|
||||||
return getEnumData<YGWrap>(flags, flexWrapOffset);
|
return getEnumData<Wrap>(flags, flexWrapOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGWrap> flexWrap() {
|
BitfieldRef<Wrap> flexWrap() {
|
||||||
return {*this, flexWrapOffset};
|
return {*this, flexWrapOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user