Skip to content

Commit ebf1079

Browse files
javachefacebook-github-bot
authored andcommitted
Remove unused View foregroundColor (facebook#36882)
Summary: Pull Request resolved: facebook#36882 This property was never used as TextAttributes has its own foreground color attribute. Changelog: [Internal] Reviewed By: rshest Differential Revision: D44884978 fbshipit-source-id: daac06c9dfcbceedc084b6adc2cb114758533036
1 parent e962d43 commit ebf1079

File tree

10 files changed

+2
-42
lines changed

10 files changed

+2
-42
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ NS_ASSUME_NONNULL_BEGIN
4848
*/
4949
@property (nonatomic, strong, nullable) NSString *nativeId;
5050

51-
/**
52-
* Provides access to `foregroundColor` prop of the component.
53-
* Must be used by subclasses only.
54-
*/
55-
@property (nonatomic, strong, nullable) UIColor *foregroundColor;
56-
5751
/**
5852
* Returns the object - usually (sub)view - which represents this
5953
* component view in terms of accessibility.

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,6 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
205205
needsInvalidateLayer = YES;
206206
}
207207

208-
// `foregroundColor`
209-
if (oldViewProps.foregroundColor != newViewProps.foregroundColor) {
210-
self.foregroundColor = RCTUIColorFromSharedColor(newViewProps.foregroundColor);
211-
}
212-
213208
// `shadowColor`
214209
if (oldViewProps.shadowColor != newViewProps.shadowColor) {
215210
CGColorRef shadowColor = RCTCreateCGColorRefFromSharedColor(newViewProps.shadowColor);

packages/react-native/ReactCommon/react/renderer/components/view/ViewProps.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ ViewProps::ViewProps(
3333
"opacity",
3434
sourceProps.opacity,
3535
(Float)1.0)),
36-
foregroundColor(
37-
CoreFeatures::enablePropIteratorSetter
38-
? sourceProps.foregroundColor
39-
: convertRawProp(
40-
context,
41-
rawProps,
42-
"foregroundColor",
43-
sourceProps.foregroundColor,
44-
{})),
4536
backgroundColor(
4637
CoreFeatures::enablePropIteratorSetter
4738
? sourceProps.backgroundColor
@@ -295,7 +286,6 @@ void ViewProps::setProp(
295286

296287
switch (hash) {
297288
RAW_SET_PROP_SWITCH_CASE_BASIC(opacity);
298-
RAW_SET_PROP_SWITCH_CASE_BASIC(foregroundColor);
299289
RAW_SET_PROP_SWITCH_CASE_BASIC(backgroundColor);
300290
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowColor);
301291
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOffset);
@@ -443,10 +433,6 @@ SharedDebugStringConvertibleList ViewProps::getDebugProps() const {
443433
SharedDebugStringConvertibleList{
444434
debugStringConvertibleItem(
445435
"opacity", opacity, defaultViewProps.opacity),
446-
debugStringConvertibleItem(
447-
"foregroundColor",
448-
foregroundColor,
449-
defaultViewProps.foregroundColor),
450436
debugStringConvertibleItem(
451437
"backgroundColor",
452438
backgroundColor,

packages/react-native/ReactCommon/react/renderer/components/view/ViewProps.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class ViewProps : public YogaStylableProps, public AccessibilityProps {
4949

5050
// Color
5151
Float opacity{1.0};
52-
SharedColor foregroundColor{};
5352
SharedColor backgroundColor{};
5453

5554
// Borders

packages/react-native/ReactCommon/react/renderer/components/view/ViewPropsMapBuffer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ void ViewProps::propsDiffMapBuffer(
5656
builder.putInt(VP_BG_COLOR, toAndroidRepr(newProps.backgroundColor));
5757
}
5858

59-
if (oldProps.foregroundColor != newProps.foregroundColor) {
60-
builder.putInt(VP_FG_COLOR, toAndroidRepr(newProps.foregroundColor));
61-
}
62-
6359
if (oldProps.borderCurves != newProps.borderCurves) {
6460
builder.putMapBuffer(
6561
VP_BORDER_CURVES, convertCascadedCorners(newProps.borderCurves));

packages/react-native/ReactCommon/react/renderer/components/view/ViewPropsMapBuffer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ constexpr MapBuffer::Key VP_POINTER_OVER_CAPTURE = 42;
4545
constexpr MapBuffer::Key VP_POINTER_OUT = 43;
4646
constexpr MapBuffer::Key VP_POINTER_OUT_CAPTURE = 44;
4747
constexpr MapBuffer::Key VP_BORDER_CURVES = 45;
48-
constexpr MapBuffer::Key VP_FG_COLOR = 46;
4948

5049
// Yoga values
5150
constexpr MapBuffer::Key YG_BORDER_WIDTH = 100;

packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ void ViewShadowNode::initialize() noexcept {
6262

6363
bool formsView = formsStackingContext ||
6464
isColorMeaningful(viewProps.backgroundColor) ||
65-
isColorMeaningful(viewProps.foregroundColor) ||
6665
!(viewProps.yogaStyle.border() == YGStyle::Edges{}) ||
6766
!viewProps.testId.empty();
6867

packages/react-native/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ TEST_F(YogaDirtyFlagTest, changingNonLayoutSubPropsMustNotDirtyYogaNode) {
114114
auto &props = *viewProps;
115115

116116
props.nativeId = "some new native Id";
117-
props.foregroundColor = whiteColor();
118117
props.backgroundColor = blackColor();
119118
props.opacity = props.opacity + 0.042;
120119
props.zIndex = props.zIndex.value_or(0) + 42;

packages/react-native/ReactCommon/react/renderer/mounting/tests/StackingContextTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ TEST_F(StackingContextTest, somePropsForceViewsToMaterialize2) {
402402
// │ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │
403403
// │ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┃ │ │ ┏━ BBA (tag: 7) ━━━━━━━━━━┓ │
404404
// │ ┃ ┏━ BB (tag: 6) ━━━━━━━━━━━━━━┓ ┃ │ │ ┃ #FormsView ┃ │
405-
// │ ┃ ┃ foregroundColor: black; ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │
405+
// │ ┃ ┃ backgroundColor: black; ┃ ┃ │ │ ┃ #FormsStackingContext ┃ │
406406
// │ ┃ ┃ ┃ ┃ │━━━▶│ ┃ ┃ │
407407
// │ ┃ ┃ ┃ ┃ │ │ ┗━━━━━━━━━━━━━━━━━━━━━━━━━┛ │
408408
// │ ┃ ┃ ┃ ┃ │ │ ┏━ BBB (tag: 8) ━━━━━━━━━━┓ │
@@ -448,7 +448,7 @@ TEST_F(StackingContextTest, somePropsForceViewsToMaterialize2) {
448448
nodeBA_, [](ViewProps &props) { props.nativeId = "42"; });
449449

450450
mutateViewShadowNodeProps_(
451-
nodeBB_, [](ViewProps &props) { props.foregroundColor = blackColor(); });
451+
nodeBB_, [](ViewProps &props) { props.backgroundColor = blackColor(); });
452452

453453
mutateViewShadowNodeProps_(nodeBBA_, [](ViewProps &props) {
454454
props.transform = Transform::Scale(2, 2, 2);

packages/react-native/ReactCommon/react/test_utils/shadowTreeGeneration.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ static inline ShadowNode::Unshared messWithLayoutableOnlyFlag(
141141
entropy.random<bool>() ? SharedColor() : whiteColor();
142142
}
143143

144-
if (entropy.random<bool>(0.1)) {
145-
viewProps.foregroundColor =
146-
entropy.random<bool>() ? SharedColor() : blackColor();
147-
}
148-
149144
if (entropy.random<bool>(0.1)) {
150145
viewProps.shadowColor =
151146
entropy.random<bool>() ? SharedColor() : blackColor();
@@ -195,7 +190,6 @@ static inline ShadowNode::Unshared messWithNodeFlattenednessFlags(
195190
viewProps.nativeId = "";
196191
viewProps.collapsable = true;
197192
viewProps.backgroundColor = SharedColor();
198-
viewProps.foregroundColor = SharedColor();
199193
viewProps.shadowColor = SharedColor();
200194
viewProps.accessible = false;
201195
viewProps.zIndex = {};
@@ -205,7 +199,6 @@ static inline ShadowNode::Unshared messWithNodeFlattenednessFlags(
205199
} else {
206200
viewProps.nativeId = "42";
207201
viewProps.backgroundColor = whiteColor();
208-
viewProps.foregroundColor = blackColor();
209202
viewProps.shadowColor = blackColor();
210203
viewProps.accessible = true;
211204
viewProps.zIndex = {entropy.random<int>()};

0 commit comments

Comments
 (0)