Skip to content

Commit add1113

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Support ReactTextViewManagerCallback in Facsimile (#51759)
Summary: Pull Request resolved: #51759 Builds upon the changes in the last diff, to let Facsimile support `ReactTextViewManagerCallback`. We use the same new mechanism, of using `RCTTextViewManager` as the callback, if present, instead of relying on view manager measure function. Changelog: [Internal] Reviewed By: javache Differential Revision: D75830964 fbshipit-source-id: 435798e6be08f579579eb0f2d30a67d4b1fcaf10
1 parent 2ba86ca commit add1113

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ public PreparedLayout prepareLayout(
652652
float maxHeight) {
653653
SurfaceMountingManager surfaceMountingManager =
654654
mMountingManager.getSurfaceManagerEnforced(surfaceId, "prepareLayout");
655+
ViewManager textViewManager = mViewManagerRegistry.get(ReactTextViewManager.REACT_CLASS);
655656

656657
return TextLayoutManager.createPreparedLayout(
657658
Preconditions.checkNotNull(surfaceMountingManager.getContext()),
@@ -660,7 +661,10 @@ public PreparedLayout prepareLayout(
660661
getYogaSize(minWidth, maxWidth),
661662
getYogaMeasureMode(minWidth, maxWidth),
662663
getYogaSize(minHeight, maxHeight),
663-
getYogaMeasureMode(minHeight, maxHeight));
664+
getYogaMeasureMode(minHeight, maxHeight),
665+
textViewManager instanceof ReactTextViewManagerCallback
666+
? (ReactTextViewManagerCallback) textViewManager
667+
: null);
664668
}
665669

666670
@AnyThread

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package com.facebook.react.views.text
99

10+
import android.text.Spannable
1011
import android.text.Spanned
1112
import android.view.View
1213
import com.facebook.react.R
@@ -34,10 +35,14 @@ import java.util.HashMap
3435

3536
@ReactModule(name = PreparedLayoutTextViewManager.REACT_CLASS)
3637
internal class PreparedLayoutTextViewManager :
37-
BaseViewManager<PreparedLayoutTextView, LayoutShadowNode>(),
38-
IViewGroupManager<PreparedLayoutTextView> {
39-
40-
init {
38+
BaseViewManager<PreparedLayoutTextView, LayoutShadowNode>,
39+
IViewGroupManager<PreparedLayoutTextView>,
40+
ReactTextViewManagerCallback {
41+
private val reactTextViewManagerCallback: ReactTextViewManagerCallback?
42+
43+
@JvmOverloads
44+
constructor(reactTextViewManagerCallback: ReactTextViewManagerCallback? = null) : super() {
45+
this.reactTextViewManagerCallback = reactTextViewManagerCallback
4146
setupViewRecycling()
4247
}
4348

@@ -205,6 +210,10 @@ internal class PreparedLayoutTextViewManager :
205210

206211
override fun needsCustomLayoutForChildren(): Boolean = false
207212

213+
override fun onPostProcessSpannable(text: Spannable) {
214+
reactTextViewManagerCallback?.onPostProcessSpannable(text)
215+
}
216+
208217
public companion object {
209218
public const val REACT_CLASS: String = "RCTText"
210219
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,8 @@ public static PreparedLayout createPreparedLayout(
705705
float width,
706706
YogaMeasureMode widthYogaMeasureMode,
707707
float height,
708-
YogaMeasureMode heightYogaMeasureMode) {
708+
YogaMeasureMode heightYogaMeasureMode,
709+
@Nullable ReactTextViewManagerCallback reactTextViewManagerCallback) {
709710
Layout layout =
710711
TextLayoutManager.createLayout(
711712
Preconditions.checkNotNull(context),
@@ -715,7 +716,7 @@ public static PreparedLayout createPreparedLayout(
715716
widthYogaMeasureMode,
716717
height,
717718
heightYogaMeasureMode,
718-
null /* T219881133: Migrate away from ReactTextViewManagerCallback */);
719+
reactTextViewManagerCallback);
719720

720721
int maximumNumberOfLines =
721722
paragraphAttributes.contains(TextLayoutManager.PA_KEY_MAX_NUMBER_OF_LINES)

0 commit comments

Comments
 (0)