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
This commit is contained in:
Valentin Shergin 2018-09-07 11:12:30 -07:00 committed by Facebook Github Bot
parent 2caa1e01fa
commit 2c3e4ec06b
4 changed files with 25 additions and 3 deletions

View File

@ -158,7 +158,6 @@ using namespace facebook::react;
// `border`
if (
oldViewProps.borderWidths != newViewProps.borderWidths ||
oldViewProps.borderStyles != newViewProps.borderStyles ||
oldViewProps.borderRadii != newViewProps.borderRadii ||
oldViewProps.borderColors != newViewProps.borderColors

View File

@ -25,7 +25,6 @@ ViewProps::ViewProps(const ViewProps &sourceProps, const RawProps &rawProps):
opacity(convertRawProp(rawProps, "opacity", sourceProps.opacity, (Float)1.0)),
foregroundColor(convertRawProp(rawProps, "foregroundColor", sourceProps.foregroundColor)),
backgroundColor(convertRawProp(rawProps, "backgroundColor", sourceProps.backgroundColor)),
borderWidths(convertRawProp(rawProps, "border", "Width", sourceProps.borderWidths)),
borderRadii(convertRawProp(rawProps, "border", "Radius", sourceProps.borderRadii)),
borderColors(convertRawProp(rawProps, "border", "Color", sourceProps.borderColors)),
borderStyles(convertRawProp(rawProps, "border", "Style", sourceProps.borderStyles)),
@ -44,6 +43,18 @@ ViewProps::ViewProps(const ViewProps &sourceProps, const RawProps &rawProps):
#pragma mark - Convenience Methods
BorderMetrics ViewProps::resolveBorderMetrics(bool isRTL) const {
auto borderWidths = CascadedBorderWidths {
.left = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeLeft]),
.top = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeTop]),
.right = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeRight]),
.bottom = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeBottom]),
.start = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeStart]),
.end = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeEnd]),
.horizontal = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeHorizontal]),
.vertical = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeVertical]),
.all = optionalFloatFromYogaValue(yogaStyle.border[YGEdgeAll])
};
return {
.borderColors = borderColors.resolve(isRTL, {}),
.borderWidths = borderWidths.resolve(isRTL, 0),

View File

@ -39,7 +39,6 @@ public:
const SharedColor backgroundColor {};
// Borders
const CascadedBorderWidths borderWidths {};
const CascadedBorderRadii borderRadii {};
const CascadedBorderColors borderColors {};
const CascadedBorderStyles borderStyles {};

View File

@ -58,6 +58,19 @@ inline YGValue yogaStyleValueFromFloat(const Float &value) {
return {(float)value, YGUnitPoint};
}
inline folly::Optional<Float> optionalFloatFromYogaValue(const YGValue &value, folly::Optional<Float> base = {}) {
switch (value.unit) {
case YGUnitUndefined:
return {};
case YGUnitPoint:
return fabricFloatFromYogaFloat(value.value);
case YGUnitPercent:
return base.has_value() ? folly::Optional<Float>(base.value() * fabricFloatFromYogaFloat(value.value)) : folly::Optional<Float>();
case YGUnitAuto:
return {};
}
}
inline LayoutMetrics layoutMetricsFromYogaNode(YGNode &yogaNode) {
LayoutMetrics layoutMetrics;