Skip to content

Commit

Permalink
Move all ReactSpan subclasses to a separate folder
Browse files Browse the repository at this point in the history
  • Loading branch information
cubuspl42 committed Jan 25, 2024
1 parent 0111523 commit 29a3267
Show file tree
Hide file tree
Showing 28 changed files with 111 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
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.span.CustomLetterSpacingSpan;
import com.facebook.react.views.text.span.CustomLineHeightSpan;
import com.facebook.react.views.text.span.CustomStyleSpan;
import com.facebook.react.views.text.span.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.span.ReactBackgroundColorSpan;
import com.facebook.react.views.text.span.ReactClickableSpan;
import com.facebook.react.views.text.span.ReactForegroundColorSpan;
import com.facebook.react.views.text.span.ReactSpan;
import com.facebook.react.views.text.span.ReactStrikethroughSpan;
import com.facebook.react.views.text.span.ReactTagSpan;
import com.facebook.react.views.text.span.ReactUnderlineSpan;
import com.facebook.react.views.text.span.SetSpanOperation;
import com.facebook.react.views.text.span.ShadowStyleSpan;
import com.facebook.react.views.text.span.TextInlineImageSpan;
import com.facebook.react.views.text.span.TextInlineViewPlaceholderSpan;
import com.facebook.yoga.YogaDirection;
import com.facebook.yoga.YogaUnit;
import com.facebook.yoga.YogaValue;
Expand Down Expand Up @@ -366,15 +381,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 @@ -8,6 +8,7 @@
package com.facebook.react.views.text;

import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.views.text.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 @@ -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.span.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.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.span.ReactTagSpan;
import com.facebook.react.views.text.span.TextInlineImageSpan;
import com.facebook.react.views.text.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.span.ReactClickableSpan;
import com.facebook.react.views.text.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.span.CustomLetterSpacingSpan;
import com.facebook.react.views.text.span.CustomLineHeightSpan;
import com.facebook.react.views.text.span.CustomStyleSpan;
import com.facebook.react.views.text.span.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.span.ReactBackgroundColorSpan;
import com.facebook.react.views.text.span.ReactClickableSpan;
import com.facebook.react.views.text.span.ReactForegroundColorSpan;
import com.facebook.react.views.text.span.ReactStrikethroughSpan;
import com.facebook.react.views.text.span.ReactTagSpan;
import com.facebook.react.views.text.span.ReactUnderlineSpan;
import com.facebook.react.views.text.span.SetSpanOperation;
import com.facebook.react.views.text.span.ShadowStyleSpan;
import com.facebook.react.views.text.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 @@ -22,6 +22,7 @@
import android.util.LayoutDirection;
import android.util.LruCache;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
Expand All @@ -37,6 +38,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.span.CustomLetterSpacingSpan;
import com.facebook.react.views.text.span.CustomLineHeightSpan;
import com.facebook.react.views.text.span.CustomStyleSpan;
import com.facebook.react.views.text.span.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.span.ReactBackgroundColorSpan;
import com.facebook.react.views.text.span.ReactClickableSpan;
import com.facebook.react.views.text.span.ReactForegroundColorSpan;
import com.facebook.react.views.text.span.ReactStrikethroughSpan;
import com.facebook.react.views.text.span.ReactTagSpan;
import com.facebook.react.views.text.span.ReactUnderlineSpan;
import com.facebook.react.views.text.span.SetSpanOperation;
import com.facebook.react.views.text.span.ShadowStyleSpan;
import com.facebook.react.views.text.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.span.CustomLetterSpacingSpan
import com.facebook.react.views.text.span.CustomLineHeightSpan
import com.facebook.react.views.text.span.CustomStyleSpan
import com.facebook.react.views.text.span.ReactAbsoluteSizeSpan
import com.facebook.react.views.text.span.ReactBackgroundColorSpan
import com.facebook.react.views.text.span.ReactClickableSpan
import com.facebook.react.views.text.span.ReactForegroundColorSpan
import com.facebook.react.views.text.span.ReactStrikethroughSpan
import com.facebook.react.views.text.span.ReactTagSpan
import com.facebook.react.views.text.span.ReactUnderlineSpan
import com.facebook.react.views.text.span.SetSpanOperation
import com.facebook.react.views.text.span.ShadowStyleSpan
import com.facebook.react.views.text.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 @@ -22,7 +22,7 @@
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.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.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,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.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.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.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.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.span;

import android.text.style.BackgroundColorSpan;

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.span;

import android.text.TextPaint;
import android.text.style.ClickableSpan;
Expand All @@ -14,6 +14,8 @@
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.views.text.ReactTextView;
import com.facebook.react.views.text.TextLayoutManager;
import com.facebook.react.views.view.ViewGroupClickEvent;

/**
Expand All @@ -36,11 +38,11 @@
* accessible (TalkBack announces that the text has links available, and the links are exposed in
* the context menu).
*/
class ReactClickableSpan extends ClickableSpan implements ReactSpan {
public class ReactClickableSpan extends ClickableSpan implements ReactSpan {

private final int mReactTag;

ReactClickableSpan(int reactTag) {
public ReactClickableSpan(int reactTag) {
mReactTag = reactTag;
}

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.span;

import android.text.style.ForegroundColorSpan;

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.span;

/*
* Enables us to distinguish between spans that were added by React Native and spans that were
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.span;

import android.text.style.StrikethroughSpan;

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.span;

/**
* Instances of this class are used to place reactTag information of nested text react nodes into
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.span;

import android.text.style.UnderlineSpan;

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.span;

import android.text.Spannable;
import android.text.SpannableStringBuilder;
Expand All @@ -17,9 +17,10 @@ public class SetSpanOperation {
static final int SPAN_MAX_PRIORITY = Spanned.SPAN_PRIORITY >> Spanned.SPAN_PRIORITY_SHIFT;

protected int start, end;
protected ReactSpan what;

SetSpanOperation(int start, int end, ReactSpan what) {
private final ReactSpan what;

public SetSpanOperation(int start, int end, ReactSpan what) {
this.start = start;
this.end = end;
this.what = what;
Expand Down Expand Up @@ -56,4 +57,8 @@ public void execute(SpannableStringBuilder sb, int priorityIndex) {

sb.setSpan(what, start, end, spanFlags);
}

public ReactSpan getWhat() {
return what;
}
}
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.span;

import android.text.TextPaint;
import android.text.style.CharacterStyle;
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.span;

import android.graphics.drawable.Drawable;
import android.text.Spannable;
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.span;

import android.graphics.Canvas;
import android.graphics.Paint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.views.text.CustomLetterSpacingSpan;
import com.facebook.react.views.text.CustomLineHeightSpan;
import com.facebook.react.views.text.CustomStyleSpan;
import com.facebook.react.views.text.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.ReactBackgroundColorSpan;
import com.facebook.react.views.text.ReactForegroundColorSpan;
import com.facebook.react.views.text.ReactSpan;
import com.facebook.react.views.text.ReactStrikethroughSpan;
import com.facebook.react.views.text.span.CustomLetterSpacingSpan;
import com.facebook.react.views.text.span.CustomLineHeightSpan;
import com.facebook.react.views.text.span.CustomStyleSpan;
import com.facebook.react.views.text.span.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.span.ReactBackgroundColorSpan;
import com.facebook.react.views.text.span.ReactForegroundColorSpan;
import com.facebook.react.views.text.span.ReactSpan;
import com.facebook.react.views.text.span.ReactStrikethroughSpan;
import com.facebook.react.views.text.ReactTextUpdate;
import com.facebook.react.views.text.ReactTypefaceUtils;
import com.facebook.react.views.text.ReactUnderlineSpan;
import com.facebook.react.views.text.span.ReactUnderlineSpan;
import com.facebook.react.views.text.TextAttributes;
import com.facebook.react.views.text.TextInlineImageSpan;
import com.facebook.react.views.text.span.TextInlineImageSpan;
import com.facebook.react.views.text.TextLayoutManager;
import com.facebook.react.views.view.ReactViewBackgroundManager;
import java.util.ArrayList;
Expand Down
Loading

0 comments on commit 29a3267

Please sign in to comment.