Don't pass tag alongside node in StateBuilder methods

Summary:
Many of StateBuilder methods take a lot of arguments, which makes it hard to read. This patch is doing a bit of cleanup by removing tag from the method signatures, because tag can be easily obtained from the node itself.

This is a pure refactoring diff and should have no functional changes.

Reviewed By: ahmedre

Differential Revision: D2915815
This commit is contained in:
Denis Koroskin 2016-02-19 17:36:59 -08:00 коммит произвёл Ahmed El-Helw
Родитель 3b63d7c3bc
Коммит 3e30b70e29
2 изменённых файлов: 14 добавлений и 23 удалений

Просмотреть файл

@ -132,8 +132,7 @@ public class FlatUIImplementation extends UIImplementation {
}
if (node.mountsToView()) {
int tag = cssNode.getReactTag();
mStateBuilder.ensureBackingViewIsCreated(node, tag, styles);
mStateBuilder.ensureBackingViewIsCreated(node, styles);
}
} else {
super.handleCreateView(cssNode, rootViewTag, styles);
@ -151,8 +150,7 @@ public class FlatUIImplementation extends UIImplementation {
node.handleUpdateProperties(styles);
if (node.mountsToView()) {
int tag = cssNode.getReactTag();
mStateBuilder.ensureBackingViewIsCreated(node, tag, styles);
mStateBuilder.ensureBackingViewIsCreated(node, styles);
}
} else {
super.handleUpdateView(cssNode, className, styles);
@ -427,13 +425,12 @@ public class FlatUIImplementation extends UIImplementation {
}
FlatShadowNode nonVirtualNode = (FlatShadowNode) node;
int nonVirtualTag = nonVirtualNode.getReactTag();
nonVirtualNode.forceMountToView();
mStateBuilder.ensureBackingViewIsCreated(nonVirtualNode, nonVirtualTag, null);
mStateBuilder.ensureBackingViewIsCreated(nonVirtualNode, null);
FlatUIViewOperationQueue operationsQueue = mStateBuilder.getOperationsQueue();
operationsQueue.enqueueSetJSResponder(
nonVirtualTag,
nonVirtualNode.getReactTag(),
possiblyVirtualReactTag,
blockNativeResponder);
}

Просмотреть файл

@ -62,8 +62,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
* DrawCommands that will then mount in UI thread to a root FlatViewGroup so that it can draw.
*/
/* package */ void applyUpdates(EventDispatcher eventDispatcher, FlatShadowNode node) {
int tag = node.getReactTag();
float width = node.getLayoutWidth();
float height = node.getLayoutHeight();
float left = node.getLayoutX();
@ -73,7 +71,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
collectStateForMountableNode(
node,
tag,
left,
top,
right,
@ -126,17 +123,18 @@ import com.facebook.react.uimanager.events.EventDispatcher;
/* package */ void ensureBackingViewIsCreated(
FlatShadowNode node,
int tag,
@Nullable ReactStylesDiffMap styles) {
if (node.isBackingViewCreated()) {
if (styles != null) {
// if the View is already created, make sure propagate new styles.
mOperationsQueue.enqueueUpdateProperties(tag, node.getViewClass(), styles);
mOperationsQueue.enqueueUpdateProperties(node.getReactTag(), node.getViewClass(), styles);
}
return;
}
int tag = node.getReactTag();
mOperationsQueue.enqueueCreateView(node.getThemedContext(), tag, node.getViewClass(), styles);
node.signalBackingViewIsCreated();
}
@ -195,7 +193,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
*/
private void collectStateForMountableNode(
FlatShadowNode node,
int tag,
float left,
float top,
float right,
@ -213,7 +210,7 @@ import com.facebook.react.uimanager.events.EventDispatcher;
boolean needsCustomLayoutForChildren = false;
if (node instanceof AndroidView) {
AndroidView androidView = (AndroidView) node;
updateViewPadding(androidView, tag);
updateViewPadding(androidView, node.getReactTag());
isAndroidView = true;
needsCustomLayoutForChildren = androidView.needsCustomLayoutForChildren();
@ -270,7 +267,7 @@ import com.facebook.react.uimanager.events.EventDispatcher;
if (shouldUpdateMountState) {
mOperationsQueue.enqueueUpdateMountState(
tag,
node.getReactTag(),
drawCommands,
listeners,
nodeRegions);
@ -283,13 +280,12 @@ import com.facebook.react.uimanager.events.EventDispatcher;
final FlatShadowNode[] nativeChildren = mNativeChildren.finish();
if (nativeChildren != null) {
updateNativeChildren(node, tag, node.getNativeChildren(), nativeChildren);
updateNativeChildren(node, node.getNativeChildren(), nativeChildren);
}
}
private void updateNativeChildren(
FlatShadowNode node,
int tag,
FlatShadowNode[] oldNativeChildren,
FlatShadowNode[] newNativeChildren) {
@ -303,6 +299,7 @@ import com.facebook.react.uimanager.events.EventDispatcher;
mViewsToDetachAllChildrenFrom.add(node);
}
int tag = node.getReactTag();
int numViewsToAdd = newNativeChildren.length;
final int[] viewsToAdd;
if (numViewsToAdd == 0) {
@ -425,8 +422,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
float parentClipBottom,
boolean parentIsAndroidView,
boolean needsCustomLayout) {
int tag = node.getReactTag();
float width = node.getLayoutWidth();
float height = node.getLayoutHeight();
@ -436,7 +431,7 @@ import com.facebook.react.uimanager.events.EventDispatcher;
float bottom = top + height;
if (node.mountsToView()) {
ensureBackingViewIsCreated(node, tag, null);
ensureBackingViewIsCreated(node, null);
addNativeChild(node);
if (!parentIsAndroidView) {
@ -449,7 +444,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
collectStateForMountableNode(
node,
tag,
left - left,
top - top,
right - left,
@ -479,11 +473,11 @@ import com.facebook.react.uimanager.events.EventDispatcher;
}
}
private void updateViewPadding(AndroidView androidView, int tag) {
private void updateViewPadding(AndroidView androidView, int reactTag) {
if (androidView.isPaddingChanged()) {
Spacing padding = androidView.getPadding();
mOperationsQueue.enqueueSetPadding(
tag,
reactTag,
Math.round(padding.get(Spacing.LEFT)),
Math.round(padding.get(Spacing.TOP)),
Math.round(padding.get(Spacing.RIGHT)),