Skip to content

Commit

Permalink
Revert D57285584: Sanitize measure function results
Browse files Browse the repository at this point in the history
Differential Revision:
D57285584

Original commit changeset: 935fcdd28c05

Original Phabricator Diff: D57285584

fbshipit-source-id: 3c5d7ccefd608885af4d6f08c0d1cd00553f1f34
  • Loading branch information
Gilad Bar authored and facebook-github-bot committed May 14, 2024
1 parent b53aa08 commit 1a56b9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
26 changes: 4 additions & 22 deletions packages/react-native/ReactCommon/yoga/yoga/node/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <iostream>

#include <yoga/debug/AssertFatal.h>
#include <yoga/debug/Log.h>
#include <yoga/node/Node.h>
#include <yoga/numeric/Comparison.h>

Expand Down Expand Up @@ -50,29 +49,12 @@ Node::Node(Node&& node) noexcept
}

YGSize Node::measure(
float availableWidth,
float width,
MeasureMode widthMode,
float availableHeight,
float height,
MeasureMode heightMode) {
const auto size = measureFunc_(
this,
availableWidth,
unscopedEnum(widthMode),
availableHeight,
unscopedEnum(heightMode));

if (yoga::isUndefined(size.height) || size.height < 0 ||
yoga::isUndefined(size.width) || size.width < 0) {
yoga::log(
this,
LogLevel::Error,
"Measure function returned an invalid dimension to Yoga: [width=%f, height=%f]",
size.width,
size.height);
return {.width = 0.0f, .height = 0.0f};
}

return size;
return measureFunc_(
this, width, unscopedEnum(widthMode), height, unscopedEnum(heightMode));
}

float Node::baseline(float width, float height) const {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/ReactCommon/yoga/yoga/node/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class YG_EXPORT Node : public ::YGNode {
}

YGSize measure(
float availableWidth,
float width,
MeasureMode widthMode,
float availableHeight,
float height,
MeasureMode heightMode);

bool hasBaselineFunc() const noexcept {
Expand Down

0 comments on commit 1a56b9a

Please sign in to comment.