A framework for building native applications using React
Clean up measurements path and ReactTextViewManagerCallback injection (#51758)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51758 ViewManager’s may implement a measure function (using MapBuffer, or ReadableMap). This isn’t used automatically, but may instead be used, by calling into FabricUIManager via JNI, and passing the component name of the view manager to use. This is only ever called manually, through specific C++ ShadowNodes. Confusingly, for some cases, like `TextInput`, we use the measure function on `RCTText` instead, because this call to FabricUIManager is hidden behind `TextLayoutManager`. This ends up really breaking Facsimile, since we want to measure these in a different way, while still measuring `TextInput` without preparing a layout. This mechanism is also used to inject `ReactTextViewManager` from the Text View Manager, into the measurement process, for both Text, and TextInput. I think we would ideally remove and replace the current View Manager measurement mechanism entirely. The interface doesn’t do what it claims to, and requires calling private Java methods via JNI, which we shouldn’t be encouraging external libraries to do. Only a single 3p librar (react-native-picker) uses this, but we have a lot of internal usages, and the current facility is valuable, for translating surface ID into a context. Ie we could not deprecate it without a well thought out replacement. Instead, this change: 1. Removes the "generalized" version of this for MapBuffer, only ever used by Text 2. Given ourselves a `measureText` function, that will use a spannable processor provided, but go through TextLayoutManager, instead of trying to use this generalized path 3. Documents some of the weirdness of the current setup, without yet deprecating it This will let the Facsimile View Manager: 1. Provide a ReactTextViewManagerCallback, like the previous version allowed, that influences measurement of both Text, and TextInput (which is... strange, but... not trying to boil the ocean here) 2. TextInput can now measure text, even if Facsimile View Manager doesn't implement this traditional measure interface Changelog: [Android][Breaking] - Remove FabricUIManager.measureMapBuffer() and MapBuffer measure functions on ViewManager. Please use ReadableMap variant. [Android][Breaking] - Remove FabricUIManager.measure overload which accepts attachment positions Reviewed By: javache Differential Revision: D75826792 fbshipit-source-id: 6739b1e2e214351b9b95ba782d73cf4278211ab8
N
Nick Gerleman committed
2ba86caf18d86f6902f987ec9a0aa94bf67c1b4e
Parent: 997b7c9
Committed by Facebook GitHub Bot <[email protected]>
on 6/5/2025, 2:33:30 AM