C++ style enums 8/N: Direction (#1392)
Summary: X-link: https://github.com/facebook/react-native/pull/39483 Pull Request resolved: https://github.com/facebook/yoga/pull/1392 Moves internal usages of YGDirection to Direction. bypass-github-export-checks Changelog: [Internal] Reviewed By: rshest Differential Revision: D49335231 fbshipit-source-id: 459fe820c91be88734cebaa8655cd3f0afda83bf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ea3869fe9f
commit
9b99e4fc22
@@ -10,6 +10,7 @@
|
||||
#include <array>
|
||||
|
||||
#include <yoga/bits/NumericBitfield.h>
|
||||
#include <yoga/enums/Direction.h>
|
||||
#include <yoga/node/CachedMeasurement.h>
|
||||
#include <yoga/numeric/FloatOptional.h>
|
||||
|
||||
@@ -27,7 +28,7 @@ struct LayoutResults {
|
||||
std::array<float, 4> padding = {};
|
||||
|
||||
private:
|
||||
uint32_t direction_ : 2 = static_cast<uint32_t>(YGDirectionInherit) & 0x03;
|
||||
Direction direction_ : bitCount<Direction>() = Direction::Inherit;
|
||||
bool hadOverflow_ : 1 = false;
|
||||
|
||||
public:
|
||||
@@ -37,7 +38,7 @@ struct LayoutResults {
|
||||
// Instead of recomputing the entire layout every single time, we cache some
|
||||
// information to break early when nothing changed
|
||||
uint32_t generationCount = 0;
|
||||
YGDirection lastOwnerDirection = YGDirectionInherit;
|
||||
Direction lastOwnerDirection = Direction::Inherit;
|
||||
|
||||
uint32_t nextCachedMeasurementsIndex = 0;
|
||||
std::array<CachedMeasurement, MaxCachedMeasurements> cachedMeasurements = {};
|
||||
@@ -45,12 +46,12 @@ struct LayoutResults {
|
||||
|
||||
CachedMeasurement cachedLayout{};
|
||||
|
||||
YGDirection direction() const {
|
||||
return static_cast<YGDirection>(direction_);
|
||||
Direction direction() const {
|
||||
return direction_;
|
||||
}
|
||||
|
||||
void setDirection(YGDirection direction) {
|
||||
direction_ = static_cast<uint32_t>(direction) & 0x03;
|
||||
void setDirection(Direction direction) {
|
||||
direction_ = direction;
|
||||
}
|
||||
|
||||
bool hadOverflow() const {
|
||||
|
@@ -296,7 +296,7 @@ void Node::removeChild(size_t index) {
|
||||
children_.erase(children_.begin() + static_cast<ptrdiff_t>(index));
|
||||
}
|
||||
|
||||
void Node::setLayoutDirection(YGDirection direction) {
|
||||
void Node::setLayoutDirection(Direction direction) {
|
||||
layout_.setDirection(direction);
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ void Node::setLayoutPadding(float padding, YGEdge edge) {
|
||||
layout_.padding[edge] = padding;
|
||||
}
|
||||
|
||||
void Node::setLayoutLastOwnerDirection(YGDirection direction) {
|
||||
void Node::setLayoutLastOwnerDirection(Direction direction) {
|
||||
layout_.lastOwnerDirection = direction;
|
||||
}
|
||||
|
||||
@@ -369,14 +369,14 @@ FloatOptional Node::relativePosition(
|
||||
}
|
||||
|
||||
void Node::setPosition(
|
||||
const YGDirection direction,
|
||||
const Direction direction,
|
||||
const float mainSize,
|
||||
const float crossSize,
|
||||
const float ownerWidth) {
|
||||
/* Root nodes should be always layouted as LTR, so we don't return negative
|
||||
* values. */
|
||||
const YGDirection directionRespectingRoot =
|
||||
owner_ != nullptr ? direction : YGDirectionLTR;
|
||||
const Direction directionRespectingRoot =
|
||||
owner_ != nullptr ? direction : Direction::LTR;
|
||||
const YGFlexDirection mainAxis =
|
||||
yoga::resolveDirection(style_.flexDirection(), directionRespectingRoot);
|
||||
const YGFlexDirection crossAxis =
|
||||
@@ -447,10 +447,10 @@ void Node::resolveDimension() {
|
||||
}
|
||||
}
|
||||
|
||||
YGDirection Node::resolveDirection(const YGDirection ownerDirection) {
|
||||
if (style_.direction() == YGDirectionInherit) {
|
||||
return ownerDirection > YGDirectionInherit ? ownerDirection
|
||||
: YGDirectionLTR;
|
||||
Direction Node::resolveDirection(const Direction ownerDirection) {
|
||||
if (style_.direction() == Direction::Inherit) {
|
||||
return ownerDirection != Direction::Inherit ? ownerDirection
|
||||
: Direction::LTR;
|
||||
} else {
|
||||
return style_.direction();
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
#include <yoga/config/Config.h>
|
||||
#include <yoga/enums/Direction.h>
|
||||
#include <yoga/enums/Errata.h>
|
||||
#include <yoga/enums/MeasureMode.h>
|
||||
#include <yoga/enums/NodeType.h>
|
||||
@@ -289,7 +290,7 @@ class YG_EXPORT Node : public ::YGNode {
|
||||
void setConfig(Config* config);
|
||||
|
||||
void setDirty(bool isDirty);
|
||||
void setLayoutLastOwnerDirection(YGDirection direction);
|
||||
void setLayoutLastOwnerDirection(Direction direction);
|
||||
void setLayoutComputedFlexBasis(const FloatOptional computedFlexBasis);
|
||||
void setLayoutComputedFlexBasisGeneration(
|
||||
uint32_t computedFlexBasisGeneration);
|
||||
@@ -298,13 +299,13 @@ class YG_EXPORT Node : public ::YGNode {
|
||||
YGDimension dimension);
|
||||
void setLayoutHadOverflow(bool hadOverflow);
|
||||
void setLayoutDimension(float dimensionValue, YGDimension dimension);
|
||||
void setLayoutDirection(YGDirection direction);
|
||||
void setLayoutDirection(Direction direction);
|
||||
void setLayoutMargin(float margin, YGEdge edge);
|
||||
void setLayoutBorder(float border, YGEdge edge);
|
||||
void setLayoutPadding(float padding, YGEdge edge);
|
||||
void setLayoutPosition(float position, YGEdge edge);
|
||||
void setPosition(
|
||||
const YGDirection direction,
|
||||
const Direction direction,
|
||||
const float mainSize,
|
||||
const float crossSize,
|
||||
const float ownerWidth);
|
||||
@@ -315,7 +316,7 @@ class YG_EXPORT Node : public ::YGNode {
|
||||
YGValue marginTrailingValue(const YGFlexDirection axis) const;
|
||||
YGValue resolveFlexBasisPtr() const;
|
||||
void resolveDimension();
|
||||
YGDirection resolveDirection(const YGDirection ownerDirection);
|
||||
Direction resolveDirection(const Direction ownerDirection);
|
||||
void clearChildren();
|
||||
/// Replaces the occurrences of oldChild with newChild
|
||||
void replaceChild(Node* oldChild, Node* newChild);
|
||||
|
Reference in New Issue
Block a user