|
9 | 9 |
|
10 | 10 | #include <folly/dynamic.h> |
11 | 11 | #include <react/debug/react_native_expect.h> |
12 | | -#include <react/featureflags/ReactNativeFeatureFlags.h> |
13 | 12 | #include <react/renderer/attributedstring/AttributedString.h> |
14 | 13 | #include <react/renderer/attributedstring/ParagraphAttributes.h> |
15 | 14 | #include <react/renderer/attributedstring/TextAttributes.h> |
|
22 | 21 | #include <react/renderer/core/conversions.h> |
23 | 22 | #include <react/renderer/core/graphicsConversions.h> |
24 | 23 | #include <react/renderer/core/propsConversions.h> |
25 | | -#include <react/renderer/css/CSSFontVariant.h> |
26 | | -#include <react/renderer/css/CSSValueParser.h> |
27 | 24 | #include <unordered_map> |
28 | 25 |
|
29 | 26 | #ifdef RN_SERIALIZABLE_STATE |
@@ -320,66 +317,7 @@ inline std::string toString(const FontStyle &fontStyle) |
320 | 317 | return "normal"; |
321 | 318 | } |
322 | 319 |
|
323 | | -inline std::optional<FontVariant> fontVariantFromCSSFontVariant(CSSFontVariant cssVariant) |
324 | | -{ |
325 | | - switch (cssVariant) { |
326 | | - case CSSFontVariant::SmallCaps: |
327 | | - return FontVariant::SmallCaps; |
328 | | - case CSSFontVariant::OldstyleNums: |
329 | | - return FontVariant::OldstyleNums; |
330 | | - case CSSFontVariant::LiningNums: |
331 | | - return FontVariant::LiningNums; |
332 | | - case CSSFontVariant::TabularNums: |
333 | | - return FontVariant::TabularNums; |
334 | | - case CSSFontVariant::ProportionalNums: |
335 | | - return FontVariant::ProportionalNums; |
336 | | - case CSSFontVariant::StylisticOne: |
337 | | - return FontVariant::StylisticOne; |
338 | | - case CSSFontVariant::StylisticTwo: |
339 | | - return FontVariant::StylisticTwo; |
340 | | - case CSSFontVariant::StylisticThree: |
341 | | - return FontVariant::StylisticThree; |
342 | | - case CSSFontVariant::StylisticFour: |
343 | | - return FontVariant::StylisticFour; |
344 | | - case CSSFontVariant::StylisticFive: |
345 | | - return FontVariant::StylisticFive; |
346 | | - case CSSFontVariant::StylisticSix: |
347 | | - return FontVariant::StylisticSix; |
348 | | - case CSSFontVariant::StylisticSeven: |
349 | | - return FontVariant::StylisticSeven; |
350 | | - case CSSFontVariant::StylisticEight: |
351 | | - return FontVariant::StylisticEight; |
352 | | - case CSSFontVariant::StylisticNine: |
353 | | - return FontVariant::StylisticNine; |
354 | | - case CSSFontVariant::StylisticTen: |
355 | | - return FontVariant::StylisticTen; |
356 | | - case CSSFontVariant::StylisticEleven: |
357 | | - return FontVariant::StylisticEleven; |
358 | | - case CSSFontVariant::StylisticTwelve: |
359 | | - return FontVariant::StylisticTwelve; |
360 | | - case CSSFontVariant::StylisticThirteen: |
361 | | - return FontVariant::StylisticThirteen; |
362 | | - case CSSFontVariant::StylisticFourteen: |
363 | | - return FontVariant::StylisticFourteen; |
364 | | - case CSSFontVariant::StylisticFifteen: |
365 | | - return FontVariant::StylisticFifteen; |
366 | | - case CSSFontVariant::StylisticSixteen: |
367 | | - return FontVariant::StylisticSixteen; |
368 | | - case CSSFontVariant::StylisticSeventeen: |
369 | | - return FontVariant::StylisticSeventeen; |
370 | | - case CSSFontVariant::StylisticEighteen: |
371 | | - return FontVariant::StylisticEighteen; |
372 | | - case CSSFontVariant::StylisticNineteen: |
373 | | - return FontVariant::StylisticNineteen; |
374 | | - case CSSFontVariant::StylisticTwenty: |
375 | | - return FontVariant::StylisticTwenty; |
376 | | - default: |
377 | | - // Ligature variants (CommonLigatures, etc.) have no FontVariant equivalent |
378 | | - return std::nullopt; |
379 | | - } |
380 | | -} |
381 | | - |
382 | | -inline void parseProcessedFontVariant(const PropsParserContext &context, const RawValue &value, FontVariant &result) |
| 320 | +inline void fromRawValue(const PropsParserContext &context, const RawValue &value, FontVariant &result) |
383 | 321 | { |
384 | 322 | result = FontVariant::Default; |
385 | 323 | react_native_expect(value.hasType<std::vector<std::string>>()); |
@@ -438,47 +376,14 @@ inline void parseProcessedFontVariant(const PropsParserContext &context, const R |
438 | 376 | result = (FontVariant)((int)result | (int)FontVariant::StylisticTwenty); |
439 | 377 | } else { |
440 | 378 | LOG(ERROR) << "Unsupported FontVariant value: " << item; |
| 379 | + react_native_expect(false); |
441 | 380 | } |
442 | 381 | } |
443 | 382 | } else { |
444 | 383 | LOG(ERROR) << "Unsupported FontVariant type"; |
445 | 384 | } |
446 | 385 | } |
447 | 386 |
|
448 | | -inline void parseUnprocessedFontVariantString(const std::string &value, FontVariant &result) |
449 | | -{ |
450 | | - auto fontVariantList = parseCSSProperty<CSSFontVariantList>(value); |
451 | | - if (!std::holds_alternative<CSSFontVariantList>(fontVariantList)) { |
452 | | - result = FontVariant::Default; |
453 | | - return; |
454 | | - } |
455 | | - |
456 | | - result = FontVariant::Default; |
457 | | - for (const auto &cssVariant : std::get<CSSFontVariantList>(fontVariantList)) { |
458 | | - if (auto fv = fontVariantFromCSSFontVariant(cssVariant)) { |
459 | | - result = (FontVariant)((int)result | (int)*fv); |
460 | | - } |
461 | | - } |
462 | | -} |
463 | | - |
464 | | -inline void parseUnprocessedFontVariant(const PropsParserContext &context, const RawValue &value, FontVariant &result) |
465 | | -{ |
466 | | - if (value.hasType<std::string>()) { |
467 | | - parseUnprocessedFontVariantString((std::string)value, result); |
468 | | - } else { |
469 | | - parseProcessedFontVariant(context, value, result); |
470 | | - } |
471 | | -} |
472 | | - |
473 | | -inline void fromRawValue(const PropsParserContext &context, const RawValue &value, FontVariant &result) |
474 | | -{ |
475 | | - if (ReactNativeFeatureFlags::enableNativeCSSParsing()) { |
476 | | - parseUnprocessedFontVariant(context, value, result); |
477 | | - } else { |
478 | | - parseProcessedFontVariant(context, value, result); |
479 | | - } |
480 | | -} |
481 | | - |
482 | 387 | inline std::string toString(const FontVariant &fontVariant) |
483 | 388 | { |
484 | 389 | auto result = std::string{}; |
|
0 commit comments