Skip to content

Commit

Permalink
Refactor BaseProps.resolveborderMetrics method (#45554)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jul 20, 2024
1 parent 6d08d3a commit a052e1e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,8 @@ static BorderRadii radiiPercentToPoint(
};
}

BorderMetrics BaseViewProps::resolveBorderMetrics(
const LayoutMetrics& layoutMetrics) const {
auto isRTL =
bool{layoutMetrics.layoutDirection == LayoutDirection::RightToLeft};

auto borderWidths = CascadedBorderWidths{
CascadedBorderWidths BaseViewProps::getBorderWidths() const {
return CascadedBorderWidths{
/* .left = */ optionalFloatFromYogaValue(
yogaStyle.border(yoga::Edge::Left)),
/* .top = */
Expand All @@ -457,6 +453,14 @@ BorderMetrics BaseViewProps::resolveBorderMetrics(
/* .all = */
optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::All)),
};
}

BorderMetrics BaseViewProps::resolveBorderMetrics(
const LayoutMetrics& layoutMetrics) const {
auto isRTL =
bool{layoutMetrics.layoutDirection == LayoutDirection::RightToLeft};

auto borderWidths = getBorderWidths();

BorderRadii radii = radiiPercentToPoint(
borderRadii.resolve(isRTL, ValueUnit{0.0f, UnitType::Point}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class BaseViewProps : public YogaStylableProps, public AccessibilityProps {

#pragma mark - Convenience Methods

CascadedBorderWidths getBorderWidths() const;
BorderMetrics resolveBorderMetrics(const LayoutMetrics& layoutMetrics) const;
Transform resolveTransform(const LayoutMetrics& layoutMetrics) const;
bool getClipsContentToBounds() const;
Expand Down

0 comments on commit a052e1e

Please sign in to comment.