ForceMountToView when Opacity or other View-specific properties are applied to a FlatShadowNode
Summary: @public There are some properties, such as alpha or scale that we ONLY handle on a View level. This means that whenever we encounter a FlatShadowNode with this property, it should be mapped to a View. This diff is doing exactly this. Reviewed By: ahmedre Differential Revision: D2694495
This commit is contained in:
parent
0d042c2ef4
commit
1da7049426
|
@ -11,6 +11,7 @@ package com.facebook.react.flat;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.facebook.react.uimanager.CatalystStylesDiffMap;
|
||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
import com.facebook.react.uimanager.ReactProp;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
|
@ -23,6 +24,15 @@ import com.facebook.react.uimanager.ViewProps;
|
|||
|
||||
/* package */ static final FlatShadowNode[] EMPTY_ARRAY = new FlatShadowNode[0];
|
||||
|
||||
private static final String PROP_DECOMPOSED_MATRIX = "decomposedMatrix";
|
||||
private static final String PROP_OPACITY = "opacity";
|
||||
private static final String PROP_RENDER_TO_HARDWARE_TEXTURE = "renderToHardwareTextureAndroid";
|
||||
private static final String PROP_ACCESSIBILITY_LABEL = "accessibilityLabel";
|
||||
private static final String PROP_ACCESSIBILITY_COMPONENT_TYPE = "accessibilityComponentType";
|
||||
private static final String PROP_ACCESSIBILITY_LIVE_REGION = "accessibilityLiveRegion";
|
||||
private static final String PROP_IMPORTANT_FOR_ACCESSIBILITY = "importantForAccessibility";
|
||||
private static final String PROP_TEST_ID = "testID";
|
||||
|
||||
private DrawCommand[] mDrawCommands = DrawCommand.EMPTY_ARRAY;
|
||||
private AttachDetachListener[] mAttachDetachListeners = AttachDetachListener.EMPTY_ARRAY;
|
||||
private NodeRegion[] mNodeRegions = NodeRegion.EMPTY_ARRAY;
|
||||
|
@ -37,6 +47,22 @@ import com.facebook.react.uimanager.ViewProps;
|
|||
private boolean mBackingViewIsCreated;
|
||||
private @Nullable DrawBackgroundColor mDrawBackground;
|
||||
|
||||
/* package */ void handleUpdateProperties(CatalystStylesDiffMap styles) {
|
||||
if (!mountsToView()) {
|
||||
// Make sure we mount this FlatShadowNode to a View if any of these properties are present.
|
||||
if (styles.hasKey(PROP_DECOMPOSED_MATRIX) ||
|
||||
styles.hasKey(PROP_OPACITY) ||
|
||||
styles.hasKey(PROP_RENDER_TO_HARDWARE_TEXTURE) ||
|
||||
styles.hasKey(PROP_TEST_ID) ||
|
||||
styles.hasKey(PROP_ACCESSIBILITY_LABEL) ||
|
||||
styles.hasKey(PROP_ACCESSIBILITY_COMPONENT_TYPE) ||
|
||||
styles.hasKey(PROP_ACCESSIBILITY_LIVE_REGION) ||
|
||||
styles.hasKey(PROP_IMPORTANT_FOR_ACCESSIBILITY)) {
|
||||
forceMountToView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects DrawCommands produced by this FlatShadoNode.
|
||||
*/
|
||||
|
|
|
@ -79,10 +79,15 @@ public class FlatUIImplementation extends UIImplementation {
|
|||
protected void handleCreateView(
|
||||
ReactShadowNode cssNode,
|
||||
int rootViewTag,
|
||||
CatalystStylesDiffMap styles) {
|
||||
int tag = cssNode.getReactTag();
|
||||
@Nullable CatalystStylesDiffMap styles) {
|
||||
FlatShadowNode node = (FlatShadowNode) cssNode;
|
||||
|
||||
if (styles != null) {
|
||||
node.handleUpdateProperties(styles);
|
||||
}
|
||||
|
||||
if (node.mountsToView()) {
|
||||
int tag = cssNode.getReactTag();
|
||||
mStateBuilder.ensureBackingViewIsCreated(node, tag, styles);
|
||||
}
|
||||
}
|
||||
|
@ -92,9 +97,12 @@ public class FlatUIImplementation extends UIImplementation {
|
|||
ReactShadowNode cssNode,
|
||||
String className,
|
||||
CatalystStylesDiffMap styles) {
|
||||
int tag = cssNode.getReactTag();
|
||||
FlatShadowNode node = (FlatShadowNode) cssNode;
|
||||
|
||||
node.handleUpdateProperties(styles);
|
||||
|
||||
if (node.mountsToView()) {
|
||||
int tag = cssNode.getReactTag();
|
||||
mStateBuilder.ensureBackingViewIsCreated(node, tag, styles);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue