Skip to content

Commit

Permalink
Rename TextLayoutManagerMapBuffer to TextLayoutManager
Browse files Browse the repository at this point in the history
Summary:
Clean this up, now that there is only one TextLayoutManager.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D56801446

fbshipit-source-id: 1b81a16031ab520d06d8935000d5019609f8a254
  • Loading branch information
NickGerleman authored and facebook-github-bot committed May 2, 2024
1 parent 8871b95 commit bbb52c5
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -7493,7 +7493,7 @@ public class com/facebook/react/views/text/TextAttributes {
public fun toString ()Ljava/lang/String;
}

public class com/facebook/react/views/text/TextLayoutManagerMapBuffer {
public class com/facebook/react/views/text/TextLayoutManager {
public static final field AS_KEY_CACHE_ID S
public static final field AS_KEY_FRAGMENTS S
public static final field AS_KEY_HASH S
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class ReactFeatureFlags {

public static boolean dispatchPointerEvents = false;

/** Feature Flag to enable a cache of Spannable objects used by TextLayoutManagerMapBuffer */
/** Feature Flag to enable a cache of Spannable objects used by TextLayoutManager */
public static boolean enableTextSpannableCache = false;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.events.FabricEventDispatcher;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.facebook.react.views.text.TextLayoutManagerMapBuffer;
import com.facebook.react.views.text.TextLayoutManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -497,7 +497,7 @@ private NativeArray measureLines(
float width,
float height) {
return (NativeArray)
TextLayoutManagerMapBuffer.measureLines(
TextLayoutManager.measureLines(
mReactApplicationContext,
attributedString,
paragraphAttributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public int compare(Object o1, Object o2) {
protected void onDraw(Canvas canvas) {
if (mAdjustsFontSizeToFit && getSpanned() != null && mShouldAdjustSpannableFontSize) {
mShouldAdjustSpannableFontSize = false;
TextLayoutManagerMapBuffer.adjustSpannableFontToFit(
TextLayoutManager.adjustSpannableFontToFit(
getSpanned(),
getWidth(),
YogaMeasureMode.EXACTLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,25 @@ private Object getReactTextUpdate(ReactTextView view, ReactStylesDiffMap props,
MapBuffer attributedString = state.getMapBuffer(TX_STATE_KEY_ATTRIBUTED_STRING);
MapBuffer paragraphAttributes = state.getMapBuffer(TX_STATE_KEY_PARAGRAPH_ATTRIBUTES);
Spannable spanned =
TextLayoutManagerMapBuffer.getOrCreateSpannableForText(
TextLayoutManager.getOrCreateSpannableForText(
view.getContext(), attributedString, mReactTextViewManagerCallback);
view.setSpanned(spanned);

float minimumFontSize =
(float) paragraphAttributes.getDouble(TextLayoutManagerMapBuffer.PA_KEY_MINIMUM_FONT_SIZE);
(float) paragraphAttributes.getDouble(TextLayoutManager.PA_KEY_MINIMUM_FONT_SIZE);
view.setMinimumFontSize(minimumFontSize);

int textBreakStrategy =
TextAttributeProps.getTextBreakStrategy(
paragraphAttributes.getString(TextLayoutManagerMapBuffer.PA_KEY_TEXT_BREAK_STRATEGY));
paragraphAttributes.getString(TextLayoutManager.PA_KEY_TEXT_BREAK_STRATEGY));
int currentJustificationMode =
Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? 0 : view.getJustificationMode();

return new ReactTextUpdate(
spanned,
-1, // UNUSED FOR TEXT
false, // TODO add this into local Data
TextLayoutManagerMapBuffer.getTextGravity(
attributedString, spanned, view.getGravityHorizontal()),
TextLayoutManager.getTextGravity(attributedString, spanned, view.getGravityHorizontal()),
textBreakStrategy,
TextAttributeProps.getJustificationMode(props, currentJustificationMode));
}
Expand Down Expand Up @@ -193,7 +192,7 @@ public long measure(
float height,
YogaMeasureMode heightMode,
@Nullable float[] attachmentsPositions) {
return TextLayoutManagerMapBuffer.measureText(
return TextLayoutManager.measureText(
context,
localData,
props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
import java.util.concurrent.ConcurrentHashMap;

/** Class responsible of creating {@link Spanned} object for the JS representation of Text */
public class TextLayoutManagerMapBuffer {
public class TextLayoutManager {

// constants for AttributedString serialization
public static final short AS_KEY_HASH = 0;
Expand Down Expand Up @@ -86,7 +86,7 @@ public class TextLayoutManagerMapBuffer {

private static final boolean ENABLE_MEASURE_LOGGING = ReactBuildConfig.DEBUG && false;

private static final String TAG = TextLayoutManagerMapBuffer.class.getSimpleName();
private static final String TAG = TextLayoutManager.class.getSimpleName();

// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import com.facebook.react.views.text.ReactTextUpdate;
import com.facebook.react.views.text.ReactTypefaceUtils;
import com.facebook.react.views.text.TextAttributes;
import com.facebook.react.views.text.TextLayoutManagerMapBuffer;
import com.facebook.react.views.text.TextLayoutManager;
import com.facebook.react.views.text.internal.span.CustomLetterSpacingSpan;
import com.facebook.react.views.text.internal.span.CustomLineHeightSpan;
import com.facebook.react.views.text.internal.span.CustomStyleSpan;
Expand Down Expand Up @@ -216,7 +216,7 @@ protected void finalize() {
if (DEBUG_MODE) {
FLog.e(TAG, "finalize[" + getId() + "] delete cached spannable");
}
TextLayoutManagerMapBuffer.deleteCachedSpannableForTag(getId());
TextLayoutManager.deleteCachedSpannableForTag(getId());
}

// After the text changes inside an EditText, TextView checks if a layout() has been requested.
Expand Down Expand Up @@ -1219,7 +1219,7 @@ private void updateCachedSpannable() {
}

addSpansFromStyleAttributes(sb);
TextLayoutManagerMapBuffer.setCachedSpannableForTag(getId(), sb);
TextLayoutManager.setCachedSpannableForTag(getId(), sb);
}

void setEventDispatcher(@Nullable EventDispatcher eventDispatcher) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import com.facebook.react.views.text.ReactTextViewManagerCallback;
import com.facebook.react.views.text.ReactTypefaceUtils;
import com.facebook.react.views.text.TextAttributeProps;
import com.facebook.react.views.text.TextLayoutManagerMapBuffer;
import com.facebook.react.views.text.TextLayoutManager;
import com.facebook.react.views.text.TextTransform;
import com.facebook.react.views.text.internal.span.TextInlineImageSpan;
import com.facebook.yoga.YogaConstants;
Expand Down Expand Up @@ -1389,20 +1389,20 @@ public Object updateState(
MapBuffer paragraphAttributes = state.getMapBuffer(TX_STATE_KEY_PARAGRAPH_ATTRIBUTES);

Spannable spanned =
TextLayoutManagerMapBuffer.getOrCreateSpannableForText(
TextLayoutManager.getOrCreateSpannableForText(
view.getContext(), attributedString, mReactTextViewManagerCallback);

int textBreakStrategy =
TextAttributeProps.getTextBreakStrategy(
paragraphAttributes.getString(TextLayoutManagerMapBuffer.PA_KEY_TEXT_BREAK_STRATEGY));
paragraphAttributes.getString(TextLayoutManager.PA_KEY_TEXT_BREAK_STRATEGY));
int currentJustificationMode =
Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? 0 : view.getJustificationMode();

return ReactTextUpdate.buildReactTextUpdateFromState(
spanned,
state.getInt(TX_STATE_KEY_MOST_RECENT_EVENT_COUNT),
TextAttributeProps.getTextAlignment(
props, TextLayoutManagerMapBuffer.isRTL(attributedString), view.getGravityHorizontal()),
props, TextLayoutManager.isRTL(attributedString), view.getGravityHorizontal()),
textBreakStrategy,
TextAttributeProps.getJustificationMode(props, currentJustificationMode));
}
Expand Down

0 comments on commit bbb52c5

Please sign in to comment.