Skip to content

Commit 877f1cd

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Fix and re-enable "view flattening" optimizations for Marketplace
Reviewed By: achen1 Differential Revision: D6751078 fbshipit-source-id: 32bfb9ac64f183fabbba85755be372016722afc6
1 parent 493f3e8 commit 877f1cd

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Diff for: ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java

+20-16
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public class ViewProps {
6767
public static final String START = "start";
6868
public static final String END = "end";
6969

70+
public static final String AUTO = "auto";
71+
public static final String NONE = "none";
72+
public static final String BOX_NONE = "box-none";
73+
7074
public static final String MIN_WIDTH = "minWidth";
7175
public static final String MAX_WIDTH = "maxWidth";
7276
public static final String MIN_HEIGHT = "minHeight";
@@ -124,6 +128,7 @@ public class ViewProps {
124128
public static final String BORDER_BOTTOM_END_RADIUS = "borderBottomEndRadius";
125129
public static final String BORDER_START_COLOR = "borderStartColor";
126130
public static final String BORDER_END_COLOR = "borderEndColor";
131+
public static final String ON_LAYOUT = "onLayout";
127132

128133
public static final int[] BORDER_SPACING_TYPES = {
129134
Spacing.ALL,
@@ -205,33 +210,33 @@ public class ViewProps {
205210
PADDING_START,
206211
PADDING_END));
207212

208-
209213
public static boolean sIsOptimizationsEnabled;
210214

211215
public static boolean isLayoutOnly(ReadableMap map, String prop) {
212216
if (LAYOUT_ONLY_PROPS.contains(prop)) {
213217
return true;
214218
} else if (POINTER_EVENTS.equals(prop)) {
215219
String value = map.getString(prop);
216-
return "auto".equals(value) || "box-none".equals(value);
220+
return AUTO.equals(value) || BOX_NONE.equals(value);
217221
}
218222

223+
219224
if (sIsOptimizationsEnabled) {
220225
switch (prop) {
221226
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;
225230
case BORDER_RADIUS: // Without a background color or border width set, a border won't show.
226231
if (map.hasKey(BACKGROUND_COLOR) && map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) {
227232
return false;
228233
}
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) {
230237
return false;
231238
}
232239
return true;
233-
case BORDER_COLOR:
234-
return map.getInt(BORDER_COLOR) == Color.TRANSPARENT;
235240
case BORDER_LEFT_COLOR:
236241
return map.getInt(BORDER_LEFT_COLOR) == Color.TRANSPARENT;
237242
case BORDER_RIGHT_COLOR:
@@ -241,24 +246,23 @@ public static boolean isLayoutOnly(ReadableMap map, String prop) {
241246
case BORDER_BOTTOM_COLOR:
242247
return map.getInt(BORDER_BOTTOM_COLOR) == Color.TRANSPARENT;
243248
case BORDER_WIDTH:
244-
return map.getDouble(BORDER_WIDTH) == 0d;
249+
return map.isNull(BORDER_WIDTH) || map.getDouble(BORDER_WIDTH) == 0d;
245250
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;
247252
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;
249254
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;
251256
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:
254259
return true;
255-
case "overflow": // We do nothing with this right now.
260+
case OVERFLOW: // We do nothing with this right now.
256261
return true;
257262
default:
258263
return false;
259264
}
260265
}
261-
262266
return false;
263267
}
264268
}

0 commit comments

Comments
 (0)