Extend Text to support measurement of empty Texts

Summary:
This diff extends the measurement of Text components in order to support empty strings.
This is required for parity with Paper.
I created a follow up task to analyze support of empty string as part of the Text infrastructure of Fabric in the future.

changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D21761171

fbshipit-source-id: d2aa074052b09732af5d35723f19014090fcabbf
This commit is contained in:
David Vacca
2020-05-28 15:07:49 -07:00
committed by Facebook GitHub Bot
parent 34b23c1220
commit 4b596fd5b3
5 changed files with 28 additions and 6 deletions
@@ -20,6 +20,7 @@ import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.LayoutDirection;
import android.util.LruCache;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.ReadableArray;
@@ -86,7 +87,7 @@ public class TextLayoutManager {
sb.append(TextTransform.apply(fragment.getString("string"), textAttributes.mTextTransform));
int end = sb.length();
int reactTag = fragment.getInt("reactTag");
int reactTag = fragment.hasKey("reactTag") ? fragment.getInt("reactTag") : View.NO_ID;
if (fragment.hasKey(ViewProps.IS_ATTACHMENT)
&& fragment.getBoolean(ViewProps.IS_ATTACHMENT)) {
float width = PixelUtil.toPixelFromSP(fragment.getDouble(ViewProps.WIDTH));