Rename Node.h's getResolvedDimension to getProcessedDimension (#1705)

Summary:
X-link: https://github.com/facebook/react-native/pull/46649

Pull Request resolved: https://github.com/facebook/yoga/pull/1705

To get the height and width we call a function currently named `getResolvedDimension`. This returns a `Style::Length`, which in most cases we "resolve" immediately by calling `resolve`. This is a bit confusing that you need to `resolve` something that is already `resolved`.

I plan on adding a new function soon for `contentBox` which would resolve the length for you, so I think this should be renamed.

Also deleted unused `getResolvedDimensions`

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63407730

fbshipit-source-id: e855c17d9c99817be308b7263fcb5d43559ede14
This commit is contained in:
Joe Vilches
2024-10-01 15:19:22 -07:00
committed by Facebook GitHub Bot
parent 22b018c957
commit b02caa8e06
4 changed files with 23 additions and 27 deletions

View File

@@ -43,7 +43,7 @@ Node::Node(Node&& node) noexcept
owner_(node.owner_),
children_(std::move(node.children_)),
config_(node.config_),
resolvedDimensions_(node.resolvedDimensions_) {
processedDimensions_(node.processedDimensions_) {
for (auto c : children_) {
c->setOwner(this);
}
@@ -292,14 +292,14 @@ Style::Length Node::resolveFlexBasisPtr() const {
return value::ofAuto();
}
void Node::resolveDimension() {
void Node::processDimensions() {
for (auto dim : {Dimension::Width, Dimension::Height}) {
if (style_.maxDimension(dim).isDefined() &&
yoga::inexactEquals(
style_.maxDimension(dim), style_.minDimension(dim))) {
resolvedDimensions_[yoga::to_underlying(dim)] = style_.maxDimension(dim);
processedDimensions_[yoga::to_underlying(dim)] = style_.maxDimension(dim);
} else {
resolvedDimensions_[yoga::to_underlying(dim)] = style_.dimension(dim);
processedDimensions_[yoga::to_underlying(dim)] = style_.dimension(dim);
}
}
}

View File

@@ -86,7 +86,7 @@ class YG_EXPORT Node : public ::YGNode {
* https://www.w3.org/TR/css-sizing-3/#definite
*/
inline bool hasDefiniteLength(Dimension dimension, float ownerSize) {
auto usedValue = getResolvedDimension(dimension).resolve(ownerSize);
auto usedValue = getProcessedDimension(dimension).resolve(ownerSize);
return usedValue.isDefined() && usedValue.unwrap() >= 0.0f;
}
@@ -152,12 +152,8 @@ class YG_EXPORT Node : public ::YGNode {
return isDirty_;
}
std::array<Style::Length, 2> getResolvedDimensions() const {
return resolvedDimensions_;
}
Style::Length getResolvedDimension(Dimension dimension) const {
return resolvedDimensions_[static_cast<size_t>(dimension)];
Style::Length getProcessedDimension(Dimension dimension) const {
return processedDimensions_[static_cast<size_t>(dimension)];
}
// Setters
@@ -233,7 +229,7 @@ class YG_EXPORT Node : public ::YGNode {
// Other methods
Style::Length resolveFlexBasisPtr() const;
void resolveDimension();
void processDimensions();
Direction resolveDirection(Direction ownerDirection);
void clearChildren();
/// Replaces the occurrences of oldChild with newChild
@@ -280,7 +276,7 @@ class YG_EXPORT Node : public ::YGNode {
Node* owner_ = nullptr;
std::vector<Node*> children_;
const Config* config_;
std::array<Style::Length, 2> resolvedDimensions_{
std::array<Style::Length, 2> processedDimensions_{
{value::undefined(), value::undefined()}};
};