Skip to content

Commit

Permalink
Move all ReactSpan subclasses to a separate folder (#42594)
Browse files Browse the repository at this point in the history
Summary:
Move all `ReactSpan` subclasses to a separate folder.

This is a minor improvement in the context of my multi-PR work on react-native-community/discussions-and-proposals#695.

I'm adding a new span class later, which was the direct motivation for this change.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[INTERNAL] [CHANGE] - Move all `ReactSpan` subclasses to a separate folder

Pull Request resolved: #42594

Reviewed By: mdvacca

Differential Revision: D53123733

Pulled By: cortinico

fbshipit-source-id: 10db214a520d157c231e6f3b97948b4209a7ad4b
  • Loading branch information
cubuspl42 authored and facebook-github-bot committed Jan 26, 2024
1 parent f8f7949 commit d4c3311
Show file tree
Hide file tree
Showing 30 changed files with 114 additions and 129 deletions.
90 changes: 0 additions & 90 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -6733,29 +6733,6 @@ public class com/facebook/react/views/switchview/ReactSwitchManager$ReactSwitchS
public fun setProperty (Lcom/facebook/react/views/switchview/ReactSwitchManager$ReactSwitchShadowNode;Ljava/lang/String;Ljava/lang/Object;)V
}

public class com/facebook/react/views/text/CustomLetterSpacingSpan : android/text/style/MetricAffectingSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> (F)V
public fun getSpacing ()F
public fun updateDrawState (Landroid/text/TextPaint;)V
public fun updateMeasureState (Landroid/text/TextPaint;)V
}

public class com/facebook/react/views/text/CustomLineHeightSpan : android/text/style/LineHeightSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> (F)V
public fun chooseHeight (Ljava/lang/CharSequence;IIIILandroid/graphics/Paint$FontMetricsInt;)V
public fun getLineHeight ()I
}

public class com/facebook/react/views/text/CustomStyleSpan : android/text/style/MetricAffectingSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> (IILjava/lang/String;Ljava/lang/String;Landroid/content/res/AssetManager;)V
public fun getFontFamily ()Ljava/lang/String;
public fun getFontFeatureSettings ()Ljava/lang/String;
public fun getStyle ()I
public fun getWeight ()I
public fun updateDrawState (Landroid/text/TextPaint;)V
public fun updateMeasureState (Landroid/text/TextPaint;)V
}

public final class com/facebook/react/views/text/DefaultStyleValuesUtil {
public static fun getDefaultTextColor (Landroid/content/Context;)Landroid/content/res/ColorStateList;
public static fun getDefaultTextColorHighlight (Landroid/content/Context;)I
Expand All @@ -6767,14 +6744,6 @@ public class com/facebook/react/views/text/FontMetricsUtil {
public static fun getFontMetrics (Ljava/lang/CharSequence;Landroid/text/Layout;Landroid/text/TextPaint;Landroid/content/Context;)Lcom/facebook/react/bridge/WritableArray;
}

public class com/facebook/react/views/text/ReactAbsoluteSizeSpan : android/text/style/AbsoluteSizeSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> (I)V
}

public class com/facebook/react/views/text/ReactBackgroundColorSpan : android/text/style/BackgroundColorSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> (I)V
}

public abstract class com/facebook/react/views/text/ReactBaseTextShadowNode : com/facebook/react/uimanager/LayoutShadowNode, com/facebook/react/views/text/BasicTextAttributeProvider {
public static final field DEFAULT_TEXT_SHADOW_COLOR I
public static final field PROP_SHADOW_COLOR Ljava/lang/String;
Expand Down Expand Up @@ -6866,10 +6835,6 @@ public class com/facebook/react/views/text/ReactFontManager {
public fun setTypeface (Ljava/lang/String;ILandroid/graphics/Typeface;)V
}

public class com/facebook/react/views/text/ReactForegroundColorSpan : android/text/style/ForegroundColorSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> (I)V
}

public class com/facebook/react/views/text/ReactRawTextManager : com/facebook/react/uimanager/ViewManager {
public fun <init> ()V
public synthetic fun createShadowNodeInstance ()Lcom/facebook/react/uimanager/ReactShadowNode;
Expand Down Expand Up @@ -6903,18 +6868,6 @@ public class com/facebook/react/views/text/ReactRawTextShadowNode$$PropsSetter :
public fun setProperty (Lcom/facebook/react/views/text/ReactRawTextShadowNode;Ljava/lang/String;Ljava/lang/Object;)V
}

public abstract interface class com/facebook/react/views/text/ReactSpan {
}

public class com/facebook/react/views/text/ReactStrikethroughSpan : android/text/style/StrikethroughSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> ()V
}

public class com/facebook/react/views/text/ReactTagSpan : com/facebook/react/views/text/ReactSpan {
public fun <init> (I)V
public fun getReactTag ()I
}

public abstract class com/facebook/react/views/text/ReactTextAnchorViewManager : com/facebook/react/uimanager/BaseViewManager {
public fun <init> ()V
public fun setAccessible (Lcom/facebook/react/views/text/ReactTextView;Z)V
Expand All @@ -6937,11 +6890,6 @@ public abstract class com/facebook/react/views/text/ReactTextAnchorViewManager :
public fun setTextAlignVertical (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
}

public abstract class com/facebook/react/views/text/ReactTextInlineImageShadowNode : com/facebook/react/uimanager/LayoutShadowNode {
public fun <init> ()V
public abstract fun buildInlineImageSpan ()Lcom/facebook/react/views/text/TextInlineImageSpan;
}

public class com/facebook/react/views/text/ReactTextShadowNode : com/facebook/react/views/text/ReactBaseTextShadowNode {
public fun <init> ()V
public fun <init> (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)V
Expand Down Expand Up @@ -7056,10 +7004,6 @@ public class com/facebook/react/views/text/ReactTypefaceUtils {
public static fun parseFontWeight (Ljava/lang/String;)I
}

public class com/facebook/react/views/text/ReactUnderlineSpan : android/text/style/UnderlineSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> ()V
}

public class com/facebook/react/views/text/ReactVirtualTextShadowNode : com/facebook/react/views/text/ReactBaseTextShadowNode {
public fun <init> ()V
public fun isVirtual ()Z
Expand Down Expand Up @@ -7089,18 +7033,6 @@ public class com/facebook/react/views/text/ReactVirtualTextViewManager$$PropsSet
public fun setProperty (Lcom/facebook/react/views/text/ReactVirtualTextViewManager;Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
}

public class com/facebook/react/views/text/SetSpanOperation {
protected field end I
protected field start I
protected field what Lcom/facebook/react/views/text/ReactSpan;
public fun execute (Landroid/text/SpannableStringBuilder;I)V
}

public class com/facebook/react/views/text/ShadowStyleSpan : android/text/style/CharacterStyle, com/facebook/react/views/text/ReactSpan {
public fun <init> (FFFI)V
public fun updateDrawState (Landroid/text/TextPaint;)V
}

public class com/facebook/react/views/text/TextAttributeProps : com/facebook/react/views/text/EffectiveTextAttributeProvider {
public static final field TA_KEY_ACCESSIBILITY_ROLE S
public static final field TA_KEY_ALIGNMENT S
Expand Down Expand Up @@ -7213,28 +7145,6 @@ public class com/facebook/react/views/text/TextAttributes {
public fun toString ()Ljava/lang/String;
}

public abstract class com/facebook/react/views/text/TextInlineImageSpan : android/text/style/ReplacementSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> ()V
public abstract fun getDrawable ()Landroid/graphics/drawable/Drawable;
public abstract fun getHeight ()I
public abstract fun getWidth ()I
public abstract fun onAttachedToWindow ()V
public abstract fun onDetachedFromWindow ()V
public abstract fun onFinishTemporaryDetach ()V
public abstract fun onStartTemporaryDetach ()V
public static fun possiblyUpdateInlineImageSpans (Landroid/text/Spannable;Landroid/widget/TextView;)V
public abstract fun setTextView (Landroid/widget/TextView;)V
}

public class com/facebook/react/views/text/TextInlineViewPlaceholderSpan : android/text/style/ReplacementSpan, com/facebook/react/views/text/ReactSpan {
public fun <init> (III)V
public fun draw (Landroid/graphics/Canvas;Ljava/lang/CharSequence;IIFIIILandroid/graphics/Paint;)V
public fun getHeight ()I
public fun getReactTag ()I
public fun getSize (Landroid/graphics/Paint;Ljava/lang/CharSequence;IILandroid/graphics/Paint$FontMetricsInt;)I
public fun getWidth ()I
}

public class com/facebook/react/views/text/TextLayoutManager {
public fun <init> ()V
public static fun deleteCachedSpannableForTag (I)V
Expand Down
1 change: 1 addition & 0 deletions packages/react-native/ReactAndroid/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ binaryCompatibilityValidator.ignoredPackages=com.facebook.debug,\
com.facebook.react.internal,\
com.facebook.react.module.processing,\
com.facebook.react.processing,\
com.facebook.react.views.text.internal,\
com.facebook.systrace,\
com.facebook.yoga
binaryCompatibilityValidator.nonPublicMarkers=com.facebook.react.common.annotations.VisibleForTesting,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@
import com.facebook.react.uimanager.ReactShadowNode;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.text.internal.ReactTextInlineImageShadowNode;
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;
import com.facebook.react.views.text.internal.span.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.internal.span.ReactBackgroundColorSpan;
import com.facebook.react.views.text.internal.span.ReactClickableSpan;
import com.facebook.react.views.text.internal.span.ReactForegroundColorSpan;
import com.facebook.react.views.text.internal.span.ReactSpan;
import com.facebook.react.views.text.internal.span.ReactStrikethroughSpan;
import com.facebook.react.views.text.internal.span.ReactTagSpan;
import com.facebook.react.views.text.internal.span.ReactUnderlineSpan;
import com.facebook.react.views.text.internal.span.SetSpanOperation;
import com.facebook.react.views.text.internal.span.ShadowStyleSpan;
import com.facebook.react.views.text.internal.span.TextInlineImageSpan;
import com.facebook.react.views.text.internal.span.TextInlineViewPlaceholderSpan;
import com.facebook.yoga.YogaDirection;
import com.facebook.yoga.YogaUnit;
import com.facebook.yoga.YogaValue;
Expand Down Expand Up @@ -366,15 +382,16 @@ protected Spannable spannedFromShadowNode(
// or images.
for (int priorityIndex = 0; priorityIndex < ops.size(); priorityIndex++) {
final SetSpanOperation op = ops.get(ops.size() - priorityIndex - 1);
final ReactSpan what = op.getWhat();

boolean isInlineImage = op.what instanceof TextInlineImageSpan;
if (isInlineImage || op.what instanceof TextInlineViewPlaceholderSpan) {
boolean isInlineImage = what instanceof TextInlineImageSpan;
if (isInlineImage || what instanceof TextInlineViewPlaceholderSpan) {
int height;
if (isInlineImage) {
height = ((TextInlineImageSpan) op.what).getHeight();
height = ((TextInlineImageSpan) what).getHeight();
textShadowNode.mContainsImages = true;
} else {
TextInlineViewPlaceholderSpan placeholder = (TextInlineViewPlaceholderSpan) op.what;
TextInlineViewPlaceholderSpan placeholder = (TextInlineViewPlaceholderSpan) what;
height = placeholder.getHeight();

// Inline views cannot be layout-only because the ReactTextView needs to be able to grab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import com.facebook.react.uimanager.UIViewOperationQueue;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.facebook.react.views.text.internal.span.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.internal.span.TextInlineViewPlaceholderSpan;
import com.facebook.yoga.YogaBaselineFunction;
import com.facebook.yoga.YogaConstants;
import com.facebook.yoga.YogaDirection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
import com.facebook.react.uimanager.ViewDefaults;
import com.facebook.react.uimanager.common.UIManagerType;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.views.text.internal.span.ReactTagSpan;
import com.facebook.react.views.text.internal.span.TextInlineImageSpan;
import com.facebook.react.views.text.internal.span.TextInlineViewPlaceholderSpan;
import com.facebook.react.views.view.ReactViewBackgroundManager;
import java.util.ArrayList;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.views.text.internal.span.ReactClickableSpan;
import com.facebook.react.views.text.internal.span.TextInlineImageSpan;
import com.facebook.yoga.YogaMeasureMode;
import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.views.text.fragments.BridgeTextFragmentList;
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;
import com.facebook.react.views.text.internal.span.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.internal.span.ReactBackgroundColorSpan;
import com.facebook.react.views.text.internal.span.ReactClickableSpan;
import com.facebook.react.views.text.internal.span.ReactForegroundColorSpan;
import com.facebook.react.views.text.internal.span.ReactStrikethroughSpan;
import com.facebook.react.views.text.internal.span.ReactTagSpan;
import com.facebook.react.views.text.internal.span.ReactUnderlineSpan;
import com.facebook.react.views.text.internal.span.SetSpanOperation;
import com.facebook.react.views.text.internal.span.ShadowStyleSpan;
import com.facebook.react.views.text.internal.span.TextInlineViewPlaceholderSpan;
import com.facebook.yoga.YogaConstants;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaMeasureOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
import com.facebook.react.uimanager.ReactAccessibilityDelegate.AccessibilityRole;
import com.facebook.react.uimanager.ReactAccessibilityDelegate.Role;
import com.facebook.react.views.text.fragments.MapBufferTextFragmentList;
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;
import com.facebook.react.views.text.internal.span.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.internal.span.ReactBackgroundColorSpan;
import com.facebook.react.views.text.internal.span.ReactClickableSpan;
import com.facebook.react.views.text.internal.span.ReactForegroundColorSpan;
import com.facebook.react.views.text.internal.span.ReactStrikethroughSpan;
import com.facebook.react.views.text.internal.span.ReactTagSpan;
import com.facebook.react.views.text.internal.span.ReactUnderlineSpan;
import com.facebook.react.views.text.internal.span.SetSpanOperation;
import com.facebook.react.views.text.internal.span.ShadowStyleSpan;
import com.facebook.react.views.text.internal.span.TextInlineViewPlaceholderSpan;
import com.facebook.yoga.YogaConstants;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaMeasureOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ package com.facebook.react.views.text

import android.content.Context
import android.graphics.Color
import android.text.*
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.view.View
import com.facebook.react.common.ReactConstants
import com.facebook.react.uimanager.PixelUtil
import com.facebook.react.uimanager.ReactAccessibilityDelegate
import com.facebook.react.views.text.fragments.TextFragment
import com.facebook.react.views.text.fragments.TextFragmentList
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
import com.facebook.react.views.text.internal.span.ReactAbsoluteSizeSpan
import com.facebook.react.views.text.internal.span.ReactBackgroundColorSpan
import com.facebook.react.views.text.internal.span.ReactClickableSpan
import com.facebook.react.views.text.internal.span.ReactForegroundColorSpan
import com.facebook.react.views.text.internal.span.ReactStrikethroughSpan
import com.facebook.react.views.text.internal.span.ReactTagSpan
import com.facebook.react.views.text.internal.span.ReactUnderlineSpan
import com.facebook.react.views.text.internal.span.SetSpanOperation
import com.facebook.react.views.text.internal.span.ShadowStyleSpan
import com.facebook.react.views.text.internal.span.TextInlineViewPlaceholderSpan

/** Utility methods for building [Spannable]s */
internal object TextLayoutUtils {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import com.facebook.react.common.ReactConstants;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.text.ReactTextInlineImageShadowNode;
import com.facebook.react.views.text.TextInlineImageSpan;
import com.facebook.react.views.text.internal.ReactTextInlineImageShadowNode;
import com.facebook.react.views.text.internal.span.TextInlineImageSpan;
import com.facebook.yoga.YogaConstants;
import java.util.Locale;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.facebook.react.modules.fresco.ReactNetworkImageRequest;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.views.image.ImageResizeMode;
import com.facebook.react.views.text.TextInlineImageSpan;
import com.facebook.react.views.text.internal.span.TextInlineImageSpan;

/**
* FrescoBasedTextInlineImageSpan is a span for Images that are inside <Text/>. It computes its size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.views.text;
package com.facebook.react.views.text.internal;

import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.views.text.internal.span.TextInlineImageSpan;
import com.facebook.yoga.YogaNode;

/** Base class for {@link YogaNode}s that represent inline images. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.views.text;
package com.facebook.react.views.text.internal.span;

import android.text.TextPaint;
import android.text.style.MetricAffectingSpan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.views.text;
package com.facebook.react.views.text.internal.span;

import android.graphics.Paint;
import android.text.style.LineHeightSpan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.views.text;
package com.facebook.react.views.text.internal.span;

import android.content.res.AssetManager;
import android.graphics.Paint;
Expand All @@ -16,6 +16,7 @@
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.assets.ReactFontManager;
import com.facebook.react.views.text.ReactTypefaceUtils;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class CustomStyleSpan extends MetricAffectingSpan implements ReactSpan {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.views.text;
package com.facebook.react.views.text.internal.span;

import android.text.style.AbsoluteSizeSpan;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.views.text;
package com.facebook.react.views.text.internal.span;

import android.text.style.BackgroundColorSpan;

Expand Down
Loading

0 comments on commit d4c3311

Please sign in to comment.