mirror of
https://github.com/status-im/react-native.git
synced 2025-01-29 02:35:41 +00:00
Start creating views before end of batch for nodes
Summary: Depends on D3120798 Depends on D3120631 Enables D3120631 for nodes. This implementation seems to work but let me know if I'm doing something really stupid. Reviewed By: ahmedre Differential Revision: D3120814
This commit is contained in:
parent
f8d623ca3a
commit
ace1b4d78e
@ -464,7 +464,6 @@ public class FlatUIImplementation extends UIImplementation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateViewHierarchy(EventDispatcher eventDispatcher) {
|
protected void updateViewHierarchy(EventDispatcher eventDispatcher) {
|
||||||
mStateBuilder.beforeUpdateViewHierarchy();
|
|
||||||
super.updateViewHierarchy(eventDispatcher);
|
super.updateViewHierarchy(eventDispatcher);
|
||||||
mStateBuilder.afterUpdateViewHierarchy(eventDispatcher);
|
mStateBuilder.afterUpdateViewHierarchy(eventDispatcher);
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
|
|||||||
private final ArrayList<FlatShadowNode> mViewsToDetachAllChildrenFrom = new ArrayList<>();
|
private final ArrayList<FlatShadowNode> mViewsToDetachAllChildrenFrom = new ArrayList<>();
|
||||||
private final ArrayList<FlatShadowNode> mViewsToDetach = new ArrayList<>();
|
private final ArrayList<FlatShadowNode> mViewsToDetach = new ArrayList<>();
|
||||||
private final ArrayList<FlatShadowNode> mViewsToDrop = new ArrayList<>();
|
private final ArrayList<FlatShadowNode> mViewsToDrop = new ArrayList<>();
|
||||||
private final ArrayList<FlatShadowNode> mViewsToUpdate = new ArrayList<>();
|
|
||||||
private final ArrayList<ReactStylesDiffMap> mStylesToUpdate = new ArrayList<>();
|
|
||||||
private final ArrayList<OnLayoutEvent> mOnLayoutEvents = new ArrayList<>();
|
private final ArrayList<OnLayoutEvent> mOnLayoutEvents = new ArrayList<>();
|
||||||
private final ArrayList<FlatUIViewOperationQueue.UpdateViewBounds> mUpdateViewBoundsOperations =
|
private final ArrayList<FlatUIViewOperationQueue.UpdateViewBounds> mUpdateViewBoundsOperations =
|
||||||
new ArrayList<>();
|
new ArrayList<>();
|
||||||
@ -61,10 +59,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
|
|||||||
return mOperationsQueue;
|
return mOperationsQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void beforeUpdateViewHierarchy() {
|
|
||||||
commitViewUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a root of the laid-out shadow node hierarchy, walks the tree and generates an array of
|
* Given a root of the laid-out shadow node hierarchy, walks the tree and generates an array of
|
||||||
* DrawCommands that will then mount in UI thread to a root FlatViewGroup so that it can draw.
|
* DrawCommands that will then mount in UI thread to a root FlatViewGroup so that it can draw.
|
||||||
@ -143,8 +137,21 @@ import com.facebook.react.uimanager.events.EventDispatcher;
|
|||||||
/* package */ void enqueueCreateOrUpdateView(
|
/* package */ void enqueueCreateOrUpdateView(
|
||||||
FlatShadowNode node,
|
FlatShadowNode node,
|
||||||
@Nullable ReactStylesDiffMap styles) {
|
@Nullable ReactStylesDiffMap styles) {
|
||||||
mViewsToUpdate.add(node);
|
if (node.isBackingViewCreated()) {
|
||||||
mStylesToUpdate.add(styles);
|
// if the View is already created, make sure propagate new styles.
|
||||||
|
mOperationsQueue.enqueueUpdateProperties(
|
||||||
|
node.getReactTag(),
|
||||||
|
node.getViewClass(),
|
||||||
|
styles);
|
||||||
|
} else {
|
||||||
|
mOperationsQueue.enqueueCreateView(
|
||||||
|
node.getThemedContext(),
|
||||||
|
node.getReactTag(),
|
||||||
|
node.getViewClass(),
|
||||||
|
styles);
|
||||||
|
|
||||||
|
node.signalBackingViewIsCreated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ boolean ensureBackingViewIsCreated(FlatShadowNode node) {
|
/* package */ boolean ensureBackingViewIsCreated(FlatShadowNode node) {
|
||||||
@ -163,36 +170,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
|
|||||||
mViewsToDrop.add(node);
|
mViewsToDrop.add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commitViewUpdates() {
|
|
||||||
for (int i = 0, numViewsToUpdate = mViewsToUpdate.size(); i != numViewsToUpdate; ++i) {
|
|
||||||
FlatShadowNode node = mViewsToUpdate.get(i);
|
|
||||||
if (node.getParent() == null) {
|
|
||||||
// Shadow node is not attached to the hierarchy, which means it is being discarded.
|
|
||||||
// No need to create or update view in this case, as the View is already gone as well.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.isBackingViewCreated()) {
|
|
||||||
// if the View is already created, make sure propagate new styles.
|
|
||||||
mOperationsQueue.enqueueUpdateProperties(
|
|
||||||
node.getReactTag(),
|
|
||||||
node.getViewClass(),
|
|
||||||
mStylesToUpdate.get(i));
|
|
||||||
} else {
|
|
||||||
mOperationsQueue.enqueueCreateView(
|
|
||||||
node.getThemedContext(),
|
|
||||||
node.getReactTag(),
|
|
||||||
node.getViewClass(),
|
|
||||||
mStylesToUpdate.get(i));
|
|
||||||
|
|
||||||
node.signalBackingViewIsCreated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mViewsToUpdate.clear();
|
|
||||||
mStylesToUpdate.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addNodeRegion(
|
private void addNodeRegion(
|
||||||
FlatShadowNode node,
|
FlatShadowNode node,
|
||||||
float left,
|
float left,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user