Add "newProps" map into ReactShadowNode
Reviewed By: achen1 Differential Revision: D7205127 fbshipit-source-id: 6c27070806de36cab7adf9c392a10c815aee90d4
This commit is contained in:
parent
e31781be61
commit
c883d4e727
|
@ -140,8 +140,7 @@ public class FabricUIManager implements UIManager {
|
||||||
ReactShadowNode node,
|
ReactShadowNode node,
|
||||||
@Nullable ReadableNativeMap newProps) {
|
@Nullable ReadableNativeMap newProps) {
|
||||||
try {
|
try {
|
||||||
ReactShadowNode clone = node.mutableCopy();
|
ReactShadowNode clone = node.mutableCopyWithNewProps(newProps == null ? null : new ReactStylesDiffMap(newProps));
|
||||||
updateProps(clone, newProps);
|
|
||||||
assertReactShadowNodeCopy(node, clone);
|
assertReactShadowNodeCopy(node, clone);
|
||||||
return clone;
|
return clone;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -161,8 +160,7 @@ public class FabricUIManager implements UIManager {
|
||||||
ReactShadowNode node,
|
ReactShadowNode node,
|
||||||
ReadableNativeMap newProps) {
|
ReadableNativeMap newProps) {
|
||||||
try {
|
try {
|
||||||
ReactShadowNode clone = node.mutableCopyWithNewChildren();
|
ReactShadowNode clone = node.mutableCopyWithNewChildrenAndProps(newProps == null ? null : new ReactStylesDiffMap(newProps));
|
||||||
updateProps(clone, newProps);
|
|
||||||
assertReactShadowNodeCopy(node, clone);
|
assertReactShadowNodeCopy(node, clone);
|
||||||
return clone;
|
return clone;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|
|
@ -72,8 +72,12 @@ public interface ReactShadowNode<T extends ReactShadowNode> {
|
||||||
*/
|
*/
|
||||||
T mutableCopy();
|
T mutableCopy();
|
||||||
|
|
||||||
|
T mutableCopyWithNewProps(@Nullable ReactStylesDiffMap newProps);
|
||||||
|
|
||||||
T mutableCopyWithNewChildren();
|
T mutableCopyWithNewChildren();
|
||||||
|
|
||||||
|
T mutableCopyWithNewChildrenAndProps(@Nullable ReactStylesDiffMap newProps);
|
||||||
|
|
||||||
String getViewClass();
|
String getViewClass();
|
||||||
|
|
||||||
boolean hasUpdates();
|
boolean hasUpdates();
|
||||||
|
@ -100,6 +104,8 @@ public interface ReactShadowNode<T extends ReactShadowNode> {
|
||||||
|
|
||||||
void removeAndDisposeAllChildren();
|
void removeAndDisposeAllChildren();
|
||||||
|
|
||||||
|
@Nullable ReactStylesDiffMap getNewProps();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be called by {@link UIManagerModule} once per batch, before calculating
|
* This method will be called by {@link UIManagerModule} once per batch, before calculating
|
||||||
* layout. Will be only called for nodes that are marked as updated with {@link #markUpdated()} or
|
* layout. Will be only called for nodes that are marked as updated with {@link #markUpdated()} or
|
||||||
|
|
|
@ -98,6 +98,8 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
||||||
private final boolean[] mPaddingIsPercent = new boolean[Spacing.ALL + 1];
|
private final boolean[] mPaddingIsPercent = new boolean[Spacing.ALL + 1];
|
||||||
private final YogaNode mYogaNode;
|
private final YogaNode mYogaNode;
|
||||||
|
|
||||||
|
private @Nullable ReactStylesDiffMap mNewProps;
|
||||||
|
|
||||||
public ReactShadowNodeImpl() {
|
public ReactShadowNodeImpl() {
|
||||||
if (!isVirtual()) {
|
if (!isVirtual()) {
|
||||||
YogaNode node = YogaNodePool.get().acquire();
|
YogaNode node = YogaNodePool.get().acquire();
|
||||||
|
@ -119,7 +121,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
||||||
mShouldNotifyOnLayout = original.mShouldNotifyOnLayout;
|
mShouldNotifyOnLayout = original.mShouldNotifyOnLayout;
|
||||||
mNodeUpdated = original.mNodeUpdated;
|
mNodeUpdated = original.mNodeUpdated;
|
||||||
mChildren = original.mChildren == null ? null : new ArrayList<>(original.mChildren);
|
mChildren = original.mChildren == null ? null : new ArrayList<>(original.mChildren);
|
||||||
mParent = null;
|
|
||||||
mIsLayoutOnly = original.mIsLayoutOnly;
|
mIsLayoutOnly = original.mIsLayoutOnly;
|
||||||
mTotalNativeChildren = original.mTotalNativeChildren;
|
mTotalNativeChildren = original.mTotalNativeChildren;
|
||||||
mNativeParent = original.mNativeParent;
|
mNativeParent = original.mNativeParent;
|
||||||
|
@ -133,6 +134,8 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
||||||
arraycopy(original.mPaddingIsPercent, 0, mPaddingIsPercent, 0, original.mPaddingIsPercent.length);
|
arraycopy(original.mPaddingIsPercent, 0, mPaddingIsPercent, 0, original.mPaddingIsPercent.length);
|
||||||
mYogaNode = original.mYogaNode.clone();
|
mYogaNode = original.mYogaNode.clone();
|
||||||
mYogaNode.setData(this);
|
mYogaNode.setData(this);
|
||||||
|
mParent = null;
|
||||||
|
mNewProps = null;
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
// it should never happen
|
// it should never happen
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
@ -152,6 +155,27 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReactShadowNodeImpl mutableCopyWithNewProps(@Nullable ReactStylesDiffMap newProps) {
|
||||||
|
ReactShadowNodeImpl copy = mutableCopy();
|
||||||
|
if (newProps != null) {
|
||||||
|
copy.updateProperties(newProps);
|
||||||
|
copy.mNewProps = newProps;
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReactShadowNodeImpl mutableCopyWithNewChildrenAndProps(@Nullable ReactStylesDiffMap newProps) {
|
||||||
|
ReactShadowNodeImpl copy = mutableCopyWithNewChildren();
|
||||||
|
if (newProps != null) {
|
||||||
|
copy.updateProperties(newProps);
|
||||||
|
copy.mNewProps = newProps;
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nodes that return {@code true} will be treated as "virtual" nodes. That is, nodes that are not
|
* Nodes that return {@code true} will be treated as "virtual" nodes. That is, nodes that are not
|
||||||
* mapped into native views (e.g. nested text node). By default this method returns {@code false}.
|
* mapped into native views (e.g. nested text node). By default this method returns {@code false}.
|
||||||
|
@ -360,6 +384,12 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public ReactStylesDiffMap getNewProps() {
|
||||||
|
return mNewProps;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after layout step at the end of the UI batch from {@link UIManagerModule}. May be used
|
* Called after layout step at the end of the UI batch from {@link UIManagerModule}. May be used
|
||||||
* to enqueue additional ui operations for the native view. Will only be called on nodes marked as
|
* to enqueue additional ui operations for the native view. Will only be called on nodes marked as
|
||||||
|
|
Loading…
Reference in New Issue