C++ Style enums 12/N: PositionType (#1399)
Summary: X-link: https://github.com/facebook/react-native/pull/39538 Pull Request resolved: https://github.com/facebook/yoga/pull/1399 Moves internal usages of YGPositionType to PositionType bypass-github-export-checks Changelog: [Internal] Reviewed By: rshest Differential Revision: D49361677 fbshipit-source-id: 526222d6cf9f3dc26eddfbfb8a04de4ba28e14a9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5bf81b1ef8
commit
4ea6b4c4f9
@@ -131,10 +131,9 @@ ACCESSOR_TEST(
|
|||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
positionType,
|
positionType,
|
||||||
YGPositionTypeStatic,
|
PositionType::Static,
|
||||||
YGPositionTypeAbsolute,
|
PositionType::Absolute,
|
||||||
YGPositionTypeRelative,
|
PositionType::Relative)
|
||||||
YGPositionTypeStatic)
|
|
||||||
|
|
||||||
ACCESSOR_TEST(
|
ACCESSOR_TEST(
|
||||||
flexWrap,
|
flexWrap,
|
||||||
|
@@ -485,10 +485,10 @@ void YGNodeStyleSetPositionType(
|
|||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGPositionType positionType) {
|
const YGPositionType positionType) {
|
||||||
updateStyle<MSVC_HINT(positionType)>(
|
updateStyle<MSVC_HINT(positionType)>(
|
||||||
node, &Style::positionType, positionType);
|
node, &Style::positionType, scopedEnum(positionType));
|
||||||
}
|
}
|
||||||
YGPositionType YGNodeStyleGetPositionType(const YGNodeConstRef node) {
|
YGPositionType YGNodeStyleGetPositionType(const YGNodeConstRef node) {
|
||||||
return resolveRef(node)->getStyle().positionType();
|
return unscopedEnum(resolveRef(node)->getStyle().positionType());
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) {
|
void YGNodeStyleSetFlexWrap(const YGNodeRef node, const YGWrap flexWrap) {
|
||||||
|
@@ -38,7 +38,7 @@ float calculateBaseline(const yoga::Node* node) {
|
|||||||
if (child->getLineIndex() > 0) {
|
if (child->getLineIndex() > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() == PositionType::Absolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (resolveChildAlignment(node, child) == Align::Baseline ||
|
if (resolveChildAlignment(node, child) == Align::Baseline ||
|
||||||
@@ -70,7 +70,7 @@ bool isBaselineLayout(const yoga::Node* node) {
|
|||||||
const auto childCount = node->getChildCount();
|
const auto childCount = node->getChildCount();
|
||||||
for (size_t i = 0; i < childCount; i++) {
|
for (size_t i = 0; i < childCount; i++) {
|
||||||
auto child = node->getChild(i);
|
auto child = node->getChild(i);
|
||||||
if (child->getStyle().positionType() != YGPositionTypeAbsolute &&
|
if (child->getStyle().positionType() != PositionType::Absolute &&
|
||||||
child->getStyle().alignSelf() == Align::Baseline) {
|
child->getStyle().alignSelf() == Align::Baseline) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -821,7 +821,7 @@ static float computeFlexBasisForChildren(
|
|||||||
childDirection, mainDim, crossDim, availableInnerWidth);
|
childDirection, mainDim, crossDim, availableInnerWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() == PositionType::Absolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child == singleFlexChild) {
|
if (child == singleFlexChild) {
|
||||||
@@ -1248,7 +1248,7 @@ static void justifyMainAxis(
|
|||||||
int numberOfAutoMarginsOnCurrentLine = 0;
|
int numberOfAutoMarginsOnCurrentLine = 0;
|
||||||
for (size_t i = startOfLineIndex; i < flexLine.endOfLineIndex; i++) {
|
for (size_t i = startOfLineIndex; i < flexLine.endOfLineIndex; i++) {
|
||||||
auto child = node->getChild(i);
|
auto child = node->getChild(i);
|
||||||
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() != PositionType::Absolute) {
|
||||||
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
||||||
numberOfAutoMarginsOnCurrentLine++;
|
numberOfAutoMarginsOnCurrentLine++;
|
||||||
}
|
}
|
||||||
@@ -1310,7 +1310,7 @@ static void justifyMainAxis(
|
|||||||
if (childStyle.display() == YGDisplayNone) {
|
if (childStyle.display() == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (childStyle.positionType() == YGPositionTypeAbsolute &&
|
if (childStyle.positionType() == PositionType::Absolute &&
|
||||||
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
|
||||||
@@ -1327,7 +1327,7 @@ static void justifyMainAxis(
|
|||||||
// 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() != YGPositionTypeAbsolute) {
|
if (childStyle.positionType() != PositionType::Absolute) {
|
||||||
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
if (child->marginLeadingValue(mainAxis).unit == YGUnitAuto) {
|
||||||
flexLine.layout.mainDim += flexLine.layout.remainingFreeSpace /
|
flexLine.layout.mainDim += flexLine.layout.remainingFreeSpace /
|
||||||
static_cast<float>(numberOfAutoMarginsOnCurrentLine);
|
static_cast<float>(numberOfAutoMarginsOnCurrentLine);
|
||||||
@@ -1866,7 +1866,7 @@ static void calculateLayoutImpl(
|
|||||||
if (child->getStyle().display() == YGDisplayNone) {
|
if (child->getStyle().display() == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() == PositionType::Absolute) {
|
||||||
// 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.
|
||||||
@@ -2072,7 +2072,7 @@ static void calculateLayoutImpl(
|
|||||||
if (child->getStyle().display() == YGDisplayNone) {
|
if (child->getStyle().display() == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() != PositionType::Absolute) {
|
||||||
if (child->getLineIndex() != i) {
|
if (child->getLineIndex() != i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2115,7 +2115,7 @@ static void calculateLayoutImpl(
|
|||||||
if (child->getStyle().display() == YGDisplayNone) {
|
if (child->getStyle().display() == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() != PositionType::Absolute) {
|
||||||
switch (resolveChildAlignment(node, child)) {
|
switch (resolveChildAlignment(node, child)) {
|
||||||
case Align::FlexStart: {
|
case Align::FlexStart: {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
@@ -2305,7 +2305,7 @@ static void calculateLayoutImpl(
|
|||||||
if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) {
|
if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) {
|
||||||
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() != YGPositionTypeAbsolute) {
|
if (child->getStyle().positionType() != PositionType::Absolute) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
node->getLayout().measuredDimensions[dimension(crossAxis)] -
|
||||||
child->getLayout().position[leadingEdge(crossAxis)] -
|
child->getLayout().position[leadingEdge(crossAxis)] -
|
||||||
@@ -2319,7 +2319,7 @@ static void calculateLayoutImpl(
|
|||||||
// 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().display() == YGDisplayNone ||
|
if (child->getStyle().display() == YGDisplayNone ||
|
||||||
child->getStyle().positionType() != YGPositionTypeAbsolute) {
|
child->getStyle().positionType() != PositionType::Absolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const bool absolutePercentageAgainstPaddingEdge =
|
const bool absolutePercentageAgainstPaddingEdge =
|
||||||
|
@@ -39,7 +39,7 @@ FlexLine calculateFlexLine(
|
|||||||
for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) {
|
for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) {
|
||||||
auto child = node->getChild(endOfLineIndex);
|
auto child = node->getChild(endOfLineIndex);
|
||||||
if (child->getStyle().display() == YGDisplayNone ||
|
if (child->getStyle().display() == YGDisplayNone ||
|
||||||
child->getStyle().positionType() == YGPositionTypeAbsolute) {
|
child->getStyle().positionType() == PositionType::Absolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -209,7 +209,7 @@ void nodeToString(
|
|||||||
|
|
||||||
if (style.positionType() != yoga::Node{}.getStyle().positionType()) {
|
if (style.positionType() != yoga::Node{}.getStyle().positionType()) {
|
||||||
appendFormattedString(
|
appendFormattedString(
|
||||||
str, "position: %s; ", YGPositionTypeToString(style.positionType()));
|
str, "position: %s; ", toString(style.positionType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
appendEdgeIfNotUndefined(str, "left", style.position(), YGEdgeLeft);
|
appendEdgeIfNotUndefined(str, "left", style.position(), YGEdgeLeft);
|
||||||
|
@@ -382,7 +382,7 @@ void Node::setPosition(
|
|||||||
const FlexDirection crossAxis =
|
const FlexDirection crossAxis =
|
||||||
yoga::resolveCrossDirection(mainAxis, directionRespectingRoot);
|
yoga::resolveCrossDirection(mainAxis, directionRespectingRoot);
|
||||||
|
|
||||||
// Here we should check for `YGPositionTypeStatic` and in this case zero inset
|
// Here we should check for `PositionType::Static` and in this case zero inset
|
||||||
// properties (left, right, top, bottom, begin, end).
|
// properties (left, right, top, bottom, begin, end).
|
||||||
// https://www.w3.org/TR/css-position-3/#valdef-position-static
|
// https://www.w3.org/TR/css-position-3/#valdef-position-static
|
||||||
const FloatOptional relativePositionMain =
|
const FloatOptional relativePositionMain =
|
||||||
@@ -522,7 +522,7 @@ float Node::resolveFlexShrink() const {
|
|||||||
|
|
||||||
bool Node::isNodeFlexible() {
|
bool Node::isNodeFlexible() {
|
||||||
return (
|
return (
|
||||||
(style_.positionType() != YGPositionTypeAbsolute) &&
|
(style_.positionType() != PositionType::Absolute) &&
|
||||||
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#include <yoga/enums/Direction.h>
|
#include <yoga/enums/Direction.h>
|
||||||
#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/numeric/FloatOptional.h>
|
#include <yoga/numeric/FloatOptional.h>
|
||||||
#include <yoga/style/CompactValue.h>
|
#include <yoga/style/CompactValue.h>
|
||||||
|
|
||||||
@@ -116,7 +117,7 @@ class YG_EXPORT Style {
|
|||||||
static constexpr uint8_t positionTypeOffset =
|
static constexpr uint8_t positionTypeOffset =
|
||||||
alignSelfOffset + minimumBitCount<Align>();
|
alignSelfOffset + minimumBitCount<Align>();
|
||||||
static constexpr uint8_t flexWrapOffset =
|
static constexpr uint8_t flexWrapOffset =
|
||||||
positionTypeOffset + minimumBitCount<YGPositionType>();
|
positionTypeOffset + minimumBitCount<PositionType>();
|
||||||
static constexpr uint8_t overflowOffset =
|
static constexpr uint8_t overflowOffset =
|
||||||
flexWrapOffset + minimumBitCount<YGWrap>();
|
flexWrapOffset + minimumBitCount<YGWrap>();
|
||||||
static constexpr uint8_t displayOffset =
|
static constexpr uint8_t displayOffset =
|
||||||
@@ -185,10 +186,10 @@ class YG_EXPORT Style {
|
|||||||
return {*this, alignSelfOffset};
|
return {*this, alignSelfOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
YGPositionType positionType() const {
|
PositionType positionType() const {
|
||||||
return getEnumData<YGPositionType>(flags, positionTypeOffset);
|
return getEnumData<PositionType>(flags, positionTypeOffset);
|
||||||
}
|
}
|
||||||
BitfieldRef<YGPositionType> positionType() {
|
BitfieldRef<PositionType> positionType() {
|
||||||
return {*this, positionTypeOffset};
|
return {*this, positionTypeOffset};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user