Skip to content

Commit

Permalink
Fabric: borderWidths field was removed from ViewProps
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shergin authored and facebook-github-bot committed Sep 7, 2018
1 parent 2caa1e0 commit 2c3e4ec
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ - (void)updateProps:(SharedProps)props

// `border`
if (
oldViewProps.borderWidths != newViewProps.borderWidths ||
oldViewProps.borderStyles != newViewProps.borderStyles ||
oldViewProps.borderRadii != newViewProps.borderRadii ||
oldViewProps.borderColors != newViewProps.borderColors
Expand Down
13 changes: 12 additions & 1 deletion ReactCommon/fabric/components/view/ViewProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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),
Expand Down
1 change: 0 additions & 1 deletion ReactCommon/fabric/components/view/ViewProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class ViewProps:
const SharedColor backgroundColor {};

// Borders
const CascadedBorderWidths borderWidths {};
const CascadedBorderRadii borderRadii {};
const CascadedBorderColors borderColors {};
const CascadedBorderStyles borderStyles {};
Expand Down
13 changes: 13 additions & 0 deletions ReactCommon/fabric/components/view/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2c3e4ec

Please sign in to comment.