Skip to content

Commit a052e1e

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Refactor BaseProps.resolveborderMetrics method (#45554)
Summary: Pull Request resolved: #45554 In this diff I'm extracting the creation of borderWidth into its own method, this is necessary for next diffs of the stack. Nh behavior change is introduced here changelog: [internal] internal Reviewed By: NickGerleman Differential Revision: D59942306 fbshipit-source-id: 85d39b64deaa4e8a8632d6f4aab72f626e594b5d
1 parent 6d08d3a commit a052e1e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,8 @@ static BorderRadii radiiPercentToPoint(
432432
};
433433
}
434434

435-
BorderMetrics BaseViewProps::resolveBorderMetrics(
436-
const LayoutMetrics& layoutMetrics) const {
437-
auto isRTL =
438-
bool{layoutMetrics.layoutDirection == LayoutDirection::RightToLeft};
439-
440-
auto borderWidths = CascadedBorderWidths{
435+
CascadedBorderWidths BaseViewProps::getBorderWidths() const {
436+
return CascadedBorderWidths{
441437
/* .left = */ optionalFloatFromYogaValue(
442438
yogaStyle.border(yoga::Edge::Left)),
443439
/* .top = */
@@ -457,6 +453,14 @@ BorderMetrics BaseViewProps::resolveBorderMetrics(
457453
/* .all = */
458454
optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::All)),
459455
};
456+
}
457+
458+
BorderMetrics BaseViewProps::resolveBorderMetrics(
459+
const LayoutMetrics& layoutMetrics) const {
460+
auto isRTL =
461+
bool{layoutMetrics.layoutDirection == LayoutDirection::RightToLeft};
462+
463+
auto borderWidths = getBorderWidths();
460464

461465
BorderRadii radii = radiiPercentToPoint(
462466
borderRadii.resolve(isRTL, ValueUnit{0.0f, UnitType::Point}),

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class BaseViewProps : public YogaStylableProps, public AccessibilityProps {
9696

9797
#pragma mark - Convenience Methods
9898

99+
CascadedBorderWidths getBorderWidths() const;
99100
BorderMetrics resolveBorderMetrics(const LayoutMetrics& layoutMetrics) const;
100101
Transform resolveTransform(const LayoutMetrics& layoutMetrics) const;
101102
bool getClipsContentToBounds() const;

0 commit comments

Comments
 (0)