Permalink
Browse files

Fix and re-enable "view flattening" optimizations for Marketplace

Reviewed By: achen1

Differential Revision: D6751078

fbshipit-source-id: 32bfb9ac64f183fabbba85755be372016722afc6
  • Loading branch information...
mdvacca authored and facebook-github-bot committed Jan 19, 2018
1 parent 493f3e8 commit 877f1cde2ebe8f304d6fd0855fc4a874d1d5ee27
Showing with 20 additions and 16 deletions.
  1. +20 −16 ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java
@@ -67,6 +67,10 @@
public static final String START = "start";
public static final String END = "end";
public static final String AUTO = "auto";
public static final String NONE = "none";
public static final String BOX_NONE = "box-none";
public static final String MIN_WIDTH = "minWidth";
public static final String MAX_WIDTH = "maxWidth";
public static final String MIN_HEIGHT = "minHeight";
@@ -124,6 +128,7 @@
public static final String BORDER_BOTTOM_END_RADIUS = "borderBottomEndRadius";
public static final String BORDER_START_COLOR = "borderStartColor";
public static final String BORDER_END_COLOR = "borderEndColor";
public static final String ON_LAYOUT = "onLayout";
public static final int[] BORDER_SPACING_TYPES = {
Spacing.ALL,
@@ -205,33 +210,33 @@
PADDING_START,
PADDING_END));
public static boolean sIsOptimizationsEnabled;
public static boolean isLayoutOnly(ReadableMap map, String prop) {
if (LAYOUT_ONLY_PROPS.contains(prop)) {
return true;
} else if (POINTER_EVENTS.equals(prop)) {
String value = map.getString(prop);
return "auto".equals(value) || "box-none".equals(value);
return AUTO.equals(value) || BOX_NONE.equals(value);
}
if (sIsOptimizationsEnabled) {
switch (prop) {
case OPACITY:
return map.getDouble(OPACITY) == 1d; // Ignore if explicitly set to default opacity.
case BACKGROUND_COLOR:
return map.getInt(BACKGROUND_COLOR) == Color.TRANSPARENT;
// null opacity behaves like opacity = 1
// Ignore if explicitly set to default opacity.
return map.isNull(OPACITY) || map.getDouble(OPACITY) == 1d;
case BORDER_RADIUS: // Without a background color or border width set, a border won't show.
if (map.hasKey(BACKGROUND_COLOR) && map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) {
return false;
}
if (map.hasKey(BORDER_WIDTH) && map.getDouble(BORDER_WIDTH) != 0d) {
if (map.hasKey(BORDER_WIDTH)
&& !map.isNull(BORDER_WIDTH)
&& map.getDouble(BORDER_WIDTH) != 0d) {
return false;
}
return true;
case BORDER_COLOR:
return map.getInt(BORDER_COLOR) == Color.TRANSPARENT;
case BORDER_LEFT_COLOR:
return map.getInt(BORDER_LEFT_COLOR) == Color.TRANSPARENT;
case BORDER_RIGHT_COLOR:
@@ -241,24 +246,23 @@ public static boolean isLayoutOnly(ReadableMap map, String prop) {
case BORDER_BOTTOM_COLOR:
return map.getInt(BORDER_BOTTOM_COLOR) == Color.TRANSPARENT;
case BORDER_WIDTH:
return map.getDouble(BORDER_WIDTH) == 0d;
return map.isNull(BORDER_WIDTH) || map.getDouble(BORDER_WIDTH) == 0d;
case BORDER_LEFT_WIDTH:
return map.getDouble(BORDER_LEFT_WIDTH) == 0d;
return map.isNull(BORDER_LEFT_WIDTH) || map.getDouble(BORDER_LEFT_WIDTH) == 0d;
case BORDER_TOP_WIDTH:
return map.getDouble(BORDER_TOP_WIDTH) == 0d;
return map.isNull(BORDER_TOP_WIDTH) || map.getDouble(BORDER_TOP_WIDTH) == 0d;
case BORDER_RIGHT_WIDTH:
return map.getDouble(BORDER_RIGHT_WIDTH) == 0d;
return map.isNull(BORDER_RIGHT_WIDTH) || map.getDouble(BORDER_RIGHT_WIDTH) == 0d;
case BORDER_BOTTOM_WIDTH:
return map.getDouble(BORDER_BOTTOM_WIDTH) == 0d;
case "onLayout":
return map.isNull(BORDER_BOTTOM_WIDTH) || map.getDouble(BORDER_BOTTOM_WIDTH) == 0d;
case ON_LAYOUT:
return true;
case "overflow": // We do nothing with this right now.
case OVERFLOW: // We do nothing with this right now.
return true;
default:
return false;
}
}
return false;
}
}

0 comments on commit 877f1cd

Please sign in to comment.