Revert D74291373: Ensure that ShadowNode measure functions respect constraints

Differential Revision:
D74291373

Original commit changeset: 44166f2e4732

Original Phabricator Diff: D74291373

fbshipit-source-id: 54a4dd0af1c020caacebe6f02cb95eba0c95c62f
This commit is contained in:
Yannick Loriot
2025-05-09 01:45:16 -07:00
committed by Facebook GitHub Bot
parent 435d2e84ef
commit 7a72037b37
4 changed files with 4 additions and 26 deletions
@@ -825,7 +825,7 @@ public class TextLayoutManager {
// where the container is measured smaller than text. Math.ceil prevents it
// See T136756103 for investigation
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
calculatedWidth = Math.min((float) Math.ceil(calculatedWidth), width);
calculatedWidth = (float) Math.ceil(calculatedWidth);
}
return calculatedWidth;
}
@@ -15,11 +15,9 @@
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/components/view/ViewShadowNode.h>
#include <react/renderer/components/view/conversions.h>
#include <react/renderer/core/ComponentDescriptor.h>
#include <react/renderer/core/LayoutConstraints.h>
#include <react/renderer/core/LayoutContext.h>
#include <react/renderer/debug/DebugStringConvertibleItem.h>
#include <react/utils/FloatComparison.h>
#include <yoga/Yoga.h>
#include <algorithm>
#include <limits>
@@ -839,21 +837,6 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
auto size = shadowNode.measureContent(
threadLocalLayoutContext, {minimumSize, maximumSize});
#ifdef REACT_NATIVE_DEBUG
bool widthInBounds = size.width + kDefaultEpsilon >= minimumSize.width &&
size.width - kDefaultEpsilon <= maximumSize.width;
bool heightInBounds = size.height + kDefaultEpsilon >= minimumSize.height &&
size.height - kDefaultEpsilon <= maximumSize.height;
if (!widthInBounds || !heightInBounds) {
LOG(FATAL) << shadowNode.getComponentDescriptor().getComponentName()
<< " returned in invalid measurement. Min: ["
<< minimumSize.width << "," << minimumSize.height << "] Max: ["
<< maximumSize.width << "," << maximumSize.height
<< "] Actual: [" << size.width << "," << size.height << "]";
}
#endif
return YGSize{
yogaFloatFromFloat(size.width), yogaFloatFromFloat(size.height)};
}
@@ -17,7 +17,7 @@ TextMeasurement TextLayoutManager::measure(
const AttributedStringBox& attributedStringBox,
const ParagraphAttributes& /*paragraphAttributes*/,
const TextLayoutContext& /*layoutContext*/,
const LayoutConstraints& layoutConstraints) const {
const LayoutConstraints& /*layoutConstraints*/) const {
TextMeasurement::Attachments attachments;
for (const auto& fragment : attributedStringBox.getValue().getFragments()) {
if (fragment.isAttachment()) {
@@ -25,10 +25,7 @@ TextMeasurement TextLayoutManager::measure(
TextMeasurement::Attachment{{{0, 0}, {0, 0}}, false});
}
}
return TextMeasurement{
{layoutConstraints.minimumSize.width,
layoutConstraints.minimumSize.height},
attachments};
return TextMeasurement{{0, 0}, attachments};
}
} // namespace facebook::react
@@ -9,9 +9,7 @@
namespace facebook::react {
constexpr float kDefaultEpsilon = 0.005f;
inline bool floatEquality(float a, float b, float epsilon = kDefaultEpsilon) {
inline bool floatEquality(float a, float b, float epsilon = 0.005f) {
return (std::isnan(a) && std::isnan(b)) ||
(!std::isnan(a) && !std::isnan(b) && fabs(a - b) < epsilon);
}