Skip to content

Commit

Permalink
Unify measure functions in Fabric Android
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Feb 25, 2020
1 parent ed5f9ee commit 6aea625
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Size TextLayoutManager::doMeasure(
static auto measure =
jni::findClassStatic("com/facebook/react/fabric/FabricUIManager")
->getMethod<jlong(
jint,
jstring,
ReadableMap::javaobject,
ReadableMap::javaobject,
Expand All @@ -70,6 +71,7 @@ Size TextLayoutManager::doMeasure(
reinterpret_cast<ReadableMap::javaobject>(paragraphAttributesRNM.get()));
return yogaMeassureToSize(measure(
fabricUIManager,
-1,
componentName.get(),
attributedStringRM.get(),
paragraphAttributesRM.get(),
Expand Down

0 comments on commit 6aea625

Please sign in to comment.