Fabric: Fixed parsing of `backfaceVisibility` prop

Summary: I have noticed that `backfaceVisibility` example crashes (because actual value is a string/enum, not a boolean), so I fixed it.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D15219261

fbshipit-source-id: 27f76cd10903794d597adacb9da7300a42813f8e
This commit is contained in:
Valentin Shergin 2019-05-06 17:01:14 -07:00 коммит произвёл Facebook Github Bot
Родитель a6d4bceca4
Коммит b5d0b6fc2a
4 изменённых файлов: 22 добавлений и 2 удалений

Просмотреть файл

@ -159,7 +159,7 @@ using namespace facebook::react;
// `backfaceVisibility`
if (oldViewProps.backfaceVisibility != newViewProps.backfaceVisibility) {
self.layer.doubleSided = newViewProps.backfaceVisibility;
self.layer.doubleSided = newViewProps.backfaceVisibility == BackfaceVisibility::Visible;
}
// `shouldRasterize`

Просмотреть файл

@ -51,7 +51,7 @@ class ViewProps : public Props,
// Transform
Transform transform{};
bool const backfaceVisibility{};
BackfaceVisibility const backfaceVisibility{};
bool const shouldRasterize{};
int const zIndex{};

Просмотреть файл

@ -475,6 +475,24 @@ inline void fromRawValue(const RawValue &value, PointerEventsMode &result) {
LOG(FATAL) << "Could not parse PointerEventsMode:" << stringValue;
}
inline void fromRawValue(const RawValue &value, BackfaceVisibility &result) {
assert(value.hasType<std::string>());
auto stringValue = (std::string)value;
if (stringValue == "auto") {
result = BackfaceVisibility::Auto;
return;
}
if (stringValue == "visible") {
result = BackfaceVisibility::Visible;
return;
}
if (stringValue == "hidden") {
result = BackfaceVisibility::Hidden;
return;
}
LOG(FATAL) << "Could not parse BackfaceVisibility:" << stringValue;
}
inline void fromRawValue(const RawValue &value, BorderStyle &result) {
assert(value.hasType<std::string>());
auto stringValue = (std::string)value;

Просмотреть файл

@ -18,6 +18,8 @@ namespace react {
enum class PointerEventsMode { Auto, None, BoxNone, BoxOnly };
enum class BackfaceVisibility { Auto, Visible, Hidden };
enum class BorderStyle { Solid, Dotted, Dashed };
template <typename T>