Skip to content

Commit 342e3ec

Browse files
NickGerlemancipolleschi
authored andcommittedJan 9, 2025··
Fix TextMeasureCacheKey Throwing Out Some LayoutConstraints (#48525)
Summary: Pull Request resolved: #48525 Fixes #48249 `TextMeasureCacheKey` hash and equality functions only incorporates the maximum width constraint. I'm guessing this was an attempt at an optimization, but it can lead to incorrect results in pretty trivial cases. E.g. if Yoga knows a definite size of `Text` in one dimension, and measures via `YGMeasureModeExactly`, we can have a minimum size corresponding specific to the style in which the text was laid out. Changelog: [General][Fixed] - Fix TextMeasureCacheKey Throwing Out Some LayoutConstraints Reviewed By: christophpurrer Differential Revision: D67922414 fbshipit-source-id: 0ee0220059fc4e4645b1684c42a0587fe728bedd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ inline bool operator==(
208208
return areAttributedStringsEquivalentLayoutWise(
209209
lhs.attributedString, rhs.attributedString) &&
210210
lhs.paragraphAttributes == rhs.paragraphAttributes &&
211-
lhs.layoutConstraints.maximumSize.width ==
212-
rhs.layoutConstraints.maximumSize.width;
211+
lhs.layoutConstraints == rhs.layoutConstraints;
213212
}
214213

215214
inline bool operator!=(
@@ -243,7 +242,7 @@ struct hash<facebook::react::TextMeasureCacheKey> {
243242
return facebook::react::hash_combine(
244243
attributedStringHashLayoutWise(key.attributedString),
245244
key.paragraphAttributes,
246-
key.layoutConstraints.maximumSize.width);
245+
key.layoutConstraints);
247246
}
248247
};
249248

0 commit comments

Comments
 (0)
Please sign in to comment.