From 6f8fc40195952d371d964b487409c177d25b5813 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 28 May 2020 13:39:30 -0700 Subject: [PATCH] Add Fabric logs to TextLayoutManager Summary: This diff add logging on Text Layout Manager. changelog: [Internal][Android] Internal changes to extend logging Reviewed By: JoshuaGross Differential Revision: D21737356 fbshipit-source-id: f34091722ff95f83ca41c9f17c49d31ce6618c9a --- .../react/views/text/TextLayoutManager.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index 41d69d8bb2e..c09a4a6220d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -21,6 +21,7 @@ import android.text.TextPaint; import android.util.LayoutDirection; import android.util.LruCache; import androidx.annotation.Nullable; +import com.facebook.common.logging.FLog; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.PixelUtil; @@ -35,6 +36,11 @@ import java.util.List; /** Class responsible of creating {@link Spanned} object for the JS representation of Text */ public class TextLayoutManager { + // TODO T67606397: Refactor configuration of fabric logs + private static final boolean ENABLE_MEASURE_LOGGING = false; + + private static final String TAG = "TextLayoutManager"; + // It's important to pass the ANTI_ALIAS_FLAG flag to the constructor rather than setting it // later by calling setFlags. This is because the latter approach triggers a bug on Android 4.4.2. // The bug is that unicode emoticons aren't measured properly which causes text to be clipped. @@ -421,8 +427,26 @@ public class TextLayoutManager { } } - return YogaMeasureOutput.make( - PixelUtil.toSPFromPixel(calculatedWidth), PixelUtil.toSPFromPixel(calculatedHeight)); + float widthInSP = PixelUtil.toSPFromPixel(calculatedWidth); + float heightInSP = PixelUtil.toSPFromPixel(calculatedHeight); + + if (ENABLE_MEASURE_LOGGING) { + FLog.e( + TAG, + "TextMeasure call ('" + + text + + "'): w: " + + calculatedWidth + + " px - h: " + + calculatedHeight + + " px - w : " + + widthInSP + + " sp - h: " + + heightInSP + + " sp"); + } + + return YogaMeasureOutput.make(widthInSP, heightInSP); } // TODO T31905686: This class should be private