C++ style enums 16/N: Dimension (#1403)
Summary: X-link: https://github.com/facebook/react-native/pull/39598 Pull Request resolved: https://github.com/facebook/yoga/pull/1403 Replaces all usages of YGDimension with Dimension. Adds `yoga::to_underlying` to act like `std::to_underlying`, added in C++ 23. This enum is oddly only used internally, and is never an input to the public API, but it handled as any other public generated enum. Potentially some more cleanup to do there. Changelog: [Internal] Reviewed By: rshest Differential Revision: D49475409 fbshipit-source-id: 7d4c31e8a84485baea0dab50b5cf16b86769fa07
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8d24fcd90f
commit
a8566a0150
@@ -339,7 +339,7 @@ void Node::setLayoutComputedFlexBasisGeneration(
|
||||
|
||||
void Node::setLayoutMeasuredDimension(
|
||||
float measuredDimension,
|
||||
YGDimension dimension) {
|
||||
Dimension dimension) {
|
||||
layout_.setMeasuredDimension(dimension, measuredDimension);
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ void Node::setLayoutHadOverflow(bool hadOverflow) {
|
||||
layout_.setHadOverflow(hadOverflow);
|
||||
}
|
||||
|
||||
void Node::setLayoutDimension(float dimensionValue, YGDimension dimension) {
|
||||
void Node::setLayoutDimension(float dimensionValue, Dimension dimension) {
|
||||
layout_.setDimension(dimension, dimensionValue);
|
||||
}
|
||||
|
||||
@@ -433,14 +433,13 @@ YGValue Node::resolveFlexBasisPtr() const {
|
||||
}
|
||||
|
||||
void Node::resolveDimension() {
|
||||
using namespace yoga;
|
||||
const Style& style = getStyle();
|
||||
for (auto dim : {YGDimensionWidth, YGDimensionHeight}) {
|
||||
for (auto dim : {Dimension::Width, Dimension::Height}) {
|
||||
if (!style.maxDimension(dim).isUndefined() &&
|
||||
yoga::inexactEquals(style.maxDimension(dim), style.minDimension(dim))) {
|
||||
resolvedDimensions_[dim] = style.maxDimension(dim);
|
||||
resolvedDimensions_[yoga::to_underlying(dim)] = style.maxDimension(dim);
|
||||
} else {
|
||||
resolvedDimensions_[dim] = style.dimension(dim);
|
||||
resolvedDimensions_[yoga::to_underlying(dim)] = style.dimension(dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user