49
49
import com .facebook .react .bridge .ReactSoftExceptionLogger ;
50
50
import com .facebook .react .common .ReactConstants ;
51
51
import com .facebook .react .common .build .ReactBuildConfig ;
52
- import com .facebook .react .internal .featureflags .ReactNativeFeatureFlags ;
53
52
import com .facebook .react .uimanager .BackgroundStyleApplicator ;
54
53
import com .facebook .react .uimanager .LengthPercentage ;
55
54
import com .facebook .react .uimanager .LengthPercentageType ;
76
75
import com .facebook .react .views .text .internal .span .ReactStrikethroughSpan ;
77
76
import com .facebook .react .views .text .internal .span .ReactUnderlineSpan ;
78
77
import com .facebook .react .views .text .internal .span .TextInlineImageSpan ;
79
- import com .facebook .react .views .view .ReactViewBackgroundManager ;
80
78
import java .util .ArrayList ;
81
79
import java .util .Objects ;
82
80
@@ -133,8 +131,6 @@ public class ReactEditText extends AppCompatEditText {
133
131
private @ Nullable String mPlaceholder = null ;
134
132
private Overflow mOverflow = Overflow .VISIBLE ;
135
133
136
- private final ReactViewBackgroundManager mReactBackgroundManager ;
137
-
138
134
private StateWrapper mStateWrapper = null ;
139
135
protected boolean mDisableTextDiffing = false ;
140
136
@@ -147,7 +143,6 @@ public ReactEditText(Context context) {
147
143
super (context );
148
144
setFocusableInTouchMode (false );
149
145
150
- mReactBackgroundManager = new ReactViewBackgroundManager (this );
151
146
mInputMethodManager =
152
147
(InputMethodManager )
153
148
Assertions .assertNotNull (context .getSystemService (Context .INPUT_METHOD_SERVICE ));
@@ -765,7 +760,9 @@ private void stripStyleEquivalentSpans(SpannableStringBuilder sb) {
765
760
stripSpansOfKind (
766
761
sb ,
767
762
ReactBackgroundColorSpan .class ,
768
- (span ) -> span .getBackgroundColor () == mReactBackgroundManager .getBackgroundColor ());
763
+ (span ) ->
764
+ Objects .equals (
765
+ span .getBackgroundColor (), BackgroundStyleApplicator .getBackgroundColor (this )));
769
766
770
767
stripSpansOfKind (
771
768
sb ,
@@ -827,8 +824,8 @@ private void addSpansFromStyleAttributes(SpannableStringBuilder workingText) {
827
824
workingText .setSpan (
828
825
new ReactForegroundColorSpan (getCurrentTextColor ()), 0 , workingText .length (), spanFlags );
829
826
830
- int backgroundColor = mReactBackgroundManager .getBackgroundColor ();
831
- if (backgroundColor != Color .TRANSPARENT ) {
827
+ @ Nullable Integer backgroundColor = BackgroundStyleApplicator .getBackgroundColor (this );
828
+ if (backgroundColor != null && backgroundColor != Color .TRANSPARENT ) {
832
829
workingText .setSpan (
833
830
new ReactBackgroundColorSpan (backgroundColor ), 0 , workingText .length (), spanFlags );
834
831
}
@@ -1087,66 +1084,42 @@ public void onFinishTemporaryDetach() {
1087
1084
1088
1085
@ Override
1089
1086
public void setBackgroundColor (int color ) {
1090
- if (ReactNativeFeatureFlags .enableBackgroundStyleApplicator ()) {
1091
- BackgroundStyleApplicator .setBackgroundColor (this , color );
1092
- } else {
1093
- mReactBackgroundManager .setBackgroundColor (color );
1094
- }
1087
+ BackgroundStyleApplicator .setBackgroundColor (this , color );
1095
1088
}
1096
1089
1097
1090
public void setBorderWidth (int position , float width ) {
1098
- if (ReactNativeFeatureFlags .enableBackgroundStyleApplicator ()) {
1099
- BackgroundStyleApplicator .setBorderWidth (
1100
- this , LogicalEdge .values ()[position ], PixelUtil .toDIPFromPixel (width ));
1101
- } else {
1102
- mReactBackgroundManager .setBorderWidth (position , width );
1103
- }
1091
+ BackgroundStyleApplicator .setBorderWidth (
1092
+ this , LogicalEdge .values ()[position ], PixelUtil .toDIPFromPixel (width ));
1104
1093
}
1105
1094
1106
1095
public void setBorderColor (int position , @ Nullable Integer color ) {
1107
- if (ReactNativeFeatureFlags .enableBackgroundStyleApplicator ()) {
1108
- BackgroundStyleApplicator .setBorderColor (this , LogicalEdge .values ()[position ], color );
1109
- } else {
1110
- mReactBackgroundManager .setBorderColor (position , color );
1111
- }
1096
+ BackgroundStyleApplicator .setBorderColor (this , LogicalEdge .values ()[position ], color );
1112
1097
}
1113
1098
1114
1099
public int getBorderColor (int position ) {
1115
- if (ReactNativeFeatureFlags .enableBackgroundStyleApplicator ()) {
1116
- @ Nullable
1117
- Integer borderColor =
1118
- BackgroundStyleApplicator .getBorderColor (this , LogicalEdge .values ()[position ]);
1119
- return borderColor == null ? Color .TRANSPARENT : borderColor ;
1120
- } else {
1121
- return mReactBackgroundManager .getBorderColor (position );
1122
- }
1100
+ @ Nullable
1101
+ Integer borderColor =
1102
+ BackgroundStyleApplicator .getBorderColor (this , LogicalEdge .values ()[position ]);
1103
+ return borderColor == null ? Color .TRANSPARENT : borderColor ;
1123
1104
}
1124
1105
1125
1106
public void setBorderRadius (float borderRadius ) {
1126
1107
setBorderRadius (borderRadius , BorderRadiusProp .BORDER_RADIUS .ordinal ());
1127
1108
}
1128
1109
1129
1110
public void setBorderRadius (float borderRadius , int position ) {
1130
- if (ReactNativeFeatureFlags .enableBackgroundStyleApplicator ()) {
1131
- @ Nullable
1132
- LengthPercentage radius =
1133
- Float .isNaN (borderRadius )
1134
- ? null
1135
- : new LengthPercentage (
1136
- PixelUtil .toDIPFromPixel (borderRadius ), LengthPercentageType .POINT );
1137
- BackgroundStyleApplicator .setBorderRadius (this , BorderRadiusProp .values ()[position ], radius );
1138
- } else {
1139
- mReactBackgroundManager .setBorderRadius (borderRadius , position );
1140
- }
1111
+ @ Nullable
1112
+ LengthPercentage radius =
1113
+ Float .isNaN (borderRadius )
1114
+ ? null
1115
+ : new LengthPercentage (
1116
+ PixelUtil .toDIPFromPixel (borderRadius ), LengthPercentageType .POINT );
1117
+ BackgroundStyleApplicator .setBorderRadius (this , BorderRadiusProp .values ()[position ], radius );
1141
1118
}
1142
1119
1143
1120
public void setBorderStyle (@ Nullable String style ) {
1144
- if (ReactNativeFeatureFlags .enableBackgroundStyleApplicator ()) {
1145
- BackgroundStyleApplicator .setBorderStyle (
1146
- this , style == null ? null : BorderStyle .fromString (style ));
1147
- } else {
1148
- mReactBackgroundManager .setBorderStyle (style );
1149
- }
1121
+ BackgroundStyleApplicator .setBorderStyle (
1122
+ this , style == null ? null : BorderStyle .fromString (style ));
1150
1123
}
1151
1124
1152
1125
public void setLetterSpacingPt (float letterSpacingPt ) {
@@ -1300,18 +1273,13 @@ public void setOverflow(@Nullable String overflow) {
1300
1273
mOverflow = parsedOverflow == null ? Overflow .VISIBLE : parsedOverflow ;
1301
1274
}
1302
1275
1303
- mReactBackgroundManager .setOverflow (overflow );
1304
1276
invalidate ();
1305
1277
}
1306
1278
1307
1279
@ Override
1308
1280
public void onDraw (Canvas canvas ) {
1309
- if (ReactNativeFeatureFlags .enableBackgroundStyleApplicator ()) {
1310
- if (mOverflow != Overflow .VISIBLE ) {
1311
- BackgroundStyleApplicator .clipToPaddingBox (this , canvas );
1312
- }
1313
- } else {
1314
- mReactBackgroundManager .maybeClipToPaddingBox (canvas );
1281
+ if (mOverflow != Overflow .VISIBLE ) {
1282
+ BackgroundStyleApplicator .clipToPaddingBox (this , canvas );
1315
1283
}
1316
1284
1317
1285
super .onDraw (canvas );
0 commit comments