Skip to content

Commit c5fef40

Browse files
andrewdacenkometa-codesync[bot]
authored andcommitted
Rename DrawCommandSpan to CanvasEffectSpan and remove UpdateAppearance
Summary: Renames `DrawCommandSpan` to `CanvasEffectSpan` for consistency with the new `AnimatedEffectSpan`, and removes the `UpdateAppearance` interface. `UpdateAppearance` is a marker interface that tells Android's text layout system the span affects text appearance (triggering re-measurement). Since `CanvasEffectSpan` only draws on top of text during `PreparedLayoutTextView`'s draw pass and never modifies paint state or text measurement, implementing `UpdateAppearance` was incorrect — the same reasoning applied when designing `AnimatedEffectSpan` without it. Reviewed By: mdvacca Differential Revision: D97399655
1 parent cec9821 commit c5fef40

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutTextView.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import com.facebook.react.uimanager.BackgroundStyleApplicator
3030
import com.facebook.react.uimanager.ReactCompoundView
3131
import com.facebook.react.uimanager.style.Overflow
3232
import com.facebook.react.views.text.internal.span.AnimatedEffectSpan
33-
import com.facebook.react.views.text.internal.span.DrawCommandSpan
33+
import com.facebook.react.views.text.internal.span.CanvasEffectSpan
3434
import com.facebook.react.views.text.internal.span.ReactFragmentIndexSpan
3535
import com.facebook.react.views.text.internal.span.ReactLinkSpan
3636
import kotlin.collections.ArrayList
@@ -134,11 +134,11 @@ internal class PreparedLayoutTextView(context: Context) : ViewGroup(context), Re
134134
}
135135

136136
val spanned = text as? Spanned
137-
val drawCommandSpans =
138-
spanned?.getSpans(0, spanned.length, DrawCommandSpan::class.java) ?: emptyArray()
137+
val canvasEffectSpans =
138+
spanned?.getSpans(0, spanned.length, CanvasEffectSpan::class.java) ?: emptyArray()
139139

140140
if (spanned != null) {
141-
for (span in drawCommandSpans) {
141+
for (span in canvasEffectSpans) {
142142
span.onPreDraw(
143143
spanned.getSpanStart(span),
144144
spanned.getSpanEnd(span),
@@ -155,7 +155,7 @@ internal class PreparedLayoutTextView(context: Context) : ViewGroup(context), Re
155155
}
156156

157157
if (spanned != null) {
158-
for (span in drawCommandSpans) {
158+
for (span in canvasEffectSpans) {
159159
span.onDraw(
160160
spanned.getSpanStart(span),
161161
spanned.getSpanEnd(span),

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/span/DrawCommandSpan.kt renamed to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/span/CanvasEffectSpan.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ package com.facebook.react.views.text.internal.span
99

1010
import android.graphics.Canvas
1111
import android.text.Layout
12-
import android.text.style.UpdateAppearance
1312

1413
/**
15-
* May be overridden to implement character styles which are applied by [PreparedLayoutTextView]
16-
* during the drawing of text, against the underlying Android canvas
14+
* A span which draws a static effect on top of text. [onPreDraw] and [onDraw] hooks are called
15+
* during [PreparedLayoutTextView] drawing, providing glyph layout information for custom rendering.
1716
*/
18-
public abstract class DrawCommandSpan : UpdateAppearance, ReactSpan {
17+
public abstract class CanvasEffectSpan {
1918
/**
2019
* Called before the text is drawn. This happens after the Paragraph component has drawn its
2120
* background, but may be called before text spans with their own background color are drawn.

0 commit comments

Comments
 (0)