mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-01 14:25:08 +08:00
Fix FlatUIImplementation.manageChildren() failing when moveFrom is not sorted
Summary: Code in FlatUIImplementation.manageChildren() incorrectly assumed that moveFrom is sorted and moveTo is not, which is actually reverse: moveFrom is not sorted, and moveTo is. This means that we need to sort moveFrom before we can traverse it, and that we no longer need to sort moveTo (we did it by moving nodes to mNodesToMove first and then sorting it). The sorting algorithm used is borrowed from Android implementation of insertion sort used in DualPivotQuicksort.doSort() when number of elements < INSERTION_SORT_THRESHOLD(32) which is 99.999% the case in UIImplementation.manageChildren() (most of the time this array is either empty or only contains 1 element). Another (very rare) bug this is fixing is that the code only worked for FlatShadowNodes, but not all shadow nodes are FlatShadowNodes (there are rare exceptions, such as ARTShape, ARTGroup etc). New code works with all types of shadow nodes. Reviewed By: ahmedre Differential Revision: D2975787
This commit is contained in:
committed by
Ahmed El-Helw
parent
42fb9a3d91
commit
848bae2e95
@@ -49,7 +49,6 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
private boolean mBackingViewIsCreated;
|
||||
private @Nullable DrawView mDrawView;
|
||||
private @Nullable DrawBackgroundColor mDrawBackground;
|
||||
private int mMoveToIndexInParent;
|
||||
private boolean mClipToBounds = false;
|
||||
private boolean mIsUpdated = true;
|
||||
private float mClipLeft;
|
||||
@@ -252,14 +251,6 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
mNodeRegions = nodeRegion;
|
||||
}
|
||||
|
||||
/* package */ final void setMoveToIndexInParent(int moveToIndexInParent) {
|
||||
mMoveToIndexInParent = moveToIndexInParent;
|
||||
}
|
||||
|
||||
/* package */ final int getMoveToIndexInParent() {
|
||||
return mMoveToIndexInParent;
|
||||
}
|
||||
|
||||
/* package */ void updateNodeRegion(float left, float top, float right, float bottom) {
|
||||
if (mNodeRegion.mLeft != left || mNodeRegion.mTop != top ||
|
||||
mNodeRegion.mRight != right || mNodeRegion.mBottom != bottom) {
|
||||
|
||||
Reference in New Issue
Block a user