diff --git a/ReactCommon/fabric/attributedstring/ParagraphAttributes.h b/ReactCommon/fabric/attributedstring/ParagraphAttributes.h index 42eb1aa0a..baa47c0c3 100644 --- a/ReactCommon/fabric/attributedstring/ParagraphAttributes.h +++ b/ReactCommon/fabric/attributedstring/ParagraphAttributes.h @@ -39,7 +39,7 @@ public: int maximumNumberOfLines {0}; /* - * In case if a text cannot fit given boudaures, defines a place where + * In case if a text cannot fit given boundaries, defines a place where * an ellipsize should be placed. */ EllipsizeMode ellipsizeMode {EllipsizeMode::Clip}; diff --git a/ReactCommon/fabric/core/shadownode/propsConversions.h b/ReactCommon/fabric/core/shadownode/propsConversions.h index 89d1808fe..290a3fa17 100644 --- a/ReactCommon/fabric/core/shadownode/propsConversions.h +++ b/ReactCommon/fabric/core/shadownode/propsConversions.h @@ -52,5 +52,22 @@ CONVERT_RAW_PROP_TEMPLATE(SharedColor, colorFromDynamic) CONVERT_RAW_PROP_TEMPLATE(Point, pointFromDynamic) CONVERT_RAW_PROP_TEMPLATE(Size, sizeFromDynamic) +inline void fromDynamic(const folly::dynamic &value, bool &result) { result = value.getBool(); } +inline void fromDynamic(const folly::dynamic &value, int &result) { result = value.getInt(); } +inline void fromDynamic(const folly::dynamic &value, Float &result) { result = value.getDouble(); } +inline void fromDynamic(const folly::dynamic &value, std::string &result) { result = value.getString(); } + +template +inline T convertRawProp(const RawProps &rawProps, const std::string &name, const T &defaultValue) { + auto &&iterator = rawProps.find(name); + if (iterator != rawProps.end()) { + T result = defaultValue; + fromDynamic(iterator->second, result); + return result; + } else { + return defaultValue; + } +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/debug/debugStringConvertibleUtils.h b/ReactCommon/fabric/debug/debugStringConvertibleUtils.h index d6be81b3c..e95620858 100644 --- a/ReactCommon/fabric/debug/debugStringConvertibleUtils.h +++ b/ReactCommon/fabric/debug/debugStringConvertibleUtils.h @@ -19,6 +19,15 @@ namespace facebook { namespace react { +template +inline SharedDebugStringConvertible debugStringConvertibleItem(std::string name, T value, T defaultValue = {}) { + if (value == defaultValue) { + return nullptr; + } + + return std::make_shared(name, toString(value)); +} + SharedDebugStringConvertibleList operator+(const SharedDebugStringConvertibleList &lhs, const SharedDebugStringConvertibleList &rhs); SharedDebugStringConvertible debugStringConvertibleItem(std::string name, DebugStringConvertible value, std::string defaultValue = ""); diff --git a/ReactCommon/fabric/text/paragraph/ParagraphLocalData.cpp b/ReactCommon/fabric/text/paragraph/ParagraphLocalData.cpp index 0064ee862..c96098981 100644 --- a/ReactCommon/fabric/text/paragraph/ParagraphLocalData.cpp +++ b/ReactCommon/fabric/text/paragraph/ParagraphLocalData.cpp @@ -8,6 +8,7 @@ #include "ParagraphLocalData.h" #include +#include namespace facebook { namespace react { @@ -38,7 +39,7 @@ std::string ParagraphLocalData::getDebugName() const { SharedDebugStringConvertibleList ParagraphLocalData::getDebugProps() const { return { - debugStringConvertibleItem("attributedString", attributedString_) + debugStringConvertibleItem("attributedString", attributedString_, "") }; }