@@ -45,64 +45,64 @@ parseProcessedFilter(const PropsParserContext &context, const RawValue &value, s
4545
4646 auto rawFilterFunction = static_cast <std::unordered_map<std::string, RawValue>>(rawFilterPrimitive);
4747 FilterFunction filterFunction{};
48- try {
49- filterFunction.type = filterTypeFromString (rawFilterFunction.begin ()->first );
50- if (filterFunction.type == FilterType::DropShadow) {
51- auto rawDropShadow = static_cast <std::unordered_map<std::string, RawValue>>(rawFilterFunction.begin ()->second );
52- DropShadowParams dropShadowParams{};
53-
54- auto offsetX = rawDropShadow.find (" offsetX" );
55- react_native_expect (offsetX != rawDropShadow.end ());
56- if (offsetX == rawDropShadow.end ()) {
57- result = {};
58- return ;
59- }
48+ auto filterType = filterTypeFromString (rawFilterFunction.begin ()->first );
49+ if (!filterType.has_value ()) {
50+ LOG (ERROR) << " Could not parse FilterFunction: " << rawFilterFunction.begin ()->first ;
51+ result = {};
52+ return ;
53+ }
54+ filterFunction.type = *filterType;
55+ if (filterFunction.type == FilterType::DropShadow) {
56+ auto rawDropShadow = static_cast <std::unordered_map<std::string, RawValue>>(rawFilterFunction.begin ()->second );
57+ DropShadowParams dropShadowParams{};
58+
59+ auto offsetX = rawDropShadow.find (" offsetX" );
60+ react_native_expect (offsetX != rawDropShadow.end ());
61+ if (offsetX == rawDropShadow.end ()) {
62+ result = {};
63+ return ;
64+ }
6065
61- react_native_expect (offsetX->second .hasType <Float>());
62- if (!offsetX->second .hasType <Float>()) {
63- result = {};
64- return ;
65- }
66- dropShadowParams.offsetX = (Float)offsetX->second ;
66+ react_native_expect (offsetX->second .hasType <Float>());
67+ if (!offsetX->second .hasType <Float>()) {
68+ result = {};
69+ return ;
70+ }
71+ dropShadowParams.offsetX = (Float)offsetX->second ;
6772
68- auto offsetY = rawDropShadow.find (" offsetY" );
69- react_native_expect (offsetY != rawDropShadow.end ());
70- if (offsetY == rawDropShadow.end ()) {
71- result = {};
72- return ;
73- }
74- react_native_expect (offsetY->second .hasType <Float>());
75- if (!offsetY->second .hasType <Float>()) {
73+ auto offsetY = rawDropShadow.find (" offsetY" );
74+ react_native_expect (offsetY != rawDropShadow.end ());
75+ if (offsetY == rawDropShadow.end ()) {
76+ result = {};
77+ return ;
78+ }
79+ react_native_expect (offsetY->second .hasType <Float>());
80+ if (!offsetY->second .hasType <Float>()) {
81+ result = {};
82+ return ;
83+ }
84+ dropShadowParams.offsetY = (Float)offsetY->second ;
85+
86+ auto standardDeviation = rawDropShadow.find (" standardDeviation" );
87+ if (standardDeviation != rawDropShadow.end ()) {
88+ react_native_expect (standardDeviation->second .hasType <Float>());
89+ if (!standardDeviation->second .hasType <Float>()) {
7690 result = {};
7791 return ;
7892 }
79- dropShadowParams.offsetY = (Float)offsetY->second ;
80-
81- auto standardDeviation = rawDropShadow.find (" standardDeviation" );
82- if (standardDeviation != rawDropShadow.end ()) {
83- react_native_expect (standardDeviation->second .hasType <Float>());
84- if (!standardDeviation->second .hasType <Float>()) {
85- result = {};
86- return ;
87- }
88- dropShadowParams.standardDeviation = (Float)standardDeviation->second ;
89- }
90-
91- auto color = rawDropShadow.find (" color" );
92- if (color != rawDropShadow.end ()) {
93- fromRawValue (context.contextContainer , context.surfaceId , color->second , dropShadowParams.color );
94- }
93+ dropShadowParams.standardDeviation = (Float)standardDeviation->second ;
94+ }
9595
96- filterFunction. parameters = dropShadowParams ;
97- } else {
98- filterFunction. parameters = ( float )rawFilterFunction. begin () ->second ;
96+ auto color = rawDropShadow. find ( " color " ) ;
97+ if (color != rawDropShadow. end ()) {
98+ fromRawValue (context. contextContainer , context. surfaceId , color ->second , dropShadowParams. color ) ;
9999 }
100- filter.push_back (std::move (filterFunction));
101- } catch (const std::exception &e) {
102- LOG (ERROR) << " Could not parse FilterFunction: " << e.what ();
103- result = {};
104- return ;
100+
101+ filterFunction.parameters = dropShadowParams;
102+ } else {
103+ filterFunction.parameters = (float )rawFilterFunction.begin ()->second ;
105104 }
105+ filter.push_back (filterFunction);
106106 }
107107
108108 result = filter;
@@ -313,11 +313,15 @@ inline std::optional<FilterFunction> parseFilterRawValue(const PropsParserContex
313313 }
314314 return {};
315315 } else {
316+ auto filterType = filterTypeFromString (filterKey);
317+ if (!filterType.has_value ()) {
318+ return {};
319+ }
316320 if (auto amount = coerceAmount (rawFilter.begin ()->second )) {
317321 if (*amount < 0 .0f ) {
318322 return {};
319323 }
320- return FilterFunction{.type = filterTypeFromString (filterKey) , .parameters = *amount};
324+ return FilterFunction{.type = *filterType , .parameters = *amount};
321325 }
322326 return {};
323327 }
0 commit comments