mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Revert D94052732 - S627731 (#55816)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55816 Changelog: [Internal] Reviewed By: andra-marinescu Differential Revision: D94756771 fbshipit-source-id: dd5cc72bc2ce65a9407ae728f149d2541d596ef9
This commit is contained in:
1 parent
ff67a1bea7
commit
83d7c46f16
5 files changed
+31
-121
No files matched your search
+1
-5
@@ -67,10 +67,6 @@ export const transformOriginAttribute: AnyAttributeType = nativeCSSParsing
|
||||
? true
|
||||
: {process: processTransformOrigin};
|
||||
|
||||
export const aspectRatioAttribute: AnyAttributeType = nativeCSSParsing
|
||||
? true
|
||||
: {process: processAspectRatio};
|
||||
|
||||
const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = {
|
||||
/**
|
||||
* Layout
|
||||
@@ -78,7 +74,7 @@ const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = {
|
||||
alignContent: true,
|
||||
alignItems: true,
|
||||
alignSelf: true,
|
||||
aspectRatio: aspectRatioAttribute,
|
||||
aspectRatio: {process: processAspectRatio},
|
||||
borderBottomWidth: true,
|
||||
borderEndWidth: true,
|
||||
borderLeftWidth: true,
|
||||
|
||||
+28
-33
@@ -147,40 +147,35 @@ void YogaStylableProps::setProp(
|
||||
REBUILD_FIELD_SWITCH_CASE_YSP(flexBasis, setFlexBasis);
|
||||
REBUILD_FIELD_SWITCH_CASE2(positionType, setPositionType, "position");
|
||||
REBUILD_FIELD_YG_GUTTER(gap, setGap, "rowGap", "columnGap", "gap");
|
||||
case CONSTEXPR_RAW_PROPS_KEY_HASH("aspectRatio"): {
|
||||
yogaStyle.setAspectRatio(
|
||||
value.hasValue() ? convertAspectRatio(context, value)
|
||||
: ygDefaults.aspectRatio());
|
||||
return;
|
||||
}
|
||||
REBUILD_FIELD_SWITCH_CASE_YSP(boxSizing, setBoxSizing);
|
||||
REBUILD_FIELD_YG_DIMENSION(dimension, setDimension, "width", "height");
|
||||
REBUILD_FIELD_YG_DIMENSION(
|
||||
minDimension, setMinDimension, "minWidth", "minHeight");
|
||||
REBUILD_FIELD_YG_DIMENSION(
|
||||
maxDimension, setMaxDimension, "maxWidth", "maxHeight");
|
||||
REBUILD_FIELD_YG_EDGES_POSITION();
|
||||
REBUILD_FIELD_YG_EDGES(margin, setMargin, "margin", "");
|
||||
REBUILD_FIELD_YG_EDGES(padding, setPadding, "padding", "");
|
||||
REBUILD_FIELD_YG_EDGES(border, setBorder, "border", "Width");
|
||||
REBUILD_FIELD_SWITCH_CASE_YSP(aspectRatio, setAspectRatio);
|
||||
REBUILD_FIELD_SWITCH_CASE_YSP(boxSizing, setBoxSizing);
|
||||
REBUILD_FIELD_YG_DIMENSION(dimension, setDimension, "width", "height");
|
||||
REBUILD_FIELD_YG_DIMENSION(
|
||||
minDimension, setMinDimension, "minWidth", "minHeight");
|
||||
REBUILD_FIELD_YG_DIMENSION(
|
||||
maxDimension, setMaxDimension, "maxWidth", "maxHeight");
|
||||
REBUILD_FIELD_YG_EDGES_POSITION();
|
||||
REBUILD_FIELD_YG_EDGES(margin, setMargin, "margin", "");
|
||||
REBUILD_FIELD_YG_EDGES(padding, setPadding, "padding", "");
|
||||
REBUILD_FIELD_YG_EDGES(border, setBorder, "border", "Width");
|
||||
|
||||
// Aliases
|
||||
RAW_SET_PROP_SWITCH_CASE(insetBlockEnd, "insetBlockEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(insetBlockStart, "insetBlockStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(insetInlineEnd, "insetInlineEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(insetInlineStart, "insetInlineStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginInline, "marginInline");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginInlineStart, "marginInlineStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginInlineEnd, "marginInlineEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginBlock, "marginBlock");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginBlockStart, "marginBlockStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginBlockEnd, "marginBlockEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingInline, "paddingInline");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingInlineStart, "paddingInlineStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingInlineEnd, "paddingInlineEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingBlock, "paddingBlock");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingBlockStart, "paddingBlockStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingBlockEnd, "paddingBlockEnd");
|
||||
// Aliases
|
||||
RAW_SET_PROP_SWITCH_CASE(insetBlockEnd, "insetBlockEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(insetBlockStart, "insetBlockStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(insetInlineEnd, "insetInlineEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(insetInlineStart, "insetInlineStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginInline, "marginInline");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginInlineStart, "marginInlineStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginInlineEnd, "marginInlineEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginBlock, "marginBlock");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginBlockStart, "marginBlockStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(marginBlockEnd, "marginBlockEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingInline, "paddingInline");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingInlineStart, "paddingInlineStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingInlineEnd, "paddingInlineEnd");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingBlock, "paddingBlock");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingBlockStart, "paddingBlockStart");
|
||||
RAW_SET_PROP_SWITCH_CASE(paddingBlockEnd, "paddingBlockEnd");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -498,23 +498,6 @@ inline void fromRawValue(const PropsParserContext &context, const RawValue &valu
|
||||
result = value.hasType<float>() ? yoga::FloatOptional((float)value) : yoga::FloatOptional();
|
||||
}
|
||||
|
||||
inline yoga::FloatOptional convertAspectRatio(const PropsParserContext &context, const RawValue &value)
|
||||
{
|
||||
if (value.hasType<float>()) {
|
||||
return yoga::FloatOptional((float)value);
|
||||
}
|
||||
if (ReactNativeFeatureFlags::enableNativeCSSParsing() && value.hasType<std::string>()) {
|
||||
auto ratio = parseCSSProperty<CSSRatio>((std::string)value);
|
||||
if (std::holds_alternative<CSSRatio>(ratio)) {
|
||||
auto r = std::get<CSSRatio>(ratio);
|
||||
if (!r.isDegenerate()) {
|
||||
return yoga::FloatOptional(r.numerator / r.denominator);
|
||||
}
|
||||
}
|
||||
}
|
||||
return yoga::FloatOptional();
|
||||
}
|
||||
|
||||
inline std::optional<Float> toRadians(const RawValue &value)
|
||||
{
|
||||
if (value.hasType<Float>()) {
|
||||
|
||||
@@ -356,12 +356,8 @@ convertRawProp(const PropsParserContext &context, const RawProps &rawProps, cons
|
||||
yoga::Dimension::Height,
|
||||
convertRawProp(context, rawProps, "maxHeight", sourceValue.maxDimension(yoga::Dimension::Height), {}));
|
||||
|
||||
{
|
||||
const auto *rawValue = rawProps.at("aspectRatio", nullptr, nullptr);
|
||||
if (rawValue != nullptr) {
|
||||
yogaStyle.setAspectRatio(rawValue->hasValue() ? convertAspectRatio(context, *rawValue) : yogaStyle.aspectRatio());
|
||||
}
|
||||
}
|
||||
yogaStyle.setAspectRatio(
|
||||
convertRawProp(context, rawProps, "aspectRatio", sourceValue.aspectRatio(), yogaStyle.aspectRatio()));
|
||||
|
||||
yogaStyle.setBoxSizing(
|
||||
convertRawProp(context, rawProps, "boxSizing", sourceValue.boxSizing(), yogaStyle.boxSizing()));
|
||||
|
||||
-60
@@ -454,64 +454,4 @@ TEST(ConversionsTest, unprocessed_transform_origin_rawvalue_string_with_z) {
|
||||
EXPECT_EQ(result.z, 15.0f);
|
||||
}
|
||||
|
||||
TEST(ConversionsTest, convert_aspect_ratio_float) {
|
||||
RawValue value{folly::dynamic(1.5)};
|
||||
auto result =
|
||||
convertAspectRatio(PropsParserContext{-1, ContextContainer{}}, value);
|
||||
|
||||
EXPECT_FALSE(result.isUndefined());
|
||||
EXPECT_EQ(result.unwrap(), 1.5f);
|
||||
}
|
||||
|
||||
TEST(ConversionsTest, convert_aspect_ratio_ratio_string) {
|
||||
// CSSRatio parses "16/9" as {numerator: 16, denominator: 9}
|
||||
auto ratio = parseCSSProperty<CSSRatio>("16/9");
|
||||
ASSERT_TRUE(std::holds_alternative<CSSRatio>(ratio));
|
||||
auto r = std::get<CSSRatio>(ratio);
|
||||
EXPECT_FALSE(r.isDegenerate());
|
||||
EXPECT_NEAR(r.numerator / r.denominator, 16.0f / 9.0f, 0.001f);
|
||||
}
|
||||
|
||||
TEST(ConversionsTest, convert_aspect_ratio_number_string) {
|
||||
// CSSRatio parses "1.5" as {numerator: 1.5, denominator: 1.0}
|
||||
auto ratio = parseCSSProperty<CSSRatio>("1.5");
|
||||
ASSERT_TRUE(std::holds_alternative<CSSRatio>(ratio));
|
||||
auto r = std::get<CSSRatio>(ratio);
|
||||
EXPECT_FALSE(r.isDegenerate());
|
||||
EXPECT_EQ(r.numerator / r.denominator, 1.5f);
|
||||
}
|
||||
|
||||
TEST(ConversionsTest, convert_aspect_ratio_degenerate) {
|
||||
auto ratio = parseCSSProperty<CSSRatio>("0/0");
|
||||
ASSERT_TRUE(std::holds_alternative<CSSRatio>(ratio));
|
||||
EXPECT_TRUE(std::get<CSSRatio>(ratio).isDegenerate());
|
||||
}
|
||||
|
||||
TEST(ConversionsTest, float_optional_from_rawvalue_float) {
|
||||
RawValue value{folly::dynamic(1.5)};
|
||||
yoga::FloatOptional result;
|
||||
fromRawValue(PropsParserContext{-1, ContextContainer{}}, value, result);
|
||||
|
||||
EXPECT_FALSE(result.isUndefined());
|
||||
EXPECT_EQ(result.unwrap(), 1.5f);
|
||||
}
|
||||
|
||||
TEST(ConversionsTest, float_optional_undefined_for_non_float) {
|
||||
RawValue value{folly::dynamic(nullptr)};
|
||||
yoga::FloatOptional result;
|
||||
fromRawValue(PropsParserContext{-1, ContextContainer{}}, value, result);
|
||||
|
||||
EXPECT_TRUE(result.isUndefined());
|
||||
}
|
||||
|
||||
TEST(ConversionsTest, float_optional_undefined_for_string) {
|
||||
// fromRawValue for FloatOptional does not parse strings —
|
||||
// that is handled by convertAspectRatio specifically.
|
||||
RawValue value{folly::dynamic("16/9")};
|
||||
yoga::FloatOptional result;
|
||||
fromRawValue(PropsParserContext{-1, ContextContainer{}}, value, result);
|
||||
|
||||
EXPECT_TRUE(result.isUndefined());
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
Reference in new issue
Block a user