Skip to content

Commit

Permalink
C++ style enu,s 13/N: Wrap
Browse files Browse the repository at this point in the history
Summary:
Moves internal usages of YGPositionType to PositionType
Changelog: [Internal]

Differential Revision: D49361746

fbshipit-source-id: c57ee76f93375f211c813dfac26a398d20959114
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Sep 19, 2023
1 parent b020ea0 commit 09a4302
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
7 changes: 1 addition & 6 deletions tests/YGStyleAccessorsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,7 @@ ACCESSOR_TEST(
PositionType::Absolute,
PositionType::Relative)

ACCESSOR_TEST(
flexWrap,
YGWrapNoWrap,
YGWrapWrap,
YGWrapWrapReverse,
YGWrapNoWrap)
ACCESSOR_TEST(flexWrap, Wrap::NoWrap, Wrap::Wrap, Wrap::WrapReverse)

ACCESSOR_TEST(
overflow,
Expand Down
5 changes: 3 additions & 2 deletions yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,11 @@ YGPositionType YGNodeStyleGetPositionType(const YGNodeConstRef node) {
}

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) {
return resolveRef(node)->getStyle().flexWrap();
return unscopedEnum(resolveRef(node)->getStyle().flexWrap());
}

void YGNodeStyleSetOverflow(const YGNodeRef node, const YGOverflow overflow) {
Expand Down
8 changes: 4 additions & 4 deletions yoga/algorithm/CalculateLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ static void layoutAbsoluteChild(
} else if (
!child->isLeadingPositionDefined(crossAxis) &&
((resolveChildAlignment(node, child) == Align::FlexEnd) ^
(node->getStyle().flexWrap() == YGWrapWrapReverse))) {
(node->getStyle().flexWrap() == Wrap::WrapReverse))) {
child->setLayoutPosition(
(node->getLayout().measuredDimensions[dimension(crossAxis)] -
child->getLayout().measuredDimensions[dimension(crossAxis)]),
Expand Down Expand Up @@ -877,7 +877,7 @@ static float distributeFreeSpaceSecondPass(
float flexGrowFactor = 0;
float deltaFreeSpace = 0;
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) {
childFlexBasis = boundAxisWithinMinAndMax(
Expand Down Expand Up @@ -1604,7 +1604,7 @@ static void calculateLayoutImpl(
resolveDirection(node->getStyle().flexDirection(), direction);
const FlexDirection crossAxis = resolveCrossDirection(mainAxis, direction);
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 crossAxisownerSize = isMainAxisRow ? ownerHeight : ownerWidth;
Expand Down Expand Up @@ -2302,7 +2302,7 @@ static void calculateLayoutImpl(

// As we only wrapped in normal direction yet, we need to reverse the
// positions on wrap-reverse.
if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) {
if (performLayout && node->getStyle().flexWrap() == Wrap::WrapReverse) {
for (size_t i = 0; i < childCount; i++) {
const auto child = node->getChild(i);
if (child->getStyle().positionType() != PositionType::Absolute) {
Expand Down
2 changes: 1 addition & 1 deletion yoga/algorithm/FlexLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ FlexLine calculateFlexLine(
float sizeConsumedIncludingMinConstraint = 0;
const FlexDirection mainAxis = resolveDirection(
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();

// Add items to the current line until it's full or we run out of items.
Expand Down
3 changes: 1 addition & 2 deletions yoga/debug/NodeToString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ void nodeToString(
appendFloatOptionalIfDefined(str, "flex", style.flex());

if (style.flexWrap() != yoga::Node{}.getStyle().flexWrap()) {
appendFormattedString(
str, "flex-wrap: %s; ", YGWrapToString(style.flexWrap()));
appendFormattedString(str, "flex-wrap: %s; ", toString(style.flexWrap()));
}

if (style.overflow() != yoga::Node{}.getStyle().overflow()) {
Expand Down
9 changes: 5 additions & 4 deletions yoga/style/Style.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <yoga/enums/FlexDirection.h>
#include <yoga/enums/Justify.h>
#include <yoga/enums/PositionType.h>
#include <yoga/enums/Wrap.h>
#include <yoga/numeric/FloatOptional.h>
#include <yoga/style/CompactValue.h>

Expand Down Expand Up @@ -119,7 +120,7 @@ class YG_EXPORT Style {
static constexpr uint8_t flexWrapOffset =
positionTypeOffset + minimumBitCount<PositionType>();
static constexpr uint8_t overflowOffset =
flexWrapOffset + minimumBitCount<YGWrap>();
flexWrapOffset + minimumBitCount<Wrap>();
static constexpr uint8_t displayOffset =
overflowOffset + minimumBitCount<YGOverflow>();

Expand Down Expand Up @@ -193,10 +194,10 @@ class YG_EXPORT Style {
return {*this, positionTypeOffset};
}

YGWrap flexWrap() const {
return getEnumData<YGWrap>(flags, flexWrapOffset);
Wrap flexWrap() const {
return getEnumData<Wrap>(flags, flexWrapOffset);
}
BitfieldRef<YGWrap> flexWrap() {
BitfieldRef<Wrap> flexWrap() {
return {*this, flexWrapOffset};
}

Expand Down

0 comments on commit 09a4302

Please sign in to comment.