use availableSize instead of measure result for measureLines (#43979)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43979

changelog: [internal]

using `availableSize` instead of `measurement` to avoid dependency on calling `textLayoutManager_->measure` before dispatching `onTextLayout` event.
This is important in subsequent optimisation.

Reviewed By: javache

Differential Revision: D55796594

fbshipit-source-id: 06b516e2afaf668c6359ad86b570229824933bae
This commit is contained in:
Samuel Susla
2024-04-11 10:00:25 -07:00
committed by Facebook GitHub Bot
parent 5e9ed14cb1
commit 77efd191a8
@@ -30,7 +30,7 @@ ParagraphShadowNode::ParagraphShadowNode(
const ShadowNodeFragment& fragment)
: ConcreteViewShadowNode(sourceShadowNode, fragment) {
auto& sourceParagraphShadowNode =
dynamic_cast<const ParagraphShadowNode&>(sourceShadowNode);
static_cast<const ParagraphShadowNode&>(sourceShadowNode);
if (!fragment.children && !fragment.props &&
sourceParagraphShadowNode.getIsLayoutClean()) {
// This ParagraphShadowNode was cloned but did not change
@@ -185,9 +185,7 @@ void ParagraphShadowNode::layout(LayoutContext layoutContext) {
if (getConcreteProps().onTextLayout) {
auto linesMeasurements = textLayoutManager_->measureLines(
content.attributedString,
content.paragraphAttributes,
measurement.size);
content.attributedString, content.paragraphAttributes, availableSize);
getConcreteEventEmitter().onTextLayout(linesMeasurements);
}