From 6aea6256a603a6ce18a4e86a903b801bda598cfa Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 24 Feb 2020 18:15:39 -0800 Subject: [PATCH] Unify measure functions in Fabric Android Summary: Until now, there were two measure functions that differ in only one parameter (rootTag). The rootTag is used to use the context associated to the tag as part of the calculation of layout, otherwise it just uses the ReactApplicationContext. This diff unifies both method into an unique method that changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D20081281 fbshipit-source-id: b1f6a6cedbf78f36f36fd0f93407c23c6996d76b --- .../react/fabric/FabricUIManager.java | 27 +++---------------- .../platform/android/TextLayoutManager.cpp | 2 ++ 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 100e3b8327da77..a5d30309eff596 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -429,31 +429,10 @@ private long measure( float maxWidth, float minHeight, float maxHeight) { + ReactContext context = + rootTag < 0 ? mReactApplicationContext : mReactContextForRootTag.get(rootTag); return mMountingManager.measure( - mReactContextForRootTag.get(rootTag), - componentName, - localData, - props, - state, - getYogaSize(minWidth, maxWidth), - getYogaMeasureMode(minWidth, maxWidth), - getYogaSize(minHeight, maxHeight), - getYogaMeasureMode(minHeight, maxHeight)); - } - - @DoNotStrip - @SuppressWarnings("unused") - private long measure( - String componentName, - @NonNull ReadableMap localData, - @NonNull ReadableMap props, - @NonNull ReadableMap state, - float minWidth, - float maxWidth, - float minHeight, - float maxHeight) { - return mMountingManager.measure( - mReactApplicationContext, + context, componentName, localData, props, diff --git a/ReactCommon/fabric/textlayoutmanager/platform/android/TextLayoutManager.cpp b/ReactCommon/fabric/textlayoutmanager/platform/android/TextLayoutManager.cpp index c5d38147b6267d..93456a2a9bdca2 100644 --- a/ReactCommon/fabric/textlayoutmanager/platform/android/TextLayoutManager.cpp +++ b/ReactCommon/fabric/textlayoutmanager/platform/android/TextLayoutManager.cpp @@ -46,6 +46,7 @@ Size TextLayoutManager::doMeasure( static auto measure = jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") ->getMethod(paragraphAttributesRNM.get())); return yogaMeassureToSize(measure( fabricUIManager, + -1, componentName.get(), attributedStringRM.get(), paragraphAttributesRM.get(),