yoga::resolveValue -> Length::resolve (#1520)
Summary: X-link: https://github.com/facebook/react-native/pull/41939 Pull Request resolved: https://github.com/facebook/yoga/pull/1520 This code originates as `YGValueResolve`, used to compute a YGValue to a length in points, using a reference for 100%. This moves it to `Style::Length`, so we can encapsulate parts of it (for style value functions), and make the API more cohesive now that we can do C++ style OOP with it. Changelog: [Internal] Reviewed By: joevilches Differential Revision: D51796973 fbshipit-source-id: a7c359c7544f4bd2066a80d976dde67a0d16f1dd
This commit is contained in:
committed by
Facebook GitHub Bot
parent
192016a0a8
commit
ca4ecc044d
@@ -71,6 +71,17 @@ class StyleLength {
|
||||
return unit_;
|
||||
}
|
||||
|
||||
constexpr FloatOptional resolve(float referenceLength) {
|
||||
switch (unit_) {
|
||||
case Unit::Point:
|
||||
return value_;
|
||||
case Unit::Percent:
|
||||
return FloatOptional{value_.unwrap() * referenceLength * 0.01f};
|
||||
default:
|
||||
return FloatOptional{};
|
||||
}
|
||||
}
|
||||
|
||||
explicit constexpr operator YGValue() const {
|
||||
return YGValue{value_.unwrap(), unscopedEnum(unit_)};
|
||||
}
|
||||
|
Reference in New Issue
Block a user