react-native-windows 0.82.3 → 0.83.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +2 -7
- package/Libraries/Animated/components/AnimatedFlatList.js +5 -3
- package/Libraries/Animated/components/AnimatedImage.js +4 -3
- package/Libraries/Animated/components/AnimatedSectionList.js +2 -2
- package/Libraries/Animated/components/AnimatedText.js +7 -3
- package/Libraries/Animated/components/AnimatedView.js +3 -2
- package/Libraries/Animated/createAnimatedComponent.js +24 -12
- package/Libraries/Animated/nodes/AnimatedColor.js +26 -10
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +43 -15
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +43 -15
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +2 -2
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +2 -2
- package/Libraries/Components/Glyph/Glyph.js +4 -1
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.d.ts +2 -2
- package/Libraries/Components/RefreshControl/RefreshControl.d.ts +3 -3
- package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +1 -0
- package/Libraries/Components/ScrollView/ScrollView.windows.js +1 -0
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -6
- package/Libraries/Components/Switch/Switch.d.ts +2 -2
- package/Libraries/Components/Switch/Switch.windows.js +1 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +2 -5
- package/Libraries/Components/TextInput/TextInput.js +6 -0
- package/Libraries/Components/TextInput/TextInput.windows.js +6 -0
- package/Libraries/Components/Touchable/TouchableBounce.js +7 -7
- package/Libraries/Components/Touchable/TouchableBounce.windows.js +7 -7
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +19 -1
- package/Libraries/Components/View/View.d.ts +2 -2
- package/Libraries/Components/View/View.windows.js +0 -1
- package/Libraries/Components/View/ViewNativeComponent.js +13 -1
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/setUpPerformance.js +2 -0
- package/Libraries/Debugging/DebuggingOverlay.js +14 -14
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +8 -2
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +5 -2
- package/Libraries/Image/Image.d.ts +3 -3
- package/Libraries/Image/ImageInjection.js +3 -6
- package/Libraries/Image/ImageTypes.flow.js +3 -7
- package/Libraries/Lists/FlatList.js +8 -8
- package/Libraries/Lists/SectionList.d.ts +5 -1
- package/Libraries/Lists/ViewabilityHelper.js +1 -1
- package/Libraries/Lists/VirtualizedList.js +1 -0
- package/Libraries/LogBox/UI/AnsiHighlight.js +4 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +11 -2
- package/Libraries/NativeComponent/NativeComponentRegistry.d.ts +98 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +2 -0
- package/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +3 -1
- package/Libraries/NativeComponent/ViewConfigIgnore.windows.js +45 -0
- package/Libraries/Network/RCTNetworking.android.js +3 -1
- package/Libraries/Network/RCTNetworking.ios.js +3 -0
- package/Libraries/Network/RCTNetworking.windows.js +3 -0
- package/Libraries/Network/XMLHttpRequest.js +1 -41
- package/Libraries/Pressability/usePressability.js +14 -3
- package/Libraries/ReactNative/PaperUIManager.windows.js +3 -3
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +20 -82
- package/Libraries/ReactNative/getNativeComponentAttributes.js +12 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +6759 -4478
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +3169 -3119
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4732 -3535
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +6646 -4070
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3136 -2825
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4761 -3312
- package/Libraries/Renderer/shims/ReactNative.js +3 -1
- package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
- package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +2 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.js +44 -0
- package/Libraries/StyleSheet/processBackgroundPosition.js +284 -0
- package/Libraries/StyleSheet/processBackgroundRepeat.js +105 -0
- package/Libraries/StyleSheet/processBackgroundSize.js +104 -0
- package/Libraries/Text/Text.d.ts +2 -2
- package/Libraries/Text/TextNativeComponent.js +10 -0
- package/Libraries/TurboModule/TurboModuleRegistry.js +3 -9
- package/Libraries/Utilities/DevLoadingView.js +14 -6
- package/Libraries/Utilities/HMRClient.js +13 -5
- package/Microsoft.ReactNative/CompositionComponentView.idl +2 -0
- package/Microsoft.ReactNative/CompositionHwndHost.idl +1 -0
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +2 -52
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +10 -40
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +3 -80
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +45 -12
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +8 -0
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +61 -74
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +4 -3
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +2 -1
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.cpp +245 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.h +80 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +20 -36
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -0
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +20 -94
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +1 -3
- package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +0 -41
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +0 -11
- package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -3
- package/Microsoft.ReactNative/ReactNativeWin32App.cpp +31 -101
- package/Microsoft.ReactNative/ReactNativeWin32App.h +2 -13
- package/Microsoft.ReactNative/ReactNativeWindow.idl +44 -0
- package/Microsoft.ReactNative.Cxx/AutoDraw.h +9 -1
- package/Microsoft.ReactNative.Cxx/ReactCommon/CallInvoker.h +13 -16
- package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +24 -36
- package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.h +5 -8
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/AString.h +8 -6
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Array.h +32 -49
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Base.h +27 -76
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bool.h +4 -2
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/CallbackWrapper.h +19 -18
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +25 -48
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Convert.h +38 -31
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Error.h +11 -6
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/EventEmitter.h +47 -45
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Function.h +69 -89
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/HighResTimeStamp.h +8 -8
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/LongLivedObject.h +6 -6
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Number.h +16 -8
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Object.h +17 -24
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Promise.h +17 -17
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Value.h +20 -29
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/debug/react_native_assert.h +2 -7
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/timing/primitives.h +127 -115
- package/PropertySheets/Generated/PackageVersion.g.props +5 -5
- package/PropertySheets/Warnings.props +2 -1
- package/ReactCommon/ReactCommon.vcxproj +11 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +5 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +4 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +6 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +2 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +25 -35
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +86 -67
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +15 -8
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +84 -68
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +31 -35
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +4 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/network/HttpUtils.cpp +2 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +24 -36
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h +28 -66
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +5 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +3 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/image/conversions.h +8 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +19 -16
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +8 -9
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +25 -95
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +85 -42
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +2 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +2 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +25 -31
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +19 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +16 -1
- package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +1 -15
- package/Scripts/creaternwapp.cmd +1 -1
- package/Scripts/perf/compare-results.js +357 -0
- package/Scripts/perf/create-perf-test.js +343 -0
- package/Scripts/perf/post-pr-comment.js +210 -0
- package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +8 -0
- package/Shared/Hermes/HermesRuntimeTargetDelegate.h +3 -0
- package/Shared/Shared.vcxitems +15 -3
- package/Shared/Shared.vcxitems.filters +11 -3
- package/codegen/NativeIntersectionObserverSpec.g.h +2 -0
- package/codegen/NativeNetworkingIOSSpec.g.h +2 -0
- package/codegen/NativePerformanceSpec.g.h +6 -0
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +229 -139
- package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +2 -1
- package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +42 -25
- package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +2 -1
- package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +2 -1
- package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +11 -6
- package/codegen/react/components/rnwcore/AndroidSwitch.g.h +11 -6
- package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +1 -0
- package/codegen/react/components/rnwcore/InputAccessory.g.h +2 -1
- package/codegen/react/components/rnwcore/ModalHostView.g.h +40 -23
- package/codegen/react/components/rnwcore/Props.cpp +6 -1
- package/codegen/react/components/rnwcore/Props.h +1 -0
- package/codegen/react/components/rnwcore/PullToRefreshView.g.h +11 -6
- package/codegen/react/components/rnwcore/SafeAreaView.g.h +1 -0
- package/codegen/react/components/rnwcore/Switch.g.h +11 -6
- package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +2 -1
- package/codegen/react/components/rnwcore/VirtualView.g.h +41 -8
- package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +45 -8
- package/codegen/rnwcoreJSI.h +3973 -6059
- package/index.js +6 -0
- package/index.windows.js +6 -0
- package/jest/mockComponent.js +6 -6
- package/jest/setup.js +15 -10
- package/package.json +27 -27
- package/src/private/components/virtualview/VirtualView.js +22 -27
- package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +6 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +100 -19
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +18 -3
- package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
- package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +1 -0
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +12 -2
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +76 -15
- package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +1 -0
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
- package/src/private/webapis/performance/ResourceTiming.js +31 -4
- package/src/private/webapis/performance/internals/RawPerformanceEntry.js +4 -1
- package/src/private/webapis/performance/specs/NativePerformance.js +3 -0
- package/stubs/double-conversion/double-conversion.h +5 -0
- package/templates/cpp-app/template.config.js +1 -1
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
- package/templates/cpp-lib/template.config.js +1 -1
- package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
- package/types/index.d.ts +1 -0
- package/types/public/ReactNativeTypes.d.ts +115 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +0 -152
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/BaseViewProps.cpp +0 -628
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h +0 -1574
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ShadowNode.cpp +0 -528
- package/Scripts/OpenSSL.nuspec +0 -39
- package/Scripts/OpenSSL.targets +0 -36
- package/codegen/rnwcoreJSI-generated.cpp +0 -3470
package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h
DELETED
|
@@ -1,1574 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
#pragma once
|
|
9
|
-
|
|
10
|
-
#include <glog/logging.h>
|
|
11
|
-
#include <react/debug/react_native_expect.h>
|
|
12
|
-
#include <react/renderer/components/view/primitives.h>
|
|
13
|
-
#include <react/renderer/core/LayoutMetrics.h>
|
|
14
|
-
#include <react/renderer/core/PropsParserContext.h>
|
|
15
|
-
#include <react/renderer/core/RawProps.h>
|
|
16
|
-
#include <react/renderer/core/graphicsConversions.h>
|
|
17
|
-
#include <react/renderer/css/CSSAngle.h>
|
|
18
|
-
#include <react/renderer/css/CSSNumber.h>
|
|
19
|
-
#include <react/renderer/css/CSSPercentage.h>
|
|
20
|
-
#include <react/renderer/css/CSSValueParser.h>
|
|
21
|
-
#include <react/renderer/graphics/BackgroundImage.h>
|
|
22
|
-
#include <react/renderer/graphics/BlendMode.h>
|
|
23
|
-
#include <react/renderer/graphics/Isolation.h>
|
|
24
|
-
#include <react/renderer/graphics/LinearGradient.h>
|
|
25
|
-
#include <react/renderer/graphics/PlatformColorParser.h>
|
|
26
|
-
#include <react/renderer/graphics/Transform.h>
|
|
27
|
-
#include <react/renderer/graphics/ValueUnit.h>
|
|
28
|
-
#include <yoga/YGEnums.h>
|
|
29
|
-
#include <yoga/node/Node.h>
|
|
30
|
-
#include <cmath>
|
|
31
|
-
#include <optional>
|
|
32
|
-
#include <string>
|
|
33
|
-
#include <unordered_map>
|
|
34
|
-
|
|
35
|
-
namespace facebook::react {
|
|
36
|
-
|
|
37
|
-
/*
|
|
38
|
-
* Yoga's `float` <-> React Native's `Float` (can be `double` or `float`)
|
|
39
|
-
*
|
|
40
|
-
* Regular Yoga `float` values represent some onscreen-position-related values.
|
|
41
|
-
* They can be real numbers or special value `YGUndefined` (which actually is
|
|
42
|
-
* `NaN`). Conceptually, layout computation process inside Yoga should never
|
|
43
|
-
* produce `NaN` values from non-`NaN` values. At the same time, ` YGUndefined`
|
|
44
|
-
* values have special "no limit" meaning in Yoga, therefore ` YGUndefined`
|
|
45
|
-
* usually corresponds to `Infinity` value.
|
|
46
|
-
*/
|
|
47
|
-
inline Float floatFromYogaFloat(float value) {
|
|
48
|
-
static_assert(
|
|
49
|
-
YGUndefined != YGUndefined,
|
|
50
|
-
"The code of this function assumes that YGUndefined is NaN.");
|
|
51
|
-
if (std::isnan(value) /* means: `value == YGUndefined` */) {
|
|
52
|
-
return std::numeric_limits<Float>::infinity();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return (Float)value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
inline float yogaFloatFromFloat(Float value) {
|
|
59
|
-
if (!std::isfinite(value)) {
|
|
60
|
-
return YGUndefined;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (float)value;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/*
|
|
67
|
-
* `yoga::FloatOptional` <-> React Native's `Float`
|
|
68
|
-
*
|
|
69
|
-
* `yoga::FloatOptional` represents optional dimensionless float values in Yoga
|
|
70
|
-
* Style object (e.g. `flex`). The most suitable analogy to empty
|
|
71
|
-
* `yoga::FloatOptional` is `NaN` value.
|
|
72
|
-
* `yoga::FloatOptional` values are usually parsed from some outside data source
|
|
73
|
-
* which usually has some special corresponding representation for an empty
|
|
74
|
-
* value.
|
|
75
|
-
*/
|
|
76
|
-
inline Float floatFromYogaOptionalFloat(yoga::FloatOptional value) {
|
|
77
|
-
if (value.isUndefined()) {
|
|
78
|
-
return std::numeric_limits<Float>::quiet_NaN();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return floatFromYogaFloat(value.unwrap());
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
inline yoga::FloatOptional yogaOptionalFloatFromFloat(Float value) {
|
|
85
|
-
if (std::isnan(value)) {
|
|
86
|
-
return yoga::FloatOptional();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return yoga::FloatOptional((float)value);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
inline std::optional<Float> optionalFloatFromYogaValue(
|
|
93
|
-
const yoga::Style::Length& length,
|
|
94
|
-
std::optional<Float> base = {}) {
|
|
95
|
-
if (length.isPoints()) {
|
|
96
|
-
return floatFromYogaOptionalFloat(length.value());
|
|
97
|
-
} else if (length.isPercent()) {
|
|
98
|
-
return base.has_value()
|
|
99
|
-
? std::optional<Float>(
|
|
100
|
-
base.value() * floatFromYogaOptionalFloat(length.value()))
|
|
101
|
-
: std::optional<Float>();
|
|
102
|
-
} else {
|
|
103
|
-
return {};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
static inline PositionType positionTypeFromYogaPositionType(
|
|
108
|
-
yoga::PositionType positionType) {
|
|
109
|
-
switch (positionType) {
|
|
110
|
-
case yoga::PositionType::Static:
|
|
111
|
-
return PositionType::Static;
|
|
112
|
-
case yoga::PositionType::Relative:
|
|
113
|
-
return PositionType::Relative;
|
|
114
|
-
case yoga::PositionType::Absolute:
|
|
115
|
-
return PositionType::Absolute;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
inline DisplayType displayTypeFromYGDisplay(YGDisplay display) {
|
|
120
|
-
switch (display) {
|
|
121
|
-
case YGDisplayNone:
|
|
122
|
-
return DisplayType::None;
|
|
123
|
-
case YGDisplayContents:
|
|
124
|
-
return DisplayType::Contents;
|
|
125
|
-
case YGDisplayFlex:
|
|
126
|
-
return DisplayType::Flex;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
inline LayoutMetrics layoutMetricsFromYogaNode(yoga::Node& yogaNode) {
|
|
131
|
-
auto layoutMetrics = LayoutMetrics{};
|
|
132
|
-
|
|
133
|
-
layoutMetrics.frame = Rect{
|
|
134
|
-
Point{
|
|
135
|
-
floatFromYogaFloat(YGNodeLayoutGetLeft(&yogaNode)),
|
|
136
|
-
floatFromYogaFloat(YGNodeLayoutGetTop(&yogaNode))},
|
|
137
|
-
Size{
|
|
138
|
-
floatFromYogaFloat(YGNodeLayoutGetWidth(&yogaNode)),
|
|
139
|
-
floatFromYogaFloat(YGNodeLayoutGetHeight(&yogaNode))}};
|
|
140
|
-
|
|
141
|
-
layoutMetrics.borderWidth = EdgeInsets{
|
|
142
|
-
floatFromYogaFloat(YGNodeLayoutGetBorder(&yogaNode, YGEdgeLeft)),
|
|
143
|
-
floatFromYogaFloat(YGNodeLayoutGetBorder(&yogaNode, YGEdgeTop)),
|
|
144
|
-
floatFromYogaFloat(YGNodeLayoutGetBorder(&yogaNode, YGEdgeRight)),
|
|
145
|
-
floatFromYogaFloat(YGNodeLayoutGetBorder(&yogaNode, YGEdgeBottom))};
|
|
146
|
-
|
|
147
|
-
layoutMetrics.contentInsets = EdgeInsets{
|
|
148
|
-
layoutMetrics.borderWidth.left +
|
|
149
|
-
floatFromYogaFloat(YGNodeLayoutGetPadding(&yogaNode, YGEdgeLeft)),
|
|
150
|
-
layoutMetrics.borderWidth.top +
|
|
151
|
-
floatFromYogaFloat(YGNodeLayoutGetPadding(&yogaNode, YGEdgeTop)),
|
|
152
|
-
layoutMetrics.borderWidth.right +
|
|
153
|
-
floatFromYogaFloat(YGNodeLayoutGetPadding(&yogaNode, YGEdgeRight)),
|
|
154
|
-
layoutMetrics.borderWidth.bottom +
|
|
155
|
-
floatFromYogaFloat(YGNodeLayoutGetPadding(&yogaNode, YGEdgeBottom))};
|
|
156
|
-
|
|
157
|
-
layoutMetrics.displayType =
|
|
158
|
-
displayTypeFromYGDisplay(YGNodeStyleGetDisplay(&yogaNode));
|
|
159
|
-
|
|
160
|
-
layoutMetrics.positionType =
|
|
161
|
-
positionTypeFromYogaPositionType(yogaNode.style().positionType());
|
|
162
|
-
|
|
163
|
-
layoutMetrics.layoutDirection =
|
|
164
|
-
YGNodeLayoutGetDirection(&yogaNode) == YGDirectionRTL
|
|
165
|
-
? LayoutDirection::RightToLeft
|
|
166
|
-
: LayoutDirection::LeftToRight;
|
|
167
|
-
|
|
168
|
-
return layoutMetrics;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
inline YGDirection yogaDirectionFromLayoutDirection(LayoutDirection direction) {
|
|
172
|
-
switch (direction) {
|
|
173
|
-
case LayoutDirection::Undefined:
|
|
174
|
-
return YGDirectionInherit;
|
|
175
|
-
case LayoutDirection::LeftToRight:
|
|
176
|
-
return YGDirectionLTR;
|
|
177
|
-
case LayoutDirection::RightToLeft:
|
|
178
|
-
return YGDirectionRTL;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
inline void fromRawValue(
|
|
183
|
-
const PropsParserContext& context,
|
|
184
|
-
const RawValue& value,
|
|
185
|
-
yoga::Direction& result) {
|
|
186
|
-
result = yoga::Direction::Inherit;
|
|
187
|
-
react_native_expect(value.hasType<std::string>());
|
|
188
|
-
if (!value.hasType<std::string>()) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
auto stringValue = (std::string)value;
|
|
192
|
-
if (stringValue == "inherit") {
|
|
193
|
-
result = yoga::Direction::Inherit;
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
if (stringValue == "ltr") {
|
|
197
|
-
result = yoga::Direction::LTR;
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
if (stringValue == "rtl") {
|
|
201
|
-
result = yoga::Direction::RTL;
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
LOG(ERROR) << "Could not parse yoga::Direction: " << stringValue;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
inline void fromRawValue(
|
|
208
|
-
const PropsParserContext& context,
|
|
209
|
-
const RawValue& value,
|
|
210
|
-
yoga::FlexDirection& result) {
|
|
211
|
-
result = yoga::FlexDirection::Column;
|
|
212
|
-
react_native_expect(value.hasType<std::string>());
|
|
213
|
-
if (!value.hasType<std::string>()) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
auto stringValue = (std::string)value;
|
|
217
|
-
if (stringValue == "row") {
|
|
218
|
-
result = yoga::FlexDirection::Row;
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
if (stringValue == "column") {
|
|
222
|
-
result = yoga::FlexDirection::Column;
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
if (stringValue == "column-reverse") {
|
|
226
|
-
result = yoga::FlexDirection::ColumnReverse;
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
if (stringValue == "row-reverse") {
|
|
230
|
-
result = yoga::FlexDirection::RowReverse;
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
LOG(ERROR) << "Could not parse yoga::FlexDirection: " << stringValue;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
inline void fromRawValue(
|
|
237
|
-
const PropsParserContext& /*context*/,
|
|
238
|
-
const RawValue& value,
|
|
239
|
-
yoga::BoxSizing& result) {
|
|
240
|
-
result = yoga::BoxSizing::BorderBox;
|
|
241
|
-
react_native_expect(value.hasType<std::string>());
|
|
242
|
-
if (!value.hasType<std::string>()) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
auto stringValue = (std::string)value;
|
|
246
|
-
if (stringValue == "border-box") {
|
|
247
|
-
result = yoga::BoxSizing::BorderBox;
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
if (stringValue == "content-box") {
|
|
251
|
-
result = yoga::BoxSizing::ContentBox;
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
LOG(ERROR) << "Could not parse yoga::BoxSizing: " << stringValue;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
inline void fromRawValue(
|
|
259
|
-
const PropsParserContext& context,
|
|
260
|
-
const RawValue& value,
|
|
261
|
-
yoga::Justify& result) {
|
|
262
|
-
result = yoga::Justify::FlexStart;
|
|
263
|
-
react_native_expect(value.hasType<std::string>());
|
|
264
|
-
if (!value.hasType<std::string>()) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
auto stringValue = (std::string)value;
|
|
268
|
-
if (stringValue == "flex-start") {
|
|
269
|
-
result = yoga::Justify::FlexStart;
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
if (stringValue == "center") {
|
|
273
|
-
result = yoga::Justify::Center;
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
if (stringValue == "flex-end") {
|
|
277
|
-
result = yoga::Justify::FlexEnd;
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
if (stringValue == "space-between") {
|
|
281
|
-
result = yoga::Justify::SpaceBetween;
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
if (stringValue == "space-around") {
|
|
285
|
-
result = yoga::Justify::SpaceAround;
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
if (stringValue == "space-evenly") {
|
|
289
|
-
result = yoga::Justify::SpaceEvenly;
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
LOG(ERROR) << "Could not parse yoga::Justify: " << stringValue;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
inline void fromRawValue(
|
|
296
|
-
const PropsParserContext& context,
|
|
297
|
-
const RawValue& value,
|
|
298
|
-
yoga::Align& result) {
|
|
299
|
-
result = yoga::Align::Stretch;
|
|
300
|
-
react_native_expect(value.hasType<std::string>());
|
|
301
|
-
if (!value.hasType<std::string>()) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
auto stringValue = (std::string)value;
|
|
305
|
-
if (stringValue == "auto") {
|
|
306
|
-
result = yoga::Align::Auto;
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
if (stringValue == "flex-start") {
|
|
310
|
-
result = yoga::Align::FlexStart;
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
if (stringValue == "center") {
|
|
314
|
-
result = yoga::Align::Center;
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
if (stringValue == "flex-end") {
|
|
318
|
-
result = yoga::Align::FlexEnd;
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
if (stringValue == "stretch") {
|
|
322
|
-
result = yoga::Align::Stretch;
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
if (stringValue == "baseline") {
|
|
326
|
-
result = yoga::Align::Baseline;
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
if (stringValue == "space-between") {
|
|
330
|
-
result = yoga::Align::SpaceBetween;
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
if (stringValue == "space-around") {
|
|
334
|
-
result = yoga::Align::SpaceAround;
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
if (stringValue == "space-evenly") {
|
|
338
|
-
result = yoga::Align::SpaceEvenly;
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
LOG(ERROR) << "Could not parse yoga::Align: " << stringValue;
|
|
342
|
-
react_native_expect(false);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
inline void fromRawValue(
|
|
346
|
-
const PropsParserContext& context,
|
|
347
|
-
const RawValue& value,
|
|
348
|
-
yoga::PositionType& result) {
|
|
349
|
-
result = yoga::PositionType::Relative;
|
|
350
|
-
react_native_expect(value.hasType<std::string>());
|
|
351
|
-
if (!value.hasType<std::string>()) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
auto stringValue = (std::string)value;
|
|
355
|
-
if (stringValue == "static") {
|
|
356
|
-
result = yoga::PositionType::Static;
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
if (stringValue == "relative") {
|
|
360
|
-
result = yoga::PositionType::Relative;
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
if (stringValue == "absolute") {
|
|
364
|
-
result = yoga::PositionType::Absolute;
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
LOG(ERROR) << "Could not parse yoga::PositionType: " << stringValue;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
inline void fromRawValue(
|
|
371
|
-
const PropsParserContext& context,
|
|
372
|
-
const RawValue& value,
|
|
373
|
-
yoga::Wrap& result) {
|
|
374
|
-
result = yoga::Wrap::NoWrap;
|
|
375
|
-
react_native_expect(value.hasType<std::string>());
|
|
376
|
-
if (!value.hasType<std::string>()) {
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
auto stringValue = (std::string)value;
|
|
380
|
-
if (stringValue == "nowrap") {
|
|
381
|
-
result = yoga::Wrap::NoWrap;
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
if (stringValue == "wrap") {
|
|
385
|
-
result = yoga::Wrap::Wrap;
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
if (stringValue == "wrap-reverse") {
|
|
389
|
-
result = yoga::Wrap::WrapReverse;
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
LOG(ERROR) << "Could not parse yoga::Wrap: " << stringValue;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
inline void fromRawValue(
|
|
396
|
-
const PropsParserContext& context,
|
|
397
|
-
const RawValue& value,
|
|
398
|
-
yoga::Overflow& result) {
|
|
399
|
-
result = yoga::Overflow::Visible;
|
|
400
|
-
react_native_expect(value.hasType<std::string>());
|
|
401
|
-
if (!value.hasType<std::string>()) {
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
auto stringValue = (std::string)value;
|
|
405
|
-
if (stringValue == "visible") {
|
|
406
|
-
result = yoga::Overflow::Visible;
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
if (stringValue == "hidden") {
|
|
410
|
-
result = yoga::Overflow::Hidden;
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (stringValue == "scroll") {
|
|
414
|
-
result = yoga::Overflow::Scroll;
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
LOG(ERROR) << "Could not parse yoga::Overflow:" << stringValue;
|
|
418
|
-
react_native_expect(false);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
inline void fromRawValue(
|
|
422
|
-
const PropsParserContext& context,
|
|
423
|
-
const RawValue& value,
|
|
424
|
-
yoga::Display& result) {
|
|
425
|
-
result = yoga::Display::Flex;
|
|
426
|
-
react_native_expect(value.hasType<std::string>());
|
|
427
|
-
if (!value.hasType<std::string>()) {
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
auto stringValue = (std::string)value;
|
|
431
|
-
if (stringValue == "flex") {
|
|
432
|
-
result = yoga::Display::Flex;
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
if (stringValue == "none") {
|
|
436
|
-
result = yoga::Display::None;
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
if (stringValue == "contents") {
|
|
440
|
-
result = yoga::Display::Contents;
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
LOG(ERROR) << "Could not parse yoga::Display: " << stringValue;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
inline void fromRawValue(
|
|
447
|
-
const PropsParserContext& /*context*/,
|
|
448
|
-
const RawValue& value,
|
|
449
|
-
yoga::Style::SizeLength& result) {
|
|
450
|
-
if (value.hasType<Float>()) {
|
|
451
|
-
result = yoga::StyleSizeLength::points((float)value);
|
|
452
|
-
return;
|
|
453
|
-
} else if (value.hasType<std::string>()) {
|
|
454
|
-
const auto stringValue = (std::string)value;
|
|
455
|
-
if (stringValue == "auto") {
|
|
456
|
-
result = yoga::StyleSizeLength::ofAuto();
|
|
457
|
-
return;
|
|
458
|
-
} else if (stringValue == "max-content") {
|
|
459
|
-
result = yoga::StyleSizeLength::ofMaxContent();
|
|
460
|
-
return;
|
|
461
|
-
} else if (stringValue == "stretch") {
|
|
462
|
-
result = yoga::StyleSizeLength::ofStretch();
|
|
463
|
-
return;
|
|
464
|
-
} else if (stringValue == "fit-content") {
|
|
465
|
-
result = yoga::StyleSizeLength::ofFitContent();
|
|
466
|
-
return;
|
|
467
|
-
} else {
|
|
468
|
-
auto parsed = parseCSSProperty<CSSNumber, CSSPercentage>(stringValue);
|
|
469
|
-
if (std::holds_alternative<CSSPercentage>(parsed)) {
|
|
470
|
-
result = yoga::StyleSizeLength::percent(
|
|
471
|
-
std::get<CSSPercentage>(parsed).value);
|
|
472
|
-
return;
|
|
473
|
-
} else if (std::holds_alternative<CSSNumber>(parsed)) {
|
|
474
|
-
result =
|
|
475
|
-
yoga::StyleSizeLength::points(std::get<CSSNumber>(parsed).value);
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
result = yoga::StyleSizeLength::undefined();
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
inline void fromRawValue(
|
|
484
|
-
const PropsParserContext& context,
|
|
485
|
-
const RawValue& value,
|
|
486
|
-
yoga::Style::Length& result) {
|
|
487
|
-
if (value.hasType<Float>()) {
|
|
488
|
-
result = yoga::StyleLength::points((float)value);
|
|
489
|
-
return;
|
|
490
|
-
} else if (value.hasType<std::string>()) {
|
|
491
|
-
const auto stringValue = (std::string)value;
|
|
492
|
-
if (stringValue == "auto") {
|
|
493
|
-
result = yoga::StyleLength::ofAuto();
|
|
494
|
-
return;
|
|
495
|
-
} else {
|
|
496
|
-
auto parsed = parseCSSProperty<CSSNumber, CSSPercentage>(stringValue);
|
|
497
|
-
if (std::holds_alternative<CSSPercentage>(parsed)) {
|
|
498
|
-
result =
|
|
499
|
-
yoga::StyleLength::percent(std::get<CSSPercentage>(parsed).value);
|
|
500
|
-
return;
|
|
501
|
-
} else if (std::holds_alternative<CSSNumber>(parsed)) {
|
|
502
|
-
result = yoga::StyleLength::points(std::get<CSSNumber>(parsed).value);
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
result = yoga::StyleLength::undefined();
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
inline void fromRawValue(
|
|
511
|
-
const PropsParserContext& context,
|
|
512
|
-
const RawValue& value,
|
|
513
|
-
YGValue& result) {
|
|
514
|
-
yoga::Style::Length length{};
|
|
515
|
-
fromRawValue(context, value, length);
|
|
516
|
-
result = (YGValue)length;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
inline void fromRawValue(
|
|
520
|
-
const PropsParserContext& context,
|
|
521
|
-
const RawValue& value,
|
|
522
|
-
yoga::FloatOptional& result) {
|
|
523
|
-
result = value.hasType<float>() ? yoga::FloatOptional((float)value)
|
|
524
|
-
: yoga::FloatOptional();
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
inline std::optional<Float> toRadians(const RawValue& value) {
|
|
528
|
-
if (value.hasType<Float>()) {
|
|
529
|
-
return (Float)value;
|
|
530
|
-
}
|
|
531
|
-
if (!value.hasType<std::string>()) {
|
|
532
|
-
return {};
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
auto angle = parseCSSProperty<CSSAngle>((std::string)value);
|
|
536
|
-
if (std::holds_alternative<CSSAngle>(angle)) {
|
|
537
|
-
return static_cast<float>(std::get<CSSAngle>(angle).degrees * M_PI / 180.0f); // [Windows #14698]
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
return {};
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
inline ValueUnit toValueUnit(const RawValue& value) {
|
|
544
|
-
if (value.hasType<Float>()) {
|
|
545
|
-
return ValueUnit((Float)value, UnitType::Point);
|
|
546
|
-
}
|
|
547
|
-
if (!value.hasType<std::string>()) {
|
|
548
|
-
return {};
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
auto pct = parseCSSProperty<CSSPercentage>((std::string)value);
|
|
552
|
-
if (std::holds_alternative<CSSPercentage>(pct)) {
|
|
553
|
-
return ValueUnit(std::get<CSSPercentage>(pct).value, UnitType::Percent);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
return {};
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
inline void fromRawValue(
|
|
560
|
-
const PropsParserContext& /*context*/,
|
|
561
|
-
const RawValue& value,
|
|
562
|
-
ValueUnit& result) {
|
|
563
|
-
result = toValueUnit(value);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
inline void fromRawValue(
|
|
567
|
-
const PropsParserContext& context,
|
|
568
|
-
const RawValue& value,
|
|
569
|
-
Transform& result) {
|
|
570
|
-
auto transformMatrix = Transform{};
|
|
571
|
-
react_native_expect(value.hasType<std::vector<RawValue>>());
|
|
572
|
-
if (!value.hasType<std::vector<RawValue>>()) {
|
|
573
|
-
result = transformMatrix;
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
auto configurations = static_cast<std::vector<RawValue>>(value);
|
|
578
|
-
for (const auto& configuration : configurations) {
|
|
579
|
-
if (!configuration.hasType<std::unordered_map<std::string, RawValue>>()) {
|
|
580
|
-
result = {};
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
auto configurationPair =
|
|
585
|
-
static_cast<std::unordered_map<std::string, RawValue>>(configuration);
|
|
586
|
-
if (configurationPair.size() != 1) {
|
|
587
|
-
result = {};
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
auto pair = configurationPair.begin();
|
|
592
|
-
auto operation = pair->first;
|
|
593
|
-
auto& parameters = pair->second;
|
|
594
|
-
auto Zero = ValueUnit(0, UnitType::Point);
|
|
595
|
-
auto One = ValueUnit(1, UnitType::Point);
|
|
596
|
-
|
|
597
|
-
if (operation == "matrix") {
|
|
598
|
-
// T215634510: We should support matrix transforms as part of a list of
|
|
599
|
-
// transforms
|
|
600
|
-
if (configurations.size() > 1) {
|
|
601
|
-
result = {};
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
if (!parameters.hasType<std::vector<Float>>()) {
|
|
606
|
-
result = {};
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
auto numbers = (std::vector<Float>)parameters;
|
|
611
|
-
if (numbers.size() != 9 && numbers.size() != 16) {
|
|
612
|
-
result = {};
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
size_t i = 0;
|
|
617
|
-
for (auto number : numbers) {
|
|
618
|
-
transformMatrix.matrix[i++] = number;
|
|
619
|
-
}
|
|
620
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
621
|
-
TransformOperationType::Arbitrary, Zero, Zero, Zero});
|
|
622
|
-
} else if (operation == "perspective") {
|
|
623
|
-
if (!parameters.hasType<Float>()) {
|
|
624
|
-
result = {};
|
|
625
|
-
return;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
629
|
-
TransformOperationType::Perspective,
|
|
630
|
-
ValueUnit((Float)parameters, UnitType::Point),
|
|
631
|
-
Zero,
|
|
632
|
-
Zero});
|
|
633
|
-
} else if (operation == "rotateX") {
|
|
634
|
-
auto radians = toRadians(parameters);
|
|
635
|
-
if (!radians.has_value()) {
|
|
636
|
-
result = {};
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
641
|
-
TransformOperationType::Rotate,
|
|
642
|
-
ValueUnit(*radians, UnitType::Point),
|
|
643
|
-
Zero,
|
|
644
|
-
Zero});
|
|
645
|
-
} else if (operation == "rotateY") {
|
|
646
|
-
auto radians = toRadians(parameters);
|
|
647
|
-
if (!radians.has_value()) {
|
|
648
|
-
result = {};
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
653
|
-
TransformOperationType::Rotate,
|
|
654
|
-
Zero,
|
|
655
|
-
ValueUnit(*radians, UnitType::Point),
|
|
656
|
-
Zero});
|
|
657
|
-
} else if (operation == "rotateZ" || operation == "rotate") {
|
|
658
|
-
auto radians = toRadians(parameters);
|
|
659
|
-
if (!radians.has_value()) {
|
|
660
|
-
result = {};
|
|
661
|
-
return;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
665
|
-
TransformOperationType::Rotate,
|
|
666
|
-
Zero,
|
|
667
|
-
Zero,
|
|
668
|
-
ValueUnit(*radians, UnitType::Point)});
|
|
669
|
-
} else if (operation == "scale") {
|
|
670
|
-
if (!parameters.hasType<Float>()) {
|
|
671
|
-
result = {};
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
auto number = ValueUnit((Float)parameters, UnitType::Point);
|
|
676
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
677
|
-
TransformOperationType::Scale, number, number, number});
|
|
678
|
-
} else if (operation == "scaleX") {
|
|
679
|
-
if (!parameters.hasType<Float>()) {
|
|
680
|
-
result = {};
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
685
|
-
TransformOperationType::Scale,
|
|
686
|
-
ValueUnit((Float)parameters, UnitType::Point),
|
|
687
|
-
One,
|
|
688
|
-
One});
|
|
689
|
-
} else if (operation == "scaleY") {
|
|
690
|
-
if (!parameters.hasType<Float>()) {
|
|
691
|
-
result = {};
|
|
692
|
-
return;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
696
|
-
TransformOperationType::Scale,
|
|
697
|
-
One,
|
|
698
|
-
ValueUnit((Float)parameters, UnitType::Point),
|
|
699
|
-
One});
|
|
700
|
-
} else if (operation == "scaleZ") {
|
|
701
|
-
if (!parameters.hasType<Float>()) {
|
|
702
|
-
result = {};
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
707
|
-
TransformOperationType::Scale,
|
|
708
|
-
One,
|
|
709
|
-
One,
|
|
710
|
-
ValueUnit((Float)parameters, UnitType::Point)});
|
|
711
|
-
} else if (operation == "translate") {
|
|
712
|
-
if (!parameters.hasType<std::vector<RawValue>>()) {
|
|
713
|
-
result = {};
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
auto numbers = (std::vector<RawValue>)parameters;
|
|
718
|
-
if (numbers.size() != 2) {
|
|
719
|
-
result = {};
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
auto valueX = toValueUnit(numbers[0]);
|
|
724
|
-
if (!valueX) {
|
|
725
|
-
result = {};
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
auto valueY = toValueUnit(numbers[1]);
|
|
730
|
-
if (!valueY) {
|
|
731
|
-
result = {};
|
|
732
|
-
return;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
736
|
-
TransformOperationType::Translate, valueX, valueY, Zero});
|
|
737
|
-
} else if (operation == "translateX") {
|
|
738
|
-
auto valueX = toValueUnit(parameters);
|
|
739
|
-
if (!valueX) {
|
|
740
|
-
result = {};
|
|
741
|
-
return;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
745
|
-
TransformOperationType::Translate, valueX, Zero, Zero});
|
|
746
|
-
} else if (operation == "translateY") {
|
|
747
|
-
auto valueY = toValueUnit(parameters);
|
|
748
|
-
if (!valueY) {
|
|
749
|
-
result = {};
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
754
|
-
TransformOperationType::Translate, Zero, valueY, Zero});
|
|
755
|
-
} else if (operation == "skewX") {
|
|
756
|
-
auto radians = toRadians(parameters);
|
|
757
|
-
if (!radians.has_value()) {
|
|
758
|
-
result = {};
|
|
759
|
-
return;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
763
|
-
TransformOperationType::Skew,
|
|
764
|
-
ValueUnit(*radians, UnitType::Point),
|
|
765
|
-
Zero,
|
|
766
|
-
Zero});
|
|
767
|
-
} else if (operation == "skewY") {
|
|
768
|
-
auto radians = toRadians(parameters);
|
|
769
|
-
if (!radians.has_value()) {
|
|
770
|
-
result = {};
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
transformMatrix.operations.push_back(TransformOperation{
|
|
775
|
-
TransformOperationType::Skew,
|
|
776
|
-
Zero,
|
|
777
|
-
ValueUnit(*radians, UnitType::Point),
|
|
778
|
-
Zero});
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
result = transformMatrix;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
inline void fromRawValue(
|
|
786
|
-
const PropsParserContext& context,
|
|
787
|
-
const RawValue& value,
|
|
788
|
-
TransformOrigin& result) {
|
|
789
|
-
if (!value.hasType<std::vector<RawValue>>()) {
|
|
790
|
-
result = {};
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
auto origins = (std::vector<RawValue>)value;
|
|
795
|
-
if (origins.size() != 3) {
|
|
796
|
-
result = {};
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
TransformOrigin transformOrigin;
|
|
801
|
-
|
|
802
|
-
for (size_t i = 0; i < 2; i++) {
|
|
803
|
-
auto origin = toValueUnit(origins[i]);
|
|
804
|
-
if (!origin) {
|
|
805
|
-
result = {};
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
transformOrigin.xy[i] = origin;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
if (!origins[2].hasType<Float>()) {
|
|
813
|
-
result = {};
|
|
814
|
-
return;
|
|
815
|
-
}
|
|
816
|
-
transformOrigin.z = (Float)origins[2];
|
|
817
|
-
|
|
818
|
-
result = transformOrigin;
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
inline void fromRawValue(
|
|
822
|
-
const PropsParserContext& context,
|
|
823
|
-
const RawValue& value,
|
|
824
|
-
PointerEventsMode& result) {
|
|
825
|
-
result = PointerEventsMode::Auto;
|
|
826
|
-
react_native_expect(value.hasType<std::string>());
|
|
827
|
-
if (!value.hasType<std::string>()) {
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
|
-
auto stringValue = (std::string)value;
|
|
831
|
-
if (stringValue == "auto") {
|
|
832
|
-
result = PointerEventsMode::Auto;
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
if (stringValue == "none") {
|
|
836
|
-
result = PointerEventsMode::None;
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
if (stringValue == "box-none") {
|
|
840
|
-
result = PointerEventsMode::BoxNone;
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
if (stringValue == "box-only") {
|
|
844
|
-
result = PointerEventsMode::BoxOnly;
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
LOG(ERROR) << "Could not parse PointerEventsMode:" << stringValue;
|
|
848
|
-
react_native_expect(false);
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
inline std::string toString(const PointerEventsMode& value) {
|
|
852
|
-
switch (value) {
|
|
853
|
-
case PointerEventsMode::Auto:
|
|
854
|
-
return "auto";
|
|
855
|
-
case PointerEventsMode::None:
|
|
856
|
-
return "none";
|
|
857
|
-
case PointerEventsMode::BoxNone:
|
|
858
|
-
return "box-none";
|
|
859
|
-
case PointerEventsMode::BoxOnly:
|
|
860
|
-
return "box-only";
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
inline void fromRawValue(
|
|
865
|
-
const PropsParserContext& context,
|
|
866
|
-
const RawValue& value,
|
|
867
|
-
BackfaceVisibility& result) {
|
|
868
|
-
result = BackfaceVisibility::Auto;
|
|
869
|
-
react_native_expect(value.hasType<std::string>());
|
|
870
|
-
if (!value.hasType<std::string>()) {
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
auto stringValue = (std::string)value;
|
|
874
|
-
if (stringValue == "auto") {
|
|
875
|
-
result = BackfaceVisibility::Auto;
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
if (stringValue == "visible") {
|
|
879
|
-
result = BackfaceVisibility::Visible;
|
|
880
|
-
return;
|
|
881
|
-
}
|
|
882
|
-
if (stringValue == "hidden") {
|
|
883
|
-
result = BackfaceVisibility::Hidden;
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
LOG(ERROR) << "Could not parse BackfaceVisibility:" << stringValue;
|
|
887
|
-
react_native_expect(false);
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
inline void fromRawValue(
|
|
891
|
-
const PropsParserContext& context,
|
|
892
|
-
const RawValue& value,
|
|
893
|
-
BorderCurve& result) {
|
|
894
|
-
result = BorderCurve::Circular;
|
|
895
|
-
react_native_expect(value.hasType<std::string>());
|
|
896
|
-
if (!value.hasType<std::string>()) {
|
|
897
|
-
return;
|
|
898
|
-
}
|
|
899
|
-
auto stringValue = (std::string)value;
|
|
900
|
-
if (stringValue == "circular") {
|
|
901
|
-
result = BorderCurve::Circular;
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
if (stringValue == "continuous") {
|
|
905
|
-
result = BorderCurve::Continuous;
|
|
906
|
-
return;
|
|
907
|
-
}
|
|
908
|
-
LOG(ERROR) << "Could not parse BorderCurve:" << stringValue;
|
|
909
|
-
react_native_expect(false);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
inline void fromRawValue(
|
|
913
|
-
const PropsParserContext& context,
|
|
914
|
-
const RawValue& value,
|
|
915
|
-
BorderStyle& result) {
|
|
916
|
-
result = BorderStyle::Solid;
|
|
917
|
-
react_native_expect(value.hasType<std::string>());
|
|
918
|
-
if (!value.hasType<std::string>()) {
|
|
919
|
-
return;
|
|
920
|
-
}
|
|
921
|
-
auto stringValue = (std::string)value;
|
|
922
|
-
if (stringValue == "solid") {
|
|
923
|
-
result = BorderStyle::Solid;
|
|
924
|
-
return;
|
|
925
|
-
}
|
|
926
|
-
if (stringValue == "dotted") {
|
|
927
|
-
result = BorderStyle::Dotted;
|
|
928
|
-
return;
|
|
929
|
-
}
|
|
930
|
-
if (stringValue == "dashed") {
|
|
931
|
-
result = BorderStyle::Dashed;
|
|
932
|
-
return;
|
|
933
|
-
}
|
|
934
|
-
LOG(ERROR) << "Could not parse BorderStyle:" << stringValue;
|
|
935
|
-
react_native_expect(false);
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
inline void fromRawValue(
|
|
939
|
-
const PropsParserContext& context,
|
|
940
|
-
const RawValue& value,
|
|
941
|
-
OutlineStyle& result) {
|
|
942
|
-
result = OutlineStyle::Solid;
|
|
943
|
-
react_native_expect(value.hasType<std::string>());
|
|
944
|
-
if (!value.hasType<std::string>()) {
|
|
945
|
-
return;
|
|
946
|
-
}
|
|
947
|
-
auto stringValue = (std::string)value;
|
|
948
|
-
if (stringValue == "solid") {
|
|
949
|
-
result = OutlineStyle::Solid;
|
|
950
|
-
return;
|
|
951
|
-
}
|
|
952
|
-
if (stringValue == "dotted") {
|
|
953
|
-
result = OutlineStyle::Dotted;
|
|
954
|
-
return;
|
|
955
|
-
}
|
|
956
|
-
if (stringValue == "dashed") {
|
|
957
|
-
result = OutlineStyle::Dashed;
|
|
958
|
-
return;
|
|
959
|
-
}
|
|
960
|
-
LOG(ERROR) << "Could not parse OutlineStyle:" << stringValue;
|
|
961
|
-
react_native_expect(false);
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
inline void fromRawValue(
|
|
965
|
-
const PropsParserContext& context,
|
|
966
|
-
const RawValue& value,
|
|
967
|
-
Cursor& result) {
|
|
968
|
-
result = Cursor::Auto;
|
|
969
|
-
react_native_expect(value.hasType<std::string>());
|
|
970
|
-
if (!value.hasType<std::string>()) {
|
|
971
|
-
return;
|
|
972
|
-
}
|
|
973
|
-
auto stringValue = (std::string)value;
|
|
974
|
-
if (stringValue == "alias") {
|
|
975
|
-
result = Cursor::Alias;
|
|
976
|
-
return;
|
|
977
|
-
}
|
|
978
|
-
if (stringValue == "all-scroll") {
|
|
979
|
-
result = Cursor::AllScroll;
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
if (stringValue == "auto") {
|
|
983
|
-
result = Cursor::Auto;
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
if (stringValue == "cell") {
|
|
987
|
-
result = Cursor::Cell;
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
if (stringValue == "col-resize") {
|
|
991
|
-
result = Cursor::ColResize;
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
|
-
if (stringValue == "context-menu") {
|
|
995
|
-
result = Cursor::ContextMenu;
|
|
996
|
-
return;
|
|
997
|
-
}
|
|
998
|
-
if (stringValue == "copy") {
|
|
999
|
-
result = Cursor::Copy;
|
|
1000
|
-
return;
|
|
1001
|
-
}
|
|
1002
|
-
if (stringValue == "crosshair") {
|
|
1003
|
-
result = Cursor::Crosshair;
|
|
1004
|
-
return;
|
|
1005
|
-
}
|
|
1006
|
-
if (stringValue == "default") {
|
|
1007
|
-
result = Cursor::Default;
|
|
1008
|
-
return;
|
|
1009
|
-
}
|
|
1010
|
-
if (stringValue == "e-resize") {
|
|
1011
|
-
result = Cursor::EResize;
|
|
1012
|
-
return;
|
|
1013
|
-
}
|
|
1014
|
-
if (stringValue == "ew-resize") {
|
|
1015
|
-
result = Cursor::EWResize;
|
|
1016
|
-
return;
|
|
1017
|
-
}
|
|
1018
|
-
if (stringValue == "grab") {
|
|
1019
|
-
result = Cursor::Grab;
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1022
|
-
if (stringValue == "grabbing") {
|
|
1023
|
-
result = Cursor::Grabbing;
|
|
1024
|
-
return;
|
|
1025
|
-
}
|
|
1026
|
-
if (stringValue == "help") {
|
|
1027
|
-
result = Cursor::Help;
|
|
1028
|
-
return;
|
|
1029
|
-
}
|
|
1030
|
-
if (stringValue == "move") {
|
|
1031
|
-
result = Cursor::Move;
|
|
1032
|
-
return;
|
|
1033
|
-
}
|
|
1034
|
-
if (stringValue == "n-resize") {
|
|
1035
|
-
result = Cursor::NResize;
|
|
1036
|
-
return;
|
|
1037
|
-
}
|
|
1038
|
-
if (stringValue == "ne-resize") {
|
|
1039
|
-
result = Cursor::NEResize;
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
if (stringValue == "nesw-resize") {
|
|
1043
|
-
result = Cursor::NESWResize;
|
|
1044
|
-
return;
|
|
1045
|
-
}
|
|
1046
|
-
if (stringValue == "ns-resize") {
|
|
1047
|
-
result = Cursor::NSResize;
|
|
1048
|
-
return;
|
|
1049
|
-
}
|
|
1050
|
-
if (stringValue == "nw-resize") {
|
|
1051
|
-
result = Cursor::NWResize;
|
|
1052
|
-
return;
|
|
1053
|
-
}
|
|
1054
|
-
if (stringValue == "nwse-resize") {
|
|
1055
|
-
result = Cursor::NWSEResize;
|
|
1056
|
-
return;
|
|
1057
|
-
}
|
|
1058
|
-
if (stringValue == "no-drop") {
|
|
1059
|
-
result = Cursor::NoDrop;
|
|
1060
|
-
return;
|
|
1061
|
-
}
|
|
1062
|
-
if (stringValue == "none") {
|
|
1063
|
-
result = Cursor::None;
|
|
1064
|
-
return;
|
|
1065
|
-
}
|
|
1066
|
-
if (stringValue == "not-allowed") {
|
|
1067
|
-
result = Cursor::NotAllowed;
|
|
1068
|
-
return;
|
|
1069
|
-
}
|
|
1070
|
-
if (stringValue == "pointer") {
|
|
1071
|
-
result = Cursor::Pointer;
|
|
1072
|
-
return;
|
|
1073
|
-
}
|
|
1074
|
-
if (stringValue == "progress") {
|
|
1075
|
-
result = Cursor::Progress;
|
|
1076
|
-
return;
|
|
1077
|
-
}
|
|
1078
|
-
if (stringValue == "row-resize") {
|
|
1079
|
-
result = Cursor::RowResize;
|
|
1080
|
-
return;
|
|
1081
|
-
}
|
|
1082
|
-
if (stringValue == "s-resize") {
|
|
1083
|
-
result = Cursor::SResize;
|
|
1084
|
-
return;
|
|
1085
|
-
}
|
|
1086
|
-
if (stringValue == "se-resize") {
|
|
1087
|
-
result = Cursor::SEResize;
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
if (stringValue == "sw-resize") {
|
|
1091
|
-
result = Cursor::SWResize;
|
|
1092
|
-
return;
|
|
1093
|
-
}
|
|
1094
|
-
if (stringValue == "text") {
|
|
1095
|
-
result = Cursor::Text;
|
|
1096
|
-
return;
|
|
1097
|
-
}
|
|
1098
|
-
if (stringValue == "url") {
|
|
1099
|
-
result = Cursor::Url;
|
|
1100
|
-
return;
|
|
1101
|
-
}
|
|
1102
|
-
if (stringValue == "w-resize") {
|
|
1103
|
-
result = Cursor::WResize;
|
|
1104
|
-
return;
|
|
1105
|
-
}
|
|
1106
|
-
if (stringValue == "wait") {
|
|
1107
|
-
result = Cursor::Wait;
|
|
1108
|
-
return;
|
|
1109
|
-
}
|
|
1110
|
-
if (stringValue == "zoom-in") {
|
|
1111
|
-
result = Cursor::ZoomIn;
|
|
1112
|
-
return;
|
|
1113
|
-
}
|
|
1114
|
-
if (stringValue == "zoom-out") {
|
|
1115
|
-
result = Cursor::ZoomOut;
|
|
1116
|
-
return;
|
|
1117
|
-
}
|
|
1118
|
-
LOG(ERROR) << "Could not parse Cursor:" << stringValue;
|
|
1119
|
-
react_native_expect(false);
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
inline void fromRawValue(
|
|
1123
|
-
const PropsParserContext& /*context*/,
|
|
1124
|
-
const RawValue& value,
|
|
1125
|
-
LayoutConformance& result) {
|
|
1126
|
-
react_native_expect(value.hasType<std::string>());
|
|
1127
|
-
result = LayoutConformance::Strict;
|
|
1128
|
-
if (!value.hasType<std::string>()) {
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
auto stringValue = (std::string)value;
|
|
1133
|
-
if (stringValue == "strict") {
|
|
1134
|
-
result = LayoutConformance::Strict;
|
|
1135
|
-
} else if (stringValue == "compatibility") {
|
|
1136
|
-
result = LayoutConformance::Compatibility;
|
|
1137
|
-
} else {
|
|
1138
|
-
LOG(ERROR) << "Unexpected LayoutConformance value:" << stringValue;
|
|
1139
|
-
react_native_expect(false);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
inline void fromRawValue(
|
|
1144
|
-
const PropsParserContext& /*context*/,
|
|
1145
|
-
const RawValue& value,
|
|
1146
|
-
BlendMode& result) {
|
|
1147
|
-
react_native_expect(value.hasType<std::string>());
|
|
1148
|
-
result = BlendMode::Normal;
|
|
1149
|
-
if (!value.hasType<std::string>()) {
|
|
1150
|
-
return;
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
auto rawBlendMode = static_cast<std::string>(value);
|
|
1154
|
-
std::optional<BlendMode> blendMode = blendModeFromString(rawBlendMode);
|
|
1155
|
-
|
|
1156
|
-
if (!blendMode) {
|
|
1157
|
-
LOG(ERROR) << "Could not parse blend mode: " << rawBlendMode;
|
|
1158
|
-
return;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
result = blendMode.value();
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
inline void fromRawValue(
|
|
1165
|
-
const PropsParserContext& context,
|
|
1166
|
-
const RawValue& value,
|
|
1167
|
-
std::vector<BackgroundImage>& result) {
|
|
1168
|
-
react_native_expect(value.hasType<std::vector<RawValue>>());
|
|
1169
|
-
if (!value.hasType<std::vector<RawValue>>()) {
|
|
1170
|
-
result = {};
|
|
1171
|
-
return;
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
std::vector<BackgroundImage> backgroundImage{};
|
|
1175
|
-
auto rawBackgroundImage = static_cast<std::vector<RawValue>>(value);
|
|
1176
|
-
for (const auto& rawBackgroundImageValue : rawBackgroundImage) {
|
|
1177
|
-
bool isMap = rawBackgroundImageValue
|
|
1178
|
-
.hasType<std::unordered_map<std::string, RawValue>>();
|
|
1179
|
-
react_native_expect(isMap);
|
|
1180
|
-
if (!isMap) {
|
|
1181
|
-
result = {};
|
|
1182
|
-
return;
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
auto rawBackgroundImageMap =
|
|
1186
|
-
static_cast<std::unordered_map<std::string, RawValue>>(
|
|
1187
|
-
rawBackgroundImageValue);
|
|
1188
|
-
|
|
1189
|
-
auto typeIt = rawBackgroundImageMap.find("type");
|
|
1190
|
-
if (typeIt == rawBackgroundImageMap.end() ||
|
|
1191
|
-
!typeIt->second.hasType<std::string>()) {
|
|
1192
|
-
continue;
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
std::string type = (std::string)(typeIt->second);
|
|
1196
|
-
std::vector<ColorStop> colorStops;
|
|
1197
|
-
auto colorStopsIt = rawBackgroundImageMap.find("colorStops");
|
|
1198
|
-
|
|
1199
|
-
if (colorStopsIt != rawBackgroundImageMap.end() &&
|
|
1200
|
-
colorStopsIt->second.hasType<std::vector<RawValue>>()) {
|
|
1201
|
-
auto rawColorStops =
|
|
1202
|
-
static_cast<std::vector<RawValue>>(colorStopsIt->second);
|
|
1203
|
-
|
|
1204
|
-
for (const auto& stop : rawColorStops) {
|
|
1205
|
-
if (stop.hasType<std::unordered_map<std::string, RawValue>>()) {
|
|
1206
|
-
auto stopMap =
|
|
1207
|
-
static_cast<std::unordered_map<std::string, RawValue>>(stop);
|
|
1208
|
-
auto positionIt = stopMap.find("position");
|
|
1209
|
-
auto colorIt = stopMap.find("color");
|
|
1210
|
-
|
|
1211
|
-
if (positionIt != stopMap.end() && colorIt != stopMap.end()) {
|
|
1212
|
-
ColorStop colorStop;
|
|
1213
|
-
if (positionIt->second.hasValue()) {
|
|
1214
|
-
auto valueUnit = toValueUnit(positionIt->second);
|
|
1215
|
-
if (!valueUnit) {
|
|
1216
|
-
result = {};
|
|
1217
|
-
return;
|
|
1218
|
-
}
|
|
1219
|
-
colorStop.position = valueUnit;
|
|
1220
|
-
}
|
|
1221
|
-
if (colorIt->second.hasValue()) {
|
|
1222
|
-
fromRawValue(
|
|
1223
|
-
context.contextContainer,
|
|
1224
|
-
context.surfaceId,
|
|
1225
|
-
colorIt->second,
|
|
1226
|
-
colorStop.color);
|
|
1227
|
-
}
|
|
1228
|
-
colorStops.push_back(colorStop);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
if (type == "linear-gradient") {
|
|
1235
|
-
LinearGradient linearGradient;
|
|
1236
|
-
|
|
1237
|
-
auto directionIt = rawBackgroundImageMap.find("direction");
|
|
1238
|
-
if (directionIt != rawBackgroundImageMap.end() &&
|
|
1239
|
-
directionIt->second
|
|
1240
|
-
.hasType<std::unordered_map<std::string, RawValue>>()) {
|
|
1241
|
-
auto directionMap =
|
|
1242
|
-
static_cast<std::unordered_map<std::string, RawValue>>(
|
|
1243
|
-
directionIt->second);
|
|
1244
|
-
|
|
1245
|
-
auto directionTypeIt = directionMap.find("type");
|
|
1246
|
-
auto valueIt = directionMap.find("value");
|
|
1247
|
-
|
|
1248
|
-
if (directionTypeIt != directionMap.end() &&
|
|
1249
|
-
valueIt != directionMap.end()) {
|
|
1250
|
-
std::string directionType = (std::string)(directionTypeIt->second);
|
|
1251
|
-
|
|
1252
|
-
if (directionType == "angle") {
|
|
1253
|
-
linearGradient.direction.type = GradientDirectionType::Angle;
|
|
1254
|
-
if (valueIt->second.hasType<Float>()) {
|
|
1255
|
-
linearGradient.direction.value = (Float)(valueIt->second);
|
|
1256
|
-
}
|
|
1257
|
-
} else if (directionType == "keyword") {
|
|
1258
|
-
linearGradient.direction.type = GradientDirectionType::Keyword;
|
|
1259
|
-
if (valueIt->second.hasType<std::string>()) {
|
|
1260
|
-
linearGradient.direction.value =
|
|
1261
|
-
parseGradientKeyword((std::string)(valueIt->second));
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
if (!colorStops.empty()) {
|
|
1268
|
-
linearGradient.colorStops = colorStops;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
backgroundImage.emplace_back(std::move(linearGradient));
|
|
1272
|
-
} else if (type == "radial-gradient") {
|
|
1273
|
-
RadialGradient radialGradient;
|
|
1274
|
-
auto shapeIt = rawBackgroundImageMap.find("shape");
|
|
1275
|
-
if (shapeIt != rawBackgroundImageMap.end() &&
|
|
1276
|
-
shapeIt->second.hasType<std::string>()) {
|
|
1277
|
-
auto shape = (std::string)(shapeIt->second);
|
|
1278
|
-
radialGradient.shape = shape == "circle" ? RadialGradientShape::Circle
|
|
1279
|
-
: RadialGradientShape::Ellipse;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
auto sizeIt = rawBackgroundImageMap.find("size");
|
|
1283
|
-
if (sizeIt != rawBackgroundImageMap.end()) {
|
|
1284
|
-
if (sizeIt->second.hasType<std::string>()) {
|
|
1285
|
-
auto sizeStr = (std::string)(sizeIt->second);
|
|
1286
|
-
if (sizeStr == "closest-side") {
|
|
1287
|
-
radialGradient.size.value =
|
|
1288
|
-
RadialGradientSize::SizeKeyword::ClosestSide;
|
|
1289
|
-
} else if (sizeStr == "farthest-side") {
|
|
1290
|
-
radialGradient.size.value =
|
|
1291
|
-
RadialGradientSize::SizeKeyword::FarthestSide;
|
|
1292
|
-
} else if (sizeStr == "closest-corner") {
|
|
1293
|
-
radialGradient.size.value =
|
|
1294
|
-
RadialGradientSize::SizeKeyword::ClosestCorner;
|
|
1295
|
-
} else if (sizeStr == "farthest-corner") {
|
|
1296
|
-
radialGradient.size.value =
|
|
1297
|
-
RadialGradientSize::SizeKeyword::FarthestCorner;
|
|
1298
|
-
}
|
|
1299
|
-
} else if (sizeIt->second
|
|
1300
|
-
.hasType<std::unordered_map<std::string, RawValue>>()) {
|
|
1301
|
-
auto sizeMap = static_cast<std::unordered_map<std::string, RawValue>>(
|
|
1302
|
-
sizeIt->second);
|
|
1303
|
-
auto xIt = sizeMap.find("x");
|
|
1304
|
-
auto yIt = sizeMap.find("y");
|
|
1305
|
-
if (xIt != sizeMap.end() && yIt != sizeMap.end()) {
|
|
1306
|
-
RadialGradientSize sizeObj;
|
|
1307
|
-
sizeObj.value = RadialGradientSize::Dimensions{
|
|
1308
|
-
toValueUnit(xIt->second), toValueUnit(yIt->second)};
|
|
1309
|
-
radialGradient.size = sizeObj;
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
auto positionIt = rawBackgroundImageMap.find("position");
|
|
1314
|
-
if (positionIt != rawBackgroundImageMap.end() &&
|
|
1315
|
-
positionIt->second
|
|
1316
|
-
.hasType<std::unordered_map<std::string, RawValue>>()) {
|
|
1317
|
-
auto positionMap =
|
|
1318
|
-
static_cast<std::unordered_map<std::string, RawValue>>(
|
|
1319
|
-
positionIt->second);
|
|
1320
|
-
|
|
1321
|
-
auto topIt = positionMap.find("top");
|
|
1322
|
-
auto bottomIt = positionMap.find("bottom");
|
|
1323
|
-
auto leftIt = positionMap.find("left");
|
|
1324
|
-
auto rightIt = positionMap.find("right");
|
|
1325
|
-
|
|
1326
|
-
if (topIt != positionMap.end()) {
|
|
1327
|
-
auto topValue = toValueUnit(topIt->second);
|
|
1328
|
-
radialGradient.position.top = topValue;
|
|
1329
|
-
} else if (bottomIt != positionMap.end()) {
|
|
1330
|
-
auto bottomValue = toValueUnit(bottomIt->second);
|
|
1331
|
-
radialGradient.position.bottom = bottomValue;
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
if (leftIt != positionMap.end()) {
|
|
1335
|
-
auto leftValue = toValueUnit(leftIt->second);
|
|
1336
|
-
radialGradient.position.left = leftValue;
|
|
1337
|
-
} else if (rightIt != positionMap.end()) {
|
|
1338
|
-
auto rightValue = toValueUnit(rightIt->second);
|
|
1339
|
-
radialGradient.position.right = rightValue;
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
if (!colorStops.empty()) {
|
|
1345
|
-
radialGradient.colorStops = colorStops;
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
backgroundImage.emplace_back(std::move(radialGradient));
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
result = backgroundImage;
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
inline void fromRawValue(
|
|
1356
|
-
const PropsParserContext& /*context*/,
|
|
1357
|
-
const RawValue& value,
|
|
1358
|
-
Isolation& result) {
|
|
1359
|
-
react_native_expect(value.hasType<std::string>());
|
|
1360
|
-
result = Isolation::Auto;
|
|
1361
|
-
if (!value.hasType<std::string>()) {
|
|
1362
|
-
return;
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
auto rawIsolation = static_cast<std::string>(value);
|
|
1366
|
-
std::optional<Isolation> isolation = isolationFromString(rawIsolation);
|
|
1367
|
-
|
|
1368
|
-
if (!isolation) {
|
|
1369
|
-
LOG(ERROR) << "Could not parse isolation: " << rawIsolation;
|
|
1370
|
-
return;
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
result = isolation.value();
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
template <size_t N>
|
|
1377
|
-
inline std::string toString(const std::array<float, N> vec) {
|
|
1378
|
-
std::string s;
|
|
1379
|
-
|
|
1380
|
-
s.append("{");
|
|
1381
|
-
for (size_t i = 0; i < N - 1; i++) {
|
|
1382
|
-
s.append(std::to_string(vec[i]) + ", ");
|
|
1383
|
-
}
|
|
1384
|
-
s.append(std::to_string(vec[N - 1]));
|
|
1385
|
-
s.append("}");
|
|
1386
|
-
|
|
1387
|
-
return s;
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
inline std::string toString(const yoga::Direction& value) {
|
|
1391
|
-
return YGDirectionToString(yoga::unscopedEnum(value));
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
inline std::string toString(const yoga::FlexDirection& value) {
|
|
1395
|
-
return YGFlexDirectionToString(yoga::unscopedEnum(value));
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
inline std::string toString(const yoga::Justify& value) {
|
|
1399
|
-
return YGJustifyToString(yoga::unscopedEnum(value));
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
inline std::string toString(const yoga::Align& value) {
|
|
1403
|
-
return YGAlignToString(yoga::unscopedEnum(value));
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
inline std::string toString(const yoga::PositionType& value) {
|
|
1407
|
-
return YGPositionTypeToString(yoga::unscopedEnum(value));
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
inline std::string toString(const yoga::Wrap& value) {
|
|
1411
|
-
return YGWrapToString(yoga::unscopedEnum(value));
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
inline std::string toString(const yoga::Overflow& value) {
|
|
1415
|
-
return YGOverflowToString(yoga::unscopedEnum(value));
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
inline std::string toString(const yoga::Display& value) {
|
|
1419
|
-
return YGDisplayToString(yoga::unscopedEnum(value));
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
inline std::string toString(const yoga::Style::Length& length) {
|
|
1423
|
-
if (length.isUndefined()) {
|
|
1424
|
-
return "undefined";
|
|
1425
|
-
} else if (length.isAuto()) {
|
|
1426
|
-
return "auto";
|
|
1427
|
-
} else if (length.isPoints()) {
|
|
1428
|
-
return std::to_string(length.value().unwrap());
|
|
1429
|
-
} else if (length.isPercent()) {
|
|
1430
|
-
return std::to_string(length.value().unwrap()) + "%";
|
|
1431
|
-
} else {
|
|
1432
|
-
return "unknown";
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
inline std::string toString(const yoga::Style::SizeLength& length) {
|
|
1437
|
-
if (length.isUndefined()) {
|
|
1438
|
-
return "undefined";
|
|
1439
|
-
} else if (length.isAuto()) {
|
|
1440
|
-
return "auto";
|
|
1441
|
-
} else if (length.isPoints()) {
|
|
1442
|
-
return std::to_string(length.value().unwrap());
|
|
1443
|
-
} else if (length.isPercent()) {
|
|
1444
|
-
return std::to_string(length.value().unwrap()) + "%";
|
|
1445
|
-
} else if (length.isMaxContent()) {
|
|
1446
|
-
return "max-content";
|
|
1447
|
-
} else if (length.isFitContent()) {
|
|
1448
|
-
return "fit-content";
|
|
1449
|
-
} else if (length.isStretch()) {
|
|
1450
|
-
return "stretch";
|
|
1451
|
-
} else {
|
|
1452
|
-
return "unknown";
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
inline std::string toString(const yoga::FloatOptional& value) {
|
|
1457
|
-
if (value.isUndefined()) {
|
|
1458
|
-
return "undefined";
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
return std::to_string(value.unwrap());
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
inline std::string toString(const LayoutConformance& value) {
|
|
1465
|
-
switch (value) {
|
|
1466
|
-
case LayoutConformance::Strict:
|
|
1467
|
-
return "strict";
|
|
1468
|
-
case LayoutConformance::Compatibility:
|
|
1469
|
-
return "compatibility";
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
inline std::string toString(const std::array<Float, 16>& m) {
|
|
1474
|
-
std::string result;
|
|
1475
|
-
result += "[ " + std::to_string(m[0]) + " " + std::to_string(m[1]) + " " +
|
|
1476
|
-
std::to_string(m[2]) + " " + std::to_string(m[3]) + " ]\n";
|
|
1477
|
-
result += "[ " + std::to_string(m[4]) + " " + std::to_string(m[5]) + " " +
|
|
1478
|
-
std::to_string(m[6]) + " " + std::to_string(m[7]) + " ]\n";
|
|
1479
|
-
result += "[ " + std::to_string(m[8]) + " " + std::to_string(m[9]) + " " +
|
|
1480
|
-
std::to_string(m[10]) + " " + std::to_string(m[11]) + " ]\n";
|
|
1481
|
-
result += "[ " + std::to_string(m[12]) + " " + std::to_string(m[13]) + " " +
|
|
1482
|
-
std::to_string(m[14]) + " " + std::to_string(m[15]) + " ]";
|
|
1483
|
-
return result;
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
inline std::string toString(const Transform& transform) {
|
|
1487
|
-
std::string result = "[";
|
|
1488
|
-
bool first = true;
|
|
1489
|
-
|
|
1490
|
-
for (const auto& operation : transform.operations) {
|
|
1491
|
-
if (!first) {
|
|
1492
|
-
result += ", ";
|
|
1493
|
-
}
|
|
1494
|
-
first = false;
|
|
1495
|
-
|
|
1496
|
-
switch (operation.type) {
|
|
1497
|
-
case TransformOperationType::Perspective: {
|
|
1498
|
-
result +=
|
|
1499
|
-
"{\"perspective\": " + std::to_string(operation.x.value) + "}";
|
|
1500
|
-
break;
|
|
1501
|
-
}
|
|
1502
|
-
case TransformOperationType::Rotate: {
|
|
1503
|
-
if (operation.x.value != 0 && operation.y.value == 0 &&
|
|
1504
|
-
operation.z.value == 0) {
|
|
1505
|
-
result +=
|
|
1506
|
-
R"({"rotateX": ")" + std::to_string(operation.x.value) + "rad\"}";
|
|
1507
|
-
} else if (
|
|
1508
|
-
operation.x.value == 0 && operation.y.value != 0 &&
|
|
1509
|
-
operation.z.value == 0) {
|
|
1510
|
-
result +=
|
|
1511
|
-
R"({"rotateY": ")" + std::to_string(operation.y.value) + "rad\"}";
|
|
1512
|
-
} else if (
|
|
1513
|
-
operation.x.value == 0 && operation.y.value == 0 &&
|
|
1514
|
-
operation.z.value != 0) {
|
|
1515
|
-
result +=
|
|
1516
|
-
R"({"rotateZ": ")" + std::to_string(operation.z.value) + "rad\"}";
|
|
1517
|
-
}
|
|
1518
|
-
break;
|
|
1519
|
-
}
|
|
1520
|
-
case TransformOperationType::Scale: {
|
|
1521
|
-
if (operation.x.value == operation.y.value &&
|
|
1522
|
-
operation.x.value == operation.z.value) {
|
|
1523
|
-
result += "{\"scale\": " + std::to_string(operation.x.value) + "}";
|
|
1524
|
-
} else if (operation.y.value == 1 && operation.z.value == 1) {
|
|
1525
|
-
result += "{\"scaleX\": " + std::to_string(operation.x.value) + "}";
|
|
1526
|
-
} else if (operation.x.value == 1 && operation.z.value == 1) {
|
|
1527
|
-
result += "{\"scaleY\": " + std::to_string(operation.y.value) + "}";
|
|
1528
|
-
} else if (operation.x.value == 1 && operation.y.value == 1) {
|
|
1529
|
-
result += "{\"scaleZ\": " + std::to_string(operation.z.value) + "}";
|
|
1530
|
-
}
|
|
1531
|
-
break;
|
|
1532
|
-
}
|
|
1533
|
-
case TransformOperationType::Translate: {
|
|
1534
|
-
if (operation.x.value != 0 && operation.y.value != 0 &&
|
|
1535
|
-
operation.z.value == 0) {
|
|
1536
|
-
result += "{\"translate\": [";
|
|
1537
|
-
result += std::to_string(operation.x.value) + ", " +
|
|
1538
|
-
std::to_string(operation.y.value);
|
|
1539
|
-
result += "]}";
|
|
1540
|
-
} else if (operation.x.value != 0 && operation.y.value == 0) {
|
|
1541
|
-
result +=
|
|
1542
|
-
"{\"translateX\": " + std::to_string(operation.x.value) + "}";
|
|
1543
|
-
} else if (operation.x.value == 0 && operation.y.value != 0) {
|
|
1544
|
-
result +=
|
|
1545
|
-
"{\"translateY\": " + std::to_string(operation.y.value) + "}";
|
|
1546
|
-
}
|
|
1547
|
-
break;
|
|
1548
|
-
}
|
|
1549
|
-
case TransformOperationType::Skew: {
|
|
1550
|
-
if (operation.x.value != 0 && operation.y.value == 0) {
|
|
1551
|
-
result +=
|
|
1552
|
-
R"({"skewX": ")" + std::to_string(operation.x.value) + "rad\"}";
|
|
1553
|
-
} else if (operation.x.value == 0 && operation.y.value != 0) {
|
|
1554
|
-
result +=
|
|
1555
|
-
R"({"skewY": ")" + std::to_string(operation.y.value) + "rad\"}";
|
|
1556
|
-
}
|
|
1557
|
-
break;
|
|
1558
|
-
}
|
|
1559
|
-
case TransformOperationType::Arbitrary: {
|
|
1560
|
-
result += "{\"matrix\": " + toString(transform.matrix) + "}";
|
|
1561
|
-
break;
|
|
1562
|
-
}
|
|
1563
|
-
case TransformOperationType::Identity: {
|
|
1564
|
-
result += "{\"identity\": true}";
|
|
1565
|
-
break;
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
result += "]";
|
|
1571
|
-
return result;
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
} // namespace facebook::react
|