@@ -67,6 +67,10 @@ public class ViewProps {
67
67
public static final String START = "start" ;
68
68
public static final String END = "end" ;
69
69
70
+ public static final String AUTO = "auto" ;
71
+ public static final String NONE = "none" ;
72
+ public static final String BOX_NONE = "box-none" ;
73
+
70
74
public static final String MIN_WIDTH = "minWidth" ;
71
75
public static final String MAX_WIDTH = "maxWidth" ;
72
76
public static final String MIN_HEIGHT = "minHeight" ;
@@ -124,6 +128,7 @@ public class ViewProps {
124
128
public static final String BORDER_BOTTOM_END_RADIUS = "borderBottomEndRadius" ;
125
129
public static final String BORDER_START_COLOR = "borderStartColor" ;
126
130
public static final String BORDER_END_COLOR = "borderEndColor" ;
131
+ public static final String ON_LAYOUT = "onLayout" ;
127
132
128
133
public static final int [] BORDER_SPACING_TYPES = {
129
134
Spacing .ALL ,
@@ -205,33 +210,33 @@ public class ViewProps {
205
210
PADDING_START ,
206
211
PADDING_END ));
207
212
208
-
209
213
public static boolean sIsOptimizationsEnabled ;
210
214
211
215
public static boolean isLayoutOnly (ReadableMap map , String prop ) {
212
216
if (LAYOUT_ONLY_PROPS .contains (prop )) {
213
217
return true ;
214
218
} else if (POINTER_EVENTS .equals (prop )) {
215
219
String value = map .getString (prop );
216
- return "auto" .equals (value ) || "box-none" .equals (value );
220
+ return AUTO .equals (value ) || BOX_NONE .equals (value );
217
221
}
218
222
223
+
219
224
if (sIsOptimizationsEnabled ) {
220
225
switch (prop ) {
221
226
case OPACITY :
222
- return map . getDouble ( OPACITY ) == 1d ; // Ignore if explicitly set to default opacity.
223
- case BACKGROUND_COLOR :
224
- return map .getInt ( BACKGROUND_COLOR ) == Color . TRANSPARENT ;
227
+ // null opacity behaves like opacity = 1
228
+ // Ignore if explicitly set to default opacity.
229
+ return map .isNull ( OPACITY ) || map . getDouble ( OPACITY ) == 1d ;
225
230
case BORDER_RADIUS : // Without a background color or border width set, a border won't show.
226
231
if (map .hasKey (BACKGROUND_COLOR ) && map .getInt (BACKGROUND_COLOR ) != Color .TRANSPARENT ) {
227
232
return false ;
228
233
}
229
- if (map .hasKey (BORDER_WIDTH ) && map .getDouble (BORDER_WIDTH ) != 0d ) {
234
+ if (map .hasKey (BORDER_WIDTH )
235
+ && !map .isNull (BORDER_WIDTH )
236
+ && map .getDouble (BORDER_WIDTH ) != 0d ) {
230
237
return false ;
231
238
}
232
239
return true ;
233
- case BORDER_COLOR :
234
- return map .getInt (BORDER_COLOR ) == Color .TRANSPARENT ;
235
240
case BORDER_LEFT_COLOR :
236
241
return map .getInt (BORDER_LEFT_COLOR ) == Color .TRANSPARENT ;
237
242
case BORDER_RIGHT_COLOR :
@@ -241,24 +246,23 @@ public static boolean isLayoutOnly(ReadableMap map, String prop) {
241
246
case BORDER_BOTTOM_COLOR :
242
247
return map .getInt (BORDER_BOTTOM_COLOR ) == Color .TRANSPARENT ;
243
248
case BORDER_WIDTH :
244
- return map .getDouble (BORDER_WIDTH ) == 0d ;
249
+ return map .isNull ( BORDER_WIDTH ) || map . getDouble (BORDER_WIDTH ) == 0d ;
245
250
case BORDER_LEFT_WIDTH :
246
- return map .getDouble (BORDER_LEFT_WIDTH ) == 0d ;
251
+ return map .isNull ( BORDER_LEFT_WIDTH ) || map . getDouble (BORDER_LEFT_WIDTH ) == 0d ;
247
252
case BORDER_TOP_WIDTH :
248
- return map .getDouble (BORDER_TOP_WIDTH ) == 0d ;
253
+ return map .isNull ( BORDER_TOP_WIDTH ) || map . getDouble (BORDER_TOP_WIDTH ) == 0d ;
249
254
case BORDER_RIGHT_WIDTH :
250
- return map .getDouble (BORDER_RIGHT_WIDTH ) == 0d ;
255
+ return map .isNull ( BORDER_RIGHT_WIDTH ) || map . getDouble (BORDER_RIGHT_WIDTH ) == 0d ;
251
256
case BORDER_BOTTOM_WIDTH :
252
- return map .getDouble (BORDER_BOTTOM_WIDTH ) == 0d ;
253
- case "onLayout" :
257
+ return map .isNull ( BORDER_BOTTOM_WIDTH ) || map . getDouble (BORDER_BOTTOM_WIDTH ) == 0d ;
258
+ case ON_LAYOUT :
254
259
return true ;
255
- case "overflow" : // We do nothing with this right now.
260
+ case OVERFLOW : // We do nothing with this right now.
256
261
return true ;
257
262
default :
258
263
return false ;
259
264
}
260
265
}
261
-
262
266
return false ;
263
267
}
264
268
}
0 commit comments