Skip to content

Commit 7a72037

Browse files
yannicklfacebook-github-bot
authored andcommitted
Revert D74291373: Ensure that ShadowNode measure functions respect constraints
Differential Revision: D74291373 Original commit changeset: 44166f2e4732 Original Phabricator Diff: D74291373 fbshipit-source-id: 54a4dd0af1c020caacebe6f02cb95eba0c95c62f
1 parent 435d2e8 commit 7a72037

4 files changed

Lines changed: 4 additions & 26 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ private static float calculateWidth(
825825
// where the container is measured smaller than text. Math.ceil prevents it
826826
// See T136756103 for investigation
827827
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
828-
calculatedWidth = Math.min((float) Math.ceil(calculatedWidth), width);
828+
calculatedWidth = (float) Math.ceil(calculatedWidth);
829829
}
830830
return calculatedWidth;
831831
}

packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
#include <react/renderer/components/view/ViewProps.h>
1616
#include <react/renderer/components/view/ViewShadowNode.h>
1717
#include <react/renderer/components/view/conversions.h>
18-
#include <react/renderer/core/ComponentDescriptor.h>
1918
#include <react/renderer/core/LayoutConstraints.h>
2019
#include <react/renderer/core/LayoutContext.h>
2120
#include <react/renderer/debug/DebugStringConvertibleItem.h>
22-
#include <react/utils/FloatComparison.h>
2321
#include <yoga/Yoga.h>
2422
#include <algorithm>
2523
#include <limits>
@@ -839,21 +837,6 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
839837
auto size = shadowNode.measureContent(
840838
threadLocalLayoutContext, {minimumSize, maximumSize});
841839

842-
#ifdef REACT_NATIVE_DEBUG
843-
bool widthInBounds = size.width + kDefaultEpsilon >= minimumSize.width &&
844-
size.width - kDefaultEpsilon <= maximumSize.width;
845-
bool heightInBounds = size.height + kDefaultEpsilon >= minimumSize.height &&
846-
size.height - kDefaultEpsilon <= maximumSize.height;
847-
848-
if (!widthInBounds || !heightInBounds) {
849-
LOG(FATAL) << shadowNode.getComponentDescriptor().getComponentName()
850-
<< " returned in invalid measurement. Min: ["
851-
<< minimumSize.width << "," << minimumSize.height << "] Max: ["
852-
<< maximumSize.width << "," << maximumSize.height
853-
<< "] Actual: [" << size.width << "," << size.height << "]";
854-
}
855-
#endif
856-
857840
return YGSize{
858841
yogaFloatFromFloat(size.width), yogaFloatFromFloat(size.height)};
859842
}

packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/cxx/react/renderer/textlayoutmanager/TextLayoutManager.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,15 @@ TextMeasurement TextLayoutManager::measure(
1717
const AttributedStringBox& attributedStringBox,
1818
const ParagraphAttributes& /*paragraphAttributes*/,
1919
const TextLayoutContext& /*layoutContext*/,
20-
const LayoutConstraints& layoutConstraints) const {
20+
const LayoutConstraints& /*layoutConstraints*/) const {
2121
TextMeasurement::Attachments attachments;
2222
for (const auto& fragment : attributedStringBox.getValue().getFragments()) {
2323
if (fragment.isAttachment()) {
2424
attachments.push_back(
2525
TextMeasurement::Attachment{{{0, 0}, {0, 0}}, false});
2626
}
2727
}
28-
return TextMeasurement{
29-
{layoutConstraints.minimumSize.width,
30-
layoutConstraints.minimumSize.height},
31-
attachments};
28+
return TextMeasurement{{0, 0}, attachments};
3229
}
3330

3431
} // namespace facebook::react

packages/react-native/ReactCommon/react/utils/FloatComparison.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
namespace facebook::react {
1111

12-
constexpr float kDefaultEpsilon = 0.005f;
13-
14-
inline bool floatEquality(float a, float b, float epsilon = kDefaultEpsilon) {
12+
inline bool floatEquality(float a, float b, float epsilon = 0.005f) {
1513
return (std::isnan(a) && std::isnan(b)) ||
1614
(!std::isnan(a) && !std::isnan(b) && fabs(a - b) < epsilon);
1715
}

0 commit comments

Comments
 (0)