Skip to content

Commit

Permalink
Fix TextMeasureCacheKey Throwing Out Some LayoutConstraints (#48525)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NickGerleman authored and robhogan committed Jan 15, 2025
1 parent bbbeef6 commit e7db7a7
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ inline bool operator==(
return areAttributedStringsEquivalentLayoutWise(
lhs.attributedString, rhs.attributedString) &&
lhs.paragraphAttributes == rhs.paragraphAttributes &&
lhs.layoutConstraints.maximumSize.width ==
rhs.layoutConstraints.maximumSize.width;
lhs.layoutConstraints == rhs.layoutConstraints;
}

inline bool operator!=(
Expand Down Expand Up @@ -243,7 +242,7 @@ struct hash<facebook::react::TextMeasureCacheKey> {
return facebook::react::hash_combine(
attributedStringHashLayoutWise(key.attributedString),
key.paragraphAttributes,
key.layoutConstraints.maximumSize.width);
key.layoutConstraints);
}
};

Expand Down

0 comments on commit e7db7a7

Please sign in to comment.