Skip to content

Commit 2b24a5e

Browse files
test
1 parent a2a72e2 commit 2b24a5e

8 files changed

Lines changed: 208 additions & 540 deletions

File tree

packages/react-native/Libraries/StyleSheet/processTransform.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,18 @@ function _validateTransform(
209209
case 'rotate':
210210
case 'skewX':
211211
case 'skewY':
212-
invariant(
213-
typeof value === 'string',
214-
'Transform with key of "%s" must be a string: %s',
215-
key,
216-
stringifySafe(transformation),
217-
);
218-
invariant(
219-
value.indexOf('deg') > -1 || value.indexOf('rad') > -1,
220-
'Rotate transform must be expressed in degrees (deg) or radians ' +
221-
'(rad): %s',
222-
stringifySafe(transformation),
223-
);
212+
// invariant(
213+
// typeof value === 'string',
214+
// 'Transform with key of "%s" must be a string: %s',
215+
// key,
216+
// stringifySafe(transformation),
217+
// );
218+
// invariant(
219+
// value.indexOf('deg') > -1 || value.indexOf('rad') > -1,
220+
// 'Rotate transform must be expressed in degrees (deg) or radians ' +
221+
// '(rad): %s',
222+
// stringifySafe(transformation),
223+
// );
224224
break;
225225
case 'perspective':
226226
invariant(

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ import kotlin.jvm.JvmStatic
2020
public open class ReadableNativeArray protected constructor() : NativeArray(), ReadableArray {
2121

2222
private val localArray: Array<Any?> by
23-
lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
23+
lazy(LazyThreadSafetyMode.NONE) {
2424
jniPassCounter++
2525
importArray()
2626
}
2727

2828
private external fun importArray(): Array<Any?>
2929

3030
private val localTypeArray: Array<ReadableType> by
31-
lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
31+
lazy(LazyThreadSafetyMode.NONE) {
3232
jniPassCounter++
3333
val tempArray = importTypeArray()
3434
Arrays.copyOf(tempArray, tempArray.size, Array<ReadableType>::class.java)

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package com.facebook.react.bridge
99

1010
import android.annotation.SuppressLint
11+
import android.util.ArrayMap
1112
import com.facebook.infer.annotation.Assertions
1213
import com.facebook.proguard.annotations.DoNotStripAny
1314

@@ -18,12 +19,12 @@ import com.facebook.proguard.annotations.DoNotStripAny
1819
@DoNotStripAny
1920
public open class ReadableNativeMap protected constructor() : NativeMap(), ReadableMap {
2021
private val keys: Array<String> by
21-
lazy(LazyThreadSafetyMode.SYNCHRONIZED) { importKeys().also { jniPassCounter++ } }
22+
lazy(LazyThreadSafetyMode.NONE) { importKeys().also { jniPassCounter++ } }
2223

23-
private val localMap: HashMap<String, Any?> by
24-
lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
24+
private val localMap: Map<String, Any?> by
25+
lazy(LazyThreadSafetyMode.NONE) {
2526
val length = keys.size
26-
val res = HashMap<String, Any?>(length)
27+
val res = if (length > 10) HashMap<String, Any?>(length) else ArrayMap(length)
2728
val values = importValues()
2829
jniPassCounter++
2930
for (i in 0 until length) {
@@ -32,10 +33,10 @@ public open class ReadableNativeMap protected constructor() : NativeMap(), Reada
3233
res
3334
}
3435

35-
private val localTypeMap: HashMap<String, ReadableType> by
36-
lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
36+
private val localTypeMap: Map<String, ReadableType> by
37+
lazy(LazyThreadSafetyMode.NONE) {
3738
val length = keys.size
38-
val res = HashMap<String, ReadableType>(length)
39+
val res = if (length > 10) HashMap<String, ReadableType>(length) else ArrayMap(length)
3940
val types = importTypes()
4041
jniPassCounter++
4142
for (i in 0 until length) {
@@ -66,16 +67,17 @@ public open class ReadableNativeMap protected constructor() : NativeMap(), Reada
6667
"Value for $name cannot be cast from ${instance?.javaClass?.simpleName ?: "NULL"} to ${type.simpleName}")
6768

6869
private fun getValue(name: String): Any {
69-
if (hasKey(name)) {
70-
return Assertions.assertNotNull(localMap[name])
70+
val value = localMap[name]
71+
if (value != null) {
72+
return value
7173
}
7274
throw NoSuchKeyException(name)
7375
}
7476

7577
private inline fun <reified T> getValue(name: String, type: Class<T>): T =
7678
checkInstance(name, getValue(name), type)
7779

78-
private fun getNullableValue(name: String): Any? = localMap.get(name)
80+
private fun getNullableValue(name: String): Any? = localMap[name]
7981

8082
private inline fun <reified T> getNullableValue(name: String, type: Class<T>): T? {
8183
val res = getNullableValue(name)

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,8 @@ protected void setTransformProperty(
637637
@Nullable ReadableArray transforms,
638638
@Nullable ReadableArray transformOrigin) {
639639
if (transforms == null) {
640-
view.setTranslationX(PixelUtil.toPixelFromDIP(0));
641-
view.setTranslationY(PixelUtil.toPixelFromDIP(0));
640+
view.setTranslationX(0);
641+
view.setTranslationY(0);
642642
view.setRotation(0);
643643
view.setRotationX(0);
644644
view.setRotationY(0);
@@ -659,6 +659,8 @@ protected void setTransformProperty(
659659
transformOrigin,
660660
allowPercentageResolution);
661661
MatrixMathHelper.decomposeMatrix(sTransformDecompositionArray, sMatrixDecompositionContext);
662+
float rotationX = sanitizeFloatPropertyValue((float) sMatrixDecompositionContext.rotationDegrees[0]);
663+
float rotationY = sanitizeFloatPropertyValue((float) sMatrixDecompositionContext.rotationDegrees[1]);
662664
view.setTranslationX(
663665
PixelUtil.toPixelFromDIP(
664666
sanitizeFloatPropertyValue((float) sMatrixDecompositionContext.translation[0])));
@@ -667,16 +669,14 @@ protected void setTransformProperty(
667669
sanitizeFloatPropertyValue((float) sMatrixDecompositionContext.translation[1])));
668670
view.setRotation(
669671
sanitizeFloatPropertyValue((float) sMatrixDecompositionContext.rotationDegrees[2]));
670-
view.setRotationX(
671-
sanitizeFloatPropertyValue((float) sMatrixDecompositionContext.rotationDegrees[0]));
672-
view.setRotationY(
673-
sanitizeFloatPropertyValue((float) sMatrixDecompositionContext.rotationDegrees[1]));
672+
view.setRotationX(rotationX);
673+
view.setRotationY(rotationY);
674674
view.setScaleX(sanitizeFloatPropertyValue((float) sMatrixDecompositionContext.scale[0]));
675675
view.setScaleY(sanitizeFloatPropertyValue((float) sMatrixDecompositionContext.scale[1]));
676676

677677
double[] perspectiveArray = sMatrixDecompositionContext.perspective;
678678

679-
if (perspectiveArray.length > PERSPECTIVE_ARRAY_INVERTED_CAMERA_DISTANCE_INDEX) {
679+
if ((rotationX != 0 || rotationY != 0) && perspectiveArray.length > PERSPECTIVE_ARRAY_INVERTED_CAMERA_DISTANCE_INDEX) {
680680
float invertedCameraDistance =
681681
(float) perspectiveArray[PERSPECTIVE_ARRAY_INVERTED_CAMERA_DISTANCE_INDEX];
682682
if (invertedCameraDistance == 0) {

0 commit comments

Comments
 (0)