Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace facebook::react {

static bool
hasValue(const RawProps& rawProps, bool defaultValue, const char* name) {
auto rawValue = rawProps.at(name, nullptr, nullptr);
auto rawValue = rawProps.at(name);

// No change to prop - use default
if (rawValue == nullptr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,8 @@ AccessibilityProps::AccessibilityProps(
role = sourceProps.role;
accessibilityTraits = sourceProps.accessibilityTraits;
} else {
auto* accessibilityRoleValue =
rawProps.at("accessibilityRole", nullptr, nullptr);
auto* roleValue = rawProps.at("role", nullptr, nullptr);
auto* accessibilityRoleValue = rawProps.at("accessibilityRole");
auto* roleValue = rawProps.at("role");

auto* precedentRoleValue =
roleValue != nullptr ? roleValue : accessibilityRoleValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,20 @@ BaseViewProps::BaseViewProps(
: convertRawProp(
context,
rawProps,
"border",
"Radius",
CascadedRectangleCornersNames{
.topLeft = "borderTopLeftRadius",
.topRight = "borderTopRightRadius",
.bottomLeft = "borderBottomLeftRadius",
.bottomRight = "borderBottomRightRadius",
.topStart = "borderTopStartRadius",
.topEnd = "borderTopEndRadius",
.bottomStart = "borderBottomStartRadius",
.bottomEnd = "borderBottomEndRadius",
.endEnd = "borderEndEndRadius",
.endStart = "borderEndStartRadius",
.startEnd = "borderStartEndRadius",
.startStart = "borderStartStartRadius",
.all = "borderRadius"},
sourceProps.borderRadii,
{})),
borderColors(
Expand All @@ -94,8 +106,19 @@ BaseViewProps::BaseViewProps(
: convertRawProp(
context,
rawProps,
"border",
"Color",
CascadedRectangleEdgesNames{
.left = "borderLeftColor",
.right = "borderRightColor",
.top = "borderTopColor",
.bottom = "borderBottomColor",
.start = "borderStartColor",
.end = "borderEndColor",
.horizontal = "borderHorizontalColor",
.vertical = "borderVerticalColor",
.block = "borderBlockColor",
.blockEnd = "borderBlockEndColor",
.blockStart = "borderBlockStartColor",
.all = "borderColor"},
sourceProps.borderColors,
{})),
borderCurves(
Expand All @@ -104,8 +127,20 @@ BaseViewProps::BaseViewProps(
: convertRawProp(
context,
rawProps,
"border",
"Curve",
CascadedRectangleCornersNames{
.topLeft = "borderTopLeftCurve",
.topRight = "borderTopRightCurve",
.bottomLeft = "borderBottomLeftCurve",
.bottomRight = "borderBottomRightCurve",
.topStart = "borderTopStartCurve",
.topEnd = "borderTopEndCurve",
.bottomStart = "borderBottomStartCurve",
.bottomEnd = "borderBottomEndCurve",
.endEnd = "borderEndEndCurve",
.endStart = "borderEndStartCurve",
.startEnd = "borderStartEndCurve",
.startStart = "borderStartStartCurve",
.all = "borderCurve"},
sourceProps.borderCurves,
{})),
borderStyles(
Expand All @@ -114,8 +149,19 @@ BaseViewProps::BaseViewProps(
: convertRawProp(
context,
rawProps,
"border",
"Style",
CascadedRectangleEdgesNames{
.left = "borderLeftStyle",
.right = "borderRightStyle",
.top = "borderTopStyle",
.bottom = "borderBottomStyle",
.start = "borderStartStyle",
.end = "borderEndStyle",
.horizontal = "borderHorizontalStyle",
.vertical = "borderVerticalStyle",
.block = "borderBlockStyle",
.blockEnd = "borderBlockEndStyle",
.blockStart = "borderBlockStartStyle",
.all = "borderStyle"},
sourceProps.borderStyles,
{})),
outlineColor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,43 +369,67 @@ convertRawProp(const PropsParserContext &context, const RawProps &rawProps, cons
return yogaStyle;
}

struct CascadedRectangleCornersNames {
const char *topLeft;
const char *topRight;
const char *bottomLeft;
const char *bottomRight;
const char *topStart;
const char *topEnd;
const char *bottomStart;
const char *bottomEnd;
const char *endEnd;
const char *endStart;
const char *startEnd;
const char *startStart;
const char *all;
};

struct CascadedRectangleEdgesNames {
const char *left;
const char *right;
const char *top;
const char *bottom;
const char *start;
const char *end;
const char *horizontal;
const char *vertical;
const char *block;
const char *blockEnd;
const char *blockStart;
const char *all;
};

// This can be deleted when non-iterator ViewProp parsing is deleted
template <typename T>
static inline CascadedRectangleCorners<T> convertRawProp(
const PropsParserContext &context,
const RawProps &rawProps,
const char *prefix,
const char *suffix,
const CascadedRectangleCornersNames &names,
const CascadedRectangleCorners<T> &sourceValue,
const CascadedRectangleCorners<T> &defaultValue)
{
CascadedRectangleCorners<T> result;

result.topLeft =
convertRawProp(context, rawProps, "TopLeft", sourceValue.topLeft, defaultValue.topLeft, prefix, suffix);
result.topRight =
convertRawProp(context, rawProps, "TopRight", sourceValue.topRight, defaultValue.topRight, prefix, suffix);
result.topLeft = convertRawProp(context, rawProps, names.topLeft, sourceValue.topLeft, defaultValue.topLeft);
result.topRight = convertRawProp(context, rawProps, names.topRight, sourceValue.topRight, defaultValue.topRight);
result.bottomLeft =
convertRawProp(context, rawProps, "BottomLeft", sourceValue.bottomLeft, defaultValue.bottomLeft, prefix, suffix);
result.bottomRight = convertRawProp(
context, rawProps, "BottomRight", sourceValue.bottomRight, defaultValue.bottomRight, prefix, suffix);

result.topStart =
convertRawProp(context, rawProps, "TopStart", sourceValue.topStart, defaultValue.topStart, prefix, suffix);
result.topEnd = convertRawProp(context, rawProps, "TopEnd", sourceValue.topEnd, defaultValue.topEnd, prefix, suffix);
result.bottomStart = convertRawProp(
context, rawProps, "BottomStart", sourceValue.bottomStart, defaultValue.bottomStart, prefix, suffix);
result.bottomEnd =
convertRawProp(context, rawProps, "BottomEnd", sourceValue.bottomEnd, defaultValue.bottomEnd, prefix, suffix);
result.endEnd = convertRawProp(context, rawProps, "EndEnd", sourceValue.endEnd, defaultValue.endEnd, prefix, suffix);
result.endStart =
convertRawProp(context, rawProps, "EndStart", sourceValue.endStart, defaultValue.endStart, prefix, suffix);
result.startEnd =
convertRawProp(context, rawProps, "StartEnd", sourceValue.startEnd, defaultValue.startEnd, prefix, suffix);
convertRawProp(context, rawProps, names.bottomLeft, sourceValue.bottomLeft, defaultValue.bottomLeft);
result.bottomRight =
convertRawProp(context, rawProps, names.bottomRight, sourceValue.bottomRight, defaultValue.bottomRight);

result.topStart = convertRawProp(context, rawProps, names.topStart, sourceValue.topStart, defaultValue.topStart);
result.topEnd = convertRawProp(context, rawProps, names.topEnd, sourceValue.topEnd, defaultValue.topEnd);
result.bottomStart =
convertRawProp(context, rawProps, names.bottomStart, sourceValue.bottomStart, defaultValue.bottomStart);
result.bottomEnd = convertRawProp(context, rawProps, names.bottomEnd, sourceValue.bottomEnd, defaultValue.bottomEnd);
result.endEnd = convertRawProp(context, rawProps, names.endEnd, sourceValue.endEnd, defaultValue.endEnd);
result.endStart = convertRawProp(context, rawProps, names.endStart, sourceValue.endStart, defaultValue.endStart);
result.startEnd = convertRawProp(context, rawProps, names.startEnd, sourceValue.startEnd, defaultValue.startEnd);
result.startStart =
convertRawProp(context, rawProps, "StartStart", sourceValue.startStart, defaultValue.startStart, prefix, suffix);
convertRawProp(context, rawProps, names.startStart, sourceValue.startStart, defaultValue.startStart);

result.all = convertRawProp(context, rawProps, "", sourceValue.all, defaultValue.all, prefix, suffix);
result.all = convertRawProp(context, rawProps, names.all, sourceValue.all, defaultValue.all);

return result;
}
Expand All @@ -414,31 +438,28 @@ template <typename T>
static inline CascadedRectangleEdges<T> convertRawProp(
const PropsParserContext &context,
const RawProps &rawProps,
const char *prefix,
const char *suffix,
const CascadedRectangleEdgesNames &names,
const CascadedRectangleEdges<T> &sourceValue,
const CascadedRectangleEdges<T> &defaultValue)
{
CascadedRectangleEdges<T> result;

result.left = convertRawProp(context, rawProps, "Left", sourceValue.left, defaultValue.left, prefix, suffix);
result.right = convertRawProp(context, rawProps, "Right", sourceValue.right, defaultValue.right, prefix, suffix);
result.top = convertRawProp(context, rawProps, "Top", sourceValue.top, defaultValue.top, prefix, suffix);
result.bottom = convertRawProp(context, rawProps, "Bottom", sourceValue.bottom, defaultValue.bottom, prefix, suffix);
result.left = convertRawProp(context, rawProps, names.left, sourceValue.left, defaultValue.left);
result.right = convertRawProp(context, rawProps, names.right, sourceValue.right, defaultValue.right);
result.top = convertRawProp(context, rawProps, names.top, sourceValue.top, defaultValue.top);
result.bottom = convertRawProp(context, rawProps, names.bottom, sourceValue.bottom, defaultValue.bottom);

result.start = convertRawProp(context, rawProps, "Start", sourceValue.start, defaultValue.start, prefix, suffix);
result.end = convertRawProp(context, rawProps, "End", sourceValue.end, defaultValue.end, prefix, suffix);
result.start = convertRawProp(context, rawProps, names.start, sourceValue.start, defaultValue.start);
result.end = convertRawProp(context, rawProps, names.end, sourceValue.end, defaultValue.end);
result.horizontal =
convertRawProp(context, rawProps, "Horizontal", sourceValue.horizontal, defaultValue.horizontal, prefix, suffix);
result.vertical =
convertRawProp(context, rawProps, "Vertical", sourceValue.vertical, defaultValue.vertical, prefix, suffix);
result.block = convertRawProp(context, rawProps, "Block", sourceValue.block, defaultValue.block, prefix, suffix);
result.blockEnd =
convertRawProp(context, rawProps, "BlockEnd", sourceValue.blockEnd, defaultValue.blockEnd, prefix, suffix);
convertRawProp(context, rawProps, names.horizontal, sourceValue.horizontal, defaultValue.horizontal);
result.vertical = convertRawProp(context, rawProps, names.vertical, sourceValue.vertical, defaultValue.vertical);
result.block = convertRawProp(context, rawProps, names.block, sourceValue.block, defaultValue.block);
result.blockEnd = convertRawProp(context, rawProps, names.blockEnd, sourceValue.blockEnd, defaultValue.blockEnd);
result.blockStart =
convertRawProp(context, rawProps, "BlockStart", sourceValue.blockStart, defaultValue.blockStart, prefix, suffix);
convertRawProp(context, rawProps, names.blockStart, sourceValue.blockStart, defaultValue.blockStart);

result.all = convertRawProp(context, rawProps, "", sourceValue.all, defaultValue.all, prefix, suffix);
result.all = convertRawProp(context, rawProps, names.all, sourceValue.all, defaultValue.all);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <cxxreact/TraceSection.h>
#include <react/debug/react_native_assert.h>
#include <react/renderer/core/RawPropsKey.h>
#include <react/renderer/core/RawPropsParser.h>

namespace facebook::react {
Expand Down Expand Up @@ -110,15 +109,11 @@ bool RawProps::isEmpty() const noexcept {
* Returns a const unowning pointer to `RawValue` of a prop with a given name.
* Returns `nullptr` if a prop with the given name does not exist.
*/
const RawValue* RawProps::at(
const char* name,
const char* prefix,
const char* suffix) const noexcept {
const RawValue* RawProps::at(const char* name) const noexcept {
react_native_assert(
parser_ &&
"The object is not parsed. `parse` must be called before `at`.");
return parser_->at(
*this, RawPropsKey{.prefix = prefix, .name = name, .suffix = suffix});
return parser_->at(*this, name);
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class RawProps final {
* Returns a const unowning pointer to `RawValue` of a prop with a given name.
* Returns `nullptr` if a prop with the given name does not exist.
*/
const RawValue *at(const char *name, const char *prefix, const char *suffix) const noexcept;
const RawValue *at(const char *name) const noexcept;

private:
friend class RawPropsParser;
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading