From 77efd191a8293bea88f3753f0404c10d37e39de5 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 11 Apr 2024 10:00:25 -0700 Subject: [PATCH] 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 --- .../react/renderer/components/text/ParagraphShadowNode.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp index 0f78030f070..98fb4fce4de 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.cpp @@ -30,7 +30,7 @@ ParagraphShadowNode::ParagraphShadowNode( const ShadowNodeFragment& fragment) : ConcreteViewShadowNode(sourceShadowNode, fragment) { auto& sourceParagraphShadowNode = - dynamic_cast(sourceShadowNode); + static_cast(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); }