Skip to content

Commit 2c3e4ec

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: borderWidths field was removed from ViewProps
Summary: @public Apperently, we don't need to store and parse this because we are already doing this for `yogaStyle` field. Reviewed By: sahrens Differential Revision: D9649549 fbshipit-source-id: a84a5518674f4c2d574a060cdbebb9562121f5f4
1 parent 2caa1e0 commit 2c3e4ec

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ - (void)updateProps:(SharedProps)props
158158

159159
// `border`
160160
if (
161-
oldViewProps.borderWidths != newViewProps.borderWidths ||
162161
oldViewProps.borderStyles != newViewProps.borderStyles ||
163162
oldViewProps.borderRadii != newViewProps.borderRadii ||
164163
oldViewProps.borderColors != newViewProps.borderColors

ReactCommon/fabric/components/view/ViewProps.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ ViewProps::ViewProps(const ViewProps &sourceProps, const RawProps &rawProps):
2525
opacity(convertRawProp(rawProps, "opacity", sourceProps.opacity, (Float)1.0)),
2626
foregroundColor(convertRawProp(rawProps, "foregroundColor", sourceProps.foregroundColor)),
2727
backgroundColor(convertRawProp(rawProps, "backgroundColor", sourceProps.backgroundColor)),
28-
borderWidths(convertRawProp(rawProps, "border", "Width", sourceProps.borderWidths)),
2928
borderRadii(convertRawProp(rawProps, "border", "Radius", sourceProps.borderRadii)),
3029
borderColors(convertRawProp(rawProps, "border", "Color", sourceProps.borderColors)),
3130
borderStyles(convertRawProp(rawProps, "border", "Style", sourceProps.borderStyles)),
@@ -44,6 +43,18 @@ ViewProps::ViewProps(const ViewProps &sourceProps, const RawProps &rawProps):
4443
#pragma mark - Convenience Methods
4544

4645
BorderMetrics ViewProps::resolveBorderMetrics(bool isRTL) const {
46+
auto borderWidths = CascadedBorderWidths {
47+
.left = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeLeft]),
48+
.top = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeTop]),
49+
.right = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeRight]),
50+
.bottom = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeBottom]),
51+
.start = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeStart]),
52+
.end = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeEnd]),
53+
.horizontal = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeHorizontal]),
54+
.vertical = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeVertical]),
55+
.all = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeAll])
56+
};
57+
4758
return {
4859
.borderColors = borderColors.resolve(isRTL, {}),
4960
.borderWidths = borderWidths.resolve(isRTL, 0),

ReactCommon/fabric/components/view/ViewProps.h

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class ViewProps:
3939
const SharedColor backgroundColor {};
4040

4141
// Borders
42-
const CascadedBorderWidths borderWidths {};
4342
const CascadedBorderRadii borderRadii {};
4443
const CascadedBorderColors borderColors {};
4544
const CascadedBorderStyles borderStyles {};

ReactCommon/fabric/components/view/conversions.h

+13
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ inline YGValue yogaStyleValueFromFloat(const Float &value) {
5858
return {(float)value, YGUnitPoint};
5959
}
6060

61+
inline folly::Optional<Float> optionalFloatFromYogaValue(const YGValue &value, folly::Optional<Float> base = {}) {
62+
switch (value.unit) {
63+
case YGUnitUndefined:
64+
return {};
65+
case YGUnitPoint:
66+
return fabricFloatFromYogaFloat(value.value);
67+
case YGUnitPercent:
68+
return base.has_value() ? folly::Optional<Float>(base.value() * fabricFloatFromYogaFloat(value.value)) : folly::Optional<Float>();
69+
case YGUnitAuto:
70+
return {};
71+
}
72+
}
73+
6174
inline LayoutMetrics layoutMetricsFromYogaNode(YGNode &yogaNode) {
6275
LayoutMetrics layoutMetrics;
6376

0 commit comments

Comments
 (0)